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

Physics character body component. More...

#include <physics/CharacterBody.hpp>

Inheritance diagram for StevEngine::Physics::CharacterBody:
StevEngine::Component

Public Member Functions

 CharacterBody (CharacterSettings settings={}, LayerID layer=LayerManager::DEFAULT)
 Create rigid body.
 
 CharacterBody (Utilities::Stream &stream)
 Create rigidbody from text serialized data.
 
virtual std::string GetType () const
 Get component type.
 
virtual Utilities::Stream Export (Utilities::StreamType type) const
 Serialize component to a stream.
 
virtual void Start ()
 Initialize component.
 
virtual void Deactivate ()
 Clean up when deactivated.
 
virtual void Update (double deltaTime)
 Update transform from physics Adds gravity to the current velocity.
 
void ExtendedUpdate (double deltaTime, JPH::CharacterVirtual::ExtendedUpdateSettings updateSettings={})
 Extended physics transform update.
 
virtual ~CharacterBody ()
 Clean up resources.
 
virtual bool RefreshShape ()
 Refresh combined collision shape Rebuilds shape from all attached colliders.
 
bool IsSupported () const
 
bool IsOnGround () const
 Is character supported (by ground/wall)
 
float GetMass () const
 Is character on the ground.
 
void SetMass (float mass)
 Get character mass (kg)
 
float GetMaxStrength () const
 Set character mass (kg)
 
void SetMaxStrength (float maxStrength)
 Maximum force with which the character can push other bodies (N)
 
float GetPenetrationRecoverySpeed () const
 
void SetPenetrationRecoverySpeed (float speed)
 This value governs how fast a penetration will be resolved, 0 = nothing is resolved, 1 = everything in one update.
 
float GetCharacterPadding () const
 Set how fast a penetration will be resolved, 0 = nothing is resolved, 1 = everything in one update.
 
uint GetMaxNumHits () const
 Character padding.
 
void SetMaxNumHits (uint maxHits)
 Max num hits to collect in order to avoid excess of contact points collection.
 
float GetHitReductionCosMaxAngle () const
 Set max num hits to collect in order to avoid excess of contact points collection.
 
void SetHitReductionCosMaxAngle (float cosMaxAngle)
 Cos(angle) where angle is the maximum angle between two hits contact normals that are allowed to be merged during hit reduction.
 
void SetMaxSlopeAngle (float maxSlopeAngle)
 Set Cos(angle) where angle is the maximum angle between two hits contact normals that are allowed to be merged during hit reduction. Default is around 2.5 degrees. Set to -1 to turn off.
 
bool IsSlopeTooSteep (Utilities::Vector3 normal) const
 Set the maximum angle of slope that character can still walk on (radians)
 
- 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.
 
virtual void Draw (const Utilities::Matrix4 &transform)
 Draw component visuals.
 

Public Attributes

Utilities::Vector3 velocity
 Character velocity.
 

Static Public Attributes

static const bool unique = true
 Only one per GameObject.
 

Protected Member Functions

bool SetShape (JPH::Ref< JPH::Shape > shape, Utilities::Vector3 shapeOffset=0)
 Set Jolt Physics collision shape.
 
JPH::Ref< JPH::Shape > GetShape () const
 Get Jolt Physics collision shape.
 

Protected Attributes

JPH::CharacterVirtualSettings settings
 Jolt Physics Virtual Character Controller Settings.
 
LayerID layer
 Physics layer.
 
- Protected Attributes inherited from StevEngine::Component
std::vector< std::pair< Utilities::ID, std::string > > handlers
 Event handler registrations.
 

Detailed Description

Physics character body component.

Adds physical objects that are simulated separately from the rest of the Jolt physics rigid bodies. Handles collision shapes, forces, and motion simulation.

Constructor & Destructor Documentation

◆ CharacterBody() [1/2]

StevEngine::Physics::CharacterBody::CharacterBody ( CharacterSettings settings = {},
LayerID layer = LayerManager::DEFAULT )

Create rigid body.

Parameters
settingsCharacter controller settings
layerCollision layer
massMass in kg

◆ CharacterBody() [2/2]

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

Create rigidbody from text serialized data.

Parameters
streamStream containing serialized component data

Member Function Documentation

◆ Deactivate()

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

Clean up when deactivated.

Reimplemented from StevEngine::Component.

◆ Export()

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

Serialize component to a stream.

Parameters
typeType of stream to export to
Returns
Serialized stream

Reimplemented from StevEngine::Component.

◆ ExtendedUpdate()

void StevEngine::Physics::CharacterBody::ExtendedUpdate ( double deltaTime,
JPH::CharacterVirtual::ExtendedUpdateSettings updateSettings = {} )

Extended physics transform update.

Parameters
deltaTimeTime since last update

◆ GetType()

virtual std::string StevEngine::Physics::CharacterBody::GetType ( ) const
inlinevirtual

Get component type.

Returns
Type identifier string

Implements StevEngine::Component.

◆ Start()

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

Initialize component.

Reimplemented from StevEngine::Component.

◆ Update()

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

Update transform from physics Adds gravity to the current velocity.

Parameters
deltaTimeTime since last update

Reimplemented from StevEngine::Component.


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