45 template <EMotionType Type1, EMotionType Type2>
75 template <EMotionType Type1, EMotionType Type2>
142 switch (
inBody1.GetMotionType())
149 switch (
inBody2.GetMotionType())
186 switch (
inBody1.GetMotionType())
191 switch (
inBody2.GetMotionType())
226 template <EMotionType Type1, EMotionType Type2>
239 JPH_DET_LOG(
"TemplatedCalculateConstraintProperties: invM1: " <<
inInvMass1 <<
" invI1: " <<
inInvI1 <<
" r1PlusU: " <<
inR1PlusU <<
" invM2: " <<
inInvMass2 <<
" invI2: " <<
inInvI2 <<
" r2: " <<
inR2 <<
" bias: " <<
inBias <<
" r1PlusUxAxis: " << mR1PlusUxAxis <<
" r2xAxis: " << mR2xAxis <<
" invI1_R1PlusUxAxis: " << mInvI1_R1PlusUxAxis <<
" invI2_R2xAxis: " << mInvI2_R2xAxis <<
" effectiveMass: " << mEffectiveMass <<
" totalLambda: " << mTotalLambda);
344 mEffectiveMass = 0.0f;
351 return mEffectiveMass != 0.0f;
355 template <EMotionType Type1, EMotionType Type2>
393 template <EMotionType Type1, EMotionType Type2>
416 float lambda = mEffectiveMass * (
jv - mSpringPart.
GetBias(mTotalLambda));
419 return mTotalLambda +
lambda;
423 template <EMotionType Type1, EMotionType Type2>
433 template <EMotionType Type1, EMotionType Type2>
675 Float3 mInvI1_R1PlusUxAxis;
677 float mEffectiveMass = 0.0f;
679 float mTotalLambda = 0.0f;
#define JPH_IF_DEBUG(...)
Definition Core.h:486
#define JPH_NAMESPACE_END
Definition Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition Core.h:361
#define JPH_DET_LOG(...)
By default we log nothing.
Definition DeterminismLog.h:155
#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
AllocateFunction Allocate
Definition Memory.cpp:59
EMotionType
Motion type of a physics body.
Definition MotionType.h:11
@ Kinematic
Movable using velocities only, does not respond to forces.
@ Dynamic
Responds to forces as a normal physics object.
@ FrequencyAndDamping
Frequency and damping are specified.
Definition AxisConstraintPart.h:43
float GetTotalLambda() const
Return lagrange multiplier.
Definition AxisConstraintPart.h:655
bool SolveVelocityConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
Definition AxisConstraintPart.h:450
void CalculateConstraintPropertiesWithSettings(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)
Selects one of the above functions based on the spring settings.
Definition AxisConstraintPart.h:329
bool SolvePositionConstraint(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inC, float inBaumgarte) const
Definition AxisConstraintPart.h:554
bool IsActive() const
Check if constraint is active.
Definition AxisConstraintPart.h:349
void SetTotalLambda(float inLambda)
Override total lagrange multiplier, can be used to set the initial value for warm starting.
Definition AxisConstraintPart.h:649
bool TemplatedSolveVelocityConstraint(MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
Templated form of SolveVelocityConstraint with the motion types baked in.
Definition AxisConstraintPart.h:434
JPH_INLINE void TemplatedCalculateConstraintProperties(float inInvMass1, Mat44Arg inInvI1, Vec3Arg inR1PlusU, float inInvMass2, Mat44Arg inInvI2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f)
Templated form of CalculateConstraintProperties with the motion types baked in.
Definition AxisConstraintPart.h:227
void CalculateConstraintPropertiesWithFrequencyAndDamping(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping)
Definition AxisConstraintPart.h:297
void WarmStart(Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inWarmStartImpulseRatio)
Definition AxisConstraintPart.h:368
void Deactivate()
Deactivate this constraint.
Definition AxisConstraintPart.h:342
void CalculateConstraintPropertiesWithMassOverride(const Body &inBody1, float inInvMass1, float inInvInertiaScale1, Vec3Arg inR1PlusU, const Body &inBody2, float inInvMass2, float inInvInertiaScale2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f)
Definition AxisConstraintPart.h:273
bool SolvePositionConstraintWithMassOverride(Body &ioBody1, float inInvMass1, Body &ioBody2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inC, float inBaumgarte) const
Definition AxisConstraintPart.h:605
JPH_INLINE float TemplatedSolveVelocityConstraintGetTotalLambda(const MotionProperties *ioMotionProperties1, const MotionProperties *ioMotionProperties2, Vec3Arg inWorldSpaceAxis) const
Templated form of SolveVelocityConstraint with the motion types baked in, part 1: get the total lambd...
Definition AxisConstraintPart.h:394
bool SolveVelocityConstraintWithMassOverride(Body &ioBody1, float inInvMass1, Body &ioBody2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
Definition AxisConstraintPart.h:503
JPH_INLINE bool TemplatedSolveVelocityConstraintApplyLambda(MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inTotalLambda)
Templated form of SolveVelocityConstraint with the motion types baked in, part 2: apply new lambda.
Definition AxisConstraintPart.h:424
void SaveState(StateRecorder &inStream) const
Save state of this constraint part.
Definition AxisConstraintPart.h:661
void TemplatedWarmStart(MotionProperties *ioMotionProperties1, float inInvMass1, MotionProperties *ioMotionProperties2, float inInvMass2, Vec3Arg inWorldSpaceAxis, float inWarmStartImpulseRatio)
Templated form of WarmStart with the motion types baked in.
Definition AxisConstraintPart.h:356
void CalculateConstraintPropertiesWithStiffnessAndDamping(float inDeltaTime, const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping)
Definition AxisConstraintPart.h:318
void CalculateConstraintProperties(const Body &inBody1, Vec3Arg inR1PlusU, const Body &inBody2, Vec3Arg inR2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f)
Definition AxisConstraintPart.h:249
void RestoreState(StateRecorder &inStream)
Restore state of this constraint part.
Definition AxisConstraintPart.h:667
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition Float3.h:13
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
The Body class only keeps track of state for static bodies, the MotionProperties class keeps the addi...
Definition MotionProperties.h:29
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
Class used in other constraint parts to calculate the required bias factor in the lagrange multiplier...
Definition SpringPart.h:14
void CalculateSpringPropertiesWithFrequencyAndDamping(float inDeltaTime, float inInvEffectiveMass, float inBias, float inC, float inFrequency, float inDamping, float &outEffectiveMass)
Definition SpringPart.h:86
void CalculateSpringPropertiesWithStiffnessAndDamping(float inDeltaTime, float inInvEffectiveMass, float inBias, float inC, float inStiffness, float inDamping, float &outEffectiveMass)
Definition SpringPart.h:116
float GetBias(float inTotalLambda) const
Get total bias b, including supplied bias and bias for spring: lambda = J v + b.
Definition SpringPart.h:137
void CalculateSpringPropertiesWithBias(float inBias)
Definition SpringPart.h:71
bool IsActive() const
Returns if this spring is active.
Definition SpringPart.h:131
Settings for a linear or angular spring.
Definition SpringSettings.h:23
Definition StateRecorder.h:48
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 void StoreFloat3(Float3 *outV) const
Store 3 floats to memory.
Definition Vec3.inl:757
static JPH_INLINE Vec3 sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (reads 32 bits extra which it doesn't use)
Definition Vec3.inl:134
static JPH_INLINE Vec3 sNaN()
Vector with all NaN's.
Definition Vec3.inl:129