15 component.dirty_.set();
16 component.dirty_properties_.set();
25 if(is_kinematic_ == kinematic)
30 is_kinematic_ = kinematic;
39void physics_component::on_change_kind()
47 is_autoscaled_ = autoscaled;
52 return is_autoscaled_;
57 if(is_using_gravity_ == use_gravity)
62 is_using_gravity_ = use_gravity;
69 return is_using_gravity_;
72void physics_component::on_change_gravity()
80 if(math::epsilonEqual(mass_,
mass, math::epsilon<float>()))
99void physics_component::on_change_mass()
121void physics_component::on_change_sensor()
134 dirty_.set(
id, dirty);
138 dirty_properties_ = {};
144 return dirty_properties_[
static_cast<std::underlying_type_t<physics_property>
>(prop)];
149 return dirty_properties_.any();
154 return dirty_properties_.all();
159 dirty_properties_[
static_cast<std::underlying_type_t<physics_property>
>(prop)] = dirty;
164 return compound_shape_.size();
168 return compound_shape_.at(index);
172 compound_shape_.at(index) =
shape;
177 return compound_shape_;
181 compound_shape_ =
shape;
186void physics_component::on_change_shape()
204 on_change_material();
207void physics_component::on_change_material()
214 const math::vec3& explosion_position,
215 float explosion_radius,
216 float upwards_modifier,
244 if(freeze_rotation_xyz_ == xyz)
249 freeze_rotation_xyz_ = xyz;
256 if(freeze_position_xyz_ == xyz)
260 freeze_position_xyz_ = xyz;
268 return freeze_rotation_xyz_;
272 return freeze_position_xyz_;
288 return angular_velocity_;
300 return collision_include_mask_;
306 collision_include_mask_ = group;
311 return collision_exclude_mask_;
317 collision_exclude_mask_ = mask;
322 return layer_mask{collision_include_mask_.
mask & ~collision_exclude_mask_.mask};
Base class for materials used in rendering.
void set_owner(entt::handle owner)
Sets the owner of the component.
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.
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.
static void clear_kinematic_velocities(physics_component &comp)
Clears kinematic velocities for the specified physics component.
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)
physics_property
Enum for different physics properties.
Represents a handle to an asset, providing access and management functions.
Represents a compound shape that can contain multiple types of shapes.
Represents the physical properties of a material.