Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::RigidBody Class Reference

Represents a rigid body for 3D physics simulation. More...

#include <RigidBody.h>

Inheritance diagram for clt::RigidBody:
clt::Component

Public Member Functions

 RigidBody (float pMass=1, int pUpdadeOrder=0)
 Constructs a RigidBody with an optional update order.
 
 ~RigidBody ()=default
 Default destructor.
 
virtual void SetOwner (Actor *pOwner) override
 Sets the owner of the component.
 
void SetVelocity (const Vector3 &pVelocity)
 Sets the velocity of the rigid body.
 
void AddVelocity (const Vector3 &pVelocity)
 Adds to the current velocity of the rigid body.
 
void AddVelocity (const Vector2 &pVelocity)
 Adds to the current velocity of the rigid body using a 2D vector.
 
void AddForce (const Vector3 &pForce)
 Adds a force to the rigid body.
 
void AddTorque (const Vector3 &pTorque)
 Adds a torque to the rigid body.
 
void ApplyForceAtPoint (const Vector3 &force, const Vector3 &point)
 Applies a force at a specific point on the rigid body.
 
void ApplyImpulseAtPoint (const Vector3 &impulse, const Vector3 &point)
 Applies an impulse at a specific point on the rigid body.
 
void SetAngularVelocity (const Vector3 &pVel)
 Sets the angular velocity of the rigid body.
 
void AddAngularVelocity (const Vector3 &pVel)
 Adds to the current angular velocity of the rigid body.
 
void AddAngularImpulse (const Vector3 &pImpulse)
 Adds an angular impulse to the rigid body.
 
void SetGravityScale (float pGravityScale)
 Sets the gravity scale of the rigid body.
 
void SetGrounded (bool grounded=true)
 Sets the grounded state of the rigid body.
 
Vector3 GetVelocity () const
 Gets the current velocity of the rigid body.
 
Vector3 GetAngularVelocity () const
 Gets the current angular velocity of the rigid body.
 
float GetGravityScale () const
 Gets the current gravity scale of the rigid body.
 
bool IsGrounded () const
 Checks if the rigid body is grounded.
 
bool SimulatePhysics () const
 Checks if the rigid body is simulating physics.
 
bool IsKinematic () const
 Checks if the rigid body is kinematic.
 
void SetSimulate (bool simulate=true)
 Sets whether the rigid body should simulate physics.
 
void SetMass (float mass)
 Sets the mass of the rigid body and updates inverse mass and inertia.
 
float GetMass () const
 Gets the mass of the rigid body.
 
float GetInvMass () const
 Gets the inverse mass of the rigid body.
 
Vector3 GetInertia () const
 Gets the inertia of the rigid body.
 
Vector3 GetInvInertia () const
 Gets the inverse inertia of the rigid body.
 
void LockRotation (bool lock=true)
 Locks or unlocks the rotation of the rigid body.
 
bool IsRotationLocked () const
 Checks if the rotation of the rigid body is locked.
 
- Public Member Functions inherited from clt::Component
 Component (int pUpdateOrder=0)
 Constructor for Component.
 
virtual ~Component ()=default
 Virtual destructor for Component.
 
virtual void Start ()
 Called when the component is started.
 
virtual void Update ()
 Called every frame to update the component.
 
virtual void Destroy ()
 Called to destroy the component.
 
void SetActive (bool pActive)
 Enables or disables the component.
 
void OnDestroy ()
 Called when the component is destroyed.
 
bool IsActive () const
 Checks if the component is enabled.
 
int GetUpdateOrder () const
 Gets the update order of the component.
 
void SetRelativeLocation (const Vector3 &loc)
 Sets the relative location of the component.
 
void SetRelativeLocation (const Vector2 &loc)
 Sets the relative location of the component.
 
void SetWorldLocation (const Vector3 &loc)
 Sets the world location of the component.
 
void SetRelativeScale (const Vector3 &scale)
 Sets the relative scale of the component.
 
void SetRelativeScale (const Vector2 &scale)
 Sets the relative scale of the component.
 
