Clutter Engine 0.0.1
|
Represents a rigid body for 3D physics simulation. More...
#include <RigidBody.h>
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. | |
![]() | |
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. | |
Actor * | GetOwner () const |
Gets the owner actor of this component. | |
Public Attributes | |
float | mGravityScale |
The scale of gravity applied to the rigid body. | |
friend | Physics |
![]() | |
friend | Actor |
Additional Inherited Members | |
![]() | |
bool | LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false) |
Performs a line trace (raycast) using the owning actor. | |
![]() | |
bool | mIsActive = true |
Indicates if the component is active. | |
int | mUpdateOrder = 0 |
The order in which the component is updated. | |
Actor * | mOwner |
The actor that owns this component. | |
Transform | mRelativeTransform |
The relative transform of the component to its owner. | |
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.
RigidBody::RigidBody | ( | float | pMass = 1, |
int | pUpdadeOrder = 0 ) |
Constructs a RigidBody with an optional update order.
pMass | The mass of the rigid body. |
pUpdadeOrder | The update order of the component. |
void RigidBody::AddAngularImpulse | ( | const Vector3 & | pImpulse | ) |
Adds an angular impulse to the rigid body.
pImpulse | The angular impulse to add. |
|
inline |
Adds to the current angular velocity of the rigid body.
pVel | The angular velocity to add. |
|
inline |
Adds a force to the rigid body.
pForce | The force to add. |
|
inline |
Adds a torque to the rigid body.
pTorque | The torque to add. |
|
inline |
Adds to the current velocity of the rigid body using a 2D vector.
pVelocity | The velocity to add. |
|
inline |
Adds to the current velocity of the rigid body.
pVelocity | The velocity to add. |
Applies a force at a specific point on the rigid body.
force | The force vector. |
point | The point of application in world coordinates. |
Applies an impulse at a specific point on the rigid body.
impulse | The impulse vector. |
point | The point of application in world coordinates. |
|
inline |
Gets the current angular velocity of the rigid body.
|
inline |
Gets the current gravity scale of the rigid body.
|
inline |
Gets the inertia of the rigid body.
|
inline |
Gets the inverse inertia of the rigid body.
|
inline |
Gets the inverse mass of the rigid body.
|
inline |
Gets the mass of the rigid body.
|
inline |
Gets the current velocity of the rigid body.
|
inline |
Checks if the rigid body is grounded.
|
inline |
Checks if the rigid body is kinematic.
|
inline |
Checks if the rotation of the rigid body is locked.
|
inline |
Locks or unlocks the rotation of the rigid body.
lock | True to lock rotation, false to unlock. |
|
inline |
Sets the angular velocity of the rigid body.
pVel | The new angular velocity. |
|
inline |
Sets the gravity scale of the rigid body.
pGravityScale | The new gravity scale. |
|
inline |
Sets the grounded state of the rigid body.
grounded | Whether the rigid body is grounded. |
|
inline |
Sets the mass of the rigid body and updates inverse mass and inertia.
mass | The new mass. |
|
overridevirtual |
Sets the owner of the component.
pOwner | The owner actor. |
Reimplemented from clt::Component.
|
inline |
Sets whether the rigid body should simulate physics.
simulate | True to simulate, false otherwise. |
|
inline |
Sets the velocity of the rigid body.
pVelocity | The new velocity. |
|
inline |
Checks if the rigid body is simulating physics.