UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CollectionTetrahedralBindingsFacade.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
5#include "Containers/Array.h"
8
10{
15 {
16 public:
18 {}
19
24
32
44 const int32 SurfaceIndex,
50 };
51
59 {
60 public:
61 // groups
62 static CHAOS_API const FName MeshBindingsGroupName;
63
64 //
65 // Attributes
66 //
67
68 static CHAOS_API const FName MeshIdAttributeName;
69
73 static CHAOS_API const FName WeightsAttributeName;
78
79 // Dependency
81
89
93 CHAOS_API void DefineSchema();
94
96 bool IsConst() const { return MeshIdAttribute.IsConst(); }
97
102 CHAOS_API bool IsValid() const;
103
108 static CHAOS_API FName GenerateMeshGroupName(const int32 TetMeshIdx, const FName& MeshId, const int32 LOD);
109
113 CHAOS_API int32 GetTetMeshIndex(const FName& MeshId, const int32 LOD) const;
114
118 CHAOS_API bool ContainsBindingsGroup(const int32 TetMeshIdx, const FName& MeshId, const int32 LOD) const;
119 CHAOS_API bool ContainsBindingsGroup(const FName& GroupName) const;
120
124 CHAOS_API void AddBindingsGroup(const int32 TetMeshIdx, const FName& MeshId, const int32 LOD);
125 CHAOS_API void AddBindingsGroup(const FName& GroupName);
126
131 CHAOS_API bool ReadBindingsGroup(const int32 TetMeshIdx, const FName& MeshId, const int32 LOD);
132 CHAOS_API bool ReadBindingsGroup(const FName& GroupName);
133
138 CHAOS_API void RemoveBindingsGroup(const int32 TetMeshIdx, const FName& MeshId, const int32 LOD);
139 CHAOS_API void RemoveBindingsGroup(const FName& GroupName);
140
154 {
156 for (int32 i = 0; i < ParentsIn.Num(); i++)
157 {
158 MaskTmp[i] = 1.0;
159 }
161 }
162
166 const TManagedArrayAccessor<FIntVector4>* GetParentsRO() const { return Parents.Get(); }
167 TManagedArrayAccessor<FIntVector4>* GetParents() { check(!IsConst()); return Parents.Get(); }
171 const TManagedArrayAccessor<FVector4f>* GetWeightsRO() const { return Weights.Get(); }
172 TManagedArrayAccessor<FVector4f>* GetWeights() { check(!IsConst()); return Weights.Get(); }
176 const TManagedArrayAccessor<FVector3f>* GetOffsetsRO() const { return Offsets.Get(); }
177 TManagedArrayAccessor<FVector3f>* GetOffsets() { check(!IsConst()); return Offsets.Get(); }
181 const TManagedArrayAccessor<float>* GetMaskRO() const { return Masks.Get(); }
182 TManagedArrayAccessor<float>* GetMask() { check(!IsConst()); return Masks.Get(); }
183
190 class Evaluator
191 {
192 public:
193 Evaluator(
195 const TManagedArrayAccessor<FVector4f>* Weights,
200 , ParentsArray(Parents)
201 , WeightsArray(Weights)
202 , OffsetsArray(Offsets)
204 {}
205
206 bool IsValid() const
207 {
208 return ParentsArray && WeightsArray && OffsetsArray &&
209 (ParentsArray->Get().Num()==WeightsArray->Get().Num() && ParentsArray->Get().Num()==OffsetsArray->Get().Num()) &&
210 (RestVerticesArray->IsValidIndex(MinIndex()) && RestVerticesArray->IsValidIndex(MaxIndex()));
211 }
212 int32 NumVertices() const { return ParentsArray->Num(); }
213 int32 MinIndex() const
214 {
216 {
217 for (const FIntVector4& Tet : ParentsArray->Get())
218 {
219 const int32 IndexEnd = Tet[3] == INDEX_NONE ? 3 : 4;
220 for (int32 LocalIdx = 0; LocalIdx < IndexEnd; ++LocalIdx)
221 {
222 MinIndexValue = FMath::Min(MinIndexValue, Tet[LocalIdx]);
223 }
224 }
225 }
226 return MinIndexValue;
227 }
228 int32 MinIndexPosition() const
229 {
232 for (int32 TetIdx = 0; TetIdx < ParentsArray->Get().Num(); ++TetIdx)
233 {
234 const FIntVector4& Tet = ParentsArray->Get()[TetIdx];
235 const int32 IndexEnd = Tet[3] == INDEX_NONE ? 3 : 4;
236 for (int32 LocalIdx = 0; LocalIdx < IndexEnd; ++LocalIdx)
237 {
239 {
240 MinIndexValue = FMath::Min(MinIndexValue, Tet[LocalIdx]);
242 }
243 }
244 }
245 return OutMinIndexPosition;
246 }
247 int32 MaxIndex() const
248 {
250 {
251 for (const FIntVector4& Tet : ParentsArray->Get())
252 {
253 const int32 IndexEnd = Tet[3] == INDEX_NONE ? 3 : 4;
254 for (int32 LocalIdx = 0; LocalIdx < IndexEnd; ++LocalIdx)
255 {
256 MaxIndexValue = FMath::Max(MaxIndexValue, Tet[LocalIdx]);
257 }
258 }
259 }
260 return MaxIndexValue;
261 }
263 {
264 return FleshDeformerImpl::GetEmbeddedPosition(Index, ParentsArray, WeightsArray, OffsetsArray, *RestVerticesArray, CurrVertices);
265 }
266
267 private:
268 mutable int32 MinIndexValue;
269 mutable int32 MaxIndexValue;
274 };
275
282 class MaskedEvaluator
283 {
284 public:
287 const TManagedArrayAccessor<FVector4f>* Weights,
288 const TManagedArrayAccessor<FVector3f>* Offsets,
289 const TManagedArrayAccessor<float>* Masks,
291 : UnmaskedEval(Parents, Weights, Offsets, RestVertices)
292 , ParentsArray(Parents)
293 , MasksArray(Masks)
294 {}
295
296 bool IsValid() const { return UnmaskedEval.IsValid() && (ParentsArray->Get().Num() == MasksArray->Get().Num()); }
297 int32 NumVertices() const { return UnmaskedEval.NumVertices(); }
298 int32 MinIndex() const { return UnmaskedEval.MinIndex(); }
299 int32 MaxIndex() const { return UnmaskedEval.MaxIndex(); }
301 {
302 const float Mask = MasksArray->Get()[Index];
303 if (Mask < 1.0e-6)
304 {
305 return RigPosition;
306 }
307 else if (Mask > 1.0 - 1.0e-6)
308 {
309 return UnmaskedEval.GetEmbeddedPosition(Index, CurrVertices);
310 }
311 else
312 {
313 FVector3f EmbeddedPos = UnmaskedEval.GetEmbeddedPosition(Index, CurrVertices);
314 return (1.0 - Mask) * RigPosition + Mask * EmbeddedPos;
315 }
316 }
317 private:
318 Evaluator UnmaskedEval;
321 };
322
327 {
328 return TUniquePtr<Evaluator>(new Evaluator(Parents.Get(), Weights.Get(), Offsets.Get(), RestVertices));
329 }
330
336 { return TUniquePtr<MaskedEvaluator>(new MaskedEvaluator(Parents.Get(), Weights.Get(), Offsets.Get(), Masks.Get(), RestVertices)); }
337
338 private:
339 TManagedArrayAccessor<FString> MeshIdAttribute;
340
345 };
346
347}
#define check(expr)
Definition AssertionMacros.h:314
@ 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
@ Num
Definition MetalRHIPrivate.h:234
uint32 Offset
Definition VulkanMemory.cpp:4033
Definition Matrix.h:21
Definition Vector.h:41
Definition NameTypes.h:617
Definition Array.h:670
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
Definition ManagedArray.h:1099
Definition UniquePtr.h:107
Definition CollectionBoundsFacade.cpp:13
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
U16 Index
Definition radfft.cpp:71
Definition ManagedArrayCollection.h:56
Definition ManagedArrayAccessor.h:20
const TManagedArray< T > & Get() const
Definition ManagedArrayAccessor.h:101
Definition NumericLimits.h:41