42 JPH_INLINE
bool ApplyVelocityStep(
Body &ioBody1,
Body &ioBody2,
float inLambda)
const
81 float inv_effective_mass = (inWorldSpaceHingeAxis1.
Dot(mInvI1_A) + inWorldSpaceHingeAxis2.
Dot(mInvI2_B) *
Square(inRatio));
82 if (inv_effective_mass == 0.0f)
85 mEffectiveMass = 1.0f / inv_effective_mass;
91 mEffectiveMass = 0.0f;
98 return mEffectiveMass != 0.0f;
107 mTotalLambda *= inWarmStartImpulseRatio;
108 ApplyVelocityStep(ioBody1, ioBody2, mTotalLambda);
123 mTotalLambda += lambda;
125 return ApplyVelocityStep(ioBody1, ioBody2, lambda);
149 float lambda = -mEffectiveMass * inBaumgarte * inC;
179 inStream.
Write(mTotalLambda);
185 inStream.
Read(mTotalLambda);
191 float mEffectiveMass = 0.0f;
192 float mTotalLambda = 0.0f;
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
JPH_INLINE constexpr T Square(T inV)
Square a value.
Definition Math.h:52
const MotionProperties * GetMotionProperties() const
Access to the motion properties.
Definition Body.h:285
bool IsDynamic() const
Check if this body is dynamic, which means that it moves and forces can act on it.
Definition Body.h:63
void AddRotationStep(Vec3Arg inAngularVelocityTimesDeltaTime)
Update rotation using an Euler step (used during position integrate & constraint solving)
Definition Body.inl:81
Quat GetRotation() const
World space rotation of the body.
Definition Body.h:267
Vec3 GetAngularVelocity() const
Get world space angular velocity of the center of mass (unit: rad/s)
Definition Body.h:157
Definition GearConstraintPart.h:40
float GetTotalLambda() const
Return lagrange multiplier.
Definition GearConstraintPart.h:129
void WarmStart(Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
Definition GearConstraintPart.h:105
bool SolveVelocityConstraint(Body &ioBody1, Vec3Arg inWorldSpaceHingeAxis1, Body &ioBody2, Vec3Arg inWorldSpaceHingeAxis2, float inRatio)
Definition GearConstraintPart.h:117
bool IsActive() const
Check if constraint is active.
Definition GearConstraintPart.h:96
void CalculateConstraintProperties(const Body &inBody1, Vec3Arg inWorldSpaceHingeAxis1, const Body &inBody2, Vec3Arg inWorldSpaceHingeAxis2, float inRatio)
Definition GearConstraintPart.h:69
void Deactivate()
Deactivate this constraint.
Definition GearConstraintPart.h:89
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition GearConstraintPart.h:183
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
Definition GearConstraintPart.h:139
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition GearConstraintPart.h:177
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:86
void AddAngularVelocityStep(Vec3Arg inAngularVelocityChange)
Definition MotionProperties.h:197
Definition StateRecorder.h:105
void Read(T &outT)
Read a primitive (e.g. float, int, etc.) from the binary stream.
Definition StreamIn.h:29
void Write(const T &inT)
Write a primitive (e.g. float, int, etc.) to the binary stream.
Definition StreamOut.h:26
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:649
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:751