Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ConstraintManager Class Reference

#include <ConstraintManager.h>

Inheritance diagram for ConstraintManager:
NonCopyable

Public Member Functions

JPH_OVERRIDE_NEW_DELETE void Add (Constraint **inConstraints, int inNumber)
 Add a new constraint. This is thread safe.
 
void Remove (Constraint **inConstraint, int inNumber)
 Remove a constraint. This is thread safe.
 
Constraints GetConstraints () const
 Get a list of all constraints.
 
uint32 GetNumConstraints () const
 Get total number of constraints.
 
void GetActiveConstraints (uint32 inStartConstraintIdx, uint32 inEndConstraintIdx, Constraint **outActiveConstraints, uint32 &outNumActiveConstraints) const
 Determine the active constraints of a subset of the constraints.
 
void DrawConstraints (DebugRenderer *inRenderer) const
 Draw all constraints.
 
void DrawConstraintLimits (DebugRenderer *inRenderer) const
 Draw all constraint limits.
 
void DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const
 Draw all constraint reference frames.
 
void SaveState (StateRecorder &inStream, const StateRecorderFilter *inFilter) const
 Save state of constraints.
 
bool RestoreState (StateRecorder &inStream)
 Restore the state of constraints. Returns false if failed.
 
void LockAllConstraints ()
 Lock all constraints. This should only be done during PhysicsSystem::Update().
 
void UnlockAllConstraints ()
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Static Public Member Functions

static void sBuildIslands (Constraint **inActiveConstraints, uint32 inNumActiveConstraints, IslandBuilder &ioBuilder, BodyManager &inBodyManager)
 Link bodies to form islands.
 
static void sSortConstraints (Constraint **inActiveConstraints, uint32 *inConstraintIdxBegin, uint32 *inConstraintIdxEnd)
 In order to have a deterministic simulation, we need to sort the constraints of an island before solving them.
 
static void sSetupVelocityConstraints (Constraint **inActiveConstraints, uint32 inNumActiveConstraints, float inDeltaTime)
 Prior to solving the velocity constraints, you must call SetupVelocityConstraints once to precalculate values that are independent of velocity.
 
template<class ConstraintCallback >
static void sWarmStartVelocityConstraints (Constraint **inActiveConstraints, const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inWarmStartImpulseRatio, ConstraintCallback &ioCallback)
 Apply last frame's impulses, must be called prior to SolveVelocityConstraints.
 
static bool sSolveVelocityConstraints (Constraint **inActiveConstraints, const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inDeltaTime)
 This function is called multiple times to iteratively come to a solution that meets all velocity constraints.
 
static bool sSolvePositionConstraints (Constraint **inActiveConstraints, const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inDeltaTime, float inBaumgarte)
 This function is called multiple times to iteratively come to a solution that meets all position constraints.
 

Detailed Description

A constraint manager manages all constraints of the same type

WARNING: This class is an internal part of PhysicsSystem, it has no functions that can be called by users of the library. Its functionality is exposed through PhysicsSystem and BodyInterface.

Member Function Documentation

◆ Add()

JPH_NAMESPACE_BEGIN void ConstraintManager::Add ( Constraint ** inConstraints,
int inNumber )

Add a new constraint. This is thread safe.

◆ DrawConstraintLimits()

void ConstraintManager::DrawConstraintLimits ( DebugRenderer * inRenderer) const

Draw all constraint limits.

◆ DrawConstraintReferenceFrame()

void ConstraintManager::DrawConstraintReferenceFrame ( DebugRenderer * inRenderer) const

Draw all constraint reference frames.

◆ DrawConstraints()

void ConstraintManager::DrawConstraints ( DebugRenderer * inRenderer) const

Draw all constraints.

◆ GetActiveConstraints()

void ConstraintManager::GetActiveConstraints ( uint32 inStartConstraintIdx,
uint32 inEndConstraintIdx,
Constraint ** outActiveConstraints,
uint32 & outNumActiveConstraints ) const

Determine the active constraints of a subset of the constraints.

◆ GetConstraints()

Constraints ConstraintManager::GetConstraints ( ) const

Get a list of all constraints.

◆ GetNumConstraints()

uint32 ConstraintManager::GetNumConstraints ( ) const
inline

Get total number of constraints.

◆ LockAllConstraints()

void ConstraintManager::LockAllConstraints ( )
inline

Lock all constraints. This should only be done during PhysicsSystem::Update().

◆ Remove()

void ConstraintManager::Remove ( Constraint ** inConstraint,
int inNumber )

Remove a constraint. This is thread safe.

◆ RestoreState()

bool ConstraintManager::RestoreState ( StateRecorder & inStream)

Restore the state of constraints. Returns false if failed.

◆ SaveState()

void ConstraintManager::SaveState ( StateRecorder & inStream,
const StateRecorderFilter * inFilter ) const

Save state of constraints.

◆ sBuildIslands()

void ConstraintManager::sBuildIslands ( Constraint ** inActiveConstraints,
uint32 inNumActiveConstraints,
IslandBuilder & ioBuilder,
BodyManager & inBodyManager )
static

Link bodies to form islands.

◆ sSetupVelocityConstraints()

void ConstraintManager::sSetupVelocityConstraints ( Constraint ** inActiveConstraints,
uint32 inNumActiveConstraints,
float inDeltaTime )
static

Prior to solving the velocity constraints, you must call SetupVelocityConstraints once to precalculate values that are independent of velocity.

◆ sSolvePositionConstraints()

bool ConstraintManager::sSolvePositionConstraints ( Constraint ** inActiveConstraints,
const uint32 * inConstraintIdxBegin,
const uint32 * inConstraintIdxEnd,
float inDeltaTime,
float inBaumgarte )
static

This function is called multiple times to iteratively come to a solution that meets all position constraints.

◆ sSolveVelocityConstraints()

bool ConstraintManager::sSolveVelocityConstraints ( Constraint ** inActiveConstraints,
const uint32 * inConstraintIdxBegin,
const uint32 * inConstraintIdxEnd,
float inDeltaTime )
static

This function is called multiple times to iteratively come to a solution that meets all velocity constraints.

◆ sSortConstraints()

void ConstraintManager::sSortConstraints ( Constraint ** inActiveConstraints,
uint32 * inConstraintIdxBegin,
uint32 * inConstraintIdxEnd )
static

In order to have a deterministic simulation, we need to sort the constraints of an island before solving them.

◆ sWarmStartVelocityConstraints()

template<class ConstraintCallback >
template void ConstraintManager::sWarmStartVelocityConstraints< DummyCalculateSolverSteps > ( Constraint ** inActiveConstraints,
const uint32 * inConstraintIdxBegin,
const uint32 * inConstraintIdxEnd,
float inWarmStartImpulseRatio,
ConstraintCallback & ioCallback )
static

Apply last frame's impulses, must be called prior to SolveVelocityConstraints.

◆ UnlockAllConstraints()

void ConstraintManager::UnlockAllConstraints ( )
inline

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