UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FStaticMeshOperations Class Reference

#include <StaticMeshOperations.h>

+ Inheritance diagram for FStaticMeshOperations:

Classes

struct  FAppendSettings
 
struct  FGenerateUVOptions
 

Public Types

enum class  EGenerateUVMethod {
  Default , Legacy , UVAtlas , XAtlas ,
  PatchBuilder
}
 

Static Public Member Functions

static STATICMESHDESCRIPTION_API void ComputeTriangleTangentsAndNormals (FMeshDescription &MeshDescription, float ComparisonThreshold=0.0f, const TCHAR *DebugName=nullptr)
 
static STATICMESHDESCRIPTION_API void ComputeTangentsAndNormals (FMeshDescription &MeshDescription, EComputeNTBsFlags ComputeNTBsOptions)
 
static STATICMESHDESCRIPTION_API void RecomputeNormalsAndTangentsIfNeeded (FMeshDescription &MeshDescription, EComputeNTBsFlags ComputeNTBsOptions)
 
static STATICMESHDESCRIPTION_API void ComputeMikktTangents (FMeshDescription &MeshDescription, bool bIgnoreDegenerateTriangles)
 
static STATICMESHDESCRIPTION_API void DetermineEdgeHardnessesFromVertexInstanceNormals (FMeshDescription &MeshDescription, float Tolerance=UE_KINDA_SMALL_NUMBER)
 
static STATICMESHDESCRIPTION_API void ConvertToRawMesh (const FMeshDescription &SourceMeshDescription, FRawMesh &DestinationRawMesh, const TMap< FName, int32 > &MaterialMap)
 
static STATICMESHDESCRIPTION_API void ConvertFromRawMesh (const FRawMesh &SourceRawMesh, FMeshDescription &DestinationMeshDescription, const TMap< int32, FName > &MaterialMap, bool bSkipNormalsAndTangents=false, const TCHAR *DebugName=nullptr)
 
static STATICMESHDESCRIPTION_API void AppendMeshDescription (const FMeshDescription &SourceMesh, FMeshDescription &TargetMesh, const FAppendSettings &AppendSettings)
 
static STATICMESHDESCRIPTION_API void AppendMeshDescriptions (const TArray< const FMeshDescription * > &SourceMeshes, FMeshDescription &TargetMesh, const FAppendSettings &AppendSettings)
 
static STATICMESHDESCRIPTION_API void HasInvalidVertexInstanceNormalsOrTangents (const FMeshDescription &MeshDescription, bool &bHasInvalidNormals, bool &bHasInvalidTangents)
 
static void AreNormalsAndTangentsValid (const FMeshDescription &MeshDescription, bool &bHasInvalidNormals, bool &bHasInvalidTangents)
 
static STATICMESHDESCRIPTION_API void FindOverlappingCorners (FOverlappingCorners &OverlappingCorners, const FMeshDescription &MeshDescription, float ComparisonThreshold)
 
static STATICMESHDESCRIPTION_API int32 GetUVChartCount (FMeshDescription &MeshDescription, int32 SrcLightmapIndex, ELightmapUVVersion LightmapUVVersion, const FOverlappingCorners &OverlappingCorners)
 
static STATICMESHDESCRIPTION_API bool CreateLightMapUVLayout (FMeshDescription &MeshDescription, int32 SrcLightmapIndex, int32 DstLightmapIndex, int32 MinLightmapResolution, ELightmapUVVersion LightmapUVVersion, const FOverlappingCorners &OverlappingCorners)
 
static STATICMESHDESCRIPTION_API bool GenerateUniqueUVsForStaticMesh (const FMeshDescription &MeshDescription, int32 TextureResolution, bool bMergeIdenticalMaterials, TArray< FVector2D > &OutTexCoords)
 
static STATICMESHDESCRIPTION_API bool GenerateUV (const FMeshDescription &MeshDescription, const FGenerateUVOptions &Options, TArray< FVector2D > &OutTexCoords)
 
