Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::physics_component Class Reference

Component that handles physics properties and behaviors. More...

#include <physics_component.h>

Inheritance diagram for unravel::physics_component:
unravel::component_crtp< physics_component, owned_component > unravel::owned_component unravel::basic_component

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.
 
- Public Member Functions inherited from unravel::owned_component
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.
 
- Public Member Functions inherited from unravel::basic_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.
 
- Static Public Member Functions inherited from unravel::owned_component
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

- Public Types inherited from unravel::component_crtp< physics_component, owned_component >
using base
 
- Public Attributes inherited from unravel::basic_component
bool eto {}
 Disable empty type optimizations.
 
- Static Public Attributes inherited from unravel::component_crtp< physics_component, owned_component >
static constexpr bool in_place_delete
 Indicates if the component can be deleted in place.
 

Detailed Description

Component that handles physics properties and behaviors.

Definition at line 143 of file physics_component.h.

Member Function Documentation

◆ apply_explosion_force()

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.

◆ apply_force()

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.

◆ apply_torque()

void unravel::physics_component::apply_torque ( const math::vec3 & torque,
force_mode mode = force_mode::force )

Applies a torque impulse to the component.

Parameters
torque_impulseThe torque impulse vector.

Definition at line 232 of file physics_component.cpp.

◆ are_all_properties_dirty()

auto unravel::physics_component::are_all_properties_dirty ( ) const -> bool
noexcept

Checks if all properties are dirty.

Returns
True if all properties are dirty, false otherwise.

Definition at line 152 of file physics_component.cpp.

◆ are_any_properties_dirty()

auto unravel::physics_component::are_any_properties_dirty ( ) const -> bool
noexcept

Checks if any properties are dirty.

Returns
True if any properties are dirty, false otherwise.

Definition at line 147 of file physics_component.cpp.

◆ clear_kinematic_velocities()

void unravel::physics_component::clear_kinematic_velocities ( )

Clears kinematic velocities.

Definition at line 237 of file physics_component.cpp.

◆ get_angular_velocity()

auto unravel::physics_component::get_angular_velocity ( ) const -> const math::vec3&

Definition at line 286 of file physics_component.cpp.

◆ get_collision_exclude_mask()

auto unravel::physics_component::get_collision_exclude_mask ( ) const -> layer_mask

Definition at line 309 of file physics_component.cpp.

◆ get_collision_include_mask()

auto unravel::physics_component::get_collision_include_mask ( ) const -> layer_mask

Definition at line 298 of file physics_component.cpp.

◆ get_collision_mask()

auto unravel::physics_component::get_collision_mask ( ) const -> layer_mask

Definition at line 320 of file physics_component.cpp.

◆ get_freeze_position()

auto unravel::physics_component::get_freeze_position ( ) const -> const math::bvec3&

Definition at line 270 of file physics_component.cpp.

◆ get_freeze_rotation()

auto unravel::physics_component::get_freeze_rotation ( ) const -> const math::bvec3&

Definition at line 266 of file physics_component.cpp.

◆ get_mass()

auto unravel::physics_component::get_mass ( ) const -> float
noexcept

Gets the mass of the component.

Returns
The mass of the component.

Definition at line 94 of file physics_component.cpp.

◆ get_material()

auto unravel::physics_component::get_material ( ) const -> const asset_handle<physics_material>&

Gets the material of the component.

Returns
The asset handle to the material.

Definition at line 192 of file physics_component.cpp.

◆ get_shape_by_index()

auto unravel::physics_component::get_shape_by_index ( size_t index) const -> const physics_compound_shape&

Gets a shape by its index.

Parameters
indexThe index of the shape.
Returns
A constant reference to the shape.

Definition at line 166 of file physics_component.cpp.

◆ get_shapes()

auto unravel::physics_component::get_shapes ( ) const -> const std::vector<physics_compound_shape>&

Gets all shapes.

Returns
A constant reference to the vector of shapes.

Definition at line 175 of file physics_component.cpp.

◆ get_shapes_count()

auto unravel::physics_component::get_shapes_count ( ) const -> size_t

Gets the count of shapes.

Returns
The number of shapes.

Definition at line 162 of file physics_component.cpp.

◆ get_velocity()

auto unravel::physics_component::get_velocity ( ) const -> const math::vec3&

Definition at line 275 of file physics_component.cpp.

◆ is_autoscaled()

auto unravel::physics_component::is_autoscaled ( ) const -> bool
noexcept

Checks if the physics shape is autoscaled.

Returns
True if autoscaled, false otherwise.

Definition at line 50 of file physics_component.cpp.

◆ is_dirty()

auto unravel::physics_component::is_dirty ( uint8_t id) const -> bool
noexcept

Checks if a specific property is dirty.

Parameters
idThe property ID.
Returns
True if the property is dirty, false otherwise.

Definition at line 127 of file physics_component.cpp.

◆ is_kinematic()

auto unravel::physics_component::is_kinematic ( ) const -> bool
noexcept