void SetRelativeRotation (Quaternion rot)
 Sets the relative rotation of the component.
 
void SetRelativeRotation (Vector3 rot)
 Sets the relative rotation of the component.
 
void SetWorldRotation (const Quaternion &rot)
 Sets the world rotation of the component.
 
void SetWorldRotation (const Vector3 &rot)
 Sets the world rotation of the component.
 
void AddRelativeRotation (Vector3 rot)
 Adds a rotation to the current relative rotation.
 
void SetRelativeRotation (float rot)
 Sets the relative rotation of the component.
 
void SetRelativeTransform (Transform &transform)
 Sets the relative transform of the component.
 
Vector3 GetRelativeLocation () const
 Gets the relative location of the component.
 
Vector3 GetRelativeScale () const
 Gets the relative scale of the component.
 
Quaternion GetRelativeRotation () const
 Gets the relative rotation of the component.
 
Vector3 GetRelativeRotationEuler () const
 Gets the relative rotation of the component as Euler angles.
 
Transform GetRelativeTransform () const
 Gets the relative transform of the component.
 
Vector3 GetWorldLocation () const
 Gets the world location of the component.
 
Vector3 GetWorldScale () const
 Gets the world scale of the component.
 
Quaternion GetWorldRotation () const
 Gets the world rotation of the component.
 
virtual Transform GetWorldTransform () const
 Gets the world transform of the component.
 
ActorGetOwner () const
 Gets the owner actor of this component.
 

Public Attributes

float mGravityScale
 The scale of gravity applied to the rigid body.
 
friend Physics
 
- Public Attributes inherited from clt::Component
friend Actor
 

Additional Inherited Members

- Protected Member Functions inherited from clt::Component
bool LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false)
 Performs a line trace (raycast) using the owning actor.
 
- Protected Attributes inherited from clt::Component
bool mIsActive = true
 Indicates if the component is active.
 
int mUpdateOrder = 0
 The order in which the component is updated.
 
ActormOwner
 The actor that owns this component.
 
Transform mRelativeTransform
 The relative transform of the component to its owner.
 

Detailed Description

Represents a rigid body for 3D physics simulation.

This component handles velocity, acceleration, forces, torque, mass, inertia, and other physical properties for an actor. It provides methods to manipulate and query the state of the rigid body, as well as to apply forces and impulses.

Constructor & Destructor Documentation

◆ RigidBody()

RigidBody::RigidBody ( float pMass = 1,
int pUpdadeOrder = 0 )

Constructs a RigidBody with an optional update order.

Parameters
pMassThe mass of the rigid body.
pUpdadeOrderThe update order of the component.

Member Function Documentation

◆ AddAngularImpulse()

void RigidBody::AddAngularImpulse ( const Vector3 & pImpulse)

Adds an angular impulse to the rigid body.

Parameters
pImpulseThe angular impulse to add.

◆ AddAngularVelocity()

void clt::RigidBody::AddAngularVelocity ( const Vector3 & pVel)
inline

Adds to the current angular velocity of the rigid body.

Parameters
pVelThe angular velocity to add.

◆ AddForce()

void clt::RigidBody::AddForce ( const Vector3 & pForce)
inline

Adds a force to the rigid body.

Parameters
pForceThe force to add.

◆ AddTorque()

void clt::RigidBody::AddTorque ( const Vector3 & pTorque)
inline

Adds a torque to the rigid body.

Parameters
pTorqueThe torque to add.

◆ AddVelocity() [1/2]

void clt::RigidBody::AddVelocity ( const Vector2 & pVelocity)
inline

Adds to the current velocity of the rigid body using a 2D vector.

Parameters
pVelocityThe velocity to add.

◆ AddVelocity() [2/2]

void clt::RigidBody::AddVelocity ( const Vector3 & pVelocity)
inline

Adds to the current velocity of the rigid body.

Parameters
pVelocityThe velocity to add.

◆ ApplyForceAtPoint()

void RigidBody::ApplyForceAtPoint ( const Vector3 & force,
const Vector3 & point )