static STATICMESHDESCRIPTION_API bool AddUVChannel (FMeshDescription &MeshDescription)
 
static STATICMESHDESCRIPTION_API bool InsertUVChannel (FMeshDescription &MeshDescription, int32 UVChannelIndex)
 
static STATICMESHDESCRIPTION_API bool RemoveUVChannel (FMeshDescription &MeshDescription, int32 UVChannelIndex)
 
static STATICMESHDESCRIPTION_API void GeneratePlanarUV (const FMeshDescription &MeshDescription, const FUVMapParameters &Params, TMap< FVertexInstanceID, FVector2D > &OutTexCoords)
 
static STATICMESHDESCRIPTION_API void GenerateCylindricalUV (FMeshDescription &MeshDescription, const FUVMapParameters &Params, TMap< FVertexInstanceID, FVector2D > &OutTexCoords)
 
static STATICMESHDESCRIPTION_API void GenerateBoxUV (const FMeshDescription &MeshDescription, const FUVMapParameters &Params, TMap< FVertexInstanceID, FVector2D > &OutTexCoords)
 
static STATICMESHDESCRIPTION_API void SwapPolygonPolygonGroup (FMeshDescription &MeshDescription, int32 SectionIndex, int32 TriangleIndexStart, int32 TriangleIndexEnd, bool bRemoveEmptyPolygonGroup)
 
static STATICMESHDESCRIPTION_API void ConvertHardEdgesToSmoothGroup (const FMeshDescription &SourceMeshDescription, TArray< uint32 > &FaceSmoothingMasks)
 
static STATICMESHDESCRIPTION_API void ConvertSmoothGroupToHardEdges (const TArray< uint32 > &FaceSmoothingMasks, FMeshDescription &DestinationMeshDescription)
 
static STATICMESHDESCRIPTION_API bool HasVertexColor (const FMeshDescription &MeshDescription)
 
static STATICMESHDESCRIPTION_API void BuildWeldedVertexIDRemap (const FMeshDescription &MeshDescription, const float WeldingThreshold, TMap< FVertexID, FVertexID > &OutVertexIDRemap)
 
static STATICMESHDESCRIPTION_API FSHAHash ComputeSHAHash (const FMeshDescription &MeshDescription, bool bSkipTransientAttributes=false)
 
static STATICMESHDESCRIPTION_API void FlipPolygons (FMeshDescription &MeshDescription)
 
static STATICMESHDESCRIPTION_API void ApplyTransform (FMeshDescription &MeshDescription, const FTransform &Transform, bool bApplyCorrectNormalTransform=false)
 
static STATICMESHDESCRIPTION_API void ApplyTransform (FMeshDescription &MeshDescription, const FMatrix &Transform, bool bApplyCorrectNormalTransform=false)
 
static STATICMESHDESCRIPTION_API int32 GetUniqueVertexCount (const FMeshDescription &MeshDescription)
 
static STATICMESHDESCRIPTION_API int32 GetUniqueVertexCount (const FMeshDescription &MeshDescription, const FOverlappingCorners &OverlappingCorners)
 
static STATICMESHDESCRIPTION_API void ReorderMeshDescriptionPolygonGroups (const FMeshDescription &SourceMeshDescription, FMeshDescription &DestinationMeshDescription, TOptional< const FString > UnmatchMaterialNameWarning, TOptional< const FString > DestinationPolygonGroupCountDifferFromSource_Msg)
 
static STATICMESHDESCRIPTION_API bool ValidateAndFixData (FMeshDescription &MeshDescription, const FString &DebugName)
 
static STATICMESHDESCRIPTION_API float ComputeMeshArea (const FMeshDescription &InMeshDescription)
 

Member Enumeration Documentation

◆ EGenerateUVMethod

Enumerator
Default 
Legacy 
UVAtlas 
XAtlas 
PatchBuilder 

