Jolt Physics
A multi core friendly Game Physics Engine
|
6 Degree Of Freedom Constraint setup structure. Allows control over each of the 6 degrees of freedom. More...
#include <SixDOFConstraint.h>
Public Types | |
enum | EAxis { TranslationX , TranslationY , TranslationZ , RotationX , RotationY , RotationZ , Num , NumTranslation = TranslationZ + 1 } |
Constraint is split up into translation/rotation around X, Y and Z axis. More... | |
Public Types inherited from ConstraintSettings | |
using | ConstraintResult = Result<Ref<ConstraintSettings>> |
Public Member Functions | |
virtual void | SaveBinaryState (StreamOut &inStream) const override |
Saves the contents of the constraint settings in binary form to inStream. | |
virtual TwoBodyConstraint * | Create (Body &inBody1, Body &inBody2) const override |
Create an instance of this constraint. | |
void | MakeFreeAxis (EAxis inAxis) |
Make axis free (unconstrained) | |
bool | IsFreeAxis (EAxis inAxis) const |
void | MakeFixedAxis (EAxis inAxis) |
Make axis fixed (fixed at value 0) | |
bool | IsFixedAxis (EAxis inAxis) const |
void | SetLimitedAxis (EAxis inAxis, float inMin, float inMax) |
Set a valid range for the constraint (if inMax < inMin, the axis will become fixed) | |
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 |
RefTarget & | operator= (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 | mPosition1 = RVec3::sZero() |
Body 1 constraint reference frame (space determined by mSpace) | |
Vec3 | mAxisX1 = Vec3::sAxisX() |
Vec3 | mAxisY1 = Vec3::sAxisY() |
RVec3 | mPosition2 = RVec3::sZero() |
Body 2 constraint reference frame (space determined by mSpace) | |
Vec3 | mAxisX2 = Vec3::sAxisX() |
Vec3 | mAxisY2 = Vec3::sAxisY() |
float | mMaxFriction [EAxis::Num] = { 0, 0, 0, 0, 0, 0 } |
ESwingType | mSwingType = ESwingType::Cone |
The type of swing constraint that we want to use. | |
float | mLimitMin [EAxis::Num] = { -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX } |
float | mLimitMax [EAxis::Num] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX } |
SpringSettings | mLimitsSpringSettings [EAxis::NumTranslation] |
MotorSettings | mMotorSettings [EAxis::Num] |
Motor settings for each 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 | |
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< uint32 > | mRefCount |
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. | |
6 Degree Of Freedom Constraint setup structure. Allows control over each of the 6 degrees of freedom.
Constraint is split up into translation/rotation around X, Y and Z axis.
Enumerator | |
---|---|
TranslationX | |
TranslationY | |
TranslationZ | |
RotationX | |
RotationY | |
RotationZ | |
Num | |
NumTranslation |
|
overridevirtual |
Create an instance of this constraint.
Implements TwoBodyConstraintSettings.
Make axis fixed (fixed at value 0)
This function should not be called directly, it is used by sRestoreFromBinaryState.
Reimplemented from ConstraintSettings.
Saves the contents of the constraint settings in binary form to inStream.
Reimplemented from ConstraintSettings.
Set a valid range for the constraint (if inMax < inMin, the axis will become fixed)
Vec3 SixDOFConstraintSettings::mAxisX1 = Vec3::sAxisX() |
Vec3 SixDOFConstraintSettings::mAxisX2 = Vec3::sAxisX() |
Vec3 SixDOFConstraintSettings::mAxisY1 = Vec3::sAxisY() |
Vec3 SixDOFConstraintSettings::mAxisY2 = Vec3::sAxisY() |
float SixDOFConstraintSettings::mLimitMax[EAxis::Num] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX } |
float SixDOFConstraintSettings::mLimitMin[EAxis::Num] = { -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX } |
Limits. For translation: Min and max linear limits in m (0 is frame of body 1 and 2 coincide). For rotation: Min and max angular limits in rad (0 is frame of body 1 and 2 coincide). See comments at Axis enum for limit ranges.
Remove degree of freedom by setting min = FLT_MAX and max = -FLT_MAX. The constraint will be driven to 0 for this axis.
Free movement over an axis is allowed when min = -FLT_MAX and max = FLT_MAX.
Rotation limit around X-Axis: When limited, should be \(\in [-\pi, \pi]\). Can be asymmetric around zero.
Rotation limit around Y-Z Axis: Forms a pyramid or cone shaped limit:
SpringSettings SixDOFConstraintSettings::mLimitsSpringSettings[EAxis::NumTranslation] |
When enabled, this makes the limits soft. When the constraint exceeds the limits, a spring force will pull it back. Only soft translation limits are supported, soft rotation limits are not currently supported.
float SixDOFConstraintSettings::mMaxFriction[EAxis::Num] = { 0, 0, 0, 0, 0, 0 } |
Friction settings. For translation: Max friction force in N. 0 = no friction. For rotation: Max friction torque in Nm. 0 = no friction.
MotorSettings SixDOFConstraintSettings::mMotorSettings[EAxis::Num] |
Motor settings for each axis.
RVec3 SixDOFConstraintSettings::mPosition1 = RVec3::sZero() |
Body 1 constraint reference frame (space determined by mSpace)
RVec3 SixDOFConstraintSettings::mPosition2 = RVec3::sZero() |
Body 2 constraint reference frame (space determined by mSpace)
EConstraintSpace SixDOFConstraintSettings::mSpace = EConstraintSpace::WorldSpace |
This determines in which space the constraint is setup, all properties below should be in the specified space.
ESwingType SixDOFConstraintSettings::mSwingType = ESwingType::Cone |
The type of swing constraint that we want to use.