38 JPH_INLINE
bool ApplyVelocityStep(
Body &ioBody1,
Body &ioBody2,
float inLambda)
const
80 float inv_effective_mass = inWorldSpaceAxis.
Dot(mInvI1_Axis + mInvI2_Axis);
83 mSpringPart.
CalculateSpringProperties(inDeltaTime, inv_effective_mass, inBias, inC, inFrequency, inDamping, mEffectiveMass);
89 mEffectiveMass = 0.0f;
96 return mEffectiveMass != 0.0f;
105 mTotalLambda *= inWarmStartImpulseRatio;
106 ApplyVelocityStep(ioBody1, ioBody2, mTotalLambda);
121 float new_lambda =
Clamp(mTotalLambda + lambda, inMinLambda, inMaxLambda);
122 lambda = new_lambda - mTotalLambda;
123 mTotalLambda = new_lambda;
125 return ApplyVelocityStep(ioBody1, ioBody2, lambda);
142 if (inC != 0.0f && !mSpringPart.
IsActive())
149 float lambda = -mEffectiveMass * inBaumgarte * inC;
179 inStream.
Write(mTotalLambda);
185 inStream.
Read(mTotalLambda);
191 float mEffectiveMass = 0.0f;
193 float mTotalLambda = 0.0f;
#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
Definition AngleConstraintPart.h:36
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
Definition AngleConstraintPart.h:139
void Deactivate()
Deactivate this constraint.
Definition AngleConstraintPart.h:87
bool IsActive() const
Check if constraint is active.
Definition AngleConstraintPart.h:94
void CalculateConstraintProperties(float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f, float inC=0.0f, float inFrequency=0.0f, float inDamping=0.0f)
Definition AngleConstraintPart.h:71
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition AngleConstraintPart.h:183
void WarmStart(Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
Definition AngleConstraintPart.h:103
bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
Definition AngleConstraintPart.h:115
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition AngleConstraintPart.h:177
float GetTotalLambda() const
Return lagrange multiplier.
Definition AngleConstraintPart.h:129
const MotionProperties * GetMotionProperties() const
Access to the motion properties.
Definition Body.h:205
bool IsDynamic() const
Check if this body is dynamic, which means that it moves and forces can act on it.
Definition Body.h:56
void AddRotationStep(Vec3Arg inAngularVelocityTimesDeltaTime)
Update rotation using an Euler step (using during position integrate & constraint solving)
Definition Body.inl:75
Quat GetRotation() const
World space rotation of the body.
Definition Body.h:187
void SubRotationStep(Vec3Arg inAngularVelocityTimesDeltaTime)
Definition Body.inl:93
Vec3 GetAngularVelocity() const
Get world space angular velocity of the center of mass (unit: rad/s)
Definition Body.h:118
void SubAngularVelocityStep(Vec3Arg inAngularVelocityChange)
Definition MotionProperties.h:129
JPH_INLINE Vec3 MultiplyWorldSpaceInverseInertiaByVector(QuatArg inBodyRotation, Vec3Arg inV) const
Multiply a vector with the inverse world space inertia tensor ( ). Zero if object is static or kinema...
Definition MotionProperties.inl:90
void AddAngularVelocityStep(Vec3Arg inAngularVelocityChange)
Definition MotionProperties.h:128
Class used in other constraint parts to calculate the required bias factor in the lagrange multiplier...
Definition SpringPart.h:14
void CalculateSpringProperties(float inDeltaTime, float inInvEffectiveMass, float inBias, float inC, float inFrequency, float inDamping, float &outEffectiveMass)
Definition SpringPart.h:25
float GetBias(float inTotalLambda) const
Get total bias b, including supplied bias and bias for spring: lambda = J v + b.
Definition SpringPart.h:98
bool IsActive() const
Returns if this spring is active.
Definition SpringPart.h:92
Definition StateRecorder.h:15
void Read(T &outT)
Read a primitive (e.g. float, int, etc.) from the binary stream.
Definition StreamIn.h:27
void Write(const T &inT)
Write a primitive (e.g. float, int, etc.) to the binary stream.
Definition StreamOut.h:24
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:637
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:737
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107