r.Editor.2DSnapMin
r.Editor.2DSnapMin
#Overview
name: r.Editor.2DSnapMin
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Tweak to define the grid rendering in 2D viewports.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Editor.2DSnapMin is to define a minimum value for the grid rendering in 2D viewports within the Unreal Engine editor. This setting is part of the editor’s user interface and viewport rendering system.
This setting variable is primarily used in the UnrealEd module, which is responsible for the Unreal Engine editor’s functionality. Based on the callsites, it’s specifically utilized in the FGridWidget class, which handles the rendering of grids in 2D viewports.
The value of this variable is set using a TAutoConsoleVariable, which allows it to be changed at runtime through console commands. It’s initialized with a default value of 0.25f.
The r.Editor.2DSnapMin variable interacts with another variable called r.Editor.2DSnapScale. Together, these variables determine the appearance and behavior of the grid in 2D viewports.
Developers should be aware that this variable affects the minimum grid size in 2D viewports, which can impact the precision of snapping and grid-based operations in the editor. Changing this value may affect the user experience when working with 2D layouts or when precise positioning is required.
Best practices when using this variable include:
- Keeping the value reasonably small to maintain precision in grid-based operations.
- Considering the relationship between this variable and r.Editor.2DSnapScale to ensure a consistent grid appearance across different zoom levels.
- Testing any changes to this variable thoroughly to ensure it doesn’t negatively impact the editor’s usability.
Regarding the associated variable CVarEditor2DSnapMin:
The purpose of CVarEditor2DSnapMin is to provide a programmatic interface to the r.Editor.2DSnapMin console variable within the C++ code of the Unreal Engine editor.
This variable is used in the UnrealEd module, specifically within the FGridWidget class for grid rendering calculations.
The value of CVarEditor2DSnapMin is set when the TAutoConsoleVariable is initialized, but it can be changed at runtime using console commands.
CVarEditor2DSnapMin interacts closely with CVarEditor2DSnapScale, as they are both used in calculations for grid rendering and snapping behavior.
Developers should be aware that accessing the value of CVarEditor2DSnapMin should be done using the GetValueOnGameThread() method to ensure thread-safe access.
Best practices for using CVarEditor2DSnapMin include:
- Always access its value using GetValueOnGameThread() to avoid potential threading issues.
- Consider caching the value if it’s used frequently in performance-critical code sections.
- Be cautious when modifying this value, as it can affect the editor’s grid rendering and potentially impact user experience.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:49
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarEditor2DSnapMin(
TEXT("r.Editor.2DSnapMin"),
0.25f,
TEXT("Tweak to define the grid rendering in 2D viewports."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarEditor2DSnapScale(
TEXT("r.Editor.2DSnapScale"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarEditor2DSnapMin
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:48
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarEditor2DSnapMin(
TEXT("r.Editor.2DSnapMin"),
0.25f,
TEXT("Tweak to define the grid rendering in 2D viewports."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarEditor2DSnapScale(
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:243
Scope (from outer to inner):
file
function void FGridWidget::DrawNewGrid
Source code excerpt:
float GridScale = CVarEditor2DSnapScale.GetValueOnGameThread();
float GridMin = CVarEditor2DSnapMin.GetValueOnGameThread();
// we need to account for a larger grids setting
SnapSplit = 1.25f * FMath::Min(GridScale / SnapGridSize / Scale, GridMin);
// hack test
GridSplitTriple.R = 0.25f * FMath::Min(GridScale / 100 / Scale * 0.01f, GridMin);