Checks if the component is kinematic.

Returns
True if kinematic, false otherwise.

Definition at line 34 of file physics_component.cpp.

◆ is_property_dirty()

auto unravel::physics_component::is_property_dirty ( physics_property prop) const -> bool
noexcept

Checks if a specific physics property is dirty.

Parameters
propThe physics property.
Returns
True if the property is dirty, false otherwise.

Definition at line 142 of file physics_component.cpp.

◆ is_sensor()

auto unravel::physics_component::is_sensor ( ) const -> bool
noexcept

Checks if the component is a sensor.

Returns
True if sensor, false otherwise.

Definition at line 116 of file physics_component.cpp.

◆ is_using_gravity()

auto unravel::physics_component::is_using_gravity ( ) const -> bool
noexcept

Checks if the component uses gravity.

Returns
True if using gravity, false otherwise.

Definition at line 67 of file physics_component.cpp.

◆ on_create_component()

void unravel::physics_component::on_create_component ( entt::registry & r,
entt::entity e )
static

Called when the component is created.

Parameters
rThe registry containing the component.
eThe entity associated with the component.

Definition at line 9 of file physics_component.cpp.

◆ on_destroy_component()

void unravel::physics_component::on_destroy_component ( entt::registry & r,
entt::entity e )
static

Called when the component is destroyed.

Parameters
rThe registry containing the component.
eThe entity associated with the component.

Definition at line 19 of file physics_component.cpp.

◆ set_angular_velocity()

void unravel::physics_component::set_angular_velocity ( const math::vec3 & velocity)

Definition at line 290 of file physics_component.cpp.

◆ set_collision_exclude_mask()

void unravel::physics_component::set_collision_exclude_mask ( layer_mask group)

Definition at line 313 of file physics_component.cpp.

◆ set_collision_include_mask()

void unravel::physics_component::set_collision_include_mask ( layer_mask group)

Definition at line 302 of file physics_component.cpp.

◆ set_dirty()

void unravel::physics_component::set_dirty ( uint8_t id,
bool dirty )
noexcept

Sets the dirty flag for a specific property.

Parameters
idThe property ID.
dirtyTrue to set the property as dirty, false otherwise.

Definition at line 132 of file physics_component.cpp.

◆ set_freeze_position()

void unravel::physics_component::set_freeze_position ( const math::bvec3 & xyz)

Definition at line 254 of file physics_component.cpp.

◆ set_freeze_rotation()

void unravel::physics_component::set_freeze_rotation ( const math::bvec3 & xyz)

Definition at line 242 of file physics_component.cpp.

◆ set_is_autoscaled()

void unravel::physics_component::set_is_autoscaled ( bool autoscaled)

Sets whether to autoscale the physics shape.

Parameters
autoscaledTrue if autoscaled, false otherwise.

Definition at line 45 of file physics_component.cpp.

◆ set_is_kinematic()

void unravel::physics_component::set_is_kinematic ( bool kinematic)

Sets whether the component is kinematic.

Parameters
kinematicTrue if kinematic, false otherwise.

Definition at line 23 of file physics_component.cpp.

◆ set_is_sensor()

void unravel::physics_component::set_is_sensor ( bool sensor)

Sets whether the component is a sensor.

Parameters
sensorTrue if sensor, false otherwise.

Definition at line 105 of file physics_component.cpp.

◆ set_is_using_gravity()

void unravel::physics_component::set_is_using_gravity ( bool use_gravity)

Sets whether the component uses gravity.

Parameters
use_gravityTrue to use gravity, false otherwise.

Definition at line 55 of file physics_component.cpp.

◆ set_mass()

void unravel::physics_component::set_mass ( float mass)

Sets the mass of the component.

Parameters
massThe mass to set.

Definition at line 78 of file physics_component.cpp.

◆ set_material()

void unravel::physics_component::set_material ( const asset_handle< physics_material > & material)

Sets the material of the component.

Parameters
materialThe material to set.

Definition at line 196 of file physics_component.cpp.

◆ set_property_dirty()

void unravel::physics_component::set_property_dirty ( physics_property prop,
bool dirty )
noexcept

Sets the dirty flag for a specific physics property.

Parameters
propThe physics property.
dirtyTrue to set the property as dirty, false otherwise.

Definition at line 157 of file physics_component.cpp.

◆ set_shape_by_index()

void unravel::physics_component::set_shape_by_index ( size_t index,
const physics_compound_shape & shape )

Sets a shape by its index.

Parameters
indexThe index of the shape.
shapeThe shape to set.

Definition at line 170 of file physics_component.cpp.

◆ set_shapes()

void unravel::physics_component::set_shapes ( const std::vector< physics_compound_shape > & shape)

Sets the shapes.

Parameters
shapeThe vector of shapes to set.

Definition at line 179 of file physics_component.cpp.

◆ set_velocity()

void unravel::physics_component::set_velocity ( const math::vec3 & velocity)

Definition at line 279 of file physics_component.cpp.


The documentation for this class was generated from the following files: