modeling.VolumeMaxTriCount

modeling.VolumeMaxTriCount

#Overview

name: modeling.VolumeMaxTriCount

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of modeling.VolumeMaxTriCount is to set a limit on the triangle count for Volumes that will be emitted by modeling tools in Unreal Engine 5. It serves as a cap to prevent performance issues when creating or updating AVolume objects with large numbers of triangles.

This setting variable is primarily used in the MeshModelingToolset plugin, specifically within the ModelingComponentsEditorOnly module. It affects the behavior of tools that create or modify Volume objects in the Unreal Engine editor.

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

The associated variable CVarModelingMaxVolumeTriangleCount directly interacts with modeling.VolumeMaxTriCount. They share the same value and are used interchangeably in the code.

Developers must be aware that:

  1. This limit is applied automatically when creating or updating Volumes.
  2. Meshes exceeding this triangle count will be automatically simplified.
  3. The limit is in place to prevent editor hang-ups when dealing with large Volumes.

Best practices when using this variable include:

  1. Adjusting the value based on the project’s performance requirements and the capabilities of target hardware.
  2. Monitoring the impact of this setting on the visual quality of Volumes in the game.
  3. Considering this limit when designing levels or objects that will be converted to Volumes.

Regarding the associated variable CVarModelingMaxVolumeTriangleCount:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Private/ToolTargets/VolumeComponentToolTarget.cpp:17

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarModelingMaxVolumeTriangleCount(
	TEXT("modeling.VolumeMaxTriCount"),
	500,
	TEXT("Limit on triangle count for Volumes that will be emitted by modeling tools. Meshes above this limit will be auto-simplified."));

UVolumeComponentToolTarget::UVolumeComponentToolTarget()
{
	// TODO: These should be user-configurable somewhere

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Public/ToolTargets/VolumeComponentToolTarget.h:17

Scope: file

Source code excerpt:


/**
 * The CVar "modeling.VolumeMaxTriCount" is used as a cap on triangles that the various Modeling Mode
 * Tools will allow an output AVolume to have. If this triangle count is exceeded, the mesh used to
 * create/update the AVolume will be auto-simplified. This is necessary because all AVolume process is
 * done on the game thread, and a large Volume (eg with 100k faces) will hang the editor for a long time
 * when it is created. The default is set to 500.
 */
extern MODELINGCOMPONENTSEDITORONLY_API TAutoConsoleVariable<int32> CVarModelingMaxVolumeTriangleCount;

/**
 * A tool target backed by AVolume
 */
UCLASS(Transient)
class MODELINGCOMPONENTSEDITORONLY_API UVolumeComponentToolTarget : public UPrimitiveComponentToolTarget,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Private/EditorModelingObjectsCreationAPI.cpp:19

Scope: file

Source code excerpt:

#include "Materials/Material.h"

#include "ToolTargets/VolumeComponentToolTarget.h"  // for CVarModelingMaxVolumeTriangleCount
#include "Engine/BlockingVolume.h"
#include "Components/BrushComponent.h"
#include "Engine/Polys.h"
#include "Model.h"
#include "BSPOps.h"		// in UnrealEd
#include "Editor/EditorEngine.h"		// for FActorLabelUtilities

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Private/EditorModelingObjectsCreationAPI.cpp:187

Scope (from outer to inner):

file
function     FCreateMeshObjectResult UEditorModelingObjectsCreationAPI::CreateVolume

Source code excerpt:

	UE::Conversion::FMeshToVolumeOptions Options;
	Options.bAutoSimplify = true;
	Options.MaxTriangles = FMath::Max(1, CVarModelingMaxVolumeTriangleCount.GetValueOnGameThread());
	if (CreateMeshParams.MeshType == ECreateMeshObjectSourceMeshType::DynamicMesh)
	{
		UE::Conversion::DynamicMeshToVolume(CreateMeshParams.DynamicMesh.GetValue(), NewVolumeActor, Options);
	}
	else if (CreateMeshParams.MeshType == ECreateMeshObjectSourceMeshType::MeshDescription)
	{

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Private/ToolTargets/VolumeComponentToolTarget.cpp:16

Scope: file

Source code excerpt:

using namespace UE::Geometry;

TAutoConsoleVariable<int32> CVarModelingMaxVolumeTriangleCount(
	TEXT("modeling.VolumeMaxTriCount"),
	500,
	TEXT("Limit on triangle count for Volumes that will be emitted by modeling tools. Meshes above this limit will be auto-simplified."));

UVolumeComponentToolTarget::UVolumeComponentToolTarget()
{

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Private/ToolTargets/VolumeComponentToolTarget.cpp:98

Scope (from outer to inner):

file
function     void UVolumeComponentToolTarget::CommitDynamicMesh

Source code excerpt:

	UE::Conversion::FMeshToVolumeOptions ConversionOptions;
	ConversionOptions.bAutoSimplify = true;
	ConversionOptions.MaxTriangles = FMath::Max(1, CVarModelingMaxVolumeTriangleCount.GetValueOnGameThread());
	UE::Conversion::DynamicMeshToVolume(Mesh, Volume, ConversionOptions);

	Volume->SetActorTransform(Transform);
	Volume->PostEditChange();
}

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponentsEditorOnly/Public/ToolTargets/VolumeComponentToolTarget.h:23

Scope: file

Source code excerpt:

 * when it is created. The default is set to 500.
 */
extern MODELINGCOMPONENTSEDITORONLY_API TAutoConsoleVariable<int32> CVarModelingMaxVolumeTriangleCount;

/**
 * A tool target backed by AVolume
 */
UCLASS(Transient)
class MODELINGCOMPONENTSEDITORONLY_API UVolumeComponentToolTarget : public UPrimitiveComponentToolTarget,