12template <EMotionType Type1>
64template <EMotionType Type2>
92template <EMotionType Type1, EMotionType Type2>
97 JPH_INLINE
bool ApplyVelocityStep(
MotionProperties *ioMotionProperties1,
float inInvMass1,
MotionProperties *ioMotionProperties2,
float inInvMass2,
Vec3Arg inWorldSpaceAxis,
float inLambda)
const
124 float inv_effective_mass;
128 Vec3 r1_plus_u_x_axis = inR1PlusU.
Cross(inWorldSpaceAxis);
129 r1_plus_u_x_axis.
StoreFloat3(&this->mR1PlusUxAxis);
134 invi1_r1_plus_u_x_axis.
StoreFloat3(&this->mInvI1_R1PlusUxAxis);
136 inv_effective_mass = inInvMass1 + invi1_r1_plus_u_x_axis.
Dot(r1_plus_u_x_axis);
139 inv_effective_mass = 0.0f;
142 inv_effective_mass = 0.0f;
146 Vec3 r2_x_axis = inR2.
Cross(inWorldSpaceAxis);
152 invi2_r2_x_axis.
StoreFloat3(&this->mInvI2_R2xAxis);
154 inv_effective_mass += inInvMass2 + invi2_r2_x_axis.
Dot(r2_x_axis);
158 if (inv_effective_mass == 0.0f)
163 this->
mBias = inBias;
172 ApplyVelocityStep(ioMotionProperties1, inInvMass1, ioMotionProperties2, inInvMass2, inWorldSpaceAxis, this->
mTotalLambda);
207 float delta_lambda = inTotalLambda - this->
mTotalLambda;
208 this->mTotalLambda = inTotalLambda;
210 return ApplyVelocityStep(ioMotionProperties1, inInvMass1, ioMotionProperties2, inInvMass2, inWorldSpaceAxis, delta_lambda);
219 total_lambda =
Clamp(total_lambda, inMinLambda, inMaxLambda);
264 inline bool SolveVelocityConstraint(
Body &inBody1,
float inInvMass1,
float inInvInertiaScale1,
Vec3Arg inR1PlusU,
Body &inBody2,
float inInvMass2,
float inInvInertiaScale2,
Vec3Arg inR2,
Vec3Arg inWorldSpaceAxis,
float inBias,
float inMinLambda,
float inMaxLambda)
325 [[maybe_unused]]
float mPadding;
#define JPH_NAMESPACE_END
Definition Core.h:428
#define JPH_NAMESPACE_BEGIN
Definition Core.h:422
#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
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.
EMotionType GetMotionType() const
Get the bodies motion type.
Definition Body.h:118
bool IsDynamic() const
Check if this body is dynamic, which means that it moves and forces can act on it.
Definition Body.h:67
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:343
Mat44 GetInverseInertia() const
Get inverse inertia tensor in world space.
Definition Body.inl:120
void SubRotationStep(Vec3Arg inAngularVelocityTimesDeltaTime)
Definition Body.inl:100
const MotionProperties * GetMotionPropertiesUnchecked() const
Access to the motion properties (version that does not check if the object is kinematic or dynamic)
Definition Body.h:312
void AddPositionStep(Vec3Arg inLinearVelocityTimesDeltaTime)
Update position using an Euler step (used during position integrate & constraint solving)
Definition Body.h:342
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
JPH_INLINE Vec3 Multiply3x3(Vec3Arg inV) const
Multiply vector by only 3x3 part of the matrix.
Definition Mat44.inl:384
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:217
Vec3 GetLinearVelocity() const
Get world space linear velocity of the center of mass.
Definition MotionProperties.h:43
Vec3 GetAngularVelocity() const
Get world space angular velocity of the center of mass.
Definition MotionProperties.h:52
void SubLinearVelocityStep(Vec3Arg inLinearVelocityChange)
Definition MotionProperties.h:218
void SubAngularVelocityStep(Vec3Arg inAngularVelocityChange)
Definition MotionProperties.h:220
void AddAngularVelocityStep(Vec3Arg inAngularVelocityChange)
Definition MotionProperties.h:219
JPH_INLINE float Dot(Vec3Arg inV2) const
Dot product.
Definition Vec3.inl:943
JPH_INLINE Vec3 Cross(Vec3Arg inV2) const
Cross product.
Definition Vec3.inl:841
JPH_INLINE bool IsNormalized(float inTolerance=1.0e-6f) const
Test if vector is normalized.
Definition Vec3.inl:1128
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store 3 floats to memory.
Definition Vec3.inl:1153
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:167