10#ifndef CHAOS_CONSTRAINTSOLVER_NAN_DIAGNOSTIC
11#define CHAOS_CONSTRAINTSOLVER_NAN_DIAGNOSTIC ((DO_CHECK && UE_BUILD_DEBUG) || ENABLE_NAN_DIAGNOSTIC)
15#define CHAOS_CONSTRAINTSOLVER_LOWPRECISION 1
18#if CHAOS_CONSTRAINTSOLVER_NAN_DIAGNOSTIC
27#define ChaosSolverCheckNaN(...)
37#if CHAOS_CONSTRAINTSOLVER_LOWPRECISION
111 SolverBody.State.Init();
195 inline const FVec3&
X()
const {
return State.X; }
213 inline const FVec3&
P()
const {
return State.P; }
248 inline const FVec3&
CoM()
const {
return State.CoM; }
421 State.Q.EnforceShortestArcWith(
InQ);
459 RoM = FRotation3::FromIdentity();
460 R = FRotation3::FromIdentity();
461 Q = FRotation3::FromIdentity();
558 inline bool IsValid()
const {
return Body !=
nullptr; }
563 inline void Reset() { Body =
nullptr; }
630 inline const FVec3&
X()
const {
return Body->
X(); }
632 inline const FVec3&
P()
const {
return Body->
P(); }
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ChaosSolverCheckNaN(...)
Definition SolverBody.h:27
VectorRegister4Double VectorRegister4
Definition UnrealMathFPU.h:94
Definition SolverBody.h:543
void EnforceShortestRotationTo(const FRotation3 &InQ)
Definition SolverBody.h:656
void ApplyPositionCorrectionDelta(const FSolverVec3 &DP)
Definition SolverBody.h:651
void SetInvIScale(FReal InValue)
Definition SolverBody.h:595
FRigidTransform3 CoMTransform() const
Definition SolverBody.h:629
bool IsDynamic() const
Whether the body is dynamic (i.e., has a finite mass) after scaling is applied.
Definition SolverBody.h:622
void ApplyPositionDelta(const FSolverVec3 &DP)
Definition SolverBody.h:649
FSolverReal ShockPropagationScale() const
Shock propagation mass and inertia scaling (0 for infinite mass, 1 for no effect)
Definition SolverBody.h:601
bool IsValid() const
True if we have been set up to decorate a SolverBody.
Definition SolverBody.h:558
const FSolverVec3 & CQ() const
Definition SolverBody.h:644
void SetSolverBody(FSolverBody &InSolverBody)
Set the inner solver body (hold by reference)
Definition SolverBody.h:574
void ApplyAngularVelocityDelta(const FSolverVec3 &DW)
Definition SolverBody.h:655
const FSolverVec3 & DP() const
Definition SolverBody.h:641
void UpdateRotationDependentState()
Definition SolverBody.h:657
FSolverBody & SolverBody()
The decorated SolverBody.
Definition SolverBody.h:582
FSolverReal InvM() const
The net scaled inverse mass.
Definition SolverBody.h:607
FSolverReal InvMScale() const
A scale applied to inverse mass.
Definition SolverBody.h:588
void ApplyVelocityDelta(const FSolverVec3 &DV, const FSolverVec3 &DW)
Definition SolverBody.h:653
const FRotation3 CorrectedActorQ() const
Definition SolverBody.h:637
FRotation3 CorrectedQ() const
Definition SolverBody.h:646
void SetInvMScale(FReal InValue)
Definition SolverBody.h:589
void SetImplicitVelocity(FReal Dt)
Definition SolverBody.h:628
FConstraintSolverBody(FSolverBody &InBody)
Definition SolverBody.h:550
FVec3 CorrectedP() const
Definition SolverBody.h:645
const FSolverBody & SolverBody() const
Definition SolverBody.h:583
FConstraintSolverBody()
Definition SolverBody.h:545
int32 Level() const
Definition SolverBody.h:640
void SetShockPropagationScale(FReal InValue)
Definition SolverBody.h:602
const FRotation3 & R() const
Definition SolverBody.h:631
void Init()
Initialize all properties to safe values.
Definition SolverBody.h:568
const FVec3 ActorP() const
Definition SolverBody.h:634
FSolverMatrix33 InvI() const
The net scaled inverse inertia.
Definition SolverBody.h:612
const FSolverVec3 & DQ() const
Definition SolverBody.h:642
FSolverReal InvIScale() const
A scale applied to inverse inertia.
Definition SolverBody.h:594
void ApplyLinearVelocityDelta(const FSolverVec3 &DV)
Definition SolverBody.h:654
const FVec3 & X() const
Definition SolverBody.h:630
void ApplyRotationDelta(const FSolverVec3 &DR)
Definition SolverBody.h:650
const FSolverVec3 & V() const
Definition SolverBody.h:638
const FSolverVec3 & CP() const
Definition SolverBody.h:643
void ApplyRotationCorrectionDelta(const FSolverVec3 &DR)
Definition SolverBody.h:652
const FSolverVec3 & W() const
Definition SolverBody.h:639
void ApplyTransformDelta(const FSolverVec3 &DP, const FSolverVec3 &DR)
Definition SolverBody.h:648
const FRotation3 & Q() const
Definition SolverBody.h:633
void Reset()
Invalidate the solver body reference.
Definition SolverBody.h:563
FSolverVec3 InvILocal() const
The net scaled local space inverse inertia.
Definition SolverBody.h:617
const FRotation3 ActorQ() const
Definition SolverBody.h:635
const FVec3 & P() const
Definition SolverBody.h:632
const FVec3 CorrectedActorP() const
Definition SolverBody.h:636
Definition SolverBodyContainer.h:37
Definition SolverBody.h:99
void SetV(const FVec3 &InV)
Definition SolverBody.h:232
static constexpr FSolverReal ZeroMassThreshold()
Definition SolverBody.h:101
const FRotation3 & R() const
Pre-integration world-space center of mass rotation.
Definition SolverBody.h:201
FVec3 ActorP() const
Get the world-space Actor position.
Definition SolverBody.h:308
FSolverBody()
Definition SolverBody.h:126
FRotation3 ActorQ() const
Get the world-space Actor rotation.
Definition SolverBody.h:313
void SetP(const FVec3 &InP)
Definition SolverBody.h:214
const FVec3 & P() const
Predicted (post-integrate) world-space center of mass position.
Definition SolverBody.h:213
void SetLevel(int32 InLevel)
Definition SolverBody.h:331
void ApplyPositionCorrectionDelta(const FSolverVec3 &CP)
Apply a world-space position correction delta to the solver body center of mass This will translate t...
Definition SolverBody.h:370
const FSolverVec3 & InvILocal() const
Get the local-space inverse inertia (diagonal elements)
Definition SolverBody.h:176
void ApplyPositionDelta(const FSolverVec3 &DP)
Apply a world-space position delta to the solver body center of mass.
Definition SolverBody.h:351
const FSolverVec3 & V() const
World-space center of mass velocity.
Definition SolverBody.h:231
void ApplyVelocityDelta(const FSolverVec3 &DV, const FSolverVec3 &DW)
Apply a world-space velocity delta to the solver body.
Definition SolverBody.h:391
FRigidTransform3 CoMTransform() const
The current CoM transform.
Definition SolverBody.h:190
void ApplyAngularVelocityDelta(const FSolverVec3 &DW)
Apply an world-space angular velocity delta to the solver body.
Definition SolverBody.h:409
const FSolverMatrix33 & InvI() const
Get the world-space inverse inertia.
Definition SolverBody.h:166
const FVec3 & X() const
Pre-integration world-space center of mass position.
Definition SolverBody.h:195
FRotation3 CorrectedQ() const
World-space rotation after applying the net correction DQ()
Definition SolverBody.h:288
void SetImplicitVelocity(FReal Dt)
Calculate and set the velocity and angular velocity from the net transform delta.
Definition SolverBody.h:142
void ApplyRotationCorrectionDelta(const FSolverVec3 &CR)
Apply a world-space rotation correction delta to the solver body This will rotate the body without in...
Definition SolverBody.h:381
void PrefetchPositionSolverData() const
Definition SolverBody.h:431
const FVec3 & CoM() const
Definition SolverBody.h:248
FVec3 CorrectedActorP() const
Get the current world-space Actor position.
Definition SolverBody.h:319
void ApplyLinearVelocityDelta(const FSolverVec3 &DV)
Apply a world-space linear velocity delta to the solver body.
Definition SolverBody.h:400
void SetInvILocal(const FVec3 &InInvILocal)
Set the local-space inverse inertia (diagonal elements)
Definition SolverBody.h:181
void Reset()
Definition SolverBody.h:131
void ApplyCorrections()
Apply the accumulated position and rotation corrections to the predicted P and Q This is only used by...
Definition SolverBody.h:295
const FSolverVec3 & W() const
World-space center of mass angular velocity.
Definition SolverBody.h:241
void SetDP(const FSolverVec3 &InDP)
Definition SolverBody.h:258
void ApplyRotationDelta(const FSolverVec3 &DR)
Apply a world-space rotation delta to the solver body and update the inverse mass.
Definition SolverBody.h:360
void SetInvM(FReal InInvM)
Set the inverse mass.
Definition SolverBody.h:161
void SetX(const FVec3 &InX)
Definition SolverBody.h:196
void ApplyTransformDelta(const FSolverVec3 &DP, const FSolverVec3 &DR)
Apply a world-space position and rotation delta to the body center of mass, and update inverse mass.
Definition SolverBody.h:342
void SetDQ(const FSolverVec3 &InDQ)
Definition SolverBody.h:264
const FRotation3 & Q() const
Predicted (post-integrate) world-space center of mass rotation.
Definition SolverBody.h:221
const FSolverVec3 & CQ() const
Net world-space rotation correction applied by the constraints (axis-angle vector equivalent to angul...
Definition SolverBody.h:276
const FRotation3 & RoM() const
Definition SolverBody.h:251
void SetR(const FRotation3 &InR)
Definition SolverBody.h:202
void UpdateRotationDependentState()
Update cached state that depends on rotation (i.e., world space inertia)
Definition SolverBody.cpp:10
FRotation3 CorrectedActorQ() const
Get the current world-space Actor rotation.
Definition SolverBody.h:325
FSolverReal InvM() const
Get the inverse mass.
Definition SolverBody.h:156
static FSolverBody MakeUninitialized()
Definition SolverBody.h:118
void SetQ(const FRotation3 &InQ)
Definition SolverBody.h:222
void SetRoM(const FRotation3 &InRoM)
Definition SolverBody.h:252
static FSolverBody MakeInitialized()
Definition SolverBody.h:108
void EnforceShortestRotationTo(const FRotation3 &InQ)
Update the rotation to be in the same hemisphere as the provided quaternion. This is used by joints w...
Definition SolverBody.h:419
const FSolverVec3 & DP() const
Net world-space position displacement applied by the constraints.
Definition SolverBody.h:257
void SetInvI(const FMatrix33 &InInvI)
Set the world-space inverse inertia.
Definition SolverBody.h:171
FVec3 CorrectedP() const
World-space position after applying the net correction DP()
Definition SolverBody.h:282
const FSolverVec3 & DQ() const
Net world-space rotation displacement applied by the constraints (axis-angle vector equivalent to ang...
Definition SolverBody.h:263
void PrefetchVelocitySolverData() const
Definition SolverBody.h:437
int32 Level() const
Contact graph level. This is used in shock propagation to determine which of two bodies should have i...
Definition SolverBody.h:330
void SetCoM(const FVec3 &InCoM)
Definition SolverBody.h:249
const FSolverVec3 & CP() const
Net world-space position correction applied by the constraints.
Definition SolverBody.h:270
void SetW(const FVec3 &InW)
Definition SolverBody.h:242
bool IsDynamic() const
Whether the body has a finite mass.
Definition SolverBody.h:337
FORCEINLINE bool ContainsNaN() const
Definition Vector.h:1101
Definition SkeletalMeshComponent.h:307
TRigidTransform< FReal, 3 > FRigidTransform3
Definition Core.h:22
TMatrix33< FSolverReal > FSolverMatrix33
Definition SolverBody.h:46
FRealDouble FReal
Definition Real.h:22
TRotation< FReal, 3 > FRotation3
Definition Core.h:19
TVec3< FSolverReal > FSolverVec3
Definition SolverBody.h:44
void SolverQuaternionNormalizeApprox(FRotation3 &InOutQ)
An approximate quaternion normalize for use in the solver.
Definition SolverBody.cpp:18
FRealSingle FSolverReal
Definition SolverBody.h:38
float FRealSingle
Definition Real.h:14
double FRealDouble
Definition Real.h:13
TVector< FReal, 3 > FVec3
Definition Core.h:17
FRotation3 SolverQuaternionApplyAngularDeltaApprox(const FRotation3 &InQ0, const FVec3 &InDR)
Definition SolverBody.cpp:69
ECompressionLevel Level
Definition OodleDataCompression.cpp:70
int32 P[512]
Definition FieldSystemNoiseAlgo.cpp:11
Definition UnrealMathFPU.h:20