Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
TwoBodyConstraint Class Referenceabstract

Base class for all constraints that involve 2 bodies. Body1 is usually considered the parent, Body2 the child. More...

#include <TwoBodyConstraint.h>

Inheritance diagram for TwoBodyConstraint:
Constraint RefTarget< Constraint > NonCopyable ConeConstraint DistanceConstraint FixedConstraint GearConstraint HingeConstraint PathConstraint PointConstraint PulleyConstraint RackAndPinionConstraint SixDOFConstraint SliderConstraint SwingTwistConstraint

Public Member Functions

JPH_OVERRIDE_NEW_DELETE TwoBodyConstraint (Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings)
 Constructor.
 
virtual EConstraintType GetType () const override
 Get the type of a constraint.
 
virtual bool IsActive () const override
 Solver interface.
 
virtual void DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const override
 
BodyGetBody1 () const
 Access to the connected bodies.
 
BodyGetBody2 () const
 
virtual Mat44 GetConstraintToBody1Matrix () const =0
 Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
 
virtual Mat44 GetConstraintToBody2Matrix () const =0
 Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
 
virtual void BuildIslands (uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) override
 Link bodies that are connected by this constraint in the island builder.
 
virtual uint BuildIslandSplits (LargeIslandSplitter &ioSplitter) const override
 Link bodies that are connected by this constraint in the same split. Returns the split index.
 
- Public Member Functions inherited from Constraint
JPH_OVERRIDE_NEW_DELETE Constraint (const ConstraintSettings &inSettings)
 Constructor.
 
virtual ~Constraint ()=default
 Virtual destructor.
 
virtual EConstraintSubType GetSubType () const =0
 Get the sub type of a constraint.
 
uint32 GetConstraintPriority () const
 
void SetConstraintPriority (uint32 inPriority)
 
void SetNumVelocityStepsOverride (uint inN)
 Used only when the constraint is active. Override for the number of solver velocity iterations to run, 0 means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.
 
uint GetNumVelocityStepsOverride () const
 
void SetNumPositionStepsOverride (uint inN)
 Used only when the constraint is active. Override for the number of solver position iterations to run, 0 means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.
 
uint GetNumPositionStepsOverride () const
 
void SetEnabled (bool inEnabled)
 
bool GetEnabled () const
 Test if a constraint is enabled.
 
uint64 GetUserData () const
 Access to the user data, can be used for anything by the application.
 
void SetUserData (uint64 inUserData)
 
virtual void NotifyShapeChanged (const BodyID &inBodyID, Vec3Arg inDeltaCOM)=0
 
virtual void ResetWarmStart ()=0
 
virtual void DrawConstraint (DebugRenderer *inRenderer) const =0
 
virtual void DrawConstraintLimits (DebugRenderer *inRenderer) const
 
float GetDrawConstraintSize () const
 Size of constraint when drawing it through the debug renderer.
 
void SetDrawConstraintSize (float inSize)
 
virtual void SaveState (StateRecorder &inStream) const
 Saving state for replay.
 
virtual void RestoreState (StateRecorder &inStream)
 Restoring state for replay.
 
virtual Ref< ConstraintSettingsGetConstraintSettings () const =0
 Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to.
 
virtual void SetupVelocityConstraint (float inDeltaTime)=0
 
virtual void WarmStartVelocityConstraint (float inWarmStartImpulseRatio)=0
 
virtual bool SolveVelocityConstraint (float inDeltaTime)=0
 
virtual bool SolvePositionConstraint (float inDeltaTime, float inBaumgarte)=0
 
- Public Member Functions inherited from RefTarget< Constraint >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Protected Attributes

BodymBody1
 The two bodies involved.
 
BodymBody2
 
- Protected Attributes inherited from Constraint
float mDrawConstraintSize
 Size of constraint when drawing it through the debug renderer.
 
- Protected Attributes inherited from RefTarget< Constraint >
atomic< uint32mRefCount
 Current reference count.
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< Constraint >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Protected Member Functions inherited from Constraint
void ToConstraintSettings (ConstraintSettings &outSettings) const
 Helper function to copy settings back to constraint settings for this base class.
 
- Static Protected Attributes inherited from RefTarget< Constraint >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Base class for all constraints that involve 2 bodies. Body1 is usually considered the parent, Body2 the child.

Constructor & Destructor Documentation

◆ TwoBodyConstraint()

JPH_OVERRIDE_NEW_DELETE TwoBodyConstraint::TwoBodyConstraint ( Body inBody1,
Body inBody2,
const TwoBodyConstraintSettings inSettings 
)
inline

Constructor.

Member Function Documentation

◆ BuildIslands()

void TwoBodyConstraint::BuildIslands ( uint32  inConstraintIndex,
IslandBuilder ioBuilder,
BodyManager inBodyManager 
)
overridevirtual

Link bodies that are connected by this constraint in the island builder.

Implements Constraint.

◆ BuildIslandSplits()

uint TwoBodyConstraint::BuildIslandSplits ( LargeIslandSplitter ioSplitter) const
overridevirtual

Link bodies that are connected by this constraint in the same split. Returns the split index.

Implements Constraint.

◆ DrawConstraintReferenceFrame()

void TwoBodyConstraint::DrawConstraintReferenceFrame ( DebugRenderer inRenderer) const
overridevirtual

Reimplemented from Constraint.

◆ GetBody1()

Body * TwoBodyConstraint::GetBody1 ( ) const
inline

Access to the connected bodies.

◆ GetBody2()

Body * TwoBodyConstraint::GetBody2 ( ) const
inline

◆ GetConstraintToBody1Matrix()

virtual Mat44 TwoBodyConstraint::GetConstraintToBody1Matrix ( ) const
pure virtual

Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.

Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, and SwingTwistConstraint.

◆ GetConstraintToBody2Matrix()

virtual Mat44 TwoBodyConstraint::GetConstraintToBody2Matrix ( ) const
pure virtual

Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.

Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, and SwingTwistConstraint.

◆ GetType()

virtual EConstraintType TwoBodyConstraint::GetType ( ) const
inlineoverridevirtual

Get the type of a constraint.

Reimplemented from Constraint.

◆ IsActive()

virtual bool TwoBodyConstraint::IsActive ( ) const
inlineoverridevirtual

Solver interface.

Reimplemented from Constraint.

Reimplemented in PathConstraint.

Member Data Documentation

◆ mBody1

Body* TwoBodyConstraint::mBody1
protected

The two bodies involved.

◆ mBody2

Body* TwoBodyConstraint::mBody2
protected

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