Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
HingeConstraintSettings Class Referencefinal

Hinge constraint settings, used to create a hinge constraint. More...

#include <HingeConstraint.h>

Inheritance diagram for HingeConstraintSettings:
TwoBodyConstraintSettings ConstraintSettings SerializableObject RefTarget< ConstraintSettings > NonCopyable

Public Member Functions

virtual void SaveBinaryState (StreamOut &inStream) const override
 Saves the contents of the constraint settings in binary form to inStream.
 
virtual TwoBodyConstraintCreate (Body &inBody1, Body &inBody2) const override
 Create an instance of this constraint.
 
- Public Member Functions inherited from SerializableObject
virtual ~SerializableObject ()=default
 Constructor.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 
- Public Member Functions inherited from RefTarget< ConstraintSettings >
 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 Attributes

EConstraintSpace mSpace = EConstraintSpace::WorldSpace
 This determines in which space the constraint is setup, all properties below should be in the specified space.
 
RVec3 mPoint1 = RVec3::sZero()
 
Vec3 mHingeAxis1 = Vec3::sAxisY()
 
Vec3 mNormalAxis1 = Vec3::sAxisX()
 
RVec3 mPoint2 = RVec3::sZero()
 Body 2 constraint reference frame (space determined by mSpace)
 
Vec3 mHingeAxis2 = Vec3::sAxisY()
 
Vec3 mNormalAxis2 = Vec3::sAxisX()
 
float mLimitsMin = -JPH_PI
 
float mLimitsMax = JPH_PI
 
SpringSettings mLimitsSpringSettings
 When enabled, this makes the limits soft. When the constraint exceeds the limits, a spring force will pull it back.
 
float mMaxFrictionTorque = 0.0f
 Maximum amount of torque (N m) to apply as friction when the constraint is not powered by a motor.
 
MotorSettings mMotorSettings
 In case the constraint is powered, this determines the motor settings around the hinge axis.
 
- Public Attributes inherited from ConstraintSettings
bool mEnabled = true
 If this constraint is enabled initially. Use Constraint::SetEnabled to toggle after creation.
 
uint32 mConstraintPriority = 0
 
uint mNumVelocityStepsOverride = 0
 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 mNumPositionStepsOverride = 0
 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.
 
float mDrawConstraintSize = 1.0f
 Size of constraint when drawing it through the debug renderer.
 
uint64 mUserData = 0
 User data value (can be used by application)
 

Protected Member Functions

virtual void RestoreBinaryState (StreamIn &inStream) override
 This function should not be called directly, it is used by sRestoreFromBinaryState.
 

Additional Inherited Members

- Public Types inherited from ConstraintSettings
using ConstraintResult = Result< Ref< ConstraintSettings > >
 
- Static Public Member Functions inherited from ConstraintSettings
static ConstraintResult sRestoreFromBinaryState (StreamIn &inStream)
 Creates a constraint of the correct type and restores its contents from the binary stream inStream.
 
- Static Public Member Functions inherited from RefTarget< ConstraintSettings >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Protected Attributes inherited from RefTarget< ConstraintSettings >
atomic< uint32mRefCount
 Current reference count.
 
- Static Protected Attributes inherited from RefTarget< ConstraintSettings >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Hinge constraint settings, used to create a hinge constraint.

Member Function Documentation

◆ Create()

TwoBodyConstraint * HingeConstraintSettings::Create ( Body inBody1,
Body inBody2 
) const
overridevirtual

Create an instance of this constraint.

Implements TwoBodyConstraintSettings.

◆ RestoreBinaryState()

void HingeConstraintSettings::RestoreBinaryState ( StreamIn inStream)
overrideprotectedvirtual

This function should not be called directly, it is used by sRestoreFromBinaryState.

Reimplemented from ConstraintSettings.

◆ SaveBinaryState()

void HingeConstraintSettings::SaveBinaryState ( StreamOut inStream) const
overridevirtual

Saves the contents of the constraint settings in binary form to inStream.

Reimplemented from ConstraintSettings.

Member Data Documentation

◆ mHingeAxis1

Vec3 HingeConstraintSettings::mHingeAxis1 = Vec3::sAxisY()

◆ mHingeAxis2

Vec3 HingeConstraintSettings::mHingeAxis2 = Vec3::sAxisY()

◆ mLimitsMax

float HingeConstraintSettings::mLimitsMax = JPH_PI

◆ mLimitsMin

float HingeConstraintSettings::mLimitsMin = -JPH_PI

Rotation around the hinge axis will be limited between [mLimitsMin, mLimitsMax] where mLimitsMin e [-pi, 0] and mLimitsMax e [0, pi]. Both angles are in radians.

◆ mLimitsSpringSettings

SpringSettings HingeConstraintSettings::mLimitsSpringSettings

When enabled, this makes the limits soft. When the constraint exceeds the limits, a spring force will pull it back.

◆ mMaxFrictionTorque

float HingeConstraintSettings::mMaxFrictionTorque = 0.0f

Maximum amount of torque (N m) to apply as friction when the constraint is not powered by a motor.

◆ mMotorSettings

MotorSettings HingeConstraintSettings::mMotorSettings

In case the constraint is powered, this determines the motor settings around the hinge axis.

◆ mNormalAxis1

Vec3 HingeConstraintSettings::mNormalAxis1 = Vec3::sAxisX()

◆ mNormalAxis2

Vec3 HingeConstraintSettings::mNormalAxis2 = Vec3::sAxisX()

◆ mPoint1

RVec3 HingeConstraintSettings::mPoint1 = RVec3::sZero()

Body 1 constraint reference frame (space determined by mSpace). Hinge axis is the axis where rotation is allowed. When the normal axis of both bodies align in world space, the hinge angle is defined to be 0. mHingeAxis1 and mNormalAxis1 should be perpendicular. mHingeAxis2 and mNormalAxis2 should also be perpendicular. If you configure the joint in world space and create both bodies with a relative rotation you want to be defined as zero, you can simply set mHingeAxis1 = mHingeAxis2 and mNormalAxis1 = mNormalAxis2.

◆ mPoint2

RVec3 HingeConstraintSettings::mPoint2 = RVec3::sZero()

Body 2 constraint reference frame (space determined by mSpace)

◆ mSpace

EConstraintSpace HingeConstraintSettings::mSpace = EConstraintSpace::WorldSpace

This determines in which space the constraint is setup, all properties below should be in the specified space.


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