StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
StevEngine::Physics::RigidBody Class Referencefinal

Physics rigid body component. More...

#include <physics/RigidBody.hpp>

Inheritance diagram for StevEngine::Physics::RigidBody:
StevEngine::Component

Public Member Functions

JPH::Body * GetBody () const
 Get Jolt physics body.
 
 RigidBody (JPH::EMotionType motionType, Layer *layer, float mass=1000)
 Create rigid body.
 
 RigidBody (Utilities::Stream &stream)
 Create rigidbody from text serialized data.
 
std::string GetType () const
 Get component type.
 
Utilities::Stream Export (Utilities::StreamType type) const
 Serialize component to a stream.
 
void Start ()
 Initialize component.
 
void Deactivate ()
 Clean up when deactivated.
 
void Update (double deltaTime)
 Update transform from physics.
 
 ~RigidBody ()
 Clean up resources.
 
void SetMotionProperties (MotionProperties properties)
 Set motion properties.
 
bool IsActive () const
 Check if body is currently active in the physics simulation.
 
bool IsStatic () const
 Check if this is a static body.
 
bool IsKinematic () const
 Check if this is a kinematic body.
 
bool IsDynamic () const
 Check if this is a dynamic body.
 
float GetFriction () const
 Get the friction coefficient.
 
void SetFriction (float inFriction)
 Set the friction coefficient.
 
Utilities::Vector3 GetLinearVelocity () const
 Get the current linear velocity.
 
void SetLinearVelocity (Utilities::Vector3 inLinearVelocity)
 Set the linear velocity.
 
void SetLinearVelocityClamped (Utilities::Vector3 inLinearVelocity)
 Set linear velocity clamped to the maximum configured value.
 
Utilities::Vector3 GetAngularVelocity () const
 Get the current angular velocity.
 
void SetAngularVelocity (Utilities::Vector3 inAngularVelocity)
 Set the angular velocity.
 
void SetAngularVelocityClamped (Utilities::Vector3 inAngularVelocity)
 Set angular velocity clamped to the maximum configured value.
 
Utilities::Vector3 GetPointVelocityCOM (Utilities::Vector3 inPointRelativeToCOM) const
 Get velocity of a point relative to center of mass.
 
Utilities::Vector3 GetPointVelocity (Utilities::Vector3 inPoint) const
 Get velocity of a point in world space.
 
void AddForce (Utilities::Vector3 inForce)
 Add force to center of mass.
 
void AddForce (Utilities::Vector3 inForce, Utilities::Vector3 inPosition)
 Add force at specified world space position.
 
void AddTorque (Utilities::Vector3 inTorque)
 Add torque around center of mass.
 
void AddImpulse (Utilities::Vector3 inImpulse)
 Add linear impulse to center of mass.
 
void AddImpulse (Utilities::Vector3 inImpulse, Utilities::Vector3 inPosition)
 Add linear impulse at specified world space position.
 
void AddAngularImpulse (Utilities::Vector3 inAngularImpulse)
 Add angular impulse around center of mass.
 
void MoveKinematic (Utilities::Vector3 inTargetPosition, Utilities::Quaternion inTargetRotation, float inDeltaTime)
 Move kinematic body towards target transform.
 
- Public Member Functions inherited from StevEngine::Component
 Component ()
 Create new component.
 
virtual ~Component ()
 Clean up component resources.
 
GameObjectGetParent () const
 Get parent GameObject.
 
SceneGetScene () const
 Get containing Scene.
 

Public Attributes

const JPH::EMotionType motionType
 Motion type (static/dynamic/kinematic)
 
const Layerlayer
 Physics collision layer.
 
const float mass
 Body mass in kg.
 

Friends

class Collider
 
class StevEngine::GameObject
 

Additional Inherited Members

- Protected Attributes inherited from StevEngine::Component
std::vector< std::pair< Utilities::ID, std::string > > handlers
 Event handler registrations.
 

Detailed Description

Physics rigid body component.

Adds physical simulation to game objects using Jolt physics. Handles collision shapes, forces, and motion simulation.

Constructor & Destructor Documentation

◆ RigidBody() [1/2]

StevEngine::Physics::RigidBody::RigidBody ( JPH::EMotionType motionType,
Layer * layer,
float mass = 1000 )

Create rigid body.

Parameters
motionTypeBody motion type
layerCollision layer
massMass in kg

◆ RigidBody() [2/2]

StevEngine::Physics::RigidBody::RigidBody ( Utilities::Stream & stream)

Create rigidbody from text serialized data.

Parameters
streamStream containing serialized component data

Member Function Documentation

◆ AddAngularImpulse()

void StevEngine::Physics::RigidBody::AddAngularImpulse ( Utilities::Vector3 inAngularImpulse)
inline

Add angular impulse around center of mass.

Parameters
inAngularImpulseAngular impulse vector in world space

◆ AddForce() [1/2]

void StevEngine::Physics::RigidBody::AddForce ( Utilities::Vector3 inForce)
inline

Add force to center of mass.

Parameters
inForceForce vector in world space

◆ AddForce() [2/2]

void StevEngine::Physics::RigidBody::AddForce ( Utilities::Vector3 inForce,
Utilities::Vector3 inPosition )
inline

Add force at specified world space position.

Parameters
inForceForce vector in world space
inPositionPosition to apply force in world space

◆ AddImpulse() [1/2]

void StevEngine::Physics::RigidBody::AddImpulse ( Utilities::Vector3 inImpulse)
inline

