Physics¶
-
namespace
tnt
-
namespace
doo
Enums
-
struct
physics_comp
¶
-
struct
physics_sys
¶ - #include <Physics.hpp>
A struct that handles the physics data of all the objects.
Public Functions
-
void
add_object
(object const &id, physics_comp const &body)¶ Add a new object to the physics system.
- Note
The position of the bounding box of the component is considered to be relative to the position of the body.
- Parameters
id
: The id of the object to add to the physics system.body
: The physics component that has the data of the object.
-
void
addForce
(object const &id, tnt::Vector const &force) noexcept¶ Apply the given force to the object with the given id.
- Parameters
id
: The id of the object.force
: The force to apply to the object.
-
void
addGlobalForce
(tnt::Vector const &force) noexcept¶ Add a force that would be applied to each object when Update is called.
- Parameters
force
: The force to be applied.
-
void
Update
(object const &id, float time_) noexcept¶ Update the physics data of the object with the given id.
- Parameters
id
: The id of the object to update.time_
: The time that passed since the last update call.
-
bool
colliding
(object const &id, object const &id2) noexcept¶ Check if the bounding boxes of the two objects are colliding.
- Return
bool
- Parameters
id
: The id of the first object.id2
: The id of the second object.
-
void
resolveVel
(object const &id, object const &id2) noexcept¶ Resolve the velocity between two objects that have collided.
- Note
This is called by resolve().
- Parameters
id
: The id of the first object.id2
: The id of the second object.
-
void
resolveInterpenetration
(object const &id, object const &id2) noexcept¶ Resolve the interpenetration between two objects that have collided.
- Note
This is called by resolve().
- Parameters
id
: The id of the first object.id2
: The id of the second object.
-
void
resolve
(object const &id, object const &id2) noexcept¶ Resolve the collision between two objects.
- Parameters
id
: The id of the first object.id2
: The id of the second object.
-
void
from_json
(object const &id, nlohmann::json const &j)¶ Load objects physics data from a json chunk.
- Parameters
id
: The id of the object to load from json.j
: The json chunk that contains the objects data.
-
void
to_json
(object const &id, nlohmann::json &j)¶ Store physics data of a specific object to a json chunk.
- Parameters
id
: The id of the object to serialize to json.j
: The json chunk where the data will be saved.
-
void
draw_imgui
(object const &id, Window const &win) noexcept¶ Draw widgets on the given window to modify the datas of the system.
- Parameters
id
: The id of the active object.win
: The window where to draw the widgets.
-
void
remove
(object const &id) noexcept¶ Remove the desired object from the physics system.
- Parameters
id
: The id of the object you want to remove.
-
void
clear
() noexcept¶ Remove all the objects from the physics system.
-
Vector
gVel
(object const &id) const noexcept¶ Get the velocity of the object in global context.
- Parameters
id
: The id of the object.
-
Vector
gMaxVel
(object const &id) const noexcept¶ Get the maximal velocity of the object in global context.
- Parameters
id
: The id of the object.
-
void
-
namespace
phys
¶
-
struct
-
namespace