109#ifdef JPH_DEBUG_RENDERER
132 inline bool IsFreeAxis(
EAxis inAxis)
const {
return (mFreeAxis & (1 << inAxis)) != 0; }
172 inline Vec3 GetTotalLambdaPosition()
const {
return IsTranslationFullyConstrained()? mPointConstraintPart.
GetTotalLambda() :
Vec3(mTranslationConstraintPart[0].GetTotalLambda(), mTranslationConstraintPart[1].GetTotalLambda(), mTranslationConstraintPart[2].GetTotalLambda()); }
174 inline Vec3 GetTotalLambdaMotorTranslation()
const {
return Vec3(mMotorTranslationConstraintPart[0].GetTotalLambda(), mMotorTranslationConstraintPart[1].GetTotalLambda(), mMotorTranslationConstraintPart[2].GetTotalLambda()); }
175 inline Vec3 GetTotalLambdaMotorRotation()
const {
return Vec3(mMotorRotationConstraintPart[0].GetTotalLambda(), mMotorRotationConstraintPart[1].GetTotalLambda(), mMotorRotationConstraintPart[2].GetTotalLambda()); }
179 inline void GetPositionConstraintProperties(
Vec3 &outR1PlusU,
Vec3 &outR2,
Vec3 &outU)
const;
182 inline void UpdateRotationLimits();
185 void CacheTranslationMotorActive();
188 void CacheRotationMotorActive();
191 inline bool IsTranslationConstrained()
const {
return (mFreeAxis & 0b111) != 0b111; }
192 inline bool IsTranslationFullyConstrained()
const {
return (mFixedAxis & 0b111) == 0b111; }
193 inline bool IsRotationConstrained()
const {
return (mFreeAxis & 0b111000) != 0b111000; }
194 inline bool IsRotationFullyConstrained()
const {
return (mFixedAxis & 0b111000) == 0b111000; }
195 inline bool HasFriction(
EAxis inAxis)
const {
return !
IsFixedAxis(inAxis) && mMaxFriction[inAxis] > 0.0f; }
200 Vec3 mLocalSpacePosition1;
201 Vec3 mLocalSpacePosition2;
204 Quat mConstraintToBody1;
205 Quat mConstraintToBody2;
210 bool mTranslationMotorActive =
false;
211 bool mRotationMotorActive =
false;
212 uint8 mRotationPositionMotorActive = 0;
213 float mLimitMin[EAxis::Num];
214 float mLimitMax[EAxis::Num];
220 float mMaxFriction[EAxis::Num];
232 Vec3 mTranslationAxis[3];
233 Vec3 mRotationAxis[3];
236 float mDisplacement[3];
EConstraintSpace
Certain constraints support setting them up in local or world space. This governs what is used.
Definition Constraint.h:58
@ WorldSpace
All constraint properties are specified in world space.
EConstraintSubType
Enum to identify constraint sub type.
Definition Constraint.h:34
#define JPH_NAMESPACE_END
Definition Core.h:240
uint8_t uint8
Definition Core.h:310
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:29
EMotorState
Definition MotorSettings.h:16
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(class_name)
Definition SerializableObject.h:100
Definition AngleConstraintPart.h:36
Definition AxisConstraintPart.h:42
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition BodyID.h:13
Simple triangle renderer for debugging purposes.
Definition DebugRenderer.h:25
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
static JPH_INLINE Mat44 sRotationTranslation(QuatArg inR, Vec3Arg inT)
Get matrix that rotates and translates.
Definition Mat44.inl:149
Definition MotorSettings.h:25
Definition PointConstraintPart.h:41
Vec3 GetTotalLambda() const
Return lagrange multiplier.
Definition PointConstraintPart.h:199
static JPH_INLINE Quat sIdentity()
Definition Quat.h:93
JPH_INLINE Quat Conjugated() const
The conjugate [w, -x, -y, -z] is the same as the inverse for unit quaternions.
Definition Quat.h:168
Definition Reference.h:101
Definition RotationEulerConstraintPart.h:36
Vec3 GetTotalLambda() const
Return lagrange multiplier.
Definition RotationEulerConstraintPart.h:245
6 Degree Of Freedom Constraint. Allows control over each of the 6 degrees of freedom.
Definition SixDOFConstraint.h:92
Vec3 GetTotalLambdaPosition() const
Definition SixDOFConstraint.h:172
const MotorSettings & GetMotorSettings(EAxis inAxis) const
Definition SixDOFConstraint.h:143
float GetLimitsMin(EAxis inAxis) const
Get constraint Limits.
Definition SixDOFConstraint.h:128
Vec3 GetTotalLambdaMotorTranslation() const
Definition SixDOFConstraint.h:174
void SetTargetOrientationBS(QuatArg inOrientation)
Definition SixDOFConstraint.h:169
SixDOFConstraint(Body &inBody1, Body &inBody2, const SixDOFConstraintSettings &inSettings)
Construct six DOF constraint.
Definition SixDOFConstraint.cpp:97
virtual bool SolveVelocityConstraint(float inDeltaTime) override
Definition SixDOFConstraint.cpp:517
MotorSettings & GetMotorSettings(EAxis inAxis)
Motor settings.
Definition SixDOFConstraint.h:142
virtual void DrawConstraint(DebugRenderer *inRenderer) const override
Definition SixDOFConstraint.cpp:679
void SetMotorState(EAxis inAxis, EMotorState inState)
Definition SixDOFConstraint.cpp:243
void SetTargetAngularVelocityCS(Vec3Arg inAngularVelocity)
Set the target angular velocity in body 2 constraint space (!)
Definition SixDOFConstraint.h:156
Vec3 GetTargetPositionCS() const
Set the target position in body 1 constraint space.
Definition SixDOFConstraint.h:160
virtual bool SolvePositionConstraint(float inDeltaTime, float inBaumgarte) override
Definition SixDOFConstraint.cpp:597
Vec3 GetTotalLambdaRotation() const
Definition SixDOFConstraint.h:173
SixDOFConstraintSettings::EAxis EAxis
Get Axis from settings class.
Definition SixDOFConstraint.h:97
float GetLimitsMax(EAxis inAxis) const
Definition SixDOFConstraint.h:129
void SetTargetPositionCS(Vec3Arg inPosition)
Definition SixDOFConstraint.h:161
virtual void NotifyShapeChanged(const BodyID &inBodyID, Vec3Arg inDeltaCOM) override
Definition SixDOFConstraint.cpp:158
virtual void RestoreState(StateRecorder &inStream) override
Restoring state for replay.
Definition SixDOFConstraint.cpp:748
Vec3 GetTotalLambdaMotorRotation() const
Definition SixDOFConstraint.h:175
float GetMaxFriction(EAxis inAxis) const
Definition SixDOFConstraint.h:136
virtual Mat44 GetConstraintToBody2Matrix() const override
Calculates the transform that transforms from constraint space to body 2 space. The first column of t...
Definition SixDOFConstraint.h:119
bool IsFixedAxis(EAxis inAxis) const
Definition SixDOFConstraint.h:131
virtual Mat44 GetConstraintToBody1Matrix() const override
Calculates the transform that transforms from constraint space to body 1 space. The first column of t...
Definition SixDOFConstraint.h:118
virtual void WarmStartVelocityConstraint(float inWarmStartImpulseRatio) override
Definition SixDOFConstraint.cpp:488
void SetTargetVelocityCS(Vec3Arg inVelocity)
Definition SixDOFConstraint.h:153
Vec3 GetTargetAngularVelocityCS() const
Definition SixDOFConstraint.h:157
bool IsFreeAxis(EAxis inAxis) const
Definition SixDOFConstraint.h:132
void SetMaxFriction(EAxis inAxis, float inFriction)
Set the max friction for each axis.
Definition SixDOFConstraint.cpp:188
Quat GetTargetOrientationCS() const
Definition SixDOFConstraint.h:165
void SetTargetOrientationCS(QuatArg inOrientation)
Set the target orientation in body 1 constraint space.
Definition SixDOFConstraint.cpp:274
virtual void SetupVelocityConstraint(float inDeltaTime) override
Definition SixDOFConstraint.cpp:288
virtual void SaveState(StateRecorder &inStream) const override
Saving state for replay.
Definition SixDOFConstraint.cpp:727
virtual void DrawConstraintLimits(DebugRenderer *inRenderer) const override
Definition SixDOFConstraint.cpp:716
EMotorState GetMotorState(EAxis inAxis) const
Definition SixDOFConstraint.h:149
Vec3 GetTargetVelocityCS() const
Set the target velocity in body 1 constraint space.
Definition SixDOFConstraint.h:152
virtual EConstraintSubType GetSubType() const override
Generic interface of a constraint.
Definition SixDOFConstraint.h:103
void SetRotationLimits(Vec3Arg inLimitMin, Vec3Arg inLimitMax)
Update the rotational limits for this constraint, note that this won't change if axis are free or not...
Definition SixDOFConstraint.cpp:176
Quat GetRotationInConstraintSpace() const
Get rotation of constraint in constraint space.
Definition SixDOFConstraint.cpp:207
virtual Ref< ConstraintSettings > GetConstraintSettings() const override
Debug function to convert a constraint to its settings, note that this will not save to which bodies ...
Definition SixDOFConstraint.cpp:769
void SetTranslationLimits(Vec3Arg inLimitMin, Vec3Arg inLimitMax)
Update the translation limits for this constraint, note that this won't change if axis are free or no...
Definition SixDOFConstraint.cpp:166
6 Degree Of Freedom Constraint setup structure. Allows control over each of the 6 degrees of freedom.
Definition SixDOFConstraint.h:19
Vec3 mAxisY2
Definition SixDOFConstraint.h:54
Vec3 mAxisY1
Definition SixDOFConstraint.h:49
float mLimitMin[EAxis::Num]
Definition SixDOFConstraint.h:68
RVec3 mPosition2
Body 2 constraint reference frame (space determined by mSpace)
Definition SixDOFConstraint.h:52
EConstraintSpace mSpace
This determines in which space the constraint is setup, all properties below should be in the specifi...
Definition SixDOFConstraint.h:44
virtual void SaveBinaryState(StreamOut &inStream) const override
Saves the contents of the constraint settings in binary form to inStream.
Definition SixDOFConstraint.cpp:36
virtual TwoBodyConstraint * Create(Body &inBody1, Body &inBody2) const override
Create an an instance of this constraint.
Definition SixDOFConstraint.cpp:72
bool IsFixedAxis(EAxis inAxis) const
Definition SixDOFConstraint.h:77
float mMaxFriction[EAxis::Num]
Definition SixDOFConstraint.h:59
float mLimitMax[EAxis::Num]
Definition SixDOFConstraint.h:69
MotorSettings mMotorSettings[EAxis::Num]
Motor settings for each axis.
Definition SixDOFConstraint.h:83
RVec3 mPosition1
Body 1 constraint reference frame (space determined by mSpace)
Definition SixDOFConstraint.h:47
virtual void RestoreBinaryState(StreamIn &inStream) override
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition SixDOFConstraint.cpp:54
void MakeFreeAxis(EAxis inAxis)
Make axis free (unconstrained)
Definition SixDOFConstraint.h:72
EAxis
Constraint is split up into translation/rotation around X, Y and Z axis.
Definition SixDOFConstraint.h:25
@ TranslationY
Definition SixDOFConstraint.h:27
@ RotationX
When limited: MinLimit needs to be [-PI, 0], MaxLimit needs to be [0, PI].
Definition SixDOFConstraint.h:30
@ TranslationZ
Definition SixDOFConstraint.h:28
@ TranslationX
Definition SixDOFConstraint.h:26
@ RotationY
When limited: MaxLimit between [0, PI]. MinLimit = -MaxLimit. Forms a cone shaped limit with Z.
Definition SixDOFConstraint.h:31
@ Num
Definition SixDOFConstraint.h:34
@ RotationZ
When limited: MaxLimit between [0, PI]. MinLimit = -MaxLimit. Forms a cone shaped limit with Y.
Definition SixDOFConstraint.h:32
void SetLimitedAxis(EAxis inAxis, float inMin, float inMax)
Set a valid range for the constraint.
Definition SixDOFConstraint.h:80
void MakeFixedAxis(EAxis inAxis)
Make axis fixed (fixed at value 0)
Definition SixDOFConstraint.h:76
Vec3 mAxisX2
Definition SixDOFConstraint.h:53
Vec3 mAxisX1
Definition SixDOFConstraint.h:48
bool IsFreeAxis(EAxis inAxis) const
Definition SixDOFConstraint.h:73
Definition StateRecorder.h:15
Simple binary input stream.
Definition StreamIn.h:11
Simple binary output stream.
Definition StreamOut.h:11
Definition SwingTwistConstraintPart.h:26
float GetTotalSwingYLambda() const
Return lagrange multiplier for swing.
Definition SwingTwistConstraintPart.h:394
float GetTotalSwingZLambda() const
Definition SwingTwistConstraintPart.h:399
float GetTotalTwistLambda() const
Return lagrange multiplier for twist.
Definition SwingTwistConstraintPart.h:405
Base class for all constraints that involve 2 bodies. Body1 is usually considered the parent,...
Definition TwoBodyConstraint.h:27
Base class for settings for all constraints that involve 2 bodies.
Definition TwoBodyConstraint.h:16
static JPH_INLINE Vec3 sAxisX()
Vectors with the principal axis.
Definition Vec3.h:51
static JPH_INLINE Vec3 sAxisY()
Definition Vec3.h:52
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107