42 JPH_INLINE
bool ApplyVelocityStep(
Body &ioBody1,
Body &ioBody2,
float inLambda)
const
79 mRatio_InvM2_B = inRatio * inv_m2 * inWorldSpaceSliderAxis;
82 float inv_effective_mass = (inWorldSpaceHingeAxis.
Dot(mInvI1_A) + inv_m2 *
Square(inRatio));
83 if (inv_effective_mass == 0.0f)
86 mEffectiveMass = 1.0f / inv_effective_mass;
92 mEffectiveMass = 0.0f;
99 return mEffectiveMass != 0.0f;
108 mTotalLambda *= inWarmStartImpulseRatio;
109 ApplyVelocityStep(ioBody1, ioBody2, mTotalLambda);
124 mTotalLambda += lambda;
126 return ApplyVelocityStep(ioBody1, ioBody2, lambda);
150 float lambda = -mEffectiveMass * inBaumgarte * inC;
180 inStream.
Write(mTotalLambda);
186 inStream.
Read(mTotalLambda);
192 float mEffectiveMass = 0.0f;
193 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
void SubPositionStep(Vec3Arg inLinearVelocityTimesDeltaTime)
Definition Body.h:320
Vec3 GetLinearVelocity() const
Get world space linear velocity of the center of mass (unit: m/s)
Definition Body.h:146
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
void SubLinearVelocityStep(Vec3Arg inLinearVelocityChange)
Definition MotionProperties.h:196
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 RackAndPinionConstraintPart.h:40
void CalculateConstraintProperties(const Body &inBody1, Vec3Arg inWorldSpaceHingeAxis, const Body &inBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio)
Definition RackAndPinionConstraintPart.h:69
bool SolveVelocityConstraint(Body &ioBody1, Vec3Arg inWorldSpaceHingeAxis, Body &ioBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio)
Definition RackAndPinionConstraintPart.h:118
float GetTotalLambda() const
Return lagrange multiplier.
Definition RackAndPinionConstraintPart.h:130
void WarmStart(Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
Definition RackAndPinionConstraintPart.h:106
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition RackAndPinionConstraintPart.h:178
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
Definition RackAndPinionConstraintPart.h:140
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition RackAndPinionConstraintPart.h:184
void Deactivate()
Deactivate this constraint.
Definition RackAndPinionConstraintPart.h:90
bool IsActive() const
Check if constraint is active.
Definition RackAndPinionConstraintPart.h:97
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