50 JPH_INLINE
bool ApplyVelocityStep(
Body &ioBody1,
Body &ioBody2,
Vec3Arg inN1,
Vec3Arg inN2,
float inRatio,
float inLambda)
const
93 float inv_effective_mass = 0.0f;
99 mR1xN1 = inR1.
Cross(inN1);
109 mRatioR2xN2 = inRatio * inR2.
Cross(inN2);
116 if (inv_effective_mass == 0.0f)
119 mEffectiveMass = 1.0f / inv_effective_mass;
125 mEffectiveMass = 0.0f;
132 return mEffectiveMass != 0.0f;
144 mTotalLambda *= inWarmStartImpulseRatio;
145 ApplyVelocityStep(ioBody1, ioBody2, inN1, inN2, inRatio, mTotalLambda);
162 float new_lambda =
Clamp(mTotalLambda + lambda, inMinLambda, inMaxLambda);
163 lambda = new_lambda - mTotalLambda;
164 mTotalLambda = new_lambda;
166 return ApplyVelocityStep(ioBody1, ioBody2, inN1, inN2, inRatio, lambda);
192 float lambda = -mEffectiveMass * inBaumgarte * inC;
228 inStream.
Write(mTotalLambda);
234 inStream.
Read(mTotalLambda);
241 Vec3 mInvI2_RatioR2xN2;
242 float mEffectiveMass = 0.0f;
243 float mTotalLambda = 0.0f;
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
JPH_INLINE constexpr T Clamp(T inV, T inMin, T inMax)
Clamp a value between two values.
Definition Math.h:48
JPH_INLINE constexpr T Square(T inV)
Square a value.
Definition Math.h:55
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
Vec3 GetLinearVelocity() const
Get world space linear velocity of the center of mass (unit: m/s)
Definition Body.h:146
bool IsStatic() const
Check if this body is static (not movable)
Definition Body.h:57
Quat GetRotation() const
World space rotation of the body.
Definition Body.h:267
const MotionProperties * GetMotionPropertiesUnchecked() const
Access to the motion properties (version that does not check if the object is kinematic or dynamic)
Definition Body.h:289
Vec3 GetAngularVelocity() const
Get world space angular velocity of the center of mass (unit: rad/s)
Definition Body.h:157
void AddPositionStep(Vec3Arg inLinearVelocityTimesDeltaTime)
Update position using an Euler step (used during position integrate & constraint solving)
Definition Body.h:319
Definition IndependentAxisConstraintPart.h:48
void CalculateConstraintProperties(const Body &inBody1, const Body &inBody2, Vec3Arg inR1, Vec3Arg inN1, Vec3Arg inR2, Vec3Arg inN2, float inRatio)
Definition IndependentAxisConstraintPart.h:89
float GetTotalLambda() const
Return lagrange multiplier.
Definition IndependentAxisConstraintPart.h:170
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition IndependentAxisConstraintPart.h:232
bool IsActive() const
Check if constraint is active.
Definition IndependentAxisConstraintPart.h:130
void WarmStart(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inWarmStartImpulseRatio)
Definition IndependentAxisConstraintPart.h:142
bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inMinLambda, float inMaxLambda)
Definition IndependentAxisConstraintPart.h:156
void Deactivate()
Deactivate this constraint.
Definition IndependentAxisConstraintPart.h:123
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inC, float inBaumgarte) const
Definition IndependentAxisConstraintPart.h:183
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition IndependentAxisConstraintPart.h:226
The Body class only keeps track of state for static bodies, the MotionProperties class keeps the addi...
Definition MotionProperties.h:29
void AddLinearVelocityStep(Vec3Arg inLinearVelocityChange)
Definition MotionProperties.h:195
float GetInverseMass() const
Get inverse mass (1 / mass). Should only be called on a dynamic object (static or kinematic bodies ha...
Definition MotionProperties.h:95
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:110
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:645
JPH_INLINE Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition Vec3.inl:590
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:747