73#ifdef JPH_DEBUG_RENDERER
101 void SetTargetAngle(
float inAngle) { mTargetAngle = mHasLimits?
Clamp(inAngle, mLimitsMin, mLimitsMax) : inAngle; }
105 void SetLimits(
float inLimitsMin,
float inLimitsMax);
118 void CalculateA1AndTheta();
119 void CalculateRotationLimitsConstraintProperties(
float inDeltaTime);
120 void CalculateMotorConstraintProperties(
float inDeltaTime);
121 inline float GetSmallestAngleToLimit()
const;
126 Vec3 mLocalSpacePosition1;
127 Vec3 mLocalSpacePosition2;
130 Vec3 mLocalSpaceHingeAxis1;
131 Vec3 mLocalSpaceHingeAxis2;
134 Vec3 mLocalSpaceNormalAxis1;
135 Vec3 mLocalSpaceNormalAxis2;
138 Quat mInvInitialOrientation;
146 float mMaxFrictionTorque;
151 float mTargetAngularVelocity = 0.0f;
152 float mTargetAngle = 0.0f;
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
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
constexpr T Clamp(T inV, T inMin, T inMax)
Clamp a value between two values.
Definition Math.h:45
#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
float GetTotalLambda() const
Return lagrange multiplier.
Definition AngleConstraintPart.h:129
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
A hinge constraint constrains 2 bodies on a single point and allows only a single axis of rotation.
Definition HingeConstraint.h:59
EMotorState GetMotorState() const
Definition HingeConstraint.h:98
virtual Mat44 GetConstraintToBody1Matrix() const override
Calculates the transform that transforms from constraint space to body 1 space. The first column of t...
Definition HingeConstraint.cpp:373
virtual void WarmStartVelocityConstraint(float inWarmStartImpulseRatio) override
Definition HingeConstraint.cpp:213
virtual bool SolvePositionConstraint(float inDeltaTime, float inBaumgarte) override
Definition HingeConstraint.cpp:270
const MotorSettings & GetMotorSettings() const
Definition HingeConstraint.h:94
virtual void SetupVelocityConstraint(float inDeltaTime) override
Definition HingeConstraint.cpp:201
float GetLimitsMax() const
Definition HingeConstraint.h:107
virtual void SaveState(StateRecorder &inStream) const override
Saving state for replay.
Definition HingeConstraint.cpp:326
float GetTotalLambdaRotationLimits() const
Definition HingeConstraint.h:113
Vector< 2 > GetTotalLambdaRotation() const
Definition HingeConstraint.h:112
float GetCurrentAngle() const
Get the current rotation angle from the rest position.
Definition HingeConstraint.cpp:123
JPH_OVERRIDE_NEW_DELETE HingeConstraint(Body &inBody1, Body &inBody2, const HingeConstraintSettings &inSettings)
Construct hinge constraint.
Definition HingeConstraint.cpp:74
void SetLimits(float inLimitsMin, float inLimitsMax)
Update the rotation limits of the hinge, value in radians (see HingeConstraintSettings)
Definition HingeConstraint.cpp:131
virtual void DrawConstraintLimits(DebugRenderer *inRenderer) const override
Definition HingeConstraint.cpp:311
MotorSettings & GetMotorSettings()
Definition HingeConstraint.h:93
float GetLimitsMin() const
Definition HingeConstraint.h:106
void SetTargetAngularVelocity(float inAngularVelocity)
rad/s
Definition HingeConstraint.h:99
float GetTargetAngle() const
Definition HingeConstraint.h:102
float GetMaxFrictionTorque() const
Definition HingeConstraint.h:90
virtual Mat44 GetConstraintToBody2Matrix() const override
Calculates the transform that transforms from constraint space to body 2 space. The first column of t...
Definition HingeConstraint.cpp:378
virtual bool SolveVelocityConstraint(float inDeltaTime) override
Definition HingeConstraint.cpp:229
void SetMotorState(EMotorState inState)
Definition HingeConstraint.h:97
virtual void RestoreState(StateRecorder &inStream) override
Restoring state for replay.
Definition HingeConstraint.cpp:340
virtual void DrawConstraint(DebugRenderer *inRenderer) const override
Definition HingeConstraint.cpp:295
virtual void NotifyShapeChanged(const BodyID &inBodyID, Vec3Arg inDeltaCOM) override
Definition HingeConstraint.cpp:115
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 HingeConstraint.cpp:355
void SetTargetAngle(float inAngle)
rad
Definition HingeConstraint.h:101
virtual EConstraintSubType GetSubType() const override
Get the sub type of a constraint.
Definition HingeConstraint.h:67
float GetTotalLambdaMotor() const
Definition HingeConstraint.h:114
float GetTargetAngularVelocity() const
Definition HingeConstraint.h:100
void SetMaxFrictionTorque(float inFrictionTorque)
Definition HingeConstraint.h:89
Vec3 GetTotalLambdaPosition() const
Definition HingeConstraint.h:111
bool HasLimits() const
Definition HingeConstraint.h:108
Hinge constraint settings, used to create a hinge constraint.
Definition HingeConstraint.h:17
float mLimitsMin
Definition HingeConstraint.h:43
float mMaxFrictionTorque
Maximum amount of torque (N m) to apply as friction when the constraint is not powered by a motor.
Definition HingeConstraint.h:47
Vec3 mHingeAxis2
Definition HingeConstraint.h:38
Vec3 mNormalAxis2
Definition HingeConstraint.h:39
EConstraintSpace mSpace
This determines in which space the constraint is setup, all properties below should be in the specifi...
Definition HingeConstraint.h:28
Vec3 mHingeAxis1
Definition HingeConstraint.h:33
float mLimitsMax
Definition HingeConstraint.h:44
virtual TwoBodyConstraint * Create(Body &inBody1, Body &inBody2) const override
Create an an instance of this constraint.
Definition HingeConstraint.cpp:69
RVec3 mPoint1
Definition HingeConstraint.h:32
virtual void RestoreBinaryState(StreamIn &inStream) override
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition HingeConstraint.cpp:53
RVec3 mPoint2
Body 2 constraint reference frame (space determined by mSpace)
Definition HingeConstraint.h:37
Vec3 mNormalAxis1
Definition HingeConstraint.h:34
virtual void SaveBinaryState(StreamOut &inStream) const override
Saves the contents of the constraint settings in binary form to inStream.
Definition HingeConstraint.cpp:36
MotorSettings mMotorSettings
In case the constraint is powered, this determines the motor settings around the hinge axis.
Definition HingeConstraint.h:50
Definition HingeRotationConstraintPart.h:42
const Vec2 & GetTotalLambda() const
Return lagrange multiplier.
Definition HingeRotationConstraintPart.h:194
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
Definition MotorSettings.h:25
bool IsValid() const
Check if settings are valid.
Definition MotorSettings.h:48
Definition PointConstraintPart.h:41
Vec3 GetTotalLambda() const
Return lagrange multiplier.
Definition PointConstraintPart.h:199
Definition Reference.h:101
Definition StateRecorder.h:15
Simple binary input stream.
Definition StreamIn.h:11
Simple binary output stream.
Definition StreamOut.h:11
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
Templatized vector class.
Definition Vector.h:12