Member Function Documentation

◆ AddUVChannel()

bool FStaticMeshOperations::AddUVChannel ( FMeshDescription MeshDescription)
static

Add a UV channel to the MeshDescription.

◆ AppendMeshDescription()

void FStaticMeshOperations::AppendMeshDescription ( const FMeshDescription SourceMesh,
FMeshDescription TargetMesh,
const FAppendSettings AppendSettings 
)
static

◆ AppendMeshDescriptions()

void FStaticMeshOperations::AppendMeshDescriptions ( const TArray< const FMeshDescription * > &  SourceMeshes,
FMeshDescription TargetMesh,
const FAppendSettings AppendSettings 
)
static

◆ ApplyTransform() [1/2]

void FStaticMeshOperations::ApplyTransform ( FMeshDescription MeshDescription,
const FMatrix Transform,
bool  bApplyCorrectNormalTransform = false 
)
static

◆ ApplyTransform() [2/2]

void FStaticMeshOperations::ApplyTransform ( FMeshDescription MeshDescription,
const FTransform Transform,
bool  bApplyCorrectNormalTransform = false 
)
static

Transforms the MeshDescription data using the provided transform.

Parameters
bApplyCorrectNormalTransformWhether to correctly transform normals and tangents. Otherwise, will match the UE renderer and transform them without scale.

◆ AreNormalsAndTangentsValid()

static void FStaticMeshOperations::AreNormalsAndTangentsValid ( const FMeshDescription MeshDescription,
bool bHasInvalidNormals,
bool bHasInvalidTangents 
)
inlinestatic

◆ BuildWeldedVertexIDRemap()

void FStaticMeshOperations::BuildWeldedVertexIDRemap ( const FMeshDescription MeshDescription,
const float  WeldingThreshold,
TMap< FVertexID, FVertexID > &  OutVertexIDRemap 
)
static

◆ ComputeMeshArea()

float FStaticMeshOperations::ComputeMeshArea ( const FMeshDescription InMeshDescription)
static

Compute the surface area of the mesh by iterating over each triangle.

◆ ComputeMikktTangents()

void FStaticMeshOperations::ComputeMikktTangents ( FMeshDescription MeshDescription,
bool  bIgnoreDegenerateTriangles 
)
static

Compute tangent and Bi-Normal using mikkt space for every vertex in the mesh description.

◆ ComputeSHAHash()

FSHAHash FStaticMeshOperations::ComputeSHAHash ( const FMeshDescription MeshDescription,
bool  bSkipTransientAttributes = false 
)
static

Computes the SHA hash of all the attributes values in the MeshDescription.

Parameters
bSkipTransientAttributesIf param is true, do not include transient attributes in the hash computation.

◆ ComputeTangentsAndNormals()

void FStaticMeshOperations::ComputeTangentsAndNormals ( FMeshDescription MeshDescription,
EComputeNTBsFlags  ComputeNTBsOptions 
)
static

Recompute any invalid normal, tangent or Bi-Normal for every vertex in the mesh description with the given options. If the EComputeNTBsFlags Normals or Tangents are set, the corresponding data will be force-recomputed.

◆ ComputeTriangleTangentsAndNormals()

void FStaticMeshOperations::ComputeTriangleTangentsAndNormals ( FMeshDescription MeshDescription,
float  ComparisonThreshold = 0.0f,
const TCHAR DebugName = nullptr 
)
static

Set the triangle tangent, normal, binormal and triangleCenter for all triangles in the mesh description.

◆ ConvertFromRawMesh()

void FStaticMeshOperations::ConvertFromRawMesh ( const FRawMesh SourceRawMesh,
FMeshDescription DestinationMeshDescription,
const TMap< int32, FName > &  MaterialMap,
bool  bSkipNormalsAndTangents = false,
const TCHAR DebugName = nullptr 
)
static

