43 float mLimitsMin = -JPH_PI;
44 float mLimitsMax = JPH_PI;
50 float mMaxFrictionTorque = 0.0f;
71 virtual void NotifyShapeChanged(
const BodyID &inBodyID,
Vec3Arg inDeltaCOM)
override;
72 virtual void SetupVelocityConstraint(
float inDeltaTime)
override;
73 virtual void WarmStartVelocityConstraint(
float inWarmStartImpulseRatio)
override;
74 virtual bool SolveVelocityConstraint(
float inDeltaTime)
override;
75 virtual bool SolvePositionConstraint(
float inDeltaTime,
float inBaumgarte)
override;
76#ifdef JPH_DEBUG_RENDERER
77 virtual void DrawConstraint(
DebugRenderer *inRenderer)
const override;
78 virtual void DrawConstraintLimits(
DebugRenderer *inRenderer)
const override;
80 virtual void SaveState(
StateRecorder &inStream)
const override;
85 virtual Mat44 GetConstraintToBody1Matrix()
const override;
86 virtual Mat44 GetConstraintToBody2Matrix()
const override;
89 float GetCurrentAngle()
const;
104 void SetTargetAngle(
float inAngle) { mTargetAngle = mHasLimits?
Clamp(inAngle, mLimitsMin, mLimitsMax) : inAngle; }
108 void SetLimits(
float inLimitsMin,
float inLimitsMax);
126 void CalculateA1AndTheta();
127 void CalculateRotationLimitsConstraintProperties(
float inDeltaTime);
128 void CalculateMotorConstraintProperties(
float inDeltaTime);
129 inline float GetSmallestAngleToLimit()
const;
134 Vec3 mLocalSpacePosition1;
135 Vec3 mLocalSpacePosition2;
138 Vec3 mLocalSpaceHingeAxis1;
139 Vec3 mLocalSpaceHingeAxis2;
142 Vec3 mLocalSpaceNormalAxis1;
143 Vec3 mLocalSpaceNormalAxis2;
146 Quat mInvInitialOrientation;
157 float mMaxFrictionTorque;
162 float mTargetAngularVelocity = 0.0f;
163 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_EXPORT
Definition Core.h:214
#define JPH_NAMESPACE_END
Definition Core.h:354
#define JPH_NAMESPACE_BEGIN
Definition Core.h:348
#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:17
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:100
Definition AngleConstraintPart.h:37
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition BodyID.h:13
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents of the constraint settings in binary form to inStream.
Definition Constraint.cpp:26
virtual void RestoreBinaryState(StreamIn &inStream)
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition Constraint.cpp:36
Simple triangle renderer for debugging purposes.
Definition DebugRenderer.h:30
A hinge constraint constrains 2 bodies on a single point and allows only a single axis of rotation.
Definition HingeConstraint.h:62
EMotorState GetMotorState() const
Definition HingeConstraint.h:101
const SpringSettings & GetLimitsSpringSettings() const
Update the limits spring settings.
Definition HingeConstraint.h:114
void SetLimitsSpringSettings(const SpringSettings &inLimitsSpringSettings)
Definition HingeConstraint.h:116
const MotorSettings & GetMotorSettings() const
Definition HingeConstraint.h:97
SpringSettings & GetLimitsSpringSettings()
Definition HingeConstraint.h:115
float GetLimitsMax() const
Definition HingeConstraint.h:110
float GetTotalLambdaRotationLimits() const
Definition HingeConstraint.h:121
Vector< 2 > GetTotalLambdaRotation() const
Definition HingeConstraint.h:120
MotorSettings & GetMotorSettings()
Definition HingeConstraint.h:96
float GetLimitsMin() const
Definition HingeConstraint.h:109
void SetTargetAngularVelocity(float inAngularVelocity)
rad/s
Definition HingeConstraint.h:102
float GetTargetAngle() const
Definition HingeConstraint.h:105
float GetMaxFrictionTorque() const
Definition HingeConstraint.h:93
void SetMotorState(EMotorState inState)
Definition HingeConstraint.h:100
void SetTargetAngle(float inAngle)
rad
Definition HingeConstraint.h:104
virtual EConstraintSubType GetSubType() const override
Get the sub type of a constraint.
Definition HingeConstraint.h:70
float GetTotalLambdaMotor() const
Definition HingeConstraint.h:122
float GetTargetAngularVelocity() const
Definition HingeConstraint.h:103
void SetMaxFrictionTorque(float inFrictionTorque)
Definition HingeConstraint.h:92
Vec3 GetTotalLambdaPosition() const
Definition HingeConstraint.h:119
bool HasLimits() const
Definition HingeConstraint.h:111
Hinge constraint settings, used to create a hinge constraint.
Definition HingeConstraint.h:17
MotorSettings mMotorSettings
In case the constraint is powered, this determines the motor settings around the hinge axis.
Definition HingeConstraint.h:53
SpringSettings mLimitsSpringSettings
When enabled, this makes the limits soft. When the constraint exceeds the limits, a spring force will...
Definition HingeConstraint.h:47
Definition HingeRotationConstraintPart.h:44
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:26
Definition PointConstraintPart.h:41
Definition Reference.h:101
Settings for a linear or angular spring.
Definition SpringSettings.h:23
Definition StateRecorder.h:48
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
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
virtual TwoBodyConstraint * Create(Body &inBody1, Body &inBody2) const =0
static JPH_INLINE Vec3 sAxisX()
Vectors with the principal axis.
Definition Vec3.h:52
static JPH_INLINE Vec3 sAxisY()
Definition Vec3.h:53
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107
Templatized vector class.
Definition Vector.h:12