Applies a force at a specific point on the rigid body.

Parameters
forceThe force vector.
pointThe point of application in world coordinates.

◆ ApplyImpulseAtPoint()

void RigidBody::ApplyImpulseAtPoint ( const Vector3 & impulse,
const Vector3 & point )

Applies an impulse at a specific point on the rigid body.

Parameters
impulseThe impulse vector.
pointThe point of application in world coordinates.

◆ GetAngularVelocity()

Vector3 clt::RigidBody::GetAngularVelocity ( ) const
inline

Gets the current angular velocity of the rigid body.

Returns
The current angular velocity.

◆ GetGravityScale()

float clt::RigidBody::GetGravityScale ( ) const
inline

Gets the current gravity scale of the rigid body.

Returns
The current gravity scale.

◆ GetInertia()

Vector3 clt::RigidBody::GetInertia ( ) const
inline

Gets the inertia of the rigid body.

Returns
The inertia vector.

◆ GetInvInertia()

Vector3 clt::RigidBody::GetInvInertia ( ) const
inline

Gets the inverse inertia of the rigid body.

Returns
The inverse inertia vector.

◆ GetInvMass()

float clt::RigidBody::GetInvMass ( ) const
inline

Gets the inverse mass of the rigid body.

Returns
The inverse mass.

◆ GetMass()

float clt::RigidBody::GetMass ( ) const
inline

Gets the mass of the rigid body.

Returns
The mass.

◆ GetVelocity()

Vector3 clt::RigidBody::GetVelocity ( ) const
inline

Gets the current velocity of the rigid body.

Returns
The current velocity.

◆ IsGrounded()

bool clt::RigidBody::IsGrounded ( ) const
inline

Checks if the rigid body is grounded.

Returns
True if grounded, false otherwise.

◆ IsKinematic()

bool clt::RigidBody::IsKinematic ( ) const
inline

Checks if the rigid body is kinematic.

Returns
True if kinematic, false otherwise.

◆ IsRotationLocked()

bool clt::RigidBody::IsRotationLocked ( ) const
inline

Checks if the rotation of the rigid body is locked.

Returns
True if rotation is locked, false otherwise.

◆ LockRotation()

void clt::RigidBody::LockRotation ( bool lock = true)
inline

Locks or unlocks the rotation of the rigid body.

Parameters
lockTrue to lock rotation, false to unlock.

◆ SetAngularVelocity()

void clt::RigidBody::SetAngularVelocity ( const Vector3 & pVel)
inline

Sets the angular velocity of the rigid body.

Parameters
pVelThe new angular velocity.

◆ SetGravityScale()

void clt::RigidBody::SetGravityScale ( float pGravityScale)
inline

Sets the gravity scale of the rigid body.

Parameters
pGravityScaleThe new gravity scale.

◆ SetGrounded()

void clt::RigidBody::SetGrounded ( bool grounded = true)
inline

Sets the grounded state of the rigid body.

Parameters
groundedWhether the rigid body is grounded.

◆ SetMass()

void clt::RigidBody::SetMass ( float mass)
inline

Sets the mass of the rigid body and updates inverse mass and inertia.

Parameters
massThe new mass.

◆ SetOwner()

void RigidBody::SetOwner ( Actor * pOwner)
overridevirtual

Sets the owner of the component.

Parameters
pOwnerThe owner actor.

Reimplemented from clt::Component.

◆ SetSimulate()

void clt::RigidBody::SetSimulate ( bool simulate = true)
inline

Sets whether the rigid body should simulate physics.

Parameters
simulateTrue to simulate, false otherwise.

◆ SetVelocity()

void clt::RigidBody::SetVelocity ( const Vector3 & pVelocity)
inline

Sets the velocity of the rigid body.

Parameters
pVelocityThe new velocity.

◆ SimulatePhysics()

bool clt::RigidBody::SimulatePhysics ( ) const
inline

Checks if the rigid body is simulating physics.

Returns
True if simulating, false otherwise.

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