modeling.EnableVolumeSnapping

modeling.EnableVolumeSnapping

#Overview

name: modeling.EnableVolumeSnapping

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of modeling.EnableVolumeSnapping is to control whether volume snapping is enabled in the Unreal Engine 5’s modeling tools. This setting allows developers to enable or disable snapping to volumes during modeling operations.

This setting variable is primarily used in the MeshModelingToolset plugin and the ModelingToolsEditorMode plugin. These plugins are part of the modeling subsystem in Unreal Engine 5, which provides various tools for 3D modeling within the engine.

The value of this variable is set through the console variable system in Unreal Engine. It can be toggled via a menu item in the Modeling Mode Toolkit, as seen in the ModelingModeToolkit_Toolbars.cpp file.

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

Developers must be aware that enabling volume snapping can impact performance and functionality, especially in levels with many overlapping large volumes. The tooltip for the menu item warns that some modeling functionality may not work correctly in such cases.

Best practices when using this variable include:

  1. Only enable it when necessary for specific modeling tasks that require volume snapping.
  2. Be cautious when using it in levels with many complex volumes.
  3. Test thoroughly to ensure that enabling this feature doesn’t negatively impact the performance or functionality of your project.

Regarding the associated variable CVarEnableModelingVolumeSnapping:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/SceneGeometrySpatialCache.cpp:14

Scope: file

Source code excerpt:

// When enabled, Volumes with a valid CollisionProfile will be included as snap targets
TAutoConsoleVariable<bool> CVarEnableModelingVolumeSnapping(
	TEXT("modeling.EnableVolumeSnapping"),
	false,
	TEXT("Enable snapping to volumes"));

namespace UE
{
namespace Local

#Loc: <Workspace>/Engine/Plugins/Editor/ModelingToolsEditorMode/Source/ModelingToolsEditorMode/Private/ModelingModeToolkit_Toolbars.cpp:182

Scope (from outer to inner):

file
namespace    UELocal
function     void MakeSubMenu_ModeToggles
lambda-function

Source code excerpt:

		FExecuteAction::CreateLambda([]
		{
			IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("modeling.EnableVolumeSnapping")); 
			bool CurValue = CVar->GetBool();
			CVar->Set(CurValue ? false : true);
		}),
		FCanExecuteAction(),
		FIsActionChecked::CreateLambda([]()
		{
			IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("modeling.EnableVolumeSnapping"));
			return (CVar->GetBool());
		}));

	MenuBuilder.AddMenuEntry(
		LOCTEXT("ToggleVolumeSnapping", "Volume Snapping"), 
		LOCTEXT("ToggleVolumeSnapping_Tooltip", "Enable Vertex/Face Snapping and Ray-hits against Volumes in the Level. Note that if your level contains many overlapping large volumes, some Modeling functionality may not work correctly"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/SceneGeometrySpatialCache.cpp:13

Scope: file

Source code excerpt:

// This CVar controls whether scene hit queries will hit volume surfaces.
// When enabled, Volumes with a valid CollisionProfile will be included as snap targets
TAutoConsoleVariable<bool> CVarEnableModelingVolumeSnapping(
	TEXT("modeling.EnableVolumeSnapping"),
	false,
	TEXT("Enable snapping to volumes"));

namespace UE
{

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/SceneGeometrySpatialCache.cpp:391

Scope (from outer to inner):

file
function     bool FSceneGeometrySpatialCache::EnableComponentTracking

Source code excerpt:

	}

	bool bEnableVolumes = CVarEnableModelingVolumeSnapping.GetValueOnAnyThread();

	TSharedPtr<ISceneGeometrySpatial> NewSpatial;
	if (bEnableVolumes && Cast<UBrushComponent>(Component) != nullptr)
	{
		IdentifierOut = FSceneGeometryID{ UniqueIDGenerator++ };

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Snapping/ModelingSceneSnappingManager.cpp:33

Scope: file

Source code excerpt:


// defined in SceneGeometrySpatialCache.cpp
extern TAutoConsoleVariable<bool> CVarEnableModelingVolumeSnapping;



void UModelingSceneSnappingManager::Initialize(TObjectPtr<UInteractiveToolsContext> ToolsContext)
{
	ParentContext = ToolsContext;

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Snapping/ModelingSceneSnappingManager.cpp:328

Scope (from outer to inner):

file
function     static bool FindNearestVisibleObjectHit_Internal

Source code excerpt:

	}

	bool bEnableVolumes = CVarEnableModelingVolumeSnapping.GetValueOnAnyThread();

	double NearestVisible = TNumericLimits<double>::Max();
	for (const FHitResult& CurResult : OutHits)
	{
		// if we have hit Component in the SpatialCache, prefer to use that
		if (SpatialCache && SpatialCache->HaveCacheForComponent(CurResult.GetComponent()) )