Unravel Engine C++ Reference
|
Component that handles physics properties and behaviors. More...
#include <physics_component.h>
Public Member Functions | |
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_is_kinematic (bool kinematic) |
Sets whether the component is kinematic. | |
auto | is_kinematic () const noexcept -> bool |
Checks if the component is kinematic. | |
void | set_is_autoscaled (bool autoscaled) |
Sets whether to autoscale the physics shape. | |
auto | is_autoscaled () const noexcept -> bool |
Checks if the physics shape is autoscaled. | |
void | set_mass (float mass) |
Sets the mass of the component. | |
auto | get_mass () const noexcept -> float |
Gets the mass of the component. | |
void | set_is_sensor (bool sensor) |
Sets whether the component is a sensor. | |
auto | is_sensor () const noexcept -> bool |
Checks if the component is a sensor. | |
auto | is_dirty (uint8_t id) const noexcept -> bool |
Checks if a specific property is dirty. | |
void | set_dirty (uint8_t id, bool dirty) noexcept |
Sets the dirty flag for a specific property. | |
auto | is_property_dirty (physics_property prop) const noexcept -> bool |
Checks if a specific physics property is dirty. | |
auto | are_any_properties_dirty () const noexcept -> bool |
Checks if any properties are dirty. | |
auto | are_all_properties_dirty () const noexcept -> bool |
Checks if all properties are dirty. | |
void | set_property_dirty (physics_property prop, bool dirty) noexcept |
Sets the dirty flag for a specific physics property. | |
auto | get_shapes_count () const -> size_t |
Gets the count of shapes. | |
auto | get_shape_by_index (size_t index) const -> const physics_compound_shape & |
Gets a shape by its index. | |
void | set_shape_by_index (size_t index, const physics_compound_shape &shape) |
Sets a shape by its index. | |
auto | get_shapes () const -> const std::vector< physics_compound_shape > & |
Gets all shapes. | |
void | set_shapes (const std::vector< physics_compound_shape > &shape) |
Sets the shapes. | |
auto | get_material () const -> const asset_handle< physics_material > & |
Gets the material of the component. | |
void | set_material (const asset_handle< physics_material > &material) |
Sets the material of the component. | |
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) |
void | apply_force (const math::vec3 &force, force_mode mode=force_mode::force) |
void | apply_torque (const math::vec3 &torque, force_mode mode=force_mode::force) |
Applies a torque impulse to the component. | |
void | set_freeze_rotation (const math::bvec3 &xyz) |
void | set_freeze_position (const math::bvec3 &xyz) |
auto | get_freeze_rotation () const -> const math::bvec3 & |
auto | get_freeze_position () const -> const math::bvec3 & |
auto | get_velocity () const -> const math::vec3 & |
void | set_velocity (const math::vec3 &velocity) |
auto | get_angular_velocity () const -> const math::vec3 & |
void | set_angular_velocity (const math::vec3 &velocity) |
auto | get_collision_include_mask () const -> layer_mask |
void | set_collision_include_mask (layer_mask group) |
auto | get_collision_exclude_mask () const -> layer_mask |
void | set_collision_exclude_mask (layer_mask group) |
auto | get_collision_mask () const -> layer_mask |
void | clear_kinematic_velocities () |
Clears kinematic velocities. | |
![]() | |
auto | operator= (const owned_component &other) -> owned_component &=default |
void | set_owner (entt::handle owner) |
Sets the owner of the component. | |
auto | get_owner () const noexcept -> entt::const_handle |
Gets the owner of the component. | |
auto | get_owner () noexcept -> entt::handle |
Gets the owner of the component. | |
![]() | |
void | touch () |
Marks the component as 'touched'. | |
Static Public Member Functions | |
static void | on_create_component (entt::registry &r, entt::entity e) |
Called when the component is created. | |
static void | on_destroy_component (entt::registry &r, entt::entity e) |
Called when the component is destroyed. | |
![]() | |
template<typename T > | |
static void | on_create_component (entt::registry &r, entt::entity e) |
template<typename T > | |
static void | on_destroy_component (entt::registry &r, entt::entity e) |
Additional Inherited Members | |
![]() | |
using | base |
![]() | |
bool | eto {} |
Disable empty type optimizations. | |
![]() | |
static constexpr bool | in_place_delete |
Indicates if the component can be deleted in place. | |
Component that handles physics properties and behaviors.
Definition at line 143 of file physics_component.h.
void unravel::physics_component::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 ) |
Definition at line 213 of file physics_component.cpp.
void unravel::physics_component::apply_force | ( | const math::vec3 & | force, |
force_mode | mode = force_mode::force ) |
Definition at line 227 of file physics_component.cpp.
void unravel::physics_component::apply_torque | ( | const math::vec3 & | torque, |
force_mode | mode = force_mode::force ) |
Applies a torque impulse to the component.
torque_impulse | The torque impulse vector. |
Definition at line 232 of file physics_component.cpp.
|
noexcept |
Checks if all properties are dirty.
Definition at line 152 of file physics_component.cpp.
|
noexcept |
Checks if any properties are dirty.
Definition at line 147 of file physics_component.cpp.
void unravel::physics_component::clear_kinematic_velocities | ( | ) |
Clears kinematic velocities.
Definition at line 237 of file physics_component.cpp.
auto unravel::physics_component::get_angular_velocity | ( | ) | const -> const math::vec3& |
Definition at line 286 of file physics_component.cpp.
auto unravel::physics_component::get_collision_exclude_mask | ( | ) | const -> layer_mask |
Definition at line 309 of file physics_component.cpp.
auto unravel::physics_component::get_collision_include_mask | ( | ) | const -> layer_mask |
Definition at line 298 of file physics_component.cpp.
auto unravel::physics_component::get_collision_mask | ( | ) | const -> layer_mask |
Definition at line 320 of file physics_component.cpp.
auto unravel::physics_component::get_freeze_position | ( | ) | const -> const math::bvec3& |
Definition at line 270 of file physics_component.cpp.
auto unravel::physics_component::get_freeze_rotation | ( | ) | const -> const math::bvec3& |
Definition at line 266 of file physics_component.cpp.
|
noexcept |
Gets the mass of the component.
Definition at line 94 of file physics_component.cpp.
auto unravel::physics_component::get_material | ( | ) | const -> const asset_handle<physics_material>& |
Gets the material of the component.
Definition at line 192 of file physics_component.cpp.
auto unravel::physics_component::get_shape_by_index | ( | size_t | index | ) | const -> const physics_compound_shape& |
Gets a shape by its index.
index | The index of the shape. |
Definition at line 166 of file physics_component.cpp.
auto unravel::physics_component::get_shapes | ( | ) | const -> const std::vector<physics_compound_shape>& |
Gets all shapes.
Definition at line 175 of file physics_component.cpp.
auto unravel::physics_component::get_shapes_count | ( | ) | const -> size_t |
Gets the count of shapes.
Definition at line 162 of file physics_component.cpp.
auto unravel::physics_component::get_velocity | ( | ) | const -> const math::vec3& |
Definition at line 275 of file physics_component.cpp.
|
noexcept |
Checks if the physics shape is autoscaled.
Definition at line 50 of file physics_component.cpp.
|
noexcept |
Checks if a specific property is dirty.
id | The property ID. |
Definition at line 127 of file physics_component.cpp.
|
noexcept |
Checks if the component is kinematic.
Definition at line 34 of file physics_component.cpp.
|
noexcept |
Checks if a specific physics property is dirty.
prop | The physics property. |
Definition at line 142 of file physics_component.cpp.
|
noexcept |
Checks if the component is a sensor.
Definition at line 116 of file physics_component.cpp.
|
noexcept |
Checks if the component uses gravity.
Definition at line 67 of file physics_component.cpp.
|
static |
Called when the component is created.
r | The registry containing the component. |
e | The entity associated with the component. |
Definition at line 9 of file physics_component.cpp.
|
static |
Called when the component is destroyed.
r | The registry containing the component. |
e | The entity associated with the component. |
Definition at line 19 of file physics_component.cpp.
void unravel::physics_component::set_angular_velocity | ( | const math::vec3 & | velocity | ) |
Definition at line 290 of file physics_component.cpp.
void unravel::physics_component::set_collision_exclude_mask | ( | layer_mask | group | ) |
Definition at line 313 of file physics_component.cpp.
void unravel::physics_component::set_collision_include_mask | ( | layer_mask | group | ) |
Definition at line 302 of file physics_component.cpp.
|
noexcept |
Sets the dirty flag for a specific property.
id | The property ID. |
dirty | True to set the property as dirty, false otherwise. |
Definition at line 132 of file physics_component.cpp.
void unravel::physics_component::set_freeze_position | ( | const math::bvec3 & | xyz | ) |
Definition at line 254 of file physics_component.cpp.
void unravel::physics_component::set_freeze_rotation | ( | const math::bvec3 & | xyz | ) |
Definition at line 242 of file physics_component.cpp.
void unravel::physics_component::set_is_autoscaled | ( | bool | autoscaled | ) |
Sets whether to autoscale the physics shape.
autoscaled | True if autoscaled, false otherwise. |
Definition at line 45 of file physics_component.cpp.
void unravel::physics_component::set_is_kinematic | ( | bool | kinematic | ) |
Sets whether the component is kinematic.
kinematic | True if kinematic, false otherwise. |
Definition at line 23 of file physics_component.cpp.
void unravel::physics_component::set_is_sensor | ( | bool | sensor | ) |
Sets whether the component is a sensor.
sensor | True if sensor, false otherwise. |
Definition at line 105 of file physics_component.cpp.
void unravel::physics_component::set_is_using_gravity | ( | bool | use_gravity | ) |
Sets whether the component uses gravity.
use_gravity | True to use gravity, false otherwise. |
Definition at line 55 of file physics_component.cpp.
void unravel::physics_component::set_mass | ( | float | mass | ) |
Sets the mass of the component.
mass | The mass to set. |
Definition at line 78 of file physics_component.cpp.
void unravel::physics_component::set_material | ( | const asset_handle< physics_material > & | material | ) |
Sets the material of the component.
material | The material to set. |
Definition at line 196 of file physics_component.cpp.
|
noexcept |
Sets the dirty flag for a specific physics property.
prop | The physics property. |
dirty | True to set the property as dirty, false otherwise. |
Definition at line 157 of file physics_component.cpp.
void unravel::physics_component::set_shape_by_index | ( | size_t | index, |
const physics_compound_shape & | shape ) |
Sets a shape by its index.
index | The index of the shape. |
shape | The shape to set. |
Definition at line 170 of file physics_component.cpp.
void unravel::physics_component::set_shapes | ( | const std::vector< physics_compound_shape > & | shape | ) |
Sets the shapes.
shape | The vector of shapes to set. |
Definition at line 179 of file physics_component.cpp.
void unravel::physics_component::set_velocity | ( | const math::vec3 & | velocity | ) |
Definition at line 279 of file physics_component.cpp.