UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PBDJointConstraintTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5
6#include "Chaos/Core.h"
7#include "Chaos/Transform.h"
8#include "Chaos/Vector.h"
9
10namespace Chaos
11{
12 class FPBDJointConstraints;
13
14 class FPBDJointConstraintHandle;
15
17
19
21
23 {
24 Free,
25 Limited,
26 Locked,
27 };
28
30 {
32 Force,
33 };
34
36 {
37 Free,
38 Shrink,
39 Grow,
40 };
41
42
46 // @todo(ccaulfield): rename EJointAngularConstraintType
48 {
49 Twist,
50 Swing2,
51 Swing1,
52 };
53
59
61 {
63 static inline const FVec3 TwistAxis() { return FVec3(1, 0, 0); }
64
66 static inline const FVec3 Swing1Axis() { return FVec3(0, 0, 1); }
67
69 static inline const FVec3 Swing2Axis() { return FVec3(0, 1, 0); }
70
72 static inline const FVec3 Axis(const EJointAngularConstraintIndex ConstraintIndex)
73 {
74 switch (ConstraintIndex)
75 {
77 return TwistAxis();
79 return Swing1Axis();
81 return Swing2Axis();
82 }
83 }
84
85 static inline const FVec3 SwingAxis(const EJointAngularConstraintIndex ConstraintIndex)
86 {
87 return (ConstraintIndex == EJointAngularConstraintIndex::Swing1) ? Swing1Axis() : Swing2Axis();
88 }
89
90 static inline const FVec3 OtherSwingAxis(const EJointAngularConstraintIndex ConstraintIndex)
91 {
92 return (ConstraintIndex == EJointAngularConstraintIndex::Swing1) ? Swing2Axis() : Swing1Axis();
93 }
94
96 static inline const int32 AxisIndex(const EJointAngularConstraintIndex ConstraintIndex)
97 {
98 if (ConstraintIndex == EJointAngularConstraintIndex::Twist)
99 {
100 return 0; // X
101 }
102 else if (ConstraintIndex == EJointAngularConstraintIndex::Swing1)
103 {
104 return 2; // Z
105 }
106 else
107 {
108 return 1; // Y
109 }
110 }
111 };
112
114 {
115 public:
117
118 // Ensure that settings are consistent and within valid ranges. Should be called
119 // whenever settings change.
120 CHAOS_API void Sanitize();
121
123 {
124 return !FMemory::Memcmp(this, &Other, sizeof(*this));
125 }
126
127 // The offsets of the joint frames from the bodies. The ordering is [child, parent]
129
131 // The amount of linear projection, between 0 and 1. Only used if bProjectionEnabled is set too.
133 // The amount of angular projection, between 0 and 1. Only used if bProjectionEnabled is set too.
138 // This inverse scales the parent mass (and inertia) during the solve. By setting this to
139 // zero, the constraint will treat the parent body as infinitely massive, and thus the
140 // constraint will only operate on the child body.
142
144 bool bProjectionEnabled; // @chaos(todo): remove - implied by Linear/AngularProjection and teleport settings
145 bool bShockPropagationEnabled; // @chaos(todo): remove - implied by ShockPropagation
147
148 // If enabled, then a linear solver will be used. However, note that the immediate solver
149 // doesn't support mixing both linear and non-linear constraints, so in that case you should
150 // make all constraints be either linear or non-linear.
152
155
156 // Order is twist, swing1, swing2
158 // The values here are in radians
160
172
176
180
189
192
203
212
214
215 void* UserData;
216 };
217
219 {
220 public:
222
224
226
227 // Tolerances
231
232 // Stability control
235
236 // Solver Stiffness (increases over iterations)
241
242 // Whether to use the linear or non-linear joint solver
243 UE_DEPRECATED(5.5, "No longer used, see per-constraint flag in FPBDJointSettings::bUseLinearSolver")
245
246 // Whether use vectorization in single precision, only available on the linear solver
248
249 // Whether the joints need to be sorted (only required for RBAN - the world solver uses the constraint graph for ordering)
251
252 // Whether to solve rotation then position limits (true), or vice versa
253 // Solving position last leads to less separation at the joints when limits are being forced
255
256 // Whether joints are position-based or velocity-based in the solver
258
259 // @todo(chaos): remove these TEMP overrides for testing
279 };
280
281}
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition PBDJointConstraints.h:28
Definition PBDJointConstraintTypes.h:114
bool bAngularSwingVelocityDriveEnabled
Definition PBDJointConstraintTypes.h:198
FVec3 LinearDriveMaxForce
Definition PBDJointConstraintTypes.h:188
FReal ShockPropagation
Definition PBDJointConstraintTypes.h:135
bool bAngularSwingPositionDriveEnabled
Definition PBDJointConstraintTypes.h:197
FVec3 AngularDriveDamping
Definition PBDJointConstraintTypes.h:201
FReal LinearBreakForce
Definition PBDJointConstraintTypes.h:204
FReal TeleportDistance
Definition PBDJointConstraintTypes.h:136
EJointForceMode LinearDriveForceMode
Definition PBDJointConstraintTypes.h:185
FReal AngularPlasticityLimit
Definition PBDJointConstraintTypes.h:211
bool bAngularSLerpPositionDriveEnabled
Definition PBDJointConstraintTypes.h:193
void * UserData
Definition PBDJointConstraintTypes.h:215
FReal ContactTransferScale
Definition PBDJointConstraintTypes.h:213
FVec3 AngularLimits
Definition PBDJointConstraintTypes.h:159
FVec3 AngularDriveStiffness
Definition PBDJointConstraintTypes.h:200
FTransformPair ConnectorTransforms
Definition PBDJointConstraintTypes.h:128
FReal AngularViolationCallbackThreshold
Definition PBDJointConstraintTypes.h:210
FReal TwistContactDistance
Definition PBDJointConstraintTypes.h:178
FReal LinearContactDistance
Definition PBDJointConstraintTypes.h:177
bool bAngularSLerpVelocityDriveEnabled
Definition PBDJointConstraintTypes.h:194
FReal SwingRestitution
Definition PBDJointConstraintTypes.h:175
FReal SoftTwistStiffness
Definition PBDJointConstraintTypes.h:168
FReal Stiffness
Definition PBDJointConstraintTypes.h:130
FReal TwistRestitution
Definition PBDJointConstraintTypes.h:174
bool bSoftLinearLimitsEnabled
Definition PBDJointConstraintTypes.h:161
bool bAngularTwistVelocityDriveEnabled
Definition PBDJointConstraintTypes.h:196
TVector< bool, 3 > bLinearPositionDriveEnabled
Definition PBDJointConstraintTypes.h:183
EPlasticityType LinearPlasticityType
Definition PBDJointConstraintTypes.h:207
FVec3 LinearDrivePositionTarget
Definition PBDJointConstraintTypes.h:181
FReal AngularProjection
Definition PBDJointConstraintTypes.h:134
bool bAngularTwistPositionDriveEnabled
Definition PBDJointConstraintTypes.h:195
FReal LinearRestitution
Definition PBDJointConstraintTypes.h:173
FReal SoftTwistDamping
Definition PBDJointConstraintTypes.h:169
EJointForceMode AngularDriveForceMode
Definition PBDJointConstraintTypes.h:199
FVec3 LinearDriveVelocityTarget
Definition PBDJointConstraintTypes.h:182
FReal LinearPlasticityInitialDistanceSquared
Definition PBDJointConstraintTypes.h:208
bool bCollisionEnabled
Definition PBDJointConstraintTypes.h:143
TVector< EJointMotionType, 3 > AngularMotionTypes
Definition PBDJointConstraintTypes.h:157
FReal LinearPlasticityLimit
Definition PBDJointConstraintTypes.h:206
bool bUseLinearSolver
Definition PBDJointConstraintTypes.h:151
bool bMassConditioningEnabled
Definition PBDJointConstraintTypes.h:146
FVec3 LinearDriveStiffness
Definition PBDJointConstraintTypes.h:186
CHAOS_API FPBDJointSettings()
Definition PBDJointConstraints.cpp:338
bool bProjectionEnabled
Definition PBDJointConstraintTypes.h:144
FReal LinearProjection
Definition PBDJointConstraintTypes.h:132
bool operator==(const FPBDJointSettings &Other) const
Definition PBDJointConstraintTypes.h:122
FReal SoftLinearDamping
Definition PBDJointConstraintTypes.h:167
FReal AngularBreakTorque
Definition PBDJointConstraintTypes.h:209
FReal ParentInvMassScale
Definition PBDJointConstraintTypes.h:141
FVec3 AngularDriveMaxTorque
Definition PBDJointConstraintTypes.h:202
TVector< bool, 3 > bLinearVelocityDriveEnabled
Definition PBDJointConstraintTypes.h:184
bool bSoftSwingLimitsEnabled
Definition PBDJointConstraintTypes.h:163
FReal LinearViolationCallbackThreshold
Definition PBDJointConstraintTypes.h:205
bool bSoftTwistLimitsEnabled
Definition PBDJointConstraintTypes.h:162
FReal LinearLimit
Definition PBDJointConstraintTypes.h:154
CHAOS_API void Sanitize()
Definition PBDJointConstraints.cpp:406
FReal TeleportAngle
Definition PBDJointConstraintTypes.h:137
EJointForceMode AngularSoftForceMode
Definition PBDJointConstraintTypes.h:165
FReal SoftSwingDamping
Definition PBDJointConstraintTypes.h:171
FRotation3 AngularDrivePositionTarget
Definition PBDJointConstraintTypes.h:190
FReal SoftLinearStiffness
Definition PBDJointConstraintTypes.h:166
TVector< EJointMotionType, 3 > LinearMotionTypes
Definition PBDJointConstraintTypes.h:153
bool bShockPropagationEnabled
Definition PBDJointConstraintTypes.h:145
EJointForceMode LinearSoftForceMode
Definition PBDJointConstraintTypes.h:164
FVec3 LinearDriveDamping
Definition PBDJointConstraintTypes.h:187
FReal SoftSwingStiffness
Definition PBDJointConstraintTypes.h:170
FVec3 AngularDriveVelocityTarget
Definition PBDJointConstraintTypes.h:191
FReal SwingContactDistance
Definition PBDJointConstraintTypes.h:179
Definition PBDJointConstraintTypes.h:219
bool bUseLinearSolver
Definition PBDJointConstraintTypes.h:244
FReal SoftLinearDampingOverride
Definition PBDJointConstraintTypes.h:274
bool bEnableDrives
Definition PBDJointConstraintTypes.h:262
FReal SoftTwistStiffnessOverride
Definition PBDJointConstraintTypes.h:275
FReal AngularDriveDampingOverride
Definition PBDJointConstraintTypes.h:272
FReal LinearDriveDampingOverride
Definition PBDJointConstraintTypes.h:270
CHAOS_API FPBDJointSolverSettings()
Definition PBDJointConstraints.cpp:510
FReal SoftLinearStiffnessOverride
Definition PBDJointConstraintTypes.h:273
FReal TwistStiffnessOverride
Definition PBDJointConstraintTypes.h:264
CHAOS_API FPBDJointSolverSettings & operator=(const FPBDJointSolverSettings &Other)
FReal LinearStiffnessOverride
Definition PBDJointConstraintTypes.h:263
FReal LinearDriveStiffnessOverride
Definition PBDJointConstraintTypes.h:269
FReal SoftTwistDampingOverride
Definition PBDJointConstraintTypes.h:276
FReal SoftSwingStiffnessOverride
Definition PBDJointConstraintTypes.h:277
int32 NumShockPropagationIterations
Definition PBDJointConstraintTypes.h:240
FReal MinSolverStiffness
Definition PBDJointConstraintTypes.h:237
FReal SoftSwingDampingOverride
Definition PBDJointConstraintTypes.h:278
FReal SwingTwistAngleTolerance
Definition PBDJointConstraintTypes.h:228
FReal SwingStiffnessOverride
Definition PBDJointConstraintTypes.h:265
bool bEnableSwingLimits
Definition PBDJointConstraintTypes.h:261
bool bEnableTwistLimits
Definition PBDJointConstraintTypes.h:260
FReal PositionTolerance
Definition PBDJointConstraintTypes.h:229
CHAOS_API FPBDJointSolverSettings(const FPBDJointSolverSettings &InSettings)
FReal AngularDriveStiffnessOverride
Definition PBDJointConstraintTypes.h:271
FReal ShockPropagationOverride
Definition PBDJointConstraintTypes.h:268
bool bSolvePositionLast
Definition PBDJointConstraintTypes.h:254
bool bUseSimd
Definition PBDJointConstraintTypes.h:247
FReal MaxInertiaRatio
Definition PBDJointConstraintTypes.h:234
FReal MaxSolverStiffness
Definition PBDJointConstraintTypes.h:238
FReal AngularProjectionOverride
Definition PBDJointConstraintTypes.h:267
FReal LinearProjectionOverride
Definition PBDJointConstraintTypes.h:266
FReal MinParentMassRatio
Definition PBDJointConstraintTypes.h:233
bool bUsePositionBasedDrives
Definition PBDJointConstraintTypes.h:257
bool bSortEnabled
Definition PBDJointConstraintTypes.h:250
FReal AngleTolerance
Definition PBDJointConstraintTypes.h:230
int32 NumIterationsAtMaxSolverStiffness
Definition PBDJointConstraintTypes.h:239
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SkeletalMeshComponent.h:307
EPlasticityType
Definition PBDJointConstraintTypes.h:36
EJointCylindricalPositionConstraintType
Definition PBDJointConstraintTypes.h:55
FRealDouble FReal
Definition Real.h:22
EJointForceMode
Definition PBDJointConstraintTypes.h:30
EJointAngularConstraintIndex
Definition PBDJointConstraintTypes.h:48
TVector< FReal, 3 > FVec3
Definition Core.h:17
EJointMotionType
Definition PBDJointConstraintTypes.h:23
Definition PBDJointConstraintTypes.h:61
static const FVec3 OtherSwingAxis(const EJointAngularConstraintIndex ConstraintIndex)
Definition PBDJointConstraintTypes.h:90
static const FVec3 Swing1Axis()
Definition PBDJointConstraintTypes.h:66
static const FVec3 Swing2Axis()
Definition PBDJointConstraintTypes.h:69
static const FVec3 Axis(const EJointAngularConstraintIndex ConstraintIndex)
Definition PBDJointConstraintTypes.h:72
static const int32 AxisIndex(const EJointAngularConstraintIndex ConstraintIndex)
Definition PBDJointConstraintTypes.h:96
static const FVec3 TwistAxis()
Definition PBDJointConstraintTypes.h:63
static const FVec3 SwingAxis(const EJointAngularConstraintIndex ConstraintIndex)
Definition PBDJointConstraintTypes.h:85
static UE_FORCEINLINE_HINT int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
Definition UnrealMemory.h:114