2#include <engine/engine_export.h>
7#include <hpp/variant.hpp>
75 hpp::variant<physics_box_shape, physics_sphere_shape, physics_capsule_shape, physics_cylinder_shape>;
206 auto get_mass()
const noexcept -> float;
225 auto is_dirty(uint8_t
id)
const noexcept -> bool;
232 void set_dirty(uint8_t
id,
bool dirty)
noexcept;
284 auto get_shapes()
const ->
const std::vector<physics_compound_shape>&;
305 const math::vec3& explosion_position,
306 float explosion_radius,
307 float upwards_modifier = 0.0f,
347 void on_change_gravity();
352 void on_change_mass();
357 void on_change_kind();
362 void on_change_shape();
367 void on_change_material();
372 void on_change_sensor();
375 bool is_kinematic_{};
377 bool is_using_gravity_{};
381 bool is_autoscaled_{
true};
390 math::vec3 velocity_{};
393 math::vec3 angular_velocity_{};
396 math::bvec3 freeze_position_xyz_{};
399 math::bvec3 freeze_rotation_xyz_{};
405 std::vector<physics_compound_shape> compound_shape_{};
408 using underlying_t = std::underlying_type_t<physics_property>;
412 std::bitset<8> dirty_;
Base class for materials used in rendering.
Component that handles physics properties and behaviors.
auto get_angular_velocity() const -> const math::vec3 &
void apply_torque(const math::vec3 &torque, force_mode mode=force_mode::force)
Applies a torque impulse to the component.
void set_shape_by_index(size_t index, const physics_compound_shape &shape)
Sets a shape by its index.
void apply_force(const math::vec3 &force, force_mode mode=force_mode::force)
auto get_shapes() const -> const std::vector< physics_compound_shape > &
Gets all shapes.
void set_is_using_gravity(bool use_gravity)
Sets whether the component uses gravity.
auto is_using_gravity() const noexcept -> bool
Checks if the component uses gravity.
void set_dirty(uint8_t id, bool dirty) noexcept
Sets the dirty flag for a specific property.
void set_is_autoscaled(bool autoscaled)
Sets whether to autoscale the physics shape.
void set_collision_include_mask(layer_mask group)
auto is_autoscaled() const noexcept -> bool
Checks if the physics shape is autoscaled.
void apply_explosion_force(float explosion_force, const math::vec3 &explosion_position, float explosion_radius, float upwards_modifier=0.0f, force_mode mode=force_mode::force)
auto get_collision_mask() const -> layer_mask
auto get_mass() const noexcept -> float
Gets the mass of the component.
void set_property_dirty(physics_property prop, bool dirty) noexcept
Sets the dirty flag for a specific physics property.
auto get_collision_include_mask() const -> layer_mask
auto get_freeze_position() const -> const math::bvec3 &
auto are_all_properties_dirty() const noexcept -> bool
Checks if all properties are dirty.
void set_collision_exclude_mask(layer_mask group)
auto get_velocity() const -> const math::vec3 &
void set_freeze_position(const math::bvec3 &xyz)
void set_shapes(const std::vector< physics_compound_shape > &shape)
Sets the shapes.
void set_velocity(const math::vec3 &velocity)
auto are_any_properties_dirty() const noexcept -> bool
Checks if any properties are dirty.
auto get_collision_exclude_mask() const -> layer_mask
void set_material(const asset_handle< physics_material > &material)
Sets the material of the component.
void set_angular_velocity(const math::vec3 &velocity)
static void on_destroy_component(entt::registry &r, entt::entity e)
Called when the component is destroyed.
void clear_kinematic_velocities()
Clears kinematic velocities.
auto get_freeze_rotation() const -> const math::bvec3 &
static void on_create_component(entt::registry &r, entt::entity e)
Called when the component is created.
auto is_kinematic() const noexcept -> bool
Checks if the component is kinematic.
auto is_sensor() const noexcept -> bool
Checks if the component is a sensor.
auto is_property_dirty(physics_property prop) const noexcept -> bool
Checks if a specific physics property is dirty.
auto get_material() const -> const asset_handle< physics_material > &
Gets the material of the component.
void set_mass(float mass)
Sets the mass of the component.
auto get_shape_by_index(size_t index) const -> const physics_compound_shape &
Gets a shape by its index.
auto get_shapes_count() const -> size_t
Gets the count of shapes.
void set_freeze_rotation(const math::bvec3 &xyz)
void set_is_kinematic(bool kinematic)
Sets whether the component is kinematic.
auto is_dirty(uint8_t id) const noexcept -> bool
Checks if a specific property is dirty.
void set_is_sensor(bool sensor)
Sets whether the component is a sensor.
physics_property
Enum for different physics properties.
Represents a handle to an asset, providing access and management functions.
CRTP (Curiously Recurring Template Pattern) base structure for components.
Represents a box shape for physics calculations.
friend auto operator==(const physics_box_shape &lhs, const physics_box_shape &rhs) -> bool=default
math::vec3 extends
Extents of the box.
math::vec3 center
Center of the box.
Represents a capsule shape for physics calculations.
friend auto operator==(const physics_capsule_shape &lhs, const physics_capsule_shape &rhs) -> bool=default
float length
Length of the capsule.
math::vec3 center
Center of the capsule.
float radius
Radius of the capsule.
Represents a compound shape that can contain multiple types of shapes.
shape_t shape
The shape contained in the compound shape.
friend auto operator==(const physics_compound_shape &lhs, const physics_compound_shape &rhs) -> bool=default
hpp::variant< physics_box_shape, physics_sphere_shape, physics_capsule_shape, physics_cylinder_shape > shape_t
Represents a cylinder shape for physics calculations.
friend auto operator==(const physics_cylinder_shape &lhs, const physics_cylinder_shape &rhs) -> bool=default
float length
Length of the cylinder.
math::vec3 center
Center of the cylinder.
float radius
Radius of the cylinder.
Represents a sphere shape for physics calculations.
float radius
Radius of the sphere.
friend auto operator==(const physics_sphere_shape &lhs, const physics_sphere_shape &rhs) -> bool=default
math::vec3 center
Center of the sphere.