28 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
30 auto& ev = ctx.get_cached<
events>();
31 ev.
on_frame_update.connect(sentinel_,
this, &physics_system::on_frame_update);
33 ev.on_play_begin.connect(sentinel_, 10,
this, &physics_system::on_play_begin);
34 ev.on_play_end.connect(sentinel_, -10,
this, &physics_system::on_play_end);
35 ev.on_pause.connect(sentinel_, 10,
this, &physics_system::on_pause);
36 ev.on_resume.connect(sentinel_, -10,
this, &physics_system::on_resume);
37 ev.on_skip_next_frame.connect(sentinel_, -10,
this, &physics_system::on_skip_next_frame);
46 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
55 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
59 auto& registry = *scn.registry;
67 APPLOG_TRACE(
"{}::{}", hpp::type_name_str(*
this), __func__);
73 auto& registry = *scn.registry;
75 registry.ctx().erase<physics_system*>();
99 if(ev.is_playing && !ev.is_paused)
105 float explosion_force,
106 const math::vec3& explosion_position,
107 float explosion_radius,
108 float upwards_modifier,
135 const math::vec3& direction,
144 const math::vec3& direction,
153 const math::vec3& direction,
163 const math::vec3& direction,
Component that handles physics properties and behaviors.
static void on_destroy_component(entt::registry &r, entt::entity e)
Called when the component is destroyed.
static void on_create_component(entt::registry &r, entt::entity e)
Called when the component is created.
Manages the physics operations using the specified backend.
auto ray_cast(const math::vec3 &origin, const math::vec3 &direction, float max_distance, int layer_mask, bool query_sensors) const -> hpp::optional< raycast_hit >
static void on_destroy_component(entt::registry &r, entt::entity e)
Called when a physics component is destroyed.
static void apply_force(physics_component &comp, const math::vec3 &force, force_mode mode)
static void apply_torque(physics_component &comp, const math::vec3 &torque, force_mode mode)
Applies a torque to the specified physics component.
auto sphere_cast_all(const math::vec3 &origin, const math::vec3 &direction, float radius, float max_distance, int layer_mask, bool query_sensors) const -> physics_vector< raycast_hit >
static void clear_kinematic_velocities(physics_component &comp)
Clears kinematic velocities for the specified physics component.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the physics system with the given context.
auto sphere_overlap(const math::vec3 &origin, float radius, int layer_mask, bool query_sensors) const -> physics_vector< entt::entity >
auto ray_cast_all(const math::vec3 &origin, const math::vec3 &direction, float max_distance, int layer_mask, bool query_sensors) const -> physics_vector< raycast_hit >
auto init(rtti::context &ctx) -> bool
Initializes the physics system with the given context.
static void on_create_component(entt::registry &r, entt::entity e)
Called when a physics component is created.
auto sphere_cast(const math::vec3 &origin, const math::vec3 &direction, float radius, float max_distance, int layer_mask, bool query_sensors) const -> hpp::optional< raycast_hit >
static void apply_explosion_force(physics_component &comp, float explosion_force, const math::vec3 &explosion_position, float explosion_radius, float upwards_modifier, force_mode mode)
std::chrono::duration< float > delta_t
#define APPLOG_TRACE(...)
hpp::small_vector< T, SmallSizeCapacity > physics_vector
#define APP_SCOPE_PERF(name)
Create a scoped performance timer that only accepts string literals.
void on_skip_next_frame(rtti::context &ctx)
static void on_create_component(entt::registry &r, entt::entity e)
void on_play_begin(rtti::context &ctx)
static void apply_force(physics_component &comp, const math::vec3 &force, force_mode mode)
void on_resume(rtti::context &ctx)
void on_pause(rtti::context &ctx)
static void apply_torque(physics_component &comp, const math::vec3 &toruqe, force_mode mode)
static void apply_explosion_force(physics_component &comp, float explosion_force, const math::vec3 &explosion_position, float explosion_radius, float upwards_modifier, force_mode mode)
static void on_destroy_component(entt::registry &r, entt::entity e)
static void clear_kinematic_velocities(physics_component &comp)
void on_frame_update(rtti::context &ctx, delta_t dt)
void on_play_end(rtti::context &ctx)
Manages the entity-component-system (ECS) operations for the ACE framework.
auto get_scene() -> scene &
Gets the current scene.
hpp::event< void(rtti::context &, delta_t)> on_frame_update