Unravel Engine C++ Reference
Loading...
Searching...
No Matches
physics_system.h
Go to the documentation of this file.
1#pragma once
2#include <base/basetypes.hpp>
3#include <context/context.hpp>
4
6
7namespace unravel
8{
9
15{
16public:
18
19
25 auto init(rtti::context& ctx) -> bool;
26
32 auto deinit(rtti::context& ctx) -> bool;
33
39 static void on_create_component(entt::registry& r, entt::entity e);
40
46 static void on_destroy_component(entt::registry& r, entt::entity e);
47
49 float explosion_force,
50 const math::vec3& explosion_position,
51 float explosion_radius,
52 float upwards_modifier,
53 force_mode mode);
54
55 static void apply_force(physics_component& comp, const math::vec3& force, force_mode mode);
56
62 static void apply_torque(physics_component& comp, const math::vec3& torque, force_mode mode);
63
69
70 auto ray_cast(const math::vec3& origin,
71 const math::vec3& direction,
72 float max_distance,
73 int layer_mask,
74 bool query_sensors) const -> hpp::optional<raycast_hit>;
75
76 auto ray_cast_all(const math::vec3& origin,
77 const math::vec3& direction,
78 float max_distance,
79 int layer_mask,
81
82 auto sphere_cast(const math::vec3& origin,
83 const math::vec3& direction,
84 float radius,
85 float max_distance,
86 int layer_mask,
87 bool query_sensors) const -> hpp::optional<raycast_hit>;
88
89 auto sphere_cast_all(const math::vec3& origin,
90 const math::vec3& direction,
91 float radius,
92 float max_distance,
93 int layer_mask,
95
96 auto sphere_overlap(const math::vec3& origin, float radius, int layer_mask, bool query_sensors) const
98
99private:
105 void on_frame_update(rtti::context& ctx, delta_t dt);
106
111 void on_play_begin(rtti::context& ctx);
112
117 void on_play_end(rtti::context& ctx);
118
123 void on_pause(rtti::context& ctx);
124
129 void on_resume(rtti::context& ctx);
130
135 void on_skip_next_frame(rtti::context& ctx);
136
137 std::shared_ptr<int> sentinel_ = std::make_shared<int>(0);
138
139 backend_type backend_;
140};
141
142} // namespace unravel
bool query_sensors
Component that handles physics properties and behaviors.
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
hpp::small_vector< T, SmallSizeCapacity > physics_vector