UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ColliderMesh.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "IndexTypes.h"
7#include "Math/Ray.h"
9#include "Math/Vector.h"
13#include "Templates/Function.h"
14#include "VectorUtil.h"
15
16namespace UE
17{
18namespace Geometry
19{
20
21class FDynamicMesh3;
22
43{
44public:
46 {
48 {
49 bBuildAABBTree = true;
50 bBuildVertexMap = false;
51 bBuildTriangleMap = false;
52 }
53
60 };
61
62public:
65
67
74
75 // mesh API required for TMeshAABBTree3
76 bool IsTriangle(int32 TriangleID) const { return TriangleID >= 0 && TriangleID < Triangles.Num(); }
77 bool IsVertex(int32 VertexID) const { return VertexID >= 0 && VertexID < Vertices.Num(); }
78 int32 MaxTriangleID() const { return Triangles.Num(); }
79 int32 MaxVertexID() const { return Vertices.Num(); }
80 int32 TriangleCount() const { return Triangles.Num(); }
81 int32 VertexCount() const { return Vertices.Num(); }
82 uint64 GetChangeStamp() const { return 0; }
83 FIndex3i GetTriangle(int32 TriangleID) const { return Triangles[TriangleID]; }
84 FVector3d GetVertex(int32 VertexID) const { return Vertices[VertexID]; }
85
86 void GetTriVertices(int32 TriangleID, FVector3d& V0, FVector3d& V1, FVector3d& V2) const
87 {
88 FIndex3i Tri = Triangles[TriangleID];
89 V0 = Vertices[Tri.A];
90 V1 = Vertices[Tri.B];
91 V2 = Vertices[Tri.C];
92 }
93
94 FVector3d GetTriNormal(int32 TriangleID) const
95 {
96 FIndex3i Tri = Triangles[TriangleID];
97 return VectorUtil::Normal(Vertices[Tri.A], Vertices[Tri.B], Vertices[Tri.C]);
98 }
99
100 bool SourceWasCompactV() const { return bSourceWasCompactV; }
101 bool HasVertexIDMap() const { return SourceVertexIDs.Num() > 0 && SourceVertexIDs.Num() == Vertices.Num(); }
103 bool SourceWasCompactT() const { return bSourceWasCompactT; }
104 bool HasTriangleIDMap() const { return SourceTriangleIDs.Num() > 0 && SourceTriangleIDs.Num() == Triangles.Num(); }
106
107 // spatial APIs
108
114
115
122
123
129
130
131
132
133protected:
134 // For large meshes it might be better to optionally use TDynamicVector here (but keeping the TArray for
135 // small meshes is still also desirable due to minimum-size). Adds a branch to every access, though.
138
143
145
146};
147
148
173
174
175
176} // end namespace UE::Geometry
177} // end namespace UE
178
179
180
181
182
EAllowShrinking
Definition AllowShrinking.h:10
#define UE_ALLOWSHRINKING_BOOL_DEPRECATED(FunctionName)
Definition AllowShrinking.h:31
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition ColliderMesh.h:153
FColliderMesh * ColliderMesh
Definition ColliderMesh.h:155
FColliderMeshProjectionTarget(FColliderMesh *ColliderMeshIn)
Definition ColliderMesh.h:162
virtual ~FColliderMeshProjectionTarget()
Definition ColliderMesh.h:168
FColliderMeshProjectionTarget()
Definition ColliderMesh.h:157
Definition ColliderMesh.h:43
uint64 GetChangeStamp() const
Definition ColliderMesh.h:82
FIndex3i GetTriangle(int32 TriangleID) const
Definition ColliderMesh.h:83
int32 MaxTriangleID() const
Definition ColliderMesh.h:78
GEOMETRYCORE_API TMeshAABBTree3< FColliderMesh > * GetRawAABBTreeUnsafe()
Definition ColliderMesh.cpp:106
TArray< int32 > SourceVertexIDs
Definition ColliderMesh.h:139
bool HasVertexIDMap() const
Definition ColliderMesh.h:101
GEOMETRYCORE_API FColliderMesh()
Definition ColliderMesh.cpp:15
FVector3d GetVertex(int32 VertexID) const
Definition ColliderMesh.h:84
bool IsVertex(int32 VertexID) const
Definition ColliderMesh.h:77
TArray< FIndex3i > Triangles
Definition ColliderMesh.h:137
bool bSourceWasCompactV
Definition ColliderMesh.h:140
bool IsTriangle(int32 TriangleID) const
Definition ColliderMesh.h:76
bool HasTriangleIDMap() const
Definition ColliderMesh.h:104
TArray< FVector3d > Vertices
Definition ColliderMesh.h:136
bool bSourceWasCompactT
Definition ColliderMesh.h:142
void GetTriVertices(int32 TriangleID, FVector3d &V0, FVector3d &V1, FVector3d &V2) const
Definition ColliderMesh.h:86
TArray< int32 > SourceTriangleIDs
Definition ColliderMesh.h:141
GEOMETRYCORE_API bool FindNearestHitTriangle(const FRay3d &Ray, double &RayParameterOut, int &HitTriangleIDOut, FVector3d &BaryCoordsOut, const IMeshSpatial::FQueryOptions &Options=IMeshSpatial::FQueryOptions()) const
Definition ColliderMesh.cpp:112
int32 TriangleCount() const
Definition ColliderMesh.h:80
GEOMETRYCORE_API int32 GetSourceVertexID(int32 VertexID) const
Definition ColliderMesh.cpp:132
int32 MaxVertexID() const
Definition ColliderMesh.h:79
int32 VertexCount() const
Definition ColliderMesh.h:81
TMeshAABBTree3< FColliderMesh > AABBTree
Definition ColliderMesh.h:144
GEOMETRYCORE_API int FindNearestTriangle(const FVector3d &Point, double &NearestDistSqrOut, const IMeshSpatial::FQueryOptions &Options=IMeshSpatial::FQueryOptions()) const
Definition ColliderMesh.cpp:122
bool SourceWasCompactT() const
Definition ColliderMesh.h:103
GEOMETRYCORE_API int32 GetSourceTriangleID(int32 TriangleID) const
Definition ColliderMesh.cpp:144
bool SourceWasCompactV() const
Definition ColliderMesh.h:100
FVector3d GetTriNormal(int32 TriangleID) const
Definition ColliderMesh.h:94
Definition DynamicMesh3.h:108
Definition SpatialInterfaces.h:171
Definition MeshAABBTree3.h:61
TVector< RealType > Normal(const TVector< RealType > &V0, const TVector< RealType > &V1, const TVector< RealType > &V2)
Definition VectorUtil.h:70
Definition AdvancedWidgetsModule.cpp:13
Definition ColliderMesh.h:46
bool bBuildTriangleMap
Definition ColliderMesh.h:59
FBuildOptions()
Definition ColliderMesh.h:47
bool bBuildAABBTree
Definition ColliderMesh.h:55
bool bBuildVertexMap
Definition ColliderMesh.h:57
Definition IndexTypes.h:158
int B
Definition IndexTypes.h:164
int A
Definition IndexTypes.h:163
int C
Definition IndexTypes.h:165
Definition SpatialInterfaces.h:57