UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChaosVDDataWrapperUtils.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Chaos/AABBTree.h"
12
14
15namespace Chaos
16{
17class FJointConstraint;
18class FSolverSerializer;
19}
20
24
25namespace Chaos
26{
27 class FCharacterGroundConstraintHandle;
28 class FPBDJointConstraintHandle;
29
30 namespace VisualDebugger
31 {
32 class FChaosVDSerializableNameTable;
33 }
34
35 class FParticlePairMidPhase;
36 class FPBDCollisionConstraint;
38}
39
40class FChaosVisualDebuggerTrace;
45
47{
48 template<typename InType,typename OutType, int32 Size, typename TransformT>
49 void TransformStaticArray(const InType (&In)[Size], OutType (&Out)[Size], TransformT Trans)
50 {
51 for (int32 Index = 0; Index < Size; Index++)
52 {
53 Out[Index] = Invoke(Trans, In[Index]);
54 }
55 }
56
57 template<typename InType,typename OutType, int32 Size>
58 void CopyStaticArray(const InType (&In)[Size], OutType (&Out)[Size])
59 {
60 FMemory::Memcpy(Out, In, Size * sizeof(InType));
61 }
62
67}
68
77{
78private:
79
81 static void CopyManifoldPointsToDataWrapper(const Chaos::FManifoldPoint& InCopyFrom, FChaosVDManifoldPoint& OutCopyTo);
82
84 static void CopyManifoldPointResultsToDataWrapper(const Chaos::FManifoldPointResult& InCopyFrom, FChaosVDManifoldPoint& OutCopyTo);
85
87 static void CopyCollisionMaterialToDataWrapper(const Chaos::FPBDCollisionConstraintMaterial& InCopyFrom, FChaosVDCollisionMaterial& OutCopyTo);
88public:
92
93private:
95 static FChaosVDConstraint BuildConstraintDataWrapperFromConstraint(const Chaos::FPBDCollisionConstraint& InConstraint);
96
98 static FChaosVDParticlePairMidPhase BuildMidPhaseDataWrapperFromMidPhase(const Chaos::FParticlePairMidPhase& InMidPhase);
99 static void CopyJointConstraintSettingsToWrapper(const Chaos::FPBDJointSettings& InSettings, FChaosVDJointSettingsDataWrapper& InOutWrappedJointSettingsData);
100
101public:
105
108
111private:
112
114
116 static FVector ConvertToFVector(const Chaos::FVec3f& VectorRef) { return FVector(VectorRef); }
117
118 static void CopyShapeDataToWrapper(const Chaos::FShapeInstancePtr& ShapeDataPtr, FChaosVDShapeCollisionData& OutCopyTo);
119
120 template<typename LeafType>
122
124 static FBox ConvertToFBox(const Chaos::TAABB<Chaos::FReal, 3>& Bounds)
125 {
126 FBox ConvertedBox(Bounds.Min(), Bounds.Max());
127 return ConvertedBox;
128 }
129
131
134
135 friend FChaosVisualDebuggerTrace;
136};
137
138template<typename LeafType>
139void FChaosVDDataWrapperUtils::BuildDataWrapperFromAABBStructure(const Chaos::TAABBTree<Chaos::FAccelerationStructureHandle, LeafType>& AABBTree, FChaosVDAABBTreeDataWrapper& OutAABBTreeWrapper)
140{
141 using namespace Chaos;
142
143 OutAABBTreeWrapper.MaxTreeDepth = AABBTree.MaxTreeDepth;
144 OutAABBTreeWrapper.MaxChildrenInLeaf = AABBTree.MaxTreeDepth;
145 OutAABBTreeWrapper.MaxPayloadBounds = AABBTree.MaxPayloadBounds;
146 OutAABBTreeWrapper.RootNodeIndex = AABBTree.RootNode;
147 OutAABBTreeWrapper.bDynamicTree = AABBTree.bDynamicTree;
148
149 const int32 NodesToCopyNum = AABBTree.Nodes.Num();
150 OutAABBTreeWrapper.Nodes.Reserve(NodesToCopyNum);
152
153 OutAABBTreeWrapper.Type = static_cast<EChaosVDAccelerationStructureType>(AABBTree.StaticType);
154
156 {
158 CVDNode.bLeaf = Node.bLeaf;
159 CVDNode.bDirtyNode = Node.bDirtyNode;
160
161 VisualDebugger::Utils::TransformStaticArray(Node.ChildrenBounds, CVDNode.ChildrenBounds, &FChaosVDDataWrapperUtils::ConvertToFBox);
162 VisualDebugger::Utils::CopyStaticArray(Node.ChildrenNodes, CVDNode.ChildrenNodes);
163
164 CVDNode.ParentNode = Node.ParentNode;
165 CVDNode.MarkAsValid();
166
167 OutAABBTreeWrapper.Nodes.Emplace(CVDNode);
168 }
169
170 AddTreeLeaves(MakeArrayView(AABBTree.Leaves.GetData(), AABBTree.Leaves.Num()), OutAABBTreeWrapper);
171
172 OutAABBTreeWrapper.MarkAsValid();
173}
constexpr auto MakeArrayView(OtherRangeType &&Other)
Definition ArrayView.h:873
EChaosVDAccelerationStructureType
Definition ChaosVDAccelerationStructureDataWrappers.h:21
#define UE_INTERNAL
Definition CoreMiscDefines.h:345
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define FVector
Definition IOSSystemIncludes.h:8
uint32 Size
Definition VulkanMemory.cpp:4034
Definition CharacterGroundConstraintContainer.h:35
Definition PBDJointConstraintData.h:38
Definition ContactPoint.h:183
A single point in a contact manifold. Each Collision Constraint will have up to 4 of these.
Definition ContactPoint.h:97
Definition PBDCollisionConstraint.h:48
A contact constraint.
Definition PBDCollisionConstraint.h:225
Definition PBDJointConstraints.h:28
Definition PBDJointConstraintTypes.h:114
Produce collisions for a particle pair A FParticlePairMidPhase object is created for every particle p...
Definition ParticlePairMidPhase.h:192
Definition ISpatialAccelerationCollection.h:23
Definition AABBTree.h:786
Definition AABB.h:37
FORCEINLINE const TVector< T, d > & Max() const
Definition AABB.h:596
FORCEINLINE const TVector< T, d > & Min() const
Definition AABB.h:595
Definition BoundingVolume.h:118
Definition ParticleHandle.h:436
Definition ParticleHandle.h:2739
Definition Vector.h:407
Definition ChaosVDDataWrapperUtils.h:77
static UE_INTERNAL FChaosVDJointConstraint BuildGTJointDataWrapper(Chaos::FJointConstraint *GTConstraintPtr)
Definition ChaosVDDataWrapperUtils.cpp:420
static UE_INTERNAL FChaosVDParticleDataWrapper BuildParticleDataWrapperFromParticle(const Chaos::FGeometryParticleHandle *ParticleHandlePtr)
Definition ChaosVDDataWrapperUtils.cpp:88
static UE_INTERNAL void ApplyJointDataWrapperToHandle(Chaos::FPBDJointConstraintHandle *ConstaintHanlde, const FChaosVDJointConstraint &WrappedJointData)
Definition ChaosVDDataWrapperUtils.cpp:534
static UE_INTERNAL void ApplyJointDataWrapperGTConstraint(Chaos::FJointConstraint *ConstraintPtr, const FChaosVDJointConstraint &InWrappedJointData)
Definition ChaosVDDataWrapperUtils.cpp:564
static UE_INTERNAL FChaosVDParticleDataWrapper BuildParticleDataWrapperFromGTParticle(const Chaos::FGeometryParticle *GTParticle)
Definition ChaosVDDataWrapperUtils.cpp:130
static UE_INTERNAL FChaosVDCharacterGroundConstraint BuildCharacterGroundConstraintDataWrapper(const Chaos::FCharacterGroundConstraintHandle *ConstaintHanlde)
Definition ChaosVDDataWrapperUtils.cpp:588
static UE_INTERNAL FChaosVDJointConstraint BuildJointDataWrapper(const Chaos::FPBDJointConstraintHandle *ConstaintHanlde)
Definition ChaosVDDataWrapperUtils.cpp:365
Definition Array.h:670
Definition UniquePtr.h:107
Definition ChaosVDDataWrapperUtils.cpp:19
void TransformStaticArray(const InType(&In)[Size], OutType(&Out)[Size], TransformT Trans)
Definition ChaosVDDataWrapperUtils.h:49
FTransform ConvertToFTransform(const FRigidTransform3 &InChaosTransform)
Definition ChaosVDDataWrapperUtils.h:63
void CopyStaticArray(const InType(&In)[Size], OutType(&Out)[Size])
Definition ChaosVDDataWrapperUtils.h:58
Definition SkeletalMeshComponent.h:307
FPBDCollisionConstraintMaterial FPBDCollisionConstraintMaterial
Definition PBDCollisionConstraint.h:129
U16 Index
Definition radfft.cpp:71
Definition AABBTree.h:260
Definition AABBTree.h:648
Definition ChaosVDAccelerationStructureDataWrappers.h:160
Definition ChaosVDAccelerationStructureDataWrappers.h:85
uint8 bLeaf
Definition ChaosVDAccelerationStructureDataWrappers.h:95
Definition ChaosVDCharacterGroundConstraintDataWrappers.h:119
Definition ChaosVDCollisionDataWrappers.h:145
Definition ChaosVDCollisionDataWrappers.h:210
Definition ChaosVDJointDataWrappers.h:405
Definition ChaosVDJointDataWrappers.h:260
Definition ChaosVDCollisionDataWrappers.h:100
Definition ChaosVDParticleDataWrapper.h:747
Definition ChaosVDCollisionDataWrappers.h:343
Definition ChaosVDCollisionDataWrappers.h:434
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160