geometry.DynamicMesh.TextBasedDupeTriThreshold

geometry.DynamicMesh.TextBasedDupeTriThreshold

#Overview

name: geometry.DynamicMesh.TextBasedDupeTriThreshold

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of geometry.DynamicMesh.TextBasedDupeTriThreshold is to set a threshold for the number of triangles in a UDynamicMesh that determines whether text-based duplication using Base64 encoding should be used during the mesh export process.

This setting variable is primarily used in the Geometry Framework module of Unreal Engine 5, specifically within the UDynamicMesh class implementation.

The value of this variable is set through a console variable (CVar) system, with a default value of 1000 triangles. It can be modified at runtime or through configuration files.

The associated variable CVarDynamicMeshTextBasedDupeTriangleCountThreshold directly interacts with geometry.DynamicMesh.TextBasedDupeTriThreshold. They share the same value and purpose.

Developers must be aware that:

  1. This threshold affects the performance of mesh duplication and serialization.
  2. Larger threshold values can significantly slow down the duplication process for complex meshes.
  3. The variable is used in the ExportCustomProperties function of UDynamicMesh to determine the serialization method.

Best practices when using this variable include:

  1. Keep the threshold reasonably low (default 1000) for optimal performance.
  2. Adjust the value only when necessary, considering the trade-off between text-based representation and performance.
  3. Monitor performance when working with large meshes and adjust the threshold accordingly.

Regarding the associated variable CVarDynamicMeshTextBasedDupeTriangleCountThreshold:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/GeometryFramework/Private/UDynamicMesh.cpp:20

Scope: file

Source code excerpt:

// these cvars are used to support T3D encoding of the internal FDynamicMesh3, see ::ExportCustomProperties() and ::ImportCustomProperties()
static TAutoConsoleVariable<int32> CVarDynamicMeshTextBasedDupeTriangleCountThreshold(
	TEXT("geometry.DynamicMesh.TextBasedDupeTriThreshold"),
	1000,
	TEXT("Triangle count threshold for text-based UDynamicMesh duplication using Base64. Large values are quite slow."));
static TAutoConsoleVariable<int32> CVarDynamicMeshDupeHelperTimeout(
	TEXT("geometry.DynamicMesh.DupeStashTimeout"),
	5*60,
	TEXT("Timeout in seconds for references held by internal UDynamicMesh duplication helper system. See FDynamicMeshCopyHelper."));

#Loc: <Workspace>/Engine/Source/Runtime/GeometryFramework/Private/UDynamicMesh.cpp:434

Scope (from outer to inner):

file
function     void UDynamicMesh::ExportCustomProperties

Source code excerpt:

	// 
	// Obviously this does not work between Editor sessions. So we also optionally do a Base64 binary encoding if
	// the mesh triangle count is below a CVar threshold (geometry.DynamicMesh.TextBasedDupeTriThreshold) 
	// defaulting to 1000. Larger meshes can be supported by increasing the CVar value if need be.
	// 
	// If the mesh is not found in the FDynamicMeshCopyHelper, and is too large to text-copy, then instead
	// of leaving an empty mesh, we emit a cube, as empty meshes can be problematic. A warning is also
	// printed to the Output Log, pointing the user to the CVars.
	// 

#Associated Variable and Callsites

This variable is associated with another variable named CVarDynamicMeshTextBasedDupeTriangleCountThreshold. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/GeometryFramework/Private/UDynamicMesh.cpp:19

Scope: file

Source code excerpt:


// these cvars are used to support T3D encoding of the internal FDynamicMesh3, see ::ExportCustomProperties() and ::ImportCustomProperties()
static TAutoConsoleVariable<int32> CVarDynamicMeshTextBasedDupeTriangleCountThreshold(
	TEXT("geometry.DynamicMesh.TextBasedDupeTriThreshold"),
	1000,
	TEXT("Triangle count threshold for text-based UDynamicMesh duplication using Base64. Large values are quite slow."));
static TAutoConsoleVariable<int32> CVarDynamicMeshDupeHelperTimeout(
	TEXT("geometry.DynamicMesh.DupeStashTimeout"),
	5*60,

#Loc: <Workspace>/Engine/Source/Runtime/GeometryFramework/Private/UDynamicMesh.cpp:452

Scope (from outer to inner):

file
function     void UDynamicMesh::ExportCustomProperties

Source code excerpt:

	Out.Logf(TEXT("MESHKEY=%d "), StashedKey);

	if (Mesh->TriangleCount() < CVarDynamicMeshTextBasedDupeTriangleCountThreshold.GetValueOnGameThread())
	{
		// serialize our mesh
		TArray<uint8> MeshWriteBuffer;
		FMemoryWriter MemWriter(MeshWriteBuffer);
		Mesh->Serialize(MemWriter);