Convert old FRawMesh format to MeshDescription.

◆ ConvertHardEdgesToSmoothGroup()

void FStaticMeshOperations::ConvertHardEdgesToSmoothGroup ( const FMeshDescription SourceMeshDescription,
TArray< uint32 > &  FaceSmoothingMasks 
)
static

◆ ConvertSmoothGroupToHardEdges()

void FStaticMeshOperations::ConvertSmoothGroupToHardEdges ( const TArray< uint32 > &  FaceSmoothingMasks,
FMeshDescription DestinationMeshDescription 
)
static

◆ ConvertToRawMesh()

void FStaticMeshOperations::ConvertToRawMesh ( const FMeshDescription SourceMeshDescription,
FRawMesh DestinationRawMesh,
const TMap< FName, int32 > &  MaterialMap 
)
static

Convert this mesh description into the old FRawMesh format.

◆ CreateLightMapUVLayout()

bool FStaticMeshOperations::CreateLightMapUVLayout ( FMeshDescription MeshDescription,
int32  SrcLightmapIndex,
int32  DstLightmapIndex,
int32  MinLightmapResolution,
ELightmapUVVersion  LightmapUVVersion,
const FOverlappingCorners OverlappingCorners 
)
static

Find and pack UV charts for lightmap. The packing algorithm uses a rasterization method, hence the resolution parameter.

If the given minimum resolution is not enough to handle all the charts, generation will fail.

Parameters
MeshDescriptionEdited mesh
SrcLightmapIndexindex of the source UV channel
DstLightmapIndexindex of the destination UV channel
MinLightmapResolutionMinimum resolution used for the packing
LightmapUVVersionAlgorithm version
OverlappingCornersOverlapping corners of the given mesh
Returns
UV layout correctly generated

◆ DetermineEdgeHardnessesFromVertexInstanceNormals()

void FStaticMeshOperations::DetermineEdgeHardnessesFromVertexInstanceNormals ( FMeshDescription MeshDescription,
float  Tolerance = UE_KINDA_SMALL_NUMBER 
)
static

Determine the edge hardnesses from existing normals

◆ FindOverlappingCorners()

void FStaticMeshOperations::FindOverlappingCorners ( FOverlappingCorners OverlappingCorners,
const FMeshDescription MeshDescription,
float  ComparisonThreshold 
)
static

Find all overlapping vertex using the threshold in the mesh description.

◆ FlipPolygons()

void FStaticMeshOperations::FlipPolygons ( FMeshDescription MeshDescription)
static

Flip the facing for a set of input polygons.

◆ GenerateBoxUV()

void FStaticMeshOperations::GenerateBoxUV ( const FMeshDescription MeshDescription,
const FUVMapParameters Params,
TMap< FVertexInstanceID, FVector2D > &  OutTexCoords 
)
static

Generate box UV mapping for the MeshDescription

◆ GenerateCylindricalUV()

void FStaticMeshOperations::GenerateCylindricalUV ( FMeshDescription MeshDescription,
const FUVMapParameters Params,
TMap< FVertexInstanceID, FVector2D > &  OutTexCoords 
)
static

Generate cylindrical UV mapping for the MeshDescription

◆ GeneratePlanarUV()

void FStaticMeshOperations::GeneratePlanarUV ( const FMeshDescription MeshDescription,
const FUVMapParameters Params,
TMap< FVertexInstanceID, FVector2D > &  OutTexCoords 
)
static

Generate planar UV mapping for the MeshDescription

◆ GenerateUniqueUVsForStaticMesh()

bool FStaticMeshOperations::GenerateUniqueUVsForStaticMesh ( const FMeshDescription MeshDescription,
int32  TextureResolution,
bool  bMergeIdenticalMaterials,
TArray< FVector2D > &  OutTexCoords 
)
static

Create some UVs from the specified mesh description data.

◆ GenerateUV()

