3#include <box2d/box2d.h>
57 const std::vector<std::reference_wrapper<GameObject>>& objects);
62 const std::vector<std::reference_wrapper<GameObject>>& objects,
67 const std::vector<std::reference_wrapper<GameObject>>& objects);
70 const std::vector<std::reference_wrapper<GameObject>>& objects);
73 const std::vector<std::reference_wrapper<GameObject>>& objects);
76 const std::vector<std::reference_wrapper<GameObject>>& objects);
80 const std::vector<std::reference_wrapper<GameObject>>& objects,
81 b2ShapeId
a, b2ShapeId
b,
133 b2WorldId world_id_{};
145 bool debug_draw_enabled_{
false};
A 2D collider base that defines the shape and physical properties of a GameObject for collision detec...
Definition collider_2d.h:31
Base class for all components that can be attached to GameObjects.
Definition component.h:24
Represents the physics world using Box2D.
Definition physics_world.h:27
int32_t velocity_iterations() const noexcept
static constexpr float meters_per_pixels
Definition physics_world.h:123
static constexpr float pixels_per_meters
Definition physics_world.h:122
static BodyDistance2D fixture_distance(const Body2DTransform &a, const Body2DTransform &b)
Calculate the distance between two bodies using their fixtures.
float gravity_x() const noexcept
void check_contact_touch_begin_events(const std::vector< std::reference_wrapper< GameObject > > &objects)
Checks for the beginning of contact touch events.
bool world_exists() const noexcept
std::optional< std::reference_wrapper< Collider2D > > find_collider_in_objects(const std::vector< std::reference_wrapper< GameObject > > &objects, Component *comp, b2ShapeId shape_id)
Finds a collider in the given objects based on the component and shape ID.
void check_sensor_touch_begin_events(const std::vector< std::reference_wrapper< GameObject > > &objects)
Checks for the beginning of sensor touch events.
void step(float dt)
Steps the physics simulation forward by the fixed time step.
PhysicsWorld & operator=(PhysicsWorld &&)=delete
PhysicsWorld & operator=(const PhysicsWorld &)=delete
void execute_valid_collider(const std::vector< std::reference_wrapper< GameObject > > &objects, b2ShapeId a, b2ShapeId b, const std::function< void(Collider2D &, Collider2D &)> &callback)
Executes a callback if the given shape IDs are valid.
PhysicsWorld(PhysicsWorld &&)=delete
void check_sensor_touch_end_events(const std::vector< std::reference_wrapper< GameObject > > &objects)
Checks for the ending of sensor touch events.
float gravity_y() const noexcept
void check_contact_touch_end_events(const std::vector< std::reference_wrapper< GameObject > > &objects)
Checks for the ending of contact touch events.
PhysicsWorld(const PhysicsWorld &)=delete
void check_collision(const std::vector< std::reference_wrapper< GameObject > > &objects)
Checks for collisions in the physics world.
b2WorldId world_id() const noexcept
PhysicsWorld()
Constructs a new physics world.
static BodyDistance2D distance(const Body2DTransform &a, const Body2DTransform &b)
Calculate the distance between two bodies.
constexpr int32_t default_velocity_iterations
Definition physics_world.h:17
constexpr float default_gravity_x
Definition physics_world.h:18
constexpr float default_gravity_y
Definition physics_world.h:19
Structure representing the transform of a 2D physics body.
Definition body_2d.h:147
Structure representing the distance information between two colliders.
Definition body_distance_2d.h:11