UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TriangleMeshImplicitObject.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Chaos/Array.h"
7#include "Chaos/ImplicitFwd.h"
10#include "Chaos/SegmentMesh.h"
11#include "Chaos/Triangle.h"
12
13#include "AABBTree.h"
14#include "BoundingVolume.h"
16#include "Box.h"
17#include "ChaosArchive.h"
18#include "ImplicitObject.h"
21
22#include <type_traits>
23
24namespace Chaos::Private
25{
26 class FMeshContactGenerator;
27}
28
29namespace Chaos
30{
32
33 struct FMTDInfo;
34 template <typename QueryGeomType>
35 struct FTriangleMeshOverlapVisitorNoMTD;
36 class FTriangleMeshImplicitObject;
37 FArchive& operator<<(FArchive& Ar, FAABBVectorized& Bounds);
38
40 {
42
43 enum class EVisitorResult
44 {
45 Stop = 0,
47 };
48
49 enum class EFilterResult
50 {
51 Skip = 0,
52 Keep,
53 };
54
55 struct alignas(16) FChildData
56 {
58 : ChildOrFaceIndex{ INDEX_NONE, INDEX_NONE }
59 , FaceCount{ 0, 0 }
60 {
61 }
62
64 {
65 return ChildOrFaceIndex[ChildIndex];
66 }
67
68 FORCEINLINE int32 GetFaceCount(int ChildIndex) const
69 {
70 return FaceCount[ChildIndex];
71 }
72
74 {
75 ChildOrFaceIndex[ChildIndex] = InChildOrFaceIndex;
76 }
77
79 {
80 FaceCount[ChildIndex] = InFaceCount;
81 }
82
83 FORCEINLINE void SetBounds(int ChildIndex, const FAABB3& AABB)
84 {
85 Bounds[ChildIndex] = FAABBVectorized(AABB);
86 }
87 FORCEINLINE void SetBounds(int ChildIndex, const TAABB<FRealSingle, 3>& AABB)
88 {
89 Bounds[ChildIndex] = FAABBVectorized(AABB);
90 }
91
92 const FAABBVectorized& GetBounds(int ChildIndex) const { return Bounds[ChildIndex]; }
93
95 {
96 Ar << Bounds[0];
97 Ar << ChildOrFaceIndex[0];
98 Ar << FaceCount[0];
99 Ar << Bounds[1];
100 Ar << ChildOrFaceIndex[1];
101 Ar << FaceCount[1];
102 }
103
104 private:
105 FAABBVectorized Bounds[2];
106 int32 ChildOrFaceIndex[2];
107 int32 FaceCount[2];
108 };
109
110 struct FNode
111 {
112 FNode() {}
113
115 {
117 }
119 };
120
121 template <typename SQVisitor>
122 FORCEINLINE_DEBUGGABLE void Raycast(const FVec3& Start, const FVec3& Dir, const FReal Length, SQVisitor& Visitor) const
123 {
124 FRealSingle CurrentLength = static_cast<FRealSingle>(Length);
129
130 const auto BoundsFilter = [&StartSimd, &InvDirSimd, &Parallel, &CurrentLength](const FAABBVectorized& Bounds) -> EFilterResult
131 {
133 const bool bHit = Bounds.RaycastFast(StartSimd, InvDirSimd, Parallel, CurDataLength);
134
136 };
137
138 const auto FaceVisitor = [&Visitor, &CurrentLength](int32 FaceIndex)
139 {
140 const bool bContinueVisiting = Visitor.VisitRaycast(FaceIndex, CurrentLength);
142 };
143
145 }
146
147 template <typename SQVisitor>
148 FORCEINLINE_DEBUGGABLE void Sweep(const FVec3& Start, const FVec3& Dir, const FReal Length, const FVec3& QueryHalfExtents, SQVisitor& Visitor) const
149 {
150 FRealSingle CurrentLength = static_cast<FRealSingle>(Length);
155
157 const auto BoundsFilter = [&StartSimd, &InvDirSimd, &Parallel, &CurrentLength, &QueryHalfExtentsSimd](const FAABBVectorized& Bounds) -> EFilterResult
158 {
161 const bool bHit = SweepBounds.RaycastFast(StartSimd, InvDirSimd, Parallel, CurDataLength);
162
164 };
165
166 const auto FaceVisitor = [&Visitor, &CurrentLength](int32 FaceIndex)
167 {
168 const bool bContinueVisiting = Visitor.VisitSweep(FaceIndex, CurrentLength);
170 };
171
173 }
174
175 template <typename SQVisitor>
176 FORCEINLINE_DEBUGGABLE void Overlap(const FAABBVectorized& AABB, SQVisitor& Visitor) const
177 {
178 const auto BoundsFilter = [&AABB](const FAABBVectorized& Bounds) -> EFilterResult
179 {
180 const bool bHit = Bounds.Intersects(AABB);
182 };
183
184 const auto FaceVisitor = [&Visitor](int32 FaceIndex)
185 {
186 const bool bContinueVisiting = Visitor.VisitOverlap(FaceIndex);
188 };
189
191 }
192
193 template <typename SQVisitor>
195 {
196 const auto BoundsFilter = [&Obb](const FAABBVectorized& Bounds) -> EFilterResult
197 {
198 const bool bHit = Obb.IntersectAABB(Bounds);
200 };
201
202 const auto FaceVisitor = [&Visitor](int32 FaceIndex)
203 {
204 const bool bContinueVisiting = Visitor.VisitOverlap(FaceIndex);
206 };
207
209 }
210
211 template <typename QueryGeomType>
212 bool FindAllIntersectionsNoMTD(const Private::FOBBVectorized& Intersection, const TRigidTransform<FReal, 3>& Transform, const QueryGeomType& QueryGeom, FReal Thickness, const FVec3& TriMeshScale, const FTriangleMeshImplicitObject* TriMesh) const;
213 template <typename QueryGeomType>
214 bool FindAllIntersectionsNoMTD(const FAABB3& Intersection, const TRigidTransform<FReal, 3>& Transform, const QueryGeomType& QueryGeom, FReal Thickness, const FVec3& TriMeshScale, const FTriangleMeshImplicitObject* TriMesh) const;
215 CHAOS_API TArray<int32> FindAllIntersections(const FAABB3& Intersection) const;
216
217 template <typename BoundsFilterType, typename FaceVisitorType>
219 {
220 const int32 EndIndex = (StartIndex + IndexCount);
221 for (int32 FaceIndex = StartIndex; FaceIndex < EndIndex; ++FaceIndex)
222 {
224 {
226 {
228 }
229 }
230 }
232 }
233
234 template <typename BoundsFilterType, typename FaceVisitorType>
236 {
237 if (Nodes.Num() == 0)
238 {
239 return;
240 }
243 while (NodeIndexStack.Num())
244 {
245 const int32 NodeIndex = NodeIndexStack.Pop(EAllowShrinking::No);
246 check(Nodes.IsValidIndex(NodeIndex));
247 const FNode& Node = Nodes[NodeIndex];
248
249 for (int32 ChildIndex = 0; ChildIndex < 2; ++ChildIndex)
250 {
251 const FChildData& ChildData = Node.Children;
252 const int32 FaceIndex = ChildData.GetChildOrFaceIndex(ChildIndex);
253 if (FaceIndex != INDEX_NONE)
254 {
255 if (BoundsFilter(ChildData.GetBounds(ChildIndex)) == EFilterResult::Keep)
256 {
257 const uint32 FaceCount = ChildData.GetFaceCount(ChildIndex);
258 if (FaceCount > 0)
259 {
261 {
262 return;
263 }
264 }
265 else
266 {
268 }
269 }
270 }
271 }
272 }
273 }
274
276 {
278 Ar << Nodes;
279 Ar << FaceBounds;
280 if (Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::RemoveTriangleMeshBVHFaces)
281 {
283 Ar << TmpFaces;
284 }
285 }
286
289 };
290
296
298 {
299 Node.Serialize(Ar);
300 return Ar;
301 }
302
308
310 {
311 alignas(16) FRealSingle Floats[4];
312 VectorStoreAligned(Bounds.GetMin(), Floats);
313 TVector<FRealSingle, 3> Min(Floats[0], Floats[1], Floats[2]);
314 VectorStoreAligned(Bounds.GetMax(), Floats);
315 TVector<FRealSingle, 3> Max(Floats[0], Floats[1], Floats[2]);
319 return Ar;
320 }
321
323 {
324 alignas(16) FRealSingle Floats[4];
325 VectorStoreAligned(Bounds.GetMin(), Floats);
326 TVector<FRealSingle, 3> Min(Floats[0], Floats[1], Floats[2]);
327 VectorStoreAligned(Bounds.GetMax(), Floats);
328 TVector<FRealSingle, 3> Max(Floats[0], Floats[1], Floats[2]);
332 return Ar;
333 }
334
340
342 {
343 public:
346
349 : LargeIdxBuffer(MoveTemp(Elements))
350 , bRequiresLargeIndices(true)
351 {
352 }
353
355 : SmallIdxBuffer(MoveTemp(Elements))
356 , bRequiresLargeIndices(false)
357 {
358 }
359
362
363
365 {
366 LargeIdxBuffer.Empty();
367 SmallIdxBuffer.Empty();
368 bRequiresLargeIndices = true;
369 LargeIdxBuffer = MoveTemp(Elements);
370 }
371
373 {
374 LargeIdxBuffer.Empty();
375 SmallIdxBuffer.Empty();
376 bRequiresLargeIndices = false;
377 SmallIdxBuffer = MoveTemp(Elements);
378 }
379
381 {
383
385 {
386 Ar << LargeIdxBuffer;
387 bRequiresLargeIndices = true;
388 }
389 else
390 {
391 Ar << bRequiresLargeIndices;
392 if (bRequiresLargeIndices)
393 {
394 Ar << LargeIdxBuffer;
395 }
396 else
397 {
398 Ar << SmallIdxBuffer;
399 }
400 }
401 }
402
404 {
405 return bRequiresLargeIndices;
406 }
407
409 {
410 check(bRequiresLargeIndices);
411 return LargeIdxBuffer;
412 }
413
415 {
416 check(!bRequiresLargeIndices);
417 return SmallIdxBuffer;
418 }
419
421 {
422 if(bRequiresLargeIndices)
423 {
424 return LargeIdxBuffer.Num();
425 }
426
427 return SmallIdxBuffer.Num();
428 }
429
430 template<typename ExpectedType>
432 {
433 if constexpr(std::is_same_v<ExpectedType, LargeIdxType>)
434 {
435 check(bRequiresLargeIndices);
436 return LargeIdxBuffer;
437 }
438 else if constexpr(std::is_same_v<ExpectedType, SmallIdxType>)
439 {
440 check(!bRequiresLargeIndices);
441 return SmallIdxBuffer;
442 }
443 else
444 {
445 static_assert(sizeof(ExpectedType) == 0, "Unsupported index buffer type");
446 return SmallIdxBuffer; // Appease the static analyzer by having a pointless return value
447 }
448 }
449
450 private:
451 TArray<TVec3<LargeIdxType>> LargeIdxBuffer;
452 TArray<TVec3<SmallIdxType>> SmallIdxBuffer;
453 bool bRequiresLargeIndices;
454 };
455
461
462 template <typename IdxType, typename ParticlesType>
463 inline void TriangleMeshTransformVertsHelper(const FVec3& TriMeshScale, int32 TriIdx, const ParticlesType& Particles,
464 const TArray<TVector<IdxType, 3>>& Elements, FVec3& OutA, FVec3& OutB, FVec3& OutC)
465 {
466 OutA = Particles.GetX(Elements[TriIdx][0]) * TriMeshScale;
467 OutB = Particles.GetX(Elements[TriIdx][1]) * TriMeshScale;
468 OutC = Particles.GetX(Elements[TriIdx][2]) * TriMeshScale;
469 }
470
471 template <typename IdxType, typename ParticlesType>
472 inline void TriangleMeshTransformVertsHelper(const FRigidTransform3& Transform, int32 TriIdx, const ParticlesType& Particles,
473 const TArray<TVector<IdxType, 3>>& Elements, FVec3& OutA, FVec3& OutB, FVec3& OutC,
475 {
476 const int32 VertexIndexA = Elements[TriIdx][0];
477 const int32 VertexIndexB = Elements[TriIdx][1];
478 const int32 VertexIndexC = Elements[TriIdx][2];
479 // Note: deliberately using scaled transform here. See VisitTriangles
480 OutA = Transform.TransformPosition(FVector(Particles.GetX(VertexIndexA)));
481 OutB = Transform.TransformPosition(FVector(Particles.GetX(VertexIndexB)));
482 OutC = Transform.TransformPosition(FVector(Particles.GetX(VertexIndexC)));
486 }
487
488
490 {
491 public:
493
496
497 template <typename IdxType>
499 : FImplicitObject(EImplicitObject::HasBoundingBox | EImplicitObject::DisableCollisions, ImplicitObjectType::TriangleMesh)
500 , MParticles(MoveTemp(Particles))
501 , MElements(MoveTemp(Elements))
502 , MLocalBoundingBox(FVec3(0), FVec3(0))
503 , MaterialIndices(MoveTemp(InMaterialIndices))
504 , ExternalFaceIndexMap(MoveTemp(InExternalFaceIndexMap))
505 , ExternalVertexIndexMap(MoveTemp(InExternalVertexIndexMap))
506 , bCullsBackFaceRaycast(bInCullsBackFaceRaycast)
507 {
508 const int32 NumTriangles = MElements.GetNumTriangles();
509 if(NumTriangles > 0)
510 {
511
512 const TArray<TVec3<IdxType>>& Tris = MElements.GetIndexBuffer<IdxType>();
513 const TVec3<IdxType>& FirstTri = Tris[0];
514
515 MLocalBoundingBox = FAABB3(MParticles.GetX(FirstTri[0]), MParticles.GetX(FirstTri[0]));
516 MLocalBoundingBox.GrowToInclude(MParticles.GetX(FirstTri[1]));
517 MLocalBoundingBox.GrowToInclude(MParticles.GetX(FirstTri[2]));
518
519 for(int32 TriangleIndex = 1; TriangleIndex < NumTriangles; ++TriangleIndex)
520 {
521 const TVec3<IdxType>& Tri = Tris[TriangleIndex];
522 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[0]));
523 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[1]));
524 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[2]));
525 }
526 }
527
528 RebuildFastBVH();
529 }
530
534
535 virtual FReal GetRadius() const override
536 {
537 return 0.0f;
538 }
539
540 CHAOS_API virtual FReal PhiWithNormal(const FVec3& x, FVec3& Normal) const override;
541
542 CHAOS_API virtual bool Raycast(const FVec3& StartPoint, const FVec3& Dir, const FReal Length, const FReal Thickness, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex) const override;
543 CHAOS_API virtual bool Overlap(const FVec3& Point, const FReal Thickness) const override;
544
545 CHAOS_API bool OverlapGeom(const FSphere& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr) const;
546 CHAOS_API bool OverlapGeom(const TBox<FReal, 3>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr) const;
547 CHAOS_API bool OverlapGeom(const FCapsule& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr) const;
548 CHAOS_API bool OverlapGeom(const FConvex& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr) const;
549
550 CHAOS_API bool OverlapGeom(const TImplicitObjectScaled<FSphere>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr, FVec3 TriMeshScale = FVec3(1.0f)) const;
551 CHAOS_API bool OverlapGeom(const TImplicitObjectScaled<TBox<FReal, 3>>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr, FVec3 TriMeshScale = FVec3(1.0f)) const;
552 CHAOS_API bool OverlapGeom(const TImplicitObjectScaled<FCapsule>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr, FVec3 TriMeshScale = FVec3(1.0f)) const;
553 CHAOS_API bool OverlapGeom(const TImplicitObjectScaled<FConvex>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr, FVec3 TriMeshScale = FVec3(1.0f)) const;
554
555 CHAOS_API bool SweepGeom(const FSphere& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
556 CHAOS_API bool SweepGeom(const TBox<FReal, 3>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
557 CHAOS_API bool SweepGeom(const FCapsule& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
558 CHAOS_API bool SweepGeom(const FConvex& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
559
560 CHAOS_API bool SweepGeom(const TImplicitObjectScaled<FSphere>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
561 CHAOS_API bool SweepGeom(const TImplicitObjectScaled<TBox<FReal, 3>>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
562 CHAOS_API bool SweepGeom(const TImplicitObjectScaled<FCapsule>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
563 CHAOS_API bool SweepGeom(const TImplicitObjectScaled<FConvex>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness = 0, const bool bComputeMTD = false, FVec3 TriMeshScale = FVec3(1.0f)) const;
564
565 // Sweep used for CCD. Ignores triangles we penetrate by less than IgnorePenetration, and calculate the TOI for a depth of TargetPenetration. If both are zero, this is equivalent to SweepGeom
566 CHAOS_API bool SweepGeomCCD(const FSphere& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
567 CHAOS_API bool SweepGeomCCD(const TBox<FReal, 3>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
568 CHAOS_API bool SweepGeomCCD(const FCapsule& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
569 CHAOS_API bool SweepGeomCCD(const FConvex& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
570 CHAOS_API bool SweepGeomCCD(const TImplicitObjectScaled<FSphere>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
571 CHAOS_API bool SweepGeomCCD(const TImplicitObjectScaled<TBox<FReal, 3>>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
572 CHAOS_API bool SweepGeomCCD(const TImplicitObjectScaled<FCapsule>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
573 CHAOS_API bool SweepGeomCCD(const TImplicitObjectScaled<FConvex>& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale = FVec3(1.0f)) const;
574
575 CHAOS_API bool GJKContactPoint(const FSphere& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex) const;
576 CHAOS_API bool GJKContactPoint(const TBox<FReal, 3>& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex) const;
577 CHAOS_API bool GJKContactPoint(const FCapsule& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex) const;
578 CHAOS_API bool GJKContactPoint(const FConvex& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex) const;
579
580 CHAOS_API bool GJKContactPoint(const TImplicitObjectScaled < FSphere >& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex, FVec3 TriMeshScale = FVec3(1.0f)) const;
581 CHAOS_API bool GJKContactPoint(const TImplicitObjectScaled < TBox<FReal, 3> >& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex, FVec3 TriMeshScale = FVec3(1.0f)) const;
582 CHAOS_API bool GJKContactPoint(const TImplicitObjectScaled < FCapsule >& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex, FVec3 TriMeshScale = FVec3(1.0f)) const;
583 CHAOS_API bool GJKContactPoint(const TImplicitObjectScaled < FConvex >& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex, FVec3 TriMeshScale = FVec3(1.0f)) const;
584
585 // Returns -1 if InternalFaceIndex is not in map, or map is invalid.
587
588 // Does Trimesh cull backfaces in raycast.
591
592
596
597 virtual const FAABB3 BoundingBox() const override
598 {
599 return MLocalBoundingBox;
600 }
601
602 const FAABB3f BoundingBoxf() const
603 {
604 return FAABB3f(MLocalBoundingBox);
605 }
606
608 {
610 }
611
614
615 UE_DEPRECATED(5.4, "Use DeepCopyGeometry instead")
617
619 {
620 Ar.UsingCustomVersion(FExternalPhysicsCustomObjectVersion::GUID);
621 Ar.UsingCustomVersion(FUE5MainStreamObjectVersion::GUID);
622
624 Ar << MParticles;
625 Ar << MElements;
626 TBox<FReal, 3>::SerializeAsAABB(Ar, MLocalBoundingBox);
627
629 {
631 Ar << ConvexHulls;
632 }
633
635 {
636 // Should now only hit when loading older trimeshes
637 RebuildFastBVH();
638 }
640 {
642 Ar << Dummy;
643 RebuildFastBVH();
644 }
645 else if (Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::UseTriangleMeshBVH)
646 {
647 // Serialize acceleration
648 BVHType BVH;
649 Ar << BVH;
650 if (BVH.GetNodes().IsEmpty())
651 {
652 RebuildFastBVH();
653 }
654 else
655 {
656 RebuildFastBVHFromTree(BVH);
657 }
658 }
659 else
660 {
661 Ar << FastBVH;
662 }
663
664 if (Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::RemoveTriangleMeshBVHFaces)
665 {
666 // Force to rebuild the BVH
667 RebuildFastBVH();
668 }
669
671 {
672 Ar << MaterialIndices;
673 }
674
676 {
677 // TODO: This data is only needed in editor unless project configuration requests this for gameplay. We should not serialize this when cooking
678 // unless it is required for gameplay, as we are wasting disk space.
679 if (Ar.IsLoading())
680 {
683 if (!ExternalFaceIndexMapTemp->IsEmpty())
684 {
685 ExternalFaceIndexMap = MoveTemp(ExternalFaceIndexMapTemp);
686 }
687 }
688 else
689 {
690 if (ExternalFaceIndexMap == nullptr)
691 {
692 TArray<int32> EmptyArray;
693 Ar << EmptyArray;
694 }
695 else
696 {
697 Ar << *ExternalFaceIndexMap;
698 }
699 }
700 }
701
702 Ar.UsingCustomVersion(FPhysicsObjectVersion::GUID);
704 {
705 if (Ar.IsLoading())
706 {
707 ExternalVertexIndexMap = MakeUnique<TArray<int32>>(TArray<int32>());
708 Ar << *ExternalVertexIndexMap;
709 }
710 else
711 {
712 if (ExternalVertexIndexMap == nullptr)
713 {
714 TArray<int32> EmptyArray;
715 Ar << EmptyArray;
716 }
717 else
718 {
719 Ar << *ExternalVertexIndexMap;
720 }
721 }
722 }
723 }
724
725 CHAOS_API virtual void Serialize(FChaosArchive& Ar) override;
726
727 virtual FString ToString() const
728 {
729 return FString::Printf(TEXT("TriangleMesh"));
730 }
731
732 CHAOS_API virtual uint32 GetTypeHash() const override;
733
734 CHAOS_API FVec3 GetFaceNormal(const int32 FaceIdx) const;
735
736 CHAOS_API virtual uint16 GetMaterialIndex(uint32 HintIndex) const override;
737
738 CHAOS_API const ParticlesType& Particles() const;
740
742
758
767
774 template<typename TriangleVisitor>
776 {
779
780 const bool bStandardWinding = ((QueryTransform.GetScale3D().X * QueryTransform.GetScale3D().Y * QueryTransform.GetScale3D().Z) >= FReal(0));
781
783 {
784 const int32 TriangleIndex = OverlapIndices[OverlapIndex];
786 int32 VertexIndex0, VertexIndex1, VertexIndex2;
787 GetTransformedTriangle(TriangleIndex, QueryTransform, Triangle, VertexIndex0, VertexIndex1, VertexIndex2);
788
789 if (!bStandardWinding)
790 {
791 Triangle.ReverseWinding();
792 Swap(VertexIndex1, VertexIndex2);
793 }
794
795 Visitor(Triangle, TriangleIndex, VertexIndex0, VertexIndex1, VertexIndex2);
796 }
797 }
798
799 // Internal: do not use - this API will change as we optimize mesh collision
801
802 // Internal: Only for CVD
804
805 private:
806 using BVHType = TAABBTree<int32, TAABBTreeLeafArray<int32, /*bComputeBounds=*/ false, FRealSingle>, /*bMutable=*/false, FRealSingle>;
807 CHAOS_API void RebuildFastBVHFromTree(const BVHType& BVH);
808 CHAOS_API void RebuildFastBVH();
809
810 ParticlesType MParticles;
811 FTrimeshIndexBuffer MElements;
812 FAABB3 MLocalBoundingBox;
813 TArray<uint16> MaterialIndices;
814 TUniquePtr<TArray<int32>> ExternalFaceIndexMap;
815 TUniquePtr<TArray<int32>> ExternalVertexIndexMap;
816 bool bCullsBackFaceRaycast;
817
818 // Initialising constructor privately declared for use in CopySlow to copy the underlying BVH
819 template <typename IdxType>
821 : FImplicitObject(EImplicitObject::HasBoundingBox | EImplicitObject::DisableCollisions, ImplicitObjectType::TriangleMesh)
822 , MParticles(MoveTemp(Particles))
823 , MElements(MoveTemp(Elements))
824 , MLocalBoundingBox(MParticles.GetX(0), MParticles.GetX(0))
825 , MaterialIndices(MoveTemp(InMaterialIndices))
826 , ExternalFaceIndexMap(MoveTemp(InExternalFaceIndexMap))
827 , ExternalVertexIndexMap(MoveTemp(InExternalVertexIndexMap))
828 , bCullsBackFaceRaycast(bInCullsBackFaceRaycast)
829 {
830 const int32 NumTriangles = MElements.GetNumTriangles();
831 if(NumTriangles > 0)
832 {
833 const TArray<TVec3<IdxType>>& Tris = MElements.GetIndexBuffer<IdxType>();
834 const TVec3<IdxType>& FirstTri = Tris[0];
835
836 MLocalBoundingBox = FAABB3(MParticles.GetX(FirstTri[0]), MParticles.GetX(FirstTri[0]));
837 MLocalBoundingBox.GrowToInclude(MParticles.GetX(FirstTri[1]));
838 MLocalBoundingBox.GrowToInclude(MParticles.GetX(FirstTri[2]));
839
840 for(int32 TriangleIndex = 1; TriangleIndex < NumTriangles; ++TriangleIndex)
841 {
842 const TVec3<IdxType>& Tri = Tris[TriangleIndex];
843 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[0]));
844 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[1]));
845 MLocalBoundingBox.GrowToInclude(MParticles.GetX(Tri[2]));
846 }
847 }
848
849 RebuildFastBVHFromTree(InBvhToCopy);
850 }
851
852 template<typename InStorageType, typename InRealType>
853 friend struct FBvEntry;
854 template <typename QueryGeomType>
856
857 template<bool bRequiresLargeIndex>
858 struct FBvEntry
859 {
861 int32 Index;
862
863 bool HasBoundingBox() const { return true; }
864
866 {
867 auto LambdaHelper = [&](const auto& Elements)
868 {
869 TAABB<FRealSingle,3> Bounds(TmData->MParticles.GetX(Elements[Index][0]), TmData->MParticles.GetX(Elements[Index][0]));
870
871 Bounds.GrowToInclude(TmData->MParticles.GetX(Elements[Index][1]));
872 Bounds.GrowToInclude(TmData->MParticles.GetX(Elements[Index][2]));
873
874 return Bounds;
875 };
876
878 {
879 return LambdaHelper(TmData->MElements.GetLargeIndexBuffer());
880 }
881 else
882 {
883 return LambdaHelper(TmData->MElements.GetSmallIndexBuffer());
884 }
885 }
886
887 template<typename TPayloadType>
888 int32 GetPayload(int32 Idx) const
889 {
890 return Idx;
891 }
892
893 FUniqueIdx UniqueIdx() const
894 {
895 return FUniqueIdx(Index);
896 }
897 };
898
899 FTrimeshBVH FastBVH;
900
901 template<typename Geom, typename IdxType>
903
904 template<typename Geom, typename IdxType>
906
907 // Required by implicit object serialization, disabled for general use.
908 friend class FImplicitObject;
909
911 : FImplicitObject(EImplicitObject::HasBoundingBox, ImplicitObjectType::TriangleMesh){};
912
913 template <typename QueryGeomType>
914 bool GJKContactPointImp(const QueryGeomType& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FVec3& Location, FVec3& Normal, FReal& Penetration, int32& FaceIndex, FVec3 TriMeshScale = FVec3(1.0)) const;
915
916 template<bool IsSpherical, typename QueryGeomType>
917 bool OverlapGeomImp(const QueryGeomType& QueryGeom, const FRigidTransform3& QueryTM, const FReal Thickness, FMTDInfo* OutMTD = nullptr, FVec3 TriMeshScale = FVec3(1.0f)) const;
918
919 template<typename QueryGeomType>
920 bool SweepGeomImp(const QueryGeomType& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FReal Thickness, const bool bComputeMTD, FVec3 TriMeshScale = FVec3(1.0f)) const;
921
922 template <typename QueryGeomType>
923 bool SweepGeomCCDImp(const QueryGeomType& QueryGeom, const FRigidTransform3& StartTM, const FVec3& Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal& OutTOI, FReal& OutPhi, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex, FVec3& OutFaceNormal, const FVec3& TriMeshScale) const;
924
925 template <typename IdxType>
926 bool RaycastImp(const TArray<TVec3<IdxType>>& Elements, const FVec3& StartPoint, const FVec3& Dir, const FReal Length, const FReal Thickness, FReal& OutTime, FVec3& OutPosition, FVec3& OutNormal, int32& OutFaceIndex) const;
927
928 template <typename IdxType>
929 bool OverlapImp(const TArray<TVec3<IdxType>>& Elements, const FVec3& Point, const FReal Thickness) const;
930
931 template<typename IdxType>
933
934 template <typename IdxType>
935 void RebuildBVImp(const TArray<TVec3<IdxType>>& Elements, BVHType& BVH);
936
937 template <typename IdxType>
938 FImplicitObjectPtr CopySlowImpl(const TArray < TVector<IdxType, 3>>& InElements) const;
939 };
940
941}
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_INTERNAL
Definition CoreMiscDefines.h:345
#define FORCEINLINE_DEBUGGABLE
Definition CoreMiscDefines.h:74
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
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
return true
Definition ExternalRpcRegistry.cpp:601
#define FVector
Definition IOSSystemIncludes.h:8
FORCEINLINE VectorRegister4Float VectorSubtract(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:731
FORCEINLINE VectorRegister4Float VectorDivide(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:834
FORCEINLINE VectorRegister4Float VectorLoadFloat1(const float *Ptr)
Definition UnrealMathFPU.h:468
FORCEINLINE VectorRegister4Float VectorCompareGT(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:974
FORCEINLINE VectorRegister4Double MakeVectorRegisterDouble(uint64 X, uint64 Y, uint64 Z, uint64 W)
Definition UnrealMathFPU.h:185
FORCEINLINE VectorRegister4Float VectorAbs(const VectorRegister4Float &Vec)
Definition UnrealMathFPU.h:661
FORCEINLINE VectorRegister4Float VectorAdd(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:704
void VectorStoreAligned(const VectorRegister4Float &Vec, float *Ptr)
Definition UnrealMathFPU.h:534
FORCEINLINE VectorRegister4Float MakeVectorRegisterFloatFromDouble(const VectorRegister4Double &Vec4d)
Definition UnrealMathFPU.h:262
FORCEINLINE VectorRegister4Float VectorOne(void)
Definition UnrealMathVectorCommon.h.inl:21
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
FORCEINLINE VectorRegister4Float VectorBitwiseNotAnd(const VectorRegister4Float &A, const VectorRegister4Float &B)
Definition VectorUtility.h:289
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AABBVectorized.h:15
FORCEINLINE_DEBUGGABLE const VectorRegister4Float & GetMin() const
Definition AABBVectorized.h:38
FORCEINLINE_DEBUGGABLE const VectorRegister4Float & GetMax() const
Definition AABBVectorized.h:39
Definition Capsule.h:23
Definition ChaosArchive.h:167
Definition Convex.h:26
Definition ImplicitObject.h:111
bool HasBoundingBox() const
Definition ImplicitObject.h:275
virtual FName GetTypeName() const
Definition ImplicitObject.h:414
CHAOS_API void SerializeImp(FArchive &Ar)
Definition ImplicitObject.cpp:337
Definition TriangleMeshImplicitObject.h:490
virtual CHAOS_API ~FTriangleMeshImplicitObject()
friend struct FBvEntry
Definition TriangleMeshImplicitObject.h:853
CHAOS_API const ParticlesType & Particles() const
Definition TriangleMeshImplicitObject.cpp:2042
CHAOS_API bool GetCullsBackFaceRaycast() const
Definition TriangleMeshImplicitObject.cpp:1031
CHAOS_API bool SweepGeomCCD(const FSphere &QueryGeom, const FRigidTransform3 &StartTM, const FVec3 &Dir, const FReal Length, const FReal IgnorePenetration, const FReal TargetPenetration, FReal &OutTOI, FReal &OutPhi, FVec3 &OutPosition, FVec3 &OutNormal, int32 &OutFaceIndex, FVec3 &OutFaceNormal, const FVec3 &TriMeshScale=FVec3(1.0f)) const
Definition TriangleMeshImplicitObject.cpp:1785
virtual FString ToString() const
Definition TriangleMeshImplicitObject.h:727
CHAOS_API TUniquePtr< FTriangleMeshImplicitObject > CopySlow() const
virtual CHAOS_API uint16 GetMaterialIndex(uint32 HintIndex) const override
Definition TriangleMeshImplicitObject.cpp:2031
CHAOS_API const FTrimeshIndexBuffer & Elements() const
Definition TriangleMeshImplicitObject.cpp:2047
CHAOS_API void UpdateVertices(const TArray< FVector > &Positions)
Definition TriangleMeshImplicitObject.cpp:2095
CHAOS_API void SetCullsBackFaceRaycast(const bool bInCullsBackFace)
Definition TriangleMeshImplicitObject.cpp:1036
virtual FReal GetRadius() const override
Definition TriangleMeshImplicitObject.h:535
CHAOS_API FVec3 GetFaceNormal(const int32 FaceIdx) const
Definition TriangleMeshImplicitObject.cpp:1994
void GetTransformedTriangle(const int32 TriangleIndex, const FRigidTransform3 &Transform, FTriangle &OutTriangle, int32 &OutVertexIndex0, int32 &OutVertexIndex1, int32 &OutVertexIndex2) const
Generate the triangle at the specified index with the specified transform (including scale)
Definition TriangleMeshImplicitObject.h:747
void VisitTriangles(const FAABB3 &QueryBounds, const FRigidTransform3 &QueryTransform, const TriangleVisitor &Visitor) const
Definition TriangleMeshImplicitObject.h:775
virtual CHAOS_API uint32 GetTypeHash() const override
Definition TriangleMeshImplicitObject.cpp:1968
CHAOS_API bool OverlapGeom(const FSphere &QueryGeom, const FRigidTransform3 &QueryTM, const FReal Thickness, FMTDInfo *OutMTD=nullptr) const
Definition TriangleMeshImplicitObject.cpp:1188
FTriangleMeshImplicitObject(FTriangleMeshImplicitObject &&Other)=delete
virtual CHAOS_API FReal PhiWithNormal(const FVec3 &x, FVec3 &Normal) const override
Definition TriangleMeshImplicitObject.cpp:806
TParticles< FRealSingle, 3 > ParticlesType
Definition TriangleMeshImplicitObject.h:494
virtual CHAOS_API Chaos::FImplicitObjectPtr CopyGeometry() const
Definition TriangleMeshImplicitObject.cpp:1954
static constexpr EImplicitObjectType StaticType()
Definition TriangleMeshImplicitObject.h:607
virtual CHAOS_API FVec3 FindGeometryOpposingNormal(const FVec3 &DenormDir, int32 FaceIndex, const FVec3 &OriginalNormal) const override
Definition TriangleMeshImplicitObject.cpp:1909
FTriangleMeshImplicitObject(const FTriangleMeshImplicitObject &Other)=delete
void FindOverlappingTriangles(const FAABB3 &QueryBounds, TArray< int32 > &OutTriangleIndices) const
Get a list of triangle indices that overlap the query bounds.
Definition TriangleMeshImplicitObject.h:763
virtual CHAOS_API Chaos::FImplicitObjectPtr DeepCopyGeometry() const
Definition TriangleMeshImplicitObject.cpp:1942
CHAOS_API bool SweepGeom(const FSphere &QueryGeom, const FRigidTransform3 &StartTM, const FVec3 &Dir, const FReal Length, FReal &OutTime, FVec3 &OutPosition, FVec3 &OutNormal, int32 &OutFaceIndex, FVec3 &OutFaceNormal, const FReal Thickness=0, const bool bComputeMTD=false, FVec3 TriMeshScale=FVec3(1.0f)) const
FTriangleMeshImplicitObject(ParticlesType &&Particles, TArray< TVec3< IdxType > > &&Elements, TArray< uint16 > &&InMaterialIndices, TUniquePtr< TArray< int32 > > &&InExternalFaceIndexMap=nullptr, TUniquePtr< TArray< int32 > > &&InExternalVertexIndexMap=nullptr, const bool bInCullsBackFaceRaycast=false)
Definition TriangleMeshImplicitObject.h:498
virtual CHAOS_API int32 FindMostOpposingFace(const FVec3 &Position, const FVec3 &UnitDir, int32 HintFaceIndex, FReal SearchDistance) const override
Definition TriangleMeshImplicitObject.cpp:1884
CHAOS_API bool GJKContactPoint(const FSphere &QueryGeom, const FRigidTransform3 &QueryTM, const FReal Thickness, FVec3 &Location, FVec3 &Normal, FReal &Penetration, int32 &FaceIndex) const
Definition TriangleMeshImplicitObject.cpp:978
virtual const FAABB3 BoundingBox() const override
Definition TriangleMeshImplicitObject.h:597
const FAABB3f BoundingBoxf() const
Definition TriangleMeshImplicitObject.h:602
void SerializeImp(FChaosArchive &Ar)
Definition TriangleMeshImplicitObject.h:618
UE_INTERNAL CHAOS_API const FTrimeshBVH & GetBVH() const
Definition TriangleMeshImplicitObject.cpp:890
virtual CHAOS_API int32 FindMostOpposingFaceScaled(const FVec3 &Position, const FVec3 &UnitDir, int32 HintFaceIndex, FReal SearchDist, const FVec3 &Scale) const override
Definition TriangleMeshImplicitObject.cpp:1897
CHAOS_API int32 GetExternalFaceIndexFromInternal(int32 InternalFaceIndex) const
Definition TriangleMeshImplicitObject.cpp:1018
void CollectTriangles(const FAABB3 &MeshQueryBounds, const FRigidTransform3 &MeshToObjectTransform, const FAABB3 &ObjectBounds, Private::FMeshContactGenerator &Collector) const
Definition TriangleMeshImplicitObject.cpp:858
Definition TriangleMeshImplicitObject.h:342
void Reinitialize(TArray< TVec3< SmallIdxType > > &&Elements)
Definition TriangleMeshImplicitObject.h:372
void Reinitialize(TArray< TVec3< LargeIdxType > > &&Elements)
Definition TriangleMeshImplicitObject.h:364
int32 LargeIdxType
Definition TriangleMeshImplicitObject.h:344
FTrimeshIndexBuffer(TArray< TVec3< LargeIdxType > > &&Elements)
Definition TriangleMeshImplicitObject.h:348
FTrimeshIndexBuffer(TArray< TVec3< SmallIdxType > > &&Elements)
Definition TriangleMeshImplicitObject.h:354
FTrimeshIndexBuffer(const FTrimeshIndexBuffer &Other)=delete
int32 GetNumTriangles() const
Definition TriangleMeshImplicitObject.h:420
const TArray< TVec3< ExpectedType > > & GetIndexBuffer() const
Definition TriangleMeshImplicitObject.h:431
const TArray< TVec3< SmallIdxType > > & GetSmallIndexBuffer() const
Definition TriangleMeshImplicitObject.h:414
uint16 SmallIdxType
Definition TriangleMeshImplicitObject.h:345
bool RequiresLargeIndices() const
Definition TriangleMeshImplicitObject.h:403
void Serialize(FArchive &Ar)
Definition TriangleMeshImplicitObject.h:380
FTrimeshIndexBuffer & operator=(const FTrimeshIndexBuffer &Other)=delete
const TArray< TVec3< LargeIdxType > > & GetLargeIndexBuffer() const
Definition TriangleMeshImplicitObject.h:408
Definition MeshContactGenerator.h:249
Definition OBBVectorized.h:14
Definition AABBTree.h:786
const TArray< TAABBTreeNode< T > > & GetNodes() const
Definition AABBTree.h:2720
FORCEINLINE void GrowToInclude(const TVector< T, d > &V)
Definition AABB.h:393
Definition BoundingVolume.h:118
Definition Box.h:23
static void SerializeAsAABB(FArchive &Ar, TAABB< T, d > &AABB)
Definition Box.h:467
Definition ImplicitObjectScaled.h:447
const TVector< T, d > & GetX(const int32 Index) const
Definition Particles.h:156
Definition Transform.h:115
Definition Vector.h:1000
virtual void Serialize(void *V, int64 Length) override
Definition ArchiveProxy.h:97
Definition Archive.h:1208
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
CORE_API int32 CustomVer(const struct FGuid &Key) const
Definition Archive.cpp:602
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT void Push(ElementType &&Item)
Definition Array.h:1224
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
Definition UniquePtr.h:107
@ TriangleMesh
Definition ImplicitObjectType.h:24
Definition BodyInstance.h:90
Definition SkeletalMeshComponent.h:307
uint8 EImplicitObjectType
Definition ImplicitObjectType.h:41
FChaosArchive & operator<<(FChaosArchive &Ar, FRigidParticleControlFlags &Flags)
Definition RigidParticleControlFlags.cpp:15
FRealDouble FReal
Definition Real.h:22
void TriangleMeshTransformVertsHelper(const FVec3 &TriMeshScale, int32 TriIdx, const ParticlesType &Particles, const TArray< TVector< IdxType, 3 > > &Elements, FVec3 &OutA, FVec3 &OutB, FVec3 &OutC)
Definition TriangleMeshImplicitObject.h:463
bool TriMeshPerPolySupport
Definition TriangleMeshImplicitObject.cpp:29
float FRealSingle
Definition Real.h:14
@ Raycast
Definition SimulationModuleBase.h:145
TVector< FReal, 3 > FVec3
Definition Core.h:17
TAABB< FRealSingle, 3 > FAABB3f
Definition Core.h:32
TAABB< FReal, 3 > FAABB3
Definition ImplicitObject.h:34
constexpr VectorRegister4Float SmallNumber
Definition UnrealMathVectorConstants.h.inl:53
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition GeometryQueries.h:27
Definition TriangleMeshImplicitObject.cpp:365
Definition TriangleMeshImplicitObject.cpp:1440
Definition TriangleMeshImplicitObject.cpp:1230
Definition TriangleMeshImplicitObject.h:56
const FAABBVectorized & GetBounds(int ChildIndex) const
Definition TriangleMeshImplicitObject.h:92
FORCEINLINE void SetBounds(int ChildIndex, const FAABB3 &AABB)
Definition TriangleMeshImplicitObject.h:83
void Serialize(FArchive &Ar)
Definition TriangleMeshImplicitObject.h:94
FChildData()
Definition TriangleMeshImplicitObject.h:57
FORCEINLINE void SetFaceCount(int ChildIndex, int32 InFaceCount)
Definition TriangleMeshImplicitObject.h:78
FORCEINLINE void SetChildOrFaceIndex(int ChildIndex, int32 InChildOrFaceIndex)
Definition TriangleMeshImplicitObject.h:73
FORCEINLINE int32 GetFaceCount(int ChildIndex) const
Definition TriangleMeshImplicitObject.h:68
FORCEINLINE int32 GetChildOrFaceIndex(int ChildIndex) const
Definition TriangleMeshImplicitObject.h:63
FORCEINLINE void SetBounds(int ChildIndex, const TAABB< FRealSingle, 3 > &AABB)
Definition TriangleMeshImplicitObject.h:87
Definition TriangleMeshImplicitObject.h:111
FNode()
Definition TriangleMeshImplicitObject.h:112
void Serialize(FArchive &Ar)
Definition TriangleMeshImplicitObject.h:114
FChildData Children
Definition TriangleMeshImplicitObject.h:118
Definition TriangleMeshImplicitObject.h:40
bool FindAllIntersectionsNoMTD(const Private::FOBBVectorized &Intersection, const TRigidTransform< FReal, 3 > &Transform, const QueryGeomType &QueryGeom, FReal Thickness, const FVec3 &TriMeshScale, const FTriangleMeshImplicitObject *TriMesh) const
Definition TriangleMeshImplicitObject.cpp:787
FORCEINLINE_DEBUGGABLE EVisitorResult VisitFaces(int32 StartIndex, int32 IndexCount, BoundsFilterType &BoundsFilter, FaceVisitorType &FaceVisitor) const
Definition TriangleMeshImplicitObject.h:218
FORCEINLINE_DEBUGGABLE void VisitTree(BoundsFilterType &BoundsFilter, FaceVisitorType &FaceVisitor) const
Definition TriangleMeshImplicitObject.h:235
EFilterResult
Definition TriangleMeshImplicitObject.h:50
TArray< FNode > Nodes
Definition TriangleMeshImplicitObject.h:287
TArray< FAABBVectorized > FaceBounds
Definition TriangleMeshImplicitObject.h:288
void Serialize(FChaosArchive &Ar)
Definition TriangleMeshImplicitObject.h:275
FORCEINLINE_DEBUGGABLE void Sweep(const FVec3 &Start, const FVec3 &Dir, const FReal Length, const FVec3 &QueryHalfExtents, SQVisitor &Visitor) const
Definition TriangleMeshImplicitObject.h:148
CHAOS_API TArray< int32 > FindAllIntersections(const FAABB3 &Intersection) const
Definition TriangleMeshImplicitObject.cpp:796
FORCEINLINE_DEBUGGABLE void OverlapOBB(const Private::FOBBVectorized &Obb, SQVisitor &Visitor) const
Definition TriangleMeshImplicitObject.h:194
EVisitorResult
Definition TriangleMeshImplicitObject.h:44
FORCEINLINE_DEBUGGABLE void Raycast(const FVec3 &Start, const FVec3 &Dir, const FReal Length, SQVisitor &Visitor) const
Definition TriangleMeshImplicitObject.h:122
FORCEINLINE_DEBUGGABLE void Overlap(const FAABBVectorized &AABB, SQVisitor &Visitor) const
Definition TriangleMeshImplicitObject.h:176
Definition AABBTree.h:260
CORE_API static const FGuid GUID
Definition ExternalPhysicsCustomObjectVersion.h:144
@ AddTrimeshMaterialIndices
Definition ExternalPhysicsCustomObjectVersion.h:70
@ RemovedConvexHullsFromTriangleMeshImplicitObject
Definition ExternalPhysicsCustomObjectVersion.h:16
@ TrimeshSerializesAABBTree
Definition ExternalPhysicsCustomObjectVersion.h:52
@ TriangleMeshHasFaceIndexMap
Definition ExternalPhysicsCustomObjectVersion.h:112
@ TrimeshSerializesBV
Definition ExternalPhysicsCustomObjectVersion.h:43
@ TrimeshCanUseSmallIndices
Definition ExternalPhysicsCustomObjectVersion.h:97
@ TriangleMeshHasVertexIndexMap
Definition PhysicsObjectVersion.h:25
CORE_API static const FGuid GUID
Definition PhysicsObjectVersion.h:78
CORE_API static const FGuid GUID
Definition UE5MainStreamObjectVersion.h:22
Definition UnrealMathFPU.h:20