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 mEffectiveMass = 1.0f / inv_effective_mass;
122 mEffectiveMass = 0.0f;
129 return mEffectiveMass != 0.0f;
141 mTotalLambda *= inWarmStartImpulseRatio;
142 ApplyVelocityStep(ioBody1, ioBody2, inN1, inN2, inRatio, mTotalLambda);
159 float new_lambda =
Clamp(mTotalLambda + lambda, inMinLambda, inMaxLambda);
160 lambda = new_lambda - mTotalLambda;
161 mTotalLambda = new_lambda;
163 return ApplyVelocityStep(ioBody1, ioBody2, inN1, inN2, inRatio, lambda);
189 float lambda = -mEffectiveMass * inBaumgarte * inC;
225 inStream.
Write(mTotalLambda);
231 inStream.
Read(mTotalLambda);
238 Vec3 mInvI2_RatioR2xN2;
239 float mEffectiveMass = 0.0f;
240 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
constexpr T Square(T inV)
Square a value.
Definition Math.h:52
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
Vec3 GetLinearVelocity() const
Get world space linear velocity of the center of mass (unit: m/s)
Definition Body.h:109
bool IsStatic() const
Check if this body is static (not movable)
Definition Body.h:50
Quat GetRotation() const
World space rotation of the body.
Definition Body.h:187
const MotionProperties * GetMotionPropertiesUnchecked() const
Access to the motion properties (version that does not check if the object is kinematic or dynamic)
Definition Body.h:209
Vec3 GetAngularVelocity() const
Get world space angular velocity of the center of mass (unit: rad/s)
Definition Body.h:118
void AddPositionStep(Vec3Arg inLinearVelocityTimesDeltaTime)
Update position using an Euler step (used during position integrate & constraint solving)
Definition Body.h:236
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:167
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition IndependentAxisConstraintPart.h:229
bool IsActive() const
Check if constraint is active.
Definition IndependentAxisConstraintPart.h:127
void WarmStart(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inWarmStartImpulseRatio)
Definition IndependentAxisConstraintPart.h:139
bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inMinLambda, float inMaxLambda)
Definition IndependentAxisConstraintPart.h:153
void Deactivate()
Deactivate this constraint.
Definition IndependentAxisConstraintPart.h:120
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inRatio, float inC, float inBaumgarte) const
Definition IndependentAxisConstraintPart.h:180
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition IndependentAxisConstraintPart.h:223
The Body class only keeps track of state for static bodies, the MotionProperties class keeps the addi...
Definition MotionProperties.h:20
void AddLinearVelocityStep(Vec3Arg inLinearVelocityChange)
Definition MotionProperties.h:126
float GetInverseMass() const
Get inverse mass (1 / mass). Should only be called on a dynamic object (static or kinematic bodies ha...
Definition MotionProperties.h:80
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
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 Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition Vec3.inl:582
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:737