Add linear impulse to center of mass.

Parameters
inImpulseImpulse vector in world space

◆ AddImpulse() [2/2]

void StevEngine::Physics::RigidBody::AddImpulse ( Utilities::Vector3 inImpulse,
Utilities::Vector3 inPosition )
inline

Add linear impulse at specified world space position.

Parameters
inImpulseImpulse vector in world space
inPositionPosition to apply impulse in world space

◆ AddTorque()

void StevEngine::Physics::RigidBody::AddTorque ( Utilities::Vector3 inTorque)
inline

Add torque around center of mass.

Parameters
inTorqueTorque vector in world space

◆ Deactivate()

void StevEngine::Physics::RigidBody::Deactivate ( )
virtual

Clean up when deactivated.

Reimplemented from StevEngine::Component.

◆ Export()

Utilities::Stream StevEngine::Physics::RigidBody::Export ( Utilities::StreamType type) const
virtual

Serialize component to a stream.

Parameters
typeType of stream to export to
Returns
Serialized stream

Implements StevEngine::Component.

◆ GetAngularVelocity()

Utilities::Vector3 StevEngine::Physics::RigidBody::GetAngularVelocity ( ) const
inline

Get the current angular velocity.

Returns
Angular velocity in world space (radians/s)

◆ GetFriction()

float StevEngine::Physics::RigidBody::GetFriction ( ) const
inline

Get the friction coefficient.

Returns
Friction coefficient [0, INF]

◆ GetLinearVelocity()

Utilities::Vector3 StevEngine::Physics::RigidBody::GetLinearVelocity ( ) const
inline

Get the current linear velocity.

Returns
Linear velocity in world space

◆ GetPointVelocity()

Utilities::Vector3 StevEngine::Physics::RigidBody::GetPointVelocity ( Utilities::Vector3 inPoint) const
inline

Get velocity of a point in world space.

Parameters
inPointPoint in world space
Returns
Velocity at the specified point

◆ GetPointVelocityCOM()

Utilities::Vector3 StevEngine::Physics::RigidBody::GetPointVelocityCOM ( Utilities::Vector3 inPointRelativeToCOM) const
inline

Get velocity of a point relative to center of mass.

Parameters
inPointRelativeToCOMPoint relative to center of mass
Returns
Velocity at the specified point

◆ GetType()

std::string StevEngine::Physics::RigidBody::GetType ( ) const
inlinevirtual

Get component type.

Returns
Type identifier string

Implements StevEngine::Component.

◆ IsActive()

bool StevEngine::Physics::RigidBody::IsActive ( ) const
inline

Check if body is currently active in the physics simulation.

Returns
True if the body is active

◆ IsDynamic()

bool StevEngine::Physics::RigidBody::IsDynamic ( ) const
inline

Check if this is a dynamic body.

Returns
True if this is a dynamic (simulated) body

◆ IsKinematic()

bool StevEngine::Physics::RigidBody::IsKinematic ( ) const
inline

Check if this is a kinematic body.

Returns
True if this is a kinematic (animated) body

◆ IsStatic()

bool StevEngine::Physics::RigidBody::IsStatic ( ) const
inline

Check if this is a static body.

Returns
True if this is a static (non-moving) body

◆ MoveKinematic()

void StevEngine::Physics::RigidBody::MoveKinematic ( Utilities::Vector3 inTargetPosition,
Utilities::Quaternion inTargetRotation,
float inDeltaTime )
inline

Move kinematic body towards target transform.

Parameters
inTargetPositionTarget position in world space
inTargetRotationTarget rotation in world space
inDeltaTimeTime step for the movement

◆ SetAngularVelocity()

void StevEngine::Physics::RigidBody::SetAngularVelocity ( Utilities::Vector3 inAngularVelocity)
inline

Set the angular velocity.

Parameters
inAngularVelocityNew angular velocity in world space (radians/s)

◆ SetAngularVelocityClamped()

void StevEngine::Physics::RigidBody::SetAngularVelocityClamped ( Utilities::Vector3 inAngularVelocity)
inline

Set angular velocity clamped to the maximum configured value.

Parameters
inAngularVelocityDesired angular velocity in world space (radians/s)

◆ SetFriction()

void StevEngine::Physics::RigidBody::SetFriction ( float inFriction)
inline

Set the friction coefficient.

Parameters
inFrictionNew friction value [0, INF]

◆ SetLinearVelocity()

void StevEngine::Physics::RigidBody::SetLinearVelocity ( Utilities::Vector3 inLinearVelocity)
inline

Set the linear velocity.

Parameters
inLinearVelocityNew velocity in world space

◆ SetLinearVelocityClamped()

void StevEngine::Physics::RigidBody::SetLinearVelocityClamped ( Utilities::Vector3 inLinearVelocity)
inline

Set linear velocity clamped to the maximum configured value.

Parameters
inLinearVelocityDesired velocity in world space

◆ SetMotionProperties()

void StevEngine::Physics::RigidBody::SetMotionProperties ( MotionProperties properties)

Set motion properties.

Parameters
propertiesNew motion settings

◆ Start()

void StevEngine::Physics::RigidBody::Start ( )
virtual

Initialize component.

Reimplemented from StevEngine::Component.

◆ Update()

void StevEngine::Physics::RigidBody::Update ( double deltaTime)
virtual

Update transform from physics.

Parameters
deltaTimeTime since last update

Reimplemented from StevEngine::Component.


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