UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Tribox.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Chaos/Core.h"
6#include "Chaos/Convex.h"
7
8namespace Chaos
9{
10namespace Private
11{
12
22{
23public :
24
30
31 // Number of planes that will be used to define the Tribox
32 static constexpr int32 NumPlanes = 18;
33
34 // Number of principal planes
35 static constexpr int32 NumPrincipalPlanes = 6;
36
37 // Number of chamfer planes
38 static constexpr int32 NumChamferPlanes = 12;
39
40 // Distance used to inflate the Tribox to avoid degenerate case
41 static constexpr FRealType InflateDistance = 0.5;
42
43 // Base Constructor
44 FORCEINLINE FTribox() : MaxDists(), bIsValid(false), bHasDatas(false)
45 {
47 {
49 }
50 };
51
52 // Base Constructor
53 FORCEINLINE FTribox(const FTribox& OtherTribox) : MaxDists(), bIsValid(false), bHasDatas(false)
54 {
56 {
57 MaxDists[DistsIndex] = OtherTribox.MaxDists[DistsIndex];
58 }
59 bIsValid = OtherTribox.bIsValid;
60 bHasDatas = OtherTribox.bHasDatas;
61 };
62
63 // Get the tribox center
64 FVec3Type GetCenter() const;
65
66 // Get the bounding box
67 FAABB3 GetBounds() const;
68
69 // Get the closest plane along the +X,-X,+Y,-Y,+Z,-Z directions
71
72 // Add a point position to the Tribox
73 void AddPoint(const FVec3Type& PointPosition);
74
75 // Add convex vertices to a tribox
76 void AddConvex(const FConvex* Convex, const FRigidTransform3Type& RelativeTransform);
77
78 // Inflate + Scale the Max distances
79 bool BuildTribox();
80
81 // Find the overlapping tribox
83
84 // Check if the tribox is overlapping or not
85 bool IsTriboxOverlapping(const FTribox& OtherTribox) const;
86
87 // Split the tribox in 2 along a defined cuttng plane
90
91 // Get the thickest tribox slab
92 int32 GetThickestSlab() const;
93
94 // Sample a point along the plane direction in betwen min and max
96
97 // Compute the tribox volume
99
100 // Create a convex from the Tribox
102
103 // Add a tribox to this and return this
105
106 // Add a tribox to this and return a new one
107 FTribox operator+( const FTribox& OtherTribox) const;
108
109 // Check ihe tribox is valid
110 bool IsValid() const {return bIsValid;}
111
112 // Set the valid flag
113 void SetValid(const bool bValid) {bIsValid = bValid;}
114
115 // Check ihe tribox have been built with datas
116 bool HasDatas() const {return bHasDatas;}
117
118 // Reset the tribox max distances
120 {
122 {
124 }
125 }
126
127private :
128 // Solve the intersection point position
129 FVec3 SolveIntersection(const int32 FaceIndex[3], const FMatrix33Type& A) const;
130
131 // Add the intersection point to the list of faces/vertices
132 void AddIntersection(const int32 FaceIndex[3], const int32 FaceOrder[3], const FVec3Type& VertexPosition, TArray<TArray<int32>>& FaceIndices, TArray<FConvex::FVec3Type>& ConvexVertices) const;
133
134 // Solve and add the intersection point in between the 3 planes
136
137 // Build the max dist along the principal axis
138 void BuildPrincipalDist(const FVec3Type& P, const int32 CoordIndexA, const int32 DistsIndexA, const int32 DistsIndexB);
139
140 // Build the max dist along the chamfer axis
141 void BuildChamferDist(const FVec3Type& P, const int32 CoordIndexA, const int32 CoordIndexB,
143
144 // Create a FConvex from a list of convex planes, face indices and convex vertices
147
148 // Max distance along eaxh tribox axis (principal + chamfer)
154
155 // Boolean to specify if the tribox is valid or not
156 bool bIsValid = false;
157
158 // Boolean to specify if the tribox has been built with datas or not
159 bool bHasDatas = false;
160};
161
162}
163}
#define FORCEINLINE
Definition AndroidPlatform.h:140
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
Definition Convex.h:26
Definition Matrix.h:21
Tribox object that represents a k-DOP18 convex.
Definition Tribox.h:22
int32 GetThickestSlab() const
Definition Tribox.cpp:569
FRealType SampleSlabPoint(const int32 PlaneAxis, const FRealType &LocalDistance) const
Definition Tribox.cpp:585
void ResetDists()
Definition Tribox.h:119
FTribox & operator+=(const FTribox &OtherTribox)
Definition Tribox.cpp:627
FImplicitObjectPtr MakeConvex() const
Definition Tribox.cpp:414
bool SplitTriboxSlab(const int32 PlaneAxis, const FRealType &PlaneDistance, FTribox &LeftTribox, FTribox &RightTribox) const
Definition Tribox.cpp:505
bool BuildTribox()
Definition Tribox.cpp:325
void SetValid(const bool bValid)
Definition Tribox.h:113
PMatrix< FRealType, 3, 3 > FMatrix33Type
Definition Tribox.h:28
static constexpr FRealType InflateDistance
Definition Tribox.h:41
static constexpr int32 NumChamferPlanes
Definition Tribox.h:38
TRigidTransform< FRealType, 3 > FRigidTransform3Type
Definition Tribox.h:27
FAABB3 GetBounds() const
Definition Tribox.cpp:486
void AddPoint(const FVec3Type &PointPosition)
Definition Tribox.cpp:292
static constexpr int32 NumPrincipalPlanes
Definition Tribox.h:35
FTribox operator+(const FTribox &OtherTribox) const
Definition Tribox.cpp:637
FORCEINLINE FTribox()
Definition Tribox.h:44
bool IsValid() const
Definition Tribox.h:110
FRealType GetClosestPlane(const FVec3Type &PointPosition, int32 &PlaneAxis, FRealType &PlaneProjection) const
Definition Tribox.cpp:590
FORCEINLINE FTribox(const FTribox &OtherTribox)
Definition Tribox.h:53
static constexpr int32 NumPlanes
Definition Tribox.h:32
bool OverlapTribox(const FTribox &OtherTribox, FTribox &OverlapTribox) const
Definition Tribox.cpp:491
FRealType ComputeVolume() const
Definition Tribox.cpp:614
bool HasDatas() const
Definition Tribox.h:116
FRealSingle FRealType
Definition Tribox.h:25
void AddConvex(const FConvex *Convex, const FRigidTransform3Type &RelativeTransform)
Definition Tribox.cpp:310
FVec3Type GetCenter() const
Definition Tribox.cpp:622
TVec3< FRealType > FVec3Type
Definition Tribox.h:26
bool IsTriboxOverlapping(const FTribox &OtherTribox) const
Definition Tribox.cpp:473
Definition CorePlane.h:12
Definition Transform.h:115
Definition Vector.h:1000
Definition Array.h:670
Definition SkeletalMeshComponent.h:307
float FRealSingle
Definition Real.h:14
Definition OverriddenPropertySet.cpp:45
@ false
Definition radaudio_common.h:23
Definition NumericLimits.h:41