UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChaosDeformableSolverProxy.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4#include "CoreMinimal.h"
8#include "Chaos/Range.h"
9#include "ChaosDeformableSolverProxy.generated.h"
10
14UENUM()
16{
17 World UMETA(DisplayName = "World"),
18 ComponentXf UMETA(DisplayName = "Component"), // Component fails on Mac
19 Bone UMETA(DisplayName = "Bone"),
20};
21
22namespace Chaos::Softs
23{
25 const UObject* Owner = nullptr;
26 FName TypeName = FName("");
27
28 public:
29 typedef const UObject* FKey;
30
32 : Owner(InOwner)
33 , TypeName(InTypeName)
34 {}
35 virtual ~FThreadingProxy() {}
36
37 FName BaseTypeName() const { return TypeName; }
38
39 template<class T>
40 T* As() { return T::TypeName().IsEqual(BaseTypeName()) ? (T*)this : nullptr; }
41
42 template<class T>
43 T* As() const { return T::TypeName().IsEqual(BaseTypeName()) ? (T*)this : nullptr; }
44
45 const UObject* GetOwner() const { return Owner; }
46
47
48 class FBuffer
49 {
50 const UObject* Owner = nullptr;
51 FName TypeName = FName("");
52
53 public:
55 : Owner(Ref.GetOwner())
56 , TypeName(Ref.BaseTypeName()) {}
57
59 : Owner(InOwner)
60 , TypeName(InTypeName) {}
61 virtual ~FBuffer() {}
62
63 FName BaseTypeName() const { return TypeName; }
64
65 template<class T>
66 T* As() { return T::Source::TypeName().IsEqual(BaseTypeName()) ? (T*)this : nullptr; }
67
68 template<class T>
69 T* As() const { return T::Source::TypeName().IsEqual(BaseTypeName()) ? (T*)this : nullptr; }
70 };
71 };
72
74 {
75 typedef FThreadingProxy Super;
76
77 // Component transform
78 FTransform WorldToComponentXf = FTransform::Identity; // component xf
79 FTransform ComponentToWorldXf = FTransform::Identity; // inv component xf
80
81 // Bone transform
82 FTransform ComponentToBoneXf = FTransform::Identity; // bone xf
83 FTransform BoneToComponentXf = FTransform::Identity; // inv bone xf
84 FTransform PrevComponentToBoneXf = FTransform::Identity; // bone xf
85 FTransform PrevBoneToComponentXf = FTransform::Identity; // inv bone xf
86
89 Chaos::FRange SolverParticleRange = Chaos::FRange(0, 0);
90 ChaosDeformableSimSpace SimSpace = ChaosDeformableSimSpace::World;
91 bool bIsCached = false;
92
93 public:
94
97 const FTransform& InWorldToComponentXf, // ComponentXf
103 , WorldToComponentXf(InWorldToComponentXf)
104 , ComponentToBoneXf(InComponentToBoneXf)
105 , Rest(InRest)
107 , SimSpace(InSimSpace)
108 {
109 ComponentToWorldXf = FTransform(WorldToComponentXf.ToMatrixWithScale().Inverse());
110 if (SimSpace == ChaosDeformableSimSpace::Bone)
111 {
112 BoneToComponentXf = FTransform(ComponentToBoneXf.ToMatrixWithScale().Inverse());
113 }
114 }
116
117 static FName TypeName() { return FName("Flesh"); }
118
119 bool CanSimulate() const
120 {
121 return Rest->NumElements(FGeometryCollection::VerticesGroup) > 0;
122 }
123
124 bool IsBoneSpace() const
125 {
126 return SimSpace == ChaosDeformableSimSpace::Bone;
127 }
128
129 void SetIsCached(bool bInIsCached) { bIsCached = bInIsCached; }
130 bool GetIsCached() const { return bIsCached; }
131
134 {
135 WorldToComponentXf = InWorldToComponentXf;
136 ComponentToWorldXf = FTransform(WorldToComponentXf.ToMatrixWithScale().Inverse());
137 if (SimSpace == ChaosDeformableSimSpace::Bone)
138 {
139 PrevComponentToBoneXf = ComponentToBoneXf;
140 PrevBoneToComponentXf = BoneToComponentXf;
141
142 ComponentToBoneXf = InComponentToBoneXf;
143 BoneToComponentXf = FTransform(ComponentToBoneXf.ToMatrixWithScale().Inverse());
144 }
145 }
146
150 {
151 switch (SimSpace)
152 {
153 case ChaosDeformableSimSpace::World:
154 // Initial points are in component space, so apply the component xf.
155 return WorldToComponentXf;
156 case ChaosDeformableSimSpace::ComponentXf:
157 // We're already in the right space.
159 case ChaosDeformableSimSpace::Bone:
160 // Points have ComponentToBoneXf baked in, so we invert it out to get
161 // points in bone space.
162 return BoneToComponentXf;
163 default:
165 }
166 }
167
169 {
170 switch (SimSpace)
171 {
172 case ChaosDeformableSimSpace::World:
173 return WorldToComponentXf;
174 case ChaosDeformableSimSpace::ComponentXf:
176 case ChaosDeformableSimSpace::Bone:
177 return BoneToComponentXf;
178 default:
180 }
181 }
182
184 {
185 switch (SimSpace)
186 {
187 case ChaosDeformableSimSpace::World:
188 return WorldToComponentXf;
189 case ChaosDeformableSimSpace::ComponentXf:
191 case ChaosDeformableSimSpace::Bone:
192 return PrevBoneToComponentXf;
193 default:
195 }
196 }
197
199 {
200 switch (SimSpace)
201 {
202 case ChaosDeformableSimSpace::World:
203 return Dir;
204 case ChaosDeformableSimSpace::ComponentXf:
205 {
207 ComponentToWorldXf.TransformVectorNoScale(FVector(Dir[0], Dir[1], Dir[2])));
208 }
209 case ChaosDeformableSimSpace::Bone:
210 {
211 FVector Tmp = ComponentToWorldXf.TransformVectorNoScale(FVector(Dir[0], Dir[1], Dir[2]));
213 }
214 default:
215 return Dir;
216 }
217 }
218
222 {
223 switch (SimSpace)
224 {
225 case ChaosDeformableSimSpace::World:
226 return ComponentToWorldXf;
227 case ChaosDeformableSimSpace::ComponentXf:
229 case ChaosDeformableSimSpace::Bone:
230 return ComponentToBoneXf;
231 default:
233 }
234 }
235
237 {
238 SolverParticleRange = Chaos::FRange(InStart, InRange);
239 }
240
242 {
243 return SolverParticleRange;
244 }
245
248 const FManagedArrayCollection& GetRestCollection() const { return *Rest; }
249
251 {
253
254 public:
256
283
312
345
347
349
352
364 };
365
367 {
369
370 public:
373 : Super(Ref)
374 {
375 // Ref.Dynamic will have updated solver data
377 Dynamic.CopyMatchingAttributesFrom(Ref.GetDynamicCollection());
378 }
380
382 };
383
401 };
402}// namespace Chaos::Softs
ChaosDeformableSimSpace
Definition ChaosDeformableSolverProxy.h:16
@ UMETA
Definition ChaosDeformableSolverProxy.h:17
@ INDEX_NONE
Definition CoreMiscDefines.h:150
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
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TTransform< double > FTransform
Definition MathFwd.h:53
#define UENUM(...)
Definition ObjectMacros.h:749
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition ChaosDeformableSolverProxy.h:251
const FManagedArrayCollection SimulationCollection
Definition ChaosDeformableSolverProxy.h:348
float InflationMultiplier
Definition ChaosDeformableSolverProxy.h:360
float IncompressibilityMultiplier
Definition ChaosDeformableSolverProxy.h:359
TArray< FTransform > Transforms
Definition ChaosDeformableSolverProxy.h:353
float DampingMultiplier
Definition ChaosDeformableSolverProxy.h:357
float StiffnessMultiplier
Definition ChaosDeformableSolverProxy.h:356
virtual ~FFleshInputBuffer()
Definition ChaosDeformableSolverProxy.h:346
float MassMultiplier
Definition ChaosDeformableSolverProxy.h:358
TArray< float > MuscleActivation
Definition ChaosDeformableSolverProxy.h:363
TArray< FTransform > RestTransforms
Definition ChaosDeformableSolverProxy.h:354
bool bEnableGravity
Definition ChaosDeformableSolverProxy.h:355
TArray< int32 > MuscleIndices
Definition ChaosDeformableSolverProxy.h:362
FTransform ComponentToBoneXf
Definition ChaosDeformableSolverProxy.h:351
FFleshInputBuffer(const FManagedArrayCollection &&InSimulationCollection, const FTransform &InWorldToComponentXf, const FTransform &InComponentToBoneXf, const int32 InSimSpaceBoneIndex, const TArray< FTransform > &&InTransforms, const TArray< FTransform > &&InRestTransforms, const bool InbEnableGravity, const float InStiffnessMultiplier, const float InDampingMultiplier, const float InMassMultiplier, const float InInCompressibilityMultiplier, const float InInflationMultiplier, const TArray< int32 > &&InMuscleIndices, const TArray< float > &&InMuscleActivation, const UObject *InOwner=nullptr)
Definition ChaosDeformableSolverProxy.h:313
int32 SimSpaceBoneIndex
Definition ChaosDeformableSolverProxy.h:361
FFleshInputBuffer(const FManagedArrayCollection &&InSimulationCollection, const FTransform &InWorldToComponentXf, const FTransform &InComponentToBoneXf, const int32 InSimSpaceBoneIndex, const bool InbEnableGravity, const float InStiffnessMultiplier, const float InDampingMultiplier, const float InMassMultiplier, const float InInCompressibilityMultiplier, const float InInflationMultiplier, const UObject *InOwner=nullptr)
Definition ChaosDeformableSolverProxy.h:257
FFleshThreadingProxy Source
Definition ChaosDeformableSolverProxy.h:255
FTransform WorldToComponentXf
Definition ChaosDeformableSolverProxy.h:350
FFleshInputBuffer(const FManagedArrayCollection &&InSimulationCollection, const FTransform &InWorldToComponentXf, const FTransform &InComponentToBoneXf, const int32 InSimSpaceBoneIndex, const TArray< FTransform > &&InTransforms, const TArray< FTransform > &&InRestTransforms, const bool InbEnableGravity, const float InStiffnessMultiplier, const float InDampingMultiplier, const float InMassMultiplier, const float InInCompressibilityMultiplier, const float InInflationMultiplier, const UObject *InOwner=nullptr)
Definition ChaosDeformableSolverProxy.h:284
Definition ChaosDeformableSolverProxy.h:367
FManagedArrayCollection Dynamic
Definition ChaosDeformableSolverProxy.h:381
virtual ~FFleshOutputBuffer()
Definition ChaosDeformableSolverProxy.h:379
FFleshThreadingProxy Source
Definition ChaosDeformableSolverProxy.h:371
FFleshOutputBuffer(const Source &Ref)
Definition ChaosDeformableSolverProxy.h:372
Definition ChaosDeformableSolverProxy.h:385
FManagedArrayCollection Dynamic
Definition ChaosDeformableSolverProxy.h:399
virtual ~FFleshRestartBuffer()
Definition ChaosDeformableSolverProxy.h:397
FFleshThreadingProxy Source
Definition ChaosDeformableSolverProxy.h:389
FFleshRestartBuffer(const FManagedArrayCollection &InDynamicCollection, const UObject *InOwner=nullptr)
Definition ChaosDeformableSolverProxy.h:390
Definition ChaosDeformableSolverProxy.h:74
FManagedArrayCollection & GetDynamicCollection()
Definition ChaosDeformableSolverProxy.h:246
const FTransform & GetCurrentPointsTransform() const
Definition ChaosDeformableSolverProxy.h:168
FFleshThreadingProxy(UObject *InOwner, const FTransform &InWorldToComponentXf, const FTransform &InComponentToBoneXf, const ChaosDeformableSimSpace InSimSpace, TSharedRef< const FManagedArrayCollection > InRest, const FManagedArrayCollection &InDynamic)
Definition ChaosDeformableSolverProxy.h:95
bool IsBoneSpace() const
Definition ChaosDeformableSolverProxy.h:124
const FTransform & GetInitialPointsTransform() const
Definition ChaosDeformableSolverProxy.h:149
const Chaos::FRange & GetSolverParticleRange() const
Definition ChaosDeformableSolverProxy.h:241
void SetIsCached(bool bInIsCached)
Definition ChaosDeformableSolverProxy.h:129
const FManagedArrayCollection & GetRestCollection() const
Definition ChaosDeformableSolverProxy.h:248
void SetSolverParticleRange(int32 InStart, int32 InRange)
Definition ChaosDeformableSolverProxy.h:236
Chaos::TVector< Chaos::FRealSingle, 3 > RotateWorldSpaceVector(const Chaos::TVector< Chaos::FRealSingle, 3 > &Dir) const
Definition ChaosDeformableSolverProxy.h:198
FTransform GetFinalTransform() const
Definition ChaosDeformableSolverProxy.h:221
bool GetIsCached() const
Definition ChaosDeformableSolverProxy.h:130
bool CanSimulate() const
Definition ChaosDeformableSolverProxy.h:119
static FName TypeName()
Definition ChaosDeformableSolverProxy.h:117
void UpdateSimSpace(const FTransform &InWorldToComponentXf, const FTransform &InComponentToBoneXf)
Update the component and bone transforms with current data from the scene.
Definition ChaosDeformableSolverProxy.h:133
const FManagedArrayCollection & GetDynamicCollection() const
Definition ChaosDeformableSolverProxy.h:247
virtual ~FFleshThreadingProxy()
Definition ChaosDeformableSolverProxy.h:115
const FTransform & GetPreviousPointsTransform() const
Definition ChaosDeformableSolverProxy.h:183
Definition ChaosDeformableSolverProxy.h:49
FName BaseTypeName() const
Definition ChaosDeformableSolverProxy.h:63
T * As() const
Definition ChaosDeformableSolverProxy.h:69
T * As()
Definition ChaosDeformableSolverProxy.h:66
FBuffer(const UObject *InOwner, FName InTypeName)
Definition ChaosDeformableSolverProxy.h:58
virtual ~FBuffer()
Definition ChaosDeformableSolverProxy.h:61
FBuffer(const FThreadingProxy &Ref)
Definition ChaosDeformableSolverProxy.h:54
Definition ChaosDeformableSolverProxy.h:24
const UObject * GetOwner() const
Definition ChaosDeformableSolverProxy.h:45
FName BaseTypeName() const
Definition ChaosDeformableSolverProxy.h:37
T * As()
Definition ChaosDeformableSolverProxy.h:40
virtual ~FThreadingProxy()
Definition ChaosDeformableSolverProxy.h:35
T * As() const
Definition ChaosDeformableSolverProxy.h:43
const UObject * FKey
Definition ChaosDeformableSolverProxy.h:29
FThreadingProxy(const UObject *InOwner=nullptr, FName InTypeName=FName(""))
Definition ChaosDeformableSolverProxy.h:31
Definition Vector.h:41
static CHAOS_API const FName VerticesGroup
Definition GeometryCollection.h:99
Definition NameTypes.h:617
Definition Array.h:670
Definition SharedPointer.h:153
Definition Object.h:95
Definition CollectionEmbeddedSpringConstraintFacade.cpp:6
@ Dynamic
Definition SpatialAccelerationCollection.h:22
Definition Range.h:9
Definition ManagedArrayCollection.h:56
CHAOS_API void CopyMatchingAttributesFrom(const FManagedArrayCollection &InCollection, const TMap< FName, TSet< FName > > *SkipList=nullptr)
Definition ManagedArrayCollection.cpp:585
TManagedArray< T > & AddAttribute(FName Name, FName Group, FConstructionParameters Parameters=FConstructionParameters())
Definition ManagedArrayCollection.h:139
TMatrix< T > Inverse() const
Definition Matrix.inl:384
static CORE_API const TTransform< double > Identity
Definition TransformNonVectorized.h:58
TMatrix< T > ToMatrixWithScale() const
Definition TransformNonVectorized.h:241
TVector< T > TransformVectorNoScale(const TVector< T > &V) const
Definition TransformNonVectorized.h:1447