73 struct FConstraintData
108 using FSolveFunctionType =
void (*)(
const FConstraintData& ConstraintData, FBodyData& BodyData, FImpulseData& ImpulseData);
109 FSolveFunctionType PositionSolveFunction;
110 FSolveFunctionType CorrectionSolveFunction;
112 static void SolveCorrectionSingleBody(
const FConstraintData& ConstraintData, FBodyData& BodyData, FImpulseData& ImpulseData);
113 static void SolvePositionSingleBody(
const FConstraintData& ConstraintData, FBodyData& BodyData, FImpulseData& ImpulseData);
114 static void SolvePositionTwoBody(
const FConstraintData& ConstraintData, FBodyData& BodyData, FImpulseData& ImpulseData);
115 static void NoSolve(
const FConstraintData&, FBodyData&, FImpulseData&) {}
123 return Dt >
UE_SMALL_NUMBER ?
FVec3(ImpulseData.LinearPositionImpulse + ImpulseData.LinearCorrectionImpulse * ConstraintData.Normal) / Dt : FVec3::ZeroVector;
128 return Dt >
UE_SMALL_NUMBER ?
FVec3(ImpulseData.AngularImpulse * ConstraintData.VerticalAxis) / Dt : FVec3::ZeroVector;
136 return Vector - FSolverVec3::DotProduct(
Vector, PlaneNormal) * PlaneNormal;
152 return FSolverVec3::ZeroVector;
171 return GroundBody.IsValid() && GroundBody.IsDynamic();
179 check(ConstraintData.IsValid());
184 (*CorrectionSolveFunction)(ConstraintData, BodyData, ImpulseData);
185 (*PositionSolveFunction)(ConstraintData, BodyData, ImpulseData);
191 const FSolverReal Error = ConstraintData.Normal.Dot(BodyData.CharacterBody.CP()) + ConstraintData.InitialError;
195 ImpulseData.LinearCorrectionImpulse +=
Delta;
196 BodyData.CharacterBody.ApplyPositionCorrectionDelta(
FSolverVec3(ConstraintData.CharacterInvM *
Delta * ConstraintData.Normal));
206 const FSolverReal Error = ConstraintData.Normal.Dot(BodyData.CharacterBody.DP()) + ConstraintData.InitialProjectedError;
210 ImpulseData.LinearPositionImpulse +=
Delta;
211 BodyData.CharacterBody.ApplyPositionDelta(
FSolverVec3(ConstraintData.CharacterInvM *
Delta));
226 BodyData.CharacterBody.ApplyRotationDelta(
FSolverVec3(ConstraintData.CharacterInvI *
Delta));
229 const FSolverReal NormalImpulse = FSolverVec3::DotProduct(ImpulseData.LinearPositionImpulse, ConstraintData.Normal);
234 const FSolverVec3 MotionTargetError = ProjectOntoPlane(BodyData.CharacterBody.DP() + ConstraintData.MotionTargetError, ConstraintData.Normal);
238 ImpulseData.LinearPositionImpulse +=
Delta;
239 BodyData.CharacterBody.ApplyPositionDelta(
FSolverVec3(ConstraintData.CharacterInvM *
Delta));
242 const FSolverReal MotionTargetAngularError = ConstraintData.MotionTargetAngularError + ConstraintData.VerticalAxis.Dot(BodyData.CharacterBody.DQ());
243 const FSolverReal NewAngularImpulse = ClampAbs(ImpulseData.AngularImpulse - ConstraintData.EffectiveInertiaT * MotionTargetAngularError, ConstraintData.AngularTwistImpulseLimit);
246 BodyData.CharacterBody.ApplyRotationDelta(
FSolverVec3(ConstraintData.CharacterInvI *
AngularDelta * ConstraintData.VerticalAxis));
256 const FSolverReal Error = ConstraintData.Normal.Dot(BodyData.CharacterBody.DP() - BodyData.GroundBody.DP() - BodyData.GroundBody.DQ().Cross(ConstraintData.GroundOffset)) + ConstraintData.InitialProjectedError;
260 ImpulseData.LinearPositionImpulse +=
Delta;
261 BodyData.CharacterBody.ApplyPositionDelta(
FSolverVec3(ConstraintData.CharacterInvM *
Delta));
262 BodyData.GroundBody.ApplyPositionDelta(
FSolverVec3(-ConstraintData.GroundInvM *
Delta));
263 BodyData.GroundBody.ApplyRotationDelta(
FSolverVec3(-ConstraintData.GroundInvI * ConstraintData.GroundOffset.Cross(
Delta)));
278 BodyData.CharacterBody.ApplyRotationDelta(
FSolverVec3(ConstraintData.CharacterInvI *
Delta));
281 const FSolverReal NormalImpulse = FSolverVec3::DotProduct(ImpulseData.LinearPositionImpulse, ConstraintData.Normal);
286 const FSolverVec3 MotionTargetError = ProjectOntoPlane(BodyData.CharacterBody.DP() - BodyData.GroundBody.DP() - BodyData.GroundBody.DQ().Cross(ConstraintData.GroundOffset) + ConstraintData.MotionTargetError, ConstraintData.Normal);
290 ImpulseData.LinearPositionImpulse +=
Delta;
291 BodyData.CharacterBody.ApplyPositionDelta(
FSolverVec3(ConstraintData.CharacterInvM *
Delta));
292 BodyData.GroundBody.ApplyPositionDelta(
FSolverVec3(-ConstraintData.MassBiasT * ConstraintData.GroundInvM *
Delta));
293 BodyData.GroundBody.ApplyRotationDelta(
FSolverVec3(-ConstraintData.MassBiasT * ConstraintData.GroundInvI * ConstraintData.GroundOffset.Cross(
Delta)));
300 const FSolverReal MotionTargetAngularError = ConstraintData.MotionTargetAngularError + ConstraintData.VerticalAxis.Dot(BodyData.CharacterBody.DQ() - BodyData.GroundBody.DQ());
301 const FSolverReal NewAngularImpulse = ClampAbs(ImpulseData.AngularImpulse - ConstraintData.EffectiveInertiaT * MotionTargetAngularError, ConstraintData.AngularTwistImpulseLimit);
304 BodyData.CharacterBody.ApplyRotationDelta(
FSolverVec3(ConstraintData.CharacterInvI *
AngularDelta * ConstraintData.VerticalAxis));
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define FORCEINLINE_DEBUGGABLE
Definition CoreMiscDefines.h:74
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void Init()
Definition LockFreeList.h:4
UE_FORCEINLINE_HINT bool IsValid(const UObject *Test)
Definition Object.h:1875
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
Definition CharacterGroundConstraintSettings.h:32
Definition CharacterGroundConstraintSettings.h:9
Definition SolverBody.h:543
Definition SolverBody.h:99
FCharacterGroundConstraintSolver class.
Definition CharacterGroundConstraintSolver.h:20
void Reset()
Definition CharacterGroundConstraintSolver.cpp:83
FVec3 GetLinearImpulse(FReal Dt) const
Gets the solver linear displacement for this constraint and converts to an impulse in units of ML/T.
Definition CharacterGroundConstraintSolver.h:121
void ScatterOutput(const FReal Dt, FVec3 &OutSolverAppliedForce, FVec3 &OutSolverAppliedTorque)
Definition CharacterGroundConstraintSolver.cpp:286
void SetBodies(FSolverBody *CharacterSolverBody, FSolverBody *GroundSolverBody=nullptr)
Must call SetBodies and GatherInput before solve.
Definition CharacterGroundConstraintSolver.cpp:78
void GatherInput(FReal Dt, const FCharacterGroundConstraintSettings &Settings, const FCharacterGroundConstraintDynamicData &Data)
Definition CharacterGroundConstraintSolver.cpp:88
void SolvePosition()
Solve function performs one iteration of the solver.
Definition CharacterGroundConstraintSolver.h:177
FVec3 GetAngularImpulse(FReal Dt) const
Gets the solver angular displacement for this constraint and converts to an impulse in units of ML/T.
Definition CharacterGroundConstraintSolver.h:126
FORCEINLINE T SizeSquared() const
Definition Vector.h:1067
Definition SkeletalMeshComponent.h:307
FRealDouble FReal
Definition Real.h:22
TVec3< FSolverReal > FSolverVec3
Definition SolverBody.h:44
FRealSingle FSolverReal
Definition SolverBody.h:38
TVector< FReal, 3 > FVec3
Definition Core.h:17
Definition OverriddenPropertySet.cpp:45
Definition Constraint.h:688