bool FStaticMeshOperations::GenerateUV ( const FMeshDescription MeshDescription,
const FGenerateUVOptions Options,
TArray< FVector2D > &  OutTexCoords 
)
static

Generate UV coordinates from the specified mesh description data.

◆ GetUniqueVertexCount() [1/2]

int32 FStaticMeshOperations::GetUniqueVertexCount ( const FMeshDescription MeshDescription)
static

Return the number of unique vertices, unique vertices are the result of welding all similar vertex instances (position, UV, tangent space, color,...)

◆ GetUniqueVertexCount() [2/2]

int32 FStaticMeshOperations::GetUniqueVertexCount ( const FMeshDescription MeshDescription,
const FOverlappingCorners OverlappingCorners 
)
static

◆ GetUVChartCount()

int32 FStaticMeshOperations::GetUVChartCount ( FMeshDescription MeshDescription,
int32  SrcLightmapIndex,
ELightmapUVVersion  LightmapUVVersion,
const FOverlappingCorners OverlappingCorners 
)
static

Find all charts in the mesh description.

◆ HasInvalidVertexInstanceNormalsOrTangents()

void FStaticMeshOperations::HasInvalidVertexInstanceNormalsOrTangents ( const FMeshDescription MeshDescription,
bool bHasInvalidNormals,
bool bHasInvalidTangents 
)
static

Check the mesh description's vertex instance normals and tangents to see if any of the values are invalid (e.g. nearly zero or they contain a NaN).

Note
This does not check if the vectors are normalized (which they should for correct normals and tangents).
Parameters
MeshDescriptionThe mesh description object to check.
bHasInvalidNormalsThe vertex instance normal attribute contains a near zero-length vector or a NaN component value.
bHasInvalidTangentsThe vertex instance tangent attribute contains a near zero-length vector or a NaN component value.

◆ HasVertexColor()

bool FStaticMeshOperations::HasVertexColor ( const FMeshDescription MeshDescription)
static

◆ InsertUVChannel()

bool FStaticMeshOperations::InsertUVChannel ( FMeshDescription MeshDescription,
int32  UVChannelIndex 
)
static

Insert a UV channel at the given index to the MeshDescription.

◆ RecomputeNormalsAndTangentsIfNeeded()

void FStaticMeshOperations::RecomputeNormalsAndTangentsIfNeeded ( FMeshDescription MeshDescription,
EComputeNTBsFlags  ComputeNTBsOptions 
)
static

◆ RemoveUVChannel()

bool FStaticMeshOperations::RemoveUVChannel ( FMeshDescription MeshDescription,
int32  UVChannelIndex 
)
static

Remove the UV channel at the given index from the MeshDescription.

◆ ReorderMeshDescriptionPolygonGroups()

void FStaticMeshOperations::ReorderMeshDescriptionPolygonGroups ( const FMeshDescription SourceMeshDescription,
FMeshDescription DestinationMeshDescription,
TOptional< const FString >  UnmatchMaterialNameWarning,
TOptional< const FString >  DestinationPolygonGroupCountDifferFromSource_Msg 
)
static

Reorder the destination mesh description polygon groups in the same order has the source mesh description polygon groups. This function use the imported material name to reorder the section.

Note: The material count MUST be the same for both the source and the destination. It will not reorder anything if the count is different.

◆ SwapPolygonPolygonGroup()

void FStaticMeshOperations::SwapPolygonPolygonGroup ( FMeshDescription MeshDescription,
int32  SectionIndex,
int32  TriangleIndexStart,
int32  TriangleIndexEnd,
bool  bRemoveEmptyPolygonGroup 
)
static

◆ ValidateAndFixData()

bool FStaticMeshOperations::ValidateAndFixData ( FMeshDescription MeshDescription,
const FString &  DebugName 
)
static

Verify the mesh data does not contain any NAN or INF float value, if such a case happen the value are set to zero or identity for matrix or quat.


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