Classes¶
Physics/Components
Brief descriptions¶
Classes |
|
Implements rigid body component logic. |
Detailed information¶
physics::RigidBodyComponent¶
engine/core/modules/physics/include/nau/physics/components/rigid_body_component.h
-
class RigidBodyComponent : public nau::scene::SceneComponent, public nau::scene::IComponentUpdate¶
Implements rigid body component logic.
Such components can be attached to scene objects to make them exhibit ‘physically correct’ behavior. Concrete behavior relies on the utilized physics engine and IPhysicsBody implementation.
Public Functions
-
virtual void updateComponent(float dt) override¶
Keeps the parent scene object transformation up to date with the transformation of the associated body in the physical world.
-
void setCollisions(CollisionDescription collisions)¶
Modifies the collection of colliders attached to the component.
- Parameters:
collisions – [in] New description to assign.
-
const CollisionDescription &getCollisions() const¶
Retrieves the collection of colliders attached to the component.
- Returns:
Collection of attached colliders.
-
CollisionDescription &getCollisions()¶
Provides access to the colliders attached to the component.
- Returns:
A reference to the collection of colliders attached to the component.
-
void setMeshCollision(AssetRef<>)¶
Changes the mesh collider attached to the component.
- Parameters:
Mesh – [in] asset to assign.
-
AssetRef getMeshCollision() const¶
Retrieves the mesh collider attached to the component.
- Returns:
Mesh asset used for the collider attached to the component.
-
void setUseConvexHullForCollision(bool useConvexHull)¶
Changes whether the attached mesh collider should considered a convex hull.
- Parameters:
useConvexHull – [in] Indicates whether the mesh collider should be considered a convex hull or a standard mesh.
-
bool useConvexHullForCollision() const¶
Checks whether the attached component should be considered a convex hull or a standard mesh.
- Returns:
true
if the attached mesh collider is considered a convex hull,false
if it is used as a standard mesh.
-
void setCollisionChannel(CollisionChannel channel)¶
Changes the component collision channel.
- Parameters:
channel – [in] Channel to assign.
-
CollisionChannel getCollisionChannel() const¶
Retrieves the collision channel assigned to the component.
- Returns:
Assigned collision channel.
-
void setMotionType(MotionType motionType)¶
Changes the rigid body motion type.
- Parameters:
motionType – [in] Motion type to assign.
-
MotionType getMotionType() const¶
Retrieves the rigid body motion type.
- Returns:
Rigid body motion type.
-
void setFriction(TFloat friction)¶
Changes the rigid body friction.
- Parameters:
friction – [in] Value to assign.
-
void setRestitution(TFloat restitution)¶
Changes the rigid body restitution.
- Parameters:
restitution – [in] Value to assign.
-
TFloat getRestitution() const¶
Retrieves the rigid body restitution.
- Returns:
Restitution of the rigid body.
-
void setIsTrigger(bool isTrigger)¶
Changes whether the rigid body collider should be considered a trigger.
- Parameters:
isTrigger – [in] Indicates whether the rigid body collider should be considered a trigger or not.
-
bool isTrigger() const¶
Checks whether the rigid body collider should be considered a trigger.
- Returns:
true
if the rigid body collider should be considered a trigger,false
otherwise.
-
void setDebugDrawEnabled(bool enabled)¶
Changes whether drawing the collider outline is enabled.
- Parameters:
`true` – [in] is drawing the collider outline should be enabled,
false
otherwise.
-
bool isDebugDrawEnabled() const¶
Checks whether drawing the collider outline is enabled.
- Returns:
true
if drawing the collider outline is enabled,false
otherwise.
-
void addForce(math::vec3 force)¶
Applies the force to the center of mass of the physics body.
- Parameters:
force – [in] Force to apply.
-
void addForce(math::vec3 force, math::vec3 applyPoint)¶
Applies the force to the physics body.
- Parameters:
force – [in] Force to apply.
applyPoint – [in] Point to apply the force at.
-
void addTorque(math::vec3 torque)¶
Applies the torque to the physics body.
- Parameters:
torque – [in] Torque to apply.
-
void addImpulse(math::vec3 impulse)¶
Applies the force to the center of mass of the physics body.
- Parameters:
impulse – [in] Impulse to apply.
-
void addImpulse(math::vec3 impulse, math::vec3 applyPoint)¶
Applies the impulse to the physics body.
- Parameters:
force – [in] Impulse to apply.
applyPoint – [in] Point to apply the impulse at.
Private Types
-
using PhysicsBodyAction = Functor<void(IPhysicsBody &body)>¶
-
using PhysicsBodyActions = eastl::vector<PhysicsBodyAction>¶
Private Functions
-
void applyPhysicsBodyActions(IPhysicsBody *body)¶
Private Members
- m_collisions
- collisions
- m_meshCollisionAsset
- meshCollision
- m_useConvexHullForCollision
- useConvexHullForCollision
- m_collisionChannel
- collisionChannel
- m_motionType
- motionType
- m_mass
- mass
- m_friction
- friction
- m_restitution
- restitution
- m_isTrigger
-
CollisionDescription m_collisions¶
-
bool m_useConvexHullForCollision = false¶
-
CollisionChannel m_collisionChannel = 0¶
-
MotionType m_motionType = MotionType::Static¶
-
bool m_isTrigger = false¶
-
bool m_isDebugDrawEnabled = false¶
-
PhysicsBodyActions m_pendingActions¶
Friends
- friend class PhysicsWorldState
-
virtual void updateComponent(float dt) override¶