UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshNormals.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3Sharp MeshNormals
4
5#pragma once
6
7#include "Containers/Array.h"
8#include "DynamicMesh3.h"
10#include "Math/UnrealMathSSE.h"
11#include "Math/Vector.h"
12
13template <typename FuncType> class TFunctionRef;
14
15namespace UE
16{
17namespace Geometry
18{
19
20
26{
27protected:
32
33public:
35 {
36 Mesh = nullptr;
37 }
38
40 {
42 }
43
44
46 {
47 this->Mesh = MeshIn;
48 }
49
50 const TArray<FVector3d>& GetNormals() const { return Normals; }
51
52 FVector3d& operator[](int i) { return Normals[i]; }
53 const FVector3d& operator[](int i) const { return Normals[i]; }
54
55
60
68
76
88
93 void RecomputeOverlayNormals(const FDynamicMeshNormalOverlay* NormalOverlay, bool bWeightByArea = true, bool bWeightByAngle = true)
94 {
96 }
97
98
104 GEOMETRYCORE_API void CopyToVertexNormals(FDynamicMesh3* SetMesh, bool bInvert = false) const;
105
111 GEOMETRYCORE_API void CopyToOverlay(FDynamicMeshNormalOverlay* NormalOverlay, bool bInvert = false) const;
112
113
118 static GEOMETRYCORE_API void QuickComputeVertexNormals(FDynamicMesh3& Mesh, bool bInvert = false);
119
120
125
126
133 static GEOMETRYCORE_API void QuickComputeVertexNormalsForTriangles(FDynamicMesh3& Mesh, const TArray<int32>& Triangles, bool bWeightByArea = true, bool bWeightByAngle = true, bool bInvert = false);
134
135
143
152
153
159 static GEOMETRYCORE_API FVector3d ComputeOverlayNormal(const FDynamicMesh3& Mesh, const FDynamicMeshNormalOverlay* NormalOverlay, int ElemIdx, bool bWeightByArea = true, bool bWeightByAngle = true);
160
166
167
172
173
175 double AngleThresholdDeg);
176
178
179
184
185
191
196 static GEOMETRYCORE_API bool QuickRecomputeOverlayNormals(FDynamicMesh3& Mesh, bool bInvert = false, bool bWeightByArea = true, bool bWeightByAngle = true, bool bParallelCompute = true);
197
201 static GEOMETRYCORE_API bool RecomputeOverlayTriNormals(FDynamicMesh3& Mesh, const TArray<int32>& Triangles, bool bWeightByArea = true, bool bWeightByAngle = true);
202
207
217
218protected:
223
226
231
232};
233
234
235} // end namespace UE::Geometry
236} // end namespace UE
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 Array.h:670
Definition AssetRegistryState.h:50
Definition DynamicMesh3.h:108
Definition MeshNormals.h:26
static GEOMETRYCORE_API bool QuickRecomputeOverlayNormals(FDynamicMesh3 &Mesh, bool bInvert=false, bool bWeightByArea=true, bool bWeightByAngle=true, bool bParallelCompute=true)
Definition MeshNormals.cpp:417
static GEOMETRYCORE_API void InitializeOverlayToPerTriangleNormals(FDynamicMeshNormalOverlay *NormalOverlay)
Definition MeshNormals.cpp:626
GEOMETRYCORE_API void CopyToOverlay(FDynamicMeshNormalOverlay *NormalOverlay, bool bInvert=false) const
Definition MeshNormals.cpp:49
static GEOMETRYCORE_API void SmoothVertexNormals(FDynamicMesh3 &Mesh, int32 SmoothingRounds, double SmoothingAlpha)
Definition MeshNormals.cpp:334
static GEOMETRYCORE_API void InitializeOverlayTopologyFromOpeningAngle(const FDynamicMesh3 *Mesh, FDynamicMeshNormalOverlay *NormalOverlay, double AngleThresholdDeg)
Definition MeshNormals.cpp:643
void RecomputeOverlayNormals(const FDynamicMeshNormalOverlay *NormalOverlay, bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.h:93
const FVector3d & operator[](int i) const
Definition MeshNormals.h:53
GEOMETRYCORE_API void SetCount(int Count, bool bClearToZero)
Definition MeshNormals.cpp:15
void SetMesh(const FDynamicMesh3 *MeshIn)
Definition MeshNormals.h:45
GEOMETRYCORE_API void CopyToVertexNormals(FDynamicMesh3 *SetMesh, bool bInvert=false) const
Definition MeshNormals.cpp:29
static GEOMETRYCORE_API FVector3d ComputeOverlayNormal(const FDynamicMesh3 &Mesh, const FDynamicMeshNormalOverlay *NormalOverlay, int ElemIdx, bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.cpp:570
static GEOMETRYCORE_API void InitializeOverlayToPerVertexNormals(FDynamicMeshNormalOverlay *NormalOverlay, bool bUseMeshVertexNormalsIfAvailable=true)
Definition MeshNormals.cpp:593
static GEOMETRYCORE_API bool RecomputeOverlayElementNormals(FDynamicMesh3 &Mesh, const TArray< int32 > &ElementIDs, bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.cpp:512
GEOMETRYCORE_API void Compute_FaceAvg(bool bWeightByArea, bool bWeightByAngle)
Definition MeshNormals.cpp:81
const FDynamicMesh3 * Mesh
Definition MeshNormals.h:29
GEOMETRYCORE_API void Compute_Overlay_FaceAvg_AreaWeighted(const FDynamicMeshNormalOverlay *NormalOverlay)
Definition MeshNormals.cpp:299
static GEOMETRYCORE_API void InitializeOverlayTopologyFromFaceGroups(const FDynamicMesh3 *Mesh, FDynamicMeshNormalOverlay *NormalOverlay)
Definition MeshNormals.cpp:656
GEOMETRYCORE_API void SetDegenerateTriangleNormalsToNeighborNormal()
Definition MeshNormals.cpp:123
static GEOMETRYCORE_API void QuickComputeVertexNormalsForTriangles(FDynamicMesh3 &Mesh, const TArray< int32 > &Triangles, bool bWeightByArea=true, bool bWeightByAngle=true, bool bInvert=false)
Definition MeshNormals.cpp:375
static GEOMETRYCORE_API void QuickComputeVertexNormals(FDynamicMesh3 &Mesh, bool bInvert=false)
Definition MeshNormals.cpp:326
void ComputeVertexNormals(bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.h:64
void ComputeTriangleNormals()
Definition MeshNormals.h:72
GEOMETRYCORE_API void Compute_Overlay_FaceAvg(const FDynamicMeshNormalOverlay *NormalOverlay, bool bWeightByArea, bool bWeightByAngle)
Definition MeshNormals.cpp:260
static GEOMETRYCORE_API void InitializeOverlayRegionToPerVertexNormals(FDynamicMeshNormalOverlay *NormalOverlay, const TArray< int32 > &Triangles)
Definition MeshNormals.cpp:677
FMeshNormals()
Definition MeshNormals.h:34
const TArray< FVector3d > & GetNormals() const
Definition MeshNormals.h:50
TArray< FVector3d > Normals
Definition MeshNormals.h:31
FVector3d & operator[](int i)
Definition MeshNormals.h:52
static GEOMETRYCORE_API FVector3d GetVertexWeightsOnTriangle(const FDynamicMesh3 *Mesh, int TriID, double TriArea, bool bWeightByArea, bool bWeightByAngle)
Definition MeshNormals.cpp:713
GEOMETRYCORE_API void Compute_Triangle()
Definition MeshNormals.cpp:110
static GEOMETRYCORE_API void InitializeMeshToPerTriangleNormals(FDynamicMesh3 *Mesh)
Definition MeshNormals.cpp:665
FMeshNormals(const FDynamicMesh3 *Mesh)
Definition MeshNormals.h:39
static GEOMETRYCORE_API bool RecomputeOverlayTriNormals(FDynamicMesh3 &Mesh, const TArray< int32 > &Triangles, bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.cpp:490
static GEOMETRYCORE_API FVector3d ComputeVertexNormal(const FDynamicMesh3 &Mesh, int VertIdx, bool bWeightByArea=true, bool bWeightByAngle=true)
Definition MeshNormals.cpp:532
GEOMETRYCORE_API void Compute_FaceAvg_AreaWeighted()
Definition MeshNormals.cpp:59
Definition DynamicMeshOverlay.h:714
Definition AdvancedWidgetsModule.cpp:13