UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FMeshNormals Class Reference

#include <MeshNormals.h>

Public Member Functions

 FMeshNormals ()
 
 FMeshNormals (const FDynamicMesh3 *Mesh)
 
void SetMesh (const FDynamicMesh3 *MeshIn)
 
const TArray< FVector3d > & GetNormals () const
 
FVector3doperator[] (int i)
 
const FVector3doperator[] (int i) const
 
GEOMETRYCORE_API void SetCount (int Count, bool bClearToZero)
 
void ComputeVertexNormals (bool bWeightByArea=true, bool bWeightByAngle=true)
 
void ComputeTriangleNormals ()
 
GEOMETRYCORE_API void SetDegenerateTriangleNormalsToNeighborNormal ()
 
void RecomputeOverlayNormals (const FDynamicMeshNormalOverlay *NormalOverlay, bool bWeightByArea=true, bool bWeightByAngle=true)
 
GEOMETRYCORE_API void CopyToVertexNormals (FDynamicMesh3 *SetMesh, bool bInvert=false) const
 
GEOMETRYCORE_API void CopyToOverlay (FDynamicMeshNormalOverlay *NormalOverlay, bool bInvert=false) const
 

Static Public Member Functions

static GEOMETRYCORE_API void QuickComputeVertexNormals (FDynamicMesh3 &Mesh, bool bInvert=false)
 
static GEOMETRYCORE_API void SmoothVertexNormals (FDynamicMesh3 &Mesh, int32 SmoothingRounds, double SmoothingAlpha)
 
static GEOMETRYCORE_API void QuickComputeVertexNormalsForTriangles (FDynamicMesh3 &Mesh, const TArray< int32 > &Triangles, bool bWeightByArea=true, bool bWeightByAngle=true, bool bInvert=false)
 
static GEOMETRYCORE_API FVector3d ComputeVertexNormal (const FDynamicMesh3 &Mesh, int VertIdx, bool bWeightByArea=true, bool bWeightByAngle=true)
 
static GEOMETRYCORE_API FVector3d ComputeVertexNormal (const FDynamicMesh3 &Mesh, int32 VertIdx, TFunctionRef< bool(int32)> TriangleFilterFunc, bool bWeightByArea=true, bool bWeightByAngle=true)
 
static GEOMETRYCORE_API FVector3d ComputeOverlayNormal (const FDynamicMesh3 &Mesh, const FDynamicMeshNormalOverlay *NormalOverlay, int ElemIdx, bool bWeightByArea=true, bool bWeightByAngle=true)
 
static GEOMETRYCORE_API void InitializeOverlayToPerVertexNormals (FDynamicMeshNormalOverlay *NormalOverlay, bool bUseMeshVertexNormalsIfAvailable=true)
 
static GEOMETRYCORE_API void InitializeOverlayToPerTriangleNormals (FDynamicMeshNormalOverlay *NormalOverlay)
 
static GEOMETRYCORE_API void InitializeOverlayTopologyFromOpeningAngle (const FDynamicMesh3 *Mesh, FDynamicMeshNormalOverlay *NormalOverlay, double AngleThresholdDeg)
 
static GEOMETRYCORE_API void InitializeOverlayTopologyFromFaceGroups (const FDynamicMesh3 *Mesh, FDynamicMeshNormalOverlay *NormalOverlay)
 
static GEOMETRYCORE_API void InitializeMeshToPerTriangleNormals (FDynamicMesh3 *Mesh)
 
static GEOMETRYCORE_API void InitializeOverlayRegionToPerVertexNormals (FDynamicMeshNormalOverlay *NormalOverlay, const TArray< int32 > &Triangles)
 
static GEOMETRYCORE_API bool QuickRecomputeOverlayNormals (FDynamicMesh3 &Mesh, bool bInvert=false, bool bWeightByArea=true, bool bWeightByAngle=true, bool bParallelCompute=true)
 
static GEOMETRYCORE_API bool RecomputeOverlayTriNormals (FDynamicMesh3 &Mesh, const TArray< int32 > &Triangles, bool bWeightByArea=true, bool bWeightByAngle=true)
 
static GEOMETRYCORE_API bool RecomputeOverlayElementNormals (FDynamicMesh3 &Mesh, const TArray< int32 > &ElementIDs, bool bWeightByArea=true, bool bWeightByAngle=true)
 
static GEOMETRYCORE_API FVector3d GetVertexWeightsOnTriangle (const FDynamicMesh3 *Mesh, int TriID, double TriArea, bool bWeightByArea, bool bWeightByAngle)
 

Protected Member Functions

GEOMETRYCORE_API void Compute_FaceAvg_AreaWeighted ()
 
GEOMETRYCORE_API void Compute_FaceAvg (bool bWeightByArea, bool bWeightByAngle)
 
GEOMETRYCORE_API void Compute_Triangle ()
 
GEOMETRYCORE_API void Compute_Overlay_FaceAvg_AreaWeighted (const FDynamicMeshNormalOverlay *NormalOverlay)
 
GEOMETRYCORE_API void Compute_Overlay_FaceAvg (const FDynamicMeshNormalOverlay *NormalOverlay, bool bWeightByArea, bool bWeightByAngle)
 

Protected Attributes

const FDynamicMesh3Mesh
 
TArray< FVector3dNormals
 

Detailed Description

FMeshNormals is a utility class that can calculate and store various types of normal vectors for a FDynamicMesh.

Constructor & Destructor Documentation

◆ FMeshNormals() [1/2]

UE::Geometry::FMeshNormals::FMeshNormals ( )
inline

◆ FMeshNormals() [2/2]

UE::Geometry::FMeshNormals::FMeshNormals ( const FDynamicMesh3 Mesh)
inline

Member Function Documentation

◆ Compute_FaceAvg()

void FMeshNormals::Compute_FaceAvg ( bool  bWeightByArea,
bool  bWeightByAngle 
)
protected

Compute per-vertex normals using a custom combination of area-weighted and angle-weighted averaging of one-ring triangle normals

◆ Compute_FaceAvg_AreaWeighted()

void FMeshNormals::Compute_FaceAvg_AreaWeighted ( )
protected

Compute per-vertex normals using area-weighted averaging of one-ring triangle normals

◆ Compute_Overlay_FaceAvg()

void FMeshNormals::Compute_Overlay_FaceAvg ( const FDynamicMeshNormalOverlay NormalOverlay,
bool  bWeightByArea,
bool  bWeightByAngle 
)
protected

Recompute the element Normals of the given attribute overlay using a custom combination of area-weighted and angle-weighted averaging of one-ring triangle normals

◆ Compute_Overlay_FaceAvg_AreaWeighted()

void FMeshNormals::Compute_Overlay_FaceAvg_AreaWeighted ( const FDynamicMeshNormalOverlay NormalOverlay)
protected

Recompute the element Normals of the given attribute overlay using area-weighted averaging of one-ring triangle normals

◆ Compute_Triangle()

void FMeshNormals::Compute_Triangle ( )
protected

Compute per-triangle normals

◆ ComputeOverlayNormal()

FVector3d FMeshNormals::ComputeOverlayNormal ( const FDynamicMesh3 Mesh,
const FDynamicMeshNormalOverlay NormalOverlay,
int  ElemIdx,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
static
Returns
the computed overlay normal at an element of the overlay (ie based on normals of triangles connected to this element)
Parameters
bWeightByAreaweight neighbor triangles by area
bWeightByAngleweight neighbor triangles by angle

◆ ComputeTriangleNormals()

void UE::Geometry::FMeshNormals::ComputeTriangleNormals ( )
inline

Compute per-triangle normals

◆ ComputeVertexNormal() [1/2]

FVector3d FMeshNormals::ComputeVertexNormal ( const FDynamicMesh3 Mesh,
int  VertIdx,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
static

Compute normal at mesh vertex by weighted sum of one-ring triangle normals. Can optionally weight by area, angle, or both (averaged)

Parameters
bWeightByAreaweight neighbor triangles by area
bWeightByAngleweight neighbor triangles by angle
Returns
the vertex normal at vertex VertIdx of Mesh.

◆ ComputeVertexNormal() [2/2]

FVector3d FMeshNormals::ComputeVertexNormal ( const FDynamicMesh3 Mesh,
int32  VertIdx,
TFunctionRef< bool(int32)>  TriangleFilterFunc,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
static

Compute normal at mesh vertex by weighted sum of subset of one-ring triangle normals. Can optionally weight by area, angle, or both (averaged)

Parameters
TriangleFilterFuncOnly one-ring triangles for which this function returns true will be included
bWeightByAreaweight neighbor triangles by area
bWeightByAngleweight neighbor triangles by angle
Returns
the vertex normal at vertex VertIdx of Mesh.

◆ ComputeVertexNormals()

void UE::Geometry::FMeshNormals::ComputeVertexNormals ( bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
inline

Compute standard per-vertex normals by averaging one-ring face normals

◆ CopyToOverlay()

void FMeshNormals::CopyToOverlay ( FDynamicMeshNormalOverlay NormalOverlay,
bool  bInvert = false 
) const

Copy the current set of normals to the NormalOverlay attribute layer

Warning
assumes that the computed normals are attribute normals
Parameters
bInvertif true, normals are flipped

◆ CopyToVertexNormals()

void FMeshNormals::CopyToVertexNormals ( FDynamicMesh3 SetMesh,
bool  bInvert = false 
) const

Copy the current set of normals to the vertex normals of SetMesh

Warning
assumes that the computed normals are vertex normals
Parameters
bInvertif true, normals are flipped

◆ GetNormals()

const TArray< FVector3d > & UE::Geometry::FMeshNormals::GetNormals ( ) const
inline

◆ GetVertexWeightsOnTriangle()

FVector3d FMeshNormals::GetVertexWeightsOnTriangle ( const FDynamicMesh3 Mesh,
int  TriID,
double  TriArea,
bool  bWeightByArea,
bool  bWeightByAngle 
)
static

Retrieve the area and/or angle weights for each vertex of a triangle

Parameters
Meshthe mesh to query
TriIDthe triangle index of the mesh to query
TriAreathe area of the triangle
bWeightByAreaif true, include weighting by the area of the triangle
bWeightByAngleif true, include weighting by the interior angles of the triangle

◆ InitializeMeshToPerTriangleNormals()

void FMeshNormals::InitializeMeshToPerTriangleNormals ( FDynamicMesh3 Mesh)
static

Initialize the given Mesh with per-face normals, ie separate overlay element for each vertex of each triangle.

◆ InitializeOverlayRegionToPerVertexNormals()

void FMeshNormals::InitializeOverlayRegionToPerVertexNormals ( FDynamicMeshNormalOverlay NormalOverlay,
const TArray< int32 > &  Triangles 
)
static

Initialize the given triangles of NormalOverlay with per-vertex normals, ie single overlay element for each mesh vertex. Only the triangles included in the region are considered when calculating per-vertex normals.

◆ InitializeOverlayToPerTriangleNormals()

void FMeshNormals::InitializeOverlayToPerTriangleNormals ( FDynamicMeshNormalOverlay NormalOverlay)
static

Initialize the given NormalOverlay with per-face normals, ie separate overlay element for each vertex of each triangle.

◆ InitializeOverlayToPerVertexNormals()

void FMeshNormals::InitializeOverlayToPerVertexNormals ( FDynamicMeshNormalOverlay NormalOverlay,
bool  bUseMeshVertexNormalsIfAvailable = true 
)
static

Initialize the given NormalOverlay with per-vertex normals, ie single overlay element for each mesh vertex.

Parameters
bUseMeshVertexNormalsIfAvailableif true and the parent mesh has per-vertex normals, use them instead of calculating new ones

◆ InitializeOverlayTopologyFromFaceGroups()

void FMeshNormals::InitializeOverlayTopologyFromFaceGroups ( const FDynamicMesh3 Mesh,
FDynamicMeshNormalOverlay NormalOverlay 
)
static

◆ InitializeOverlayTopologyFromOpeningAngle()

void FMeshNormals::InitializeOverlayTopologyFromOpeningAngle ( const FDynamicMesh3 Mesh,
FDynamicMeshNormalOverlay NormalOverlay,
double  AngleThresholdDeg 
)
static

◆ operator[]() [1/2]

FVector3d & UE::Geometry::FMeshNormals::operator[] ( int  i)
inline

◆ operator[]() [2/2]

const FVector3d & UE::Geometry::FMeshNormals::operator[] ( int  i) const
inline

◆ QuickComputeVertexNormals()

void FMeshNormals::QuickComputeVertexNormals ( FDynamicMesh3 Mesh,
bool  bInvert = false 
)
static

Compute per-vertex normals for the given Mesh

Parameters
bInvertif true, normals are flipped

◆ QuickComputeVertexNormalsForTriangles()

void FMeshNormals::QuickComputeVertexNormalsForTriangles ( FDynamicMesh3 Mesh,
const TArray< int32 > &  Triangles,
bool  bWeightByArea = true,
bool  bWeightByAngle = true,
bool  bInvert = false 
)
static

Compute per-vertex normals for the vertices of a set of triangles of a Mesh

Parameters
bWeightByAreaweight neighbor triangles by area
bWeightByAngleweight neighbor triangles by angle
bInvertif true, normals are flipped

◆ QuickRecomputeOverlayNormals()

bool FMeshNormals::QuickRecomputeOverlayNormals ( FDynamicMesh3 Mesh,
bool  bInvert = false,
bool  bWeightByArea = true,
bool  bWeightByAngle = true,
bool  bParallelCompute = true 
)
static

Compute overlay normals for the given mesh

Parameters
bInvertif true, normals are flipped

◆ RecomputeOverlayElementNormals()

bool FMeshNormals::RecomputeOverlayElementNormals ( FDynamicMesh3 Mesh,
const TArray< int32 > &  ElementIDs,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
static

Compute overlay normals for the given mesh, for the given set of element IDs

◆ RecomputeOverlayNormals()

void UE::Geometry::FMeshNormals::RecomputeOverlayNormals ( const FDynamicMeshNormalOverlay NormalOverlay,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
inline

Recompute the per-element normals of the given overlay by averaging one-ring face normals

Warning
NormalOverlay must be attached to ParentMesh or an exact copy

◆ RecomputeOverlayTriNormals()

bool FMeshNormals::RecomputeOverlayTriNormals ( FDynamicMesh3 Mesh,
const TArray< int32 > &  Triangles,
bool  bWeightByArea = true,
bool  bWeightByAngle = true 
)
static

Compute overlay normals for the given mesh, for the given set of triangles

◆ SetCount()

void FMeshNormals::SetCount ( int  Count,
bool  bClearToZero 
)

Set the size of the Normals array to Count, and optionally clear all values to (0,0,0)

◆ SetDegenerateTriangleNormalsToNeighborNormal()

void FMeshNormals::SetDegenerateTriangleNormalsToNeighborNormal ( )

Assumes that ComputeTriangleNormals() has already been run.

Looks through the normals for any that are zero, and tries to set them to the normal of some neighboring triangle, preferring the triangle on its longer side if possible. This is useful for finding connected components based on normals, as it prevents degenerate triangles with 0 normals from connecting otherwise disconnected components. This won't help if a whole mesh componenent is entirely made of such degenerate triangles (which is usually ok).

◆ SetMesh()

void UE::Geometry::FMeshNormals::SetMesh ( const FDynamicMesh3 MeshIn)
inline

◆ SmoothVertexNormals()

void FMeshNormals::SmoothVertexNormals ( FDynamicMesh3 Mesh,
int32  SmoothingRounds,
double  SmoothingAlpha 
)
static

Apply rounds of explicit uniform-weighted normal smoothing to the VertexNormals attribute of the given Mesh.

Member Data Documentation

◆ Mesh

const FDynamicMesh3* UE::Geometry::FMeshNormals::Mesh
protected

Target Mesh

◆ Normals

TArray<FVector3d> UE::Geometry::FMeshNormals::Normals
protected

Set of computed normals


The documentation for this class was generated from the following files: