r.Editor.2DSnapScale
r.Editor.2DSnapScale
#Overview
name: r.Editor.2DSnapScale
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.2DSnapScale is to define the grid rendering in 2D viewports within the Unreal Engine editor. This setting variable is primarily used for the editor’s rendering system, specifically for 2D viewport grid visualization.
The Unreal Engine subsystem that relies on this setting variable is the editor’s rendering system, particularly the components responsible for drawing grids in 2D viewports. This can be inferred from the file location (UnrealEd/Private/EditorComponents.cpp) and the usage within the FGridWidget::DrawNewGrid function.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through console commands. The default value is set to 10.0f.
The associated variable CVarEditor2DSnapScale interacts directly with r.Editor.2DSnapScale. They share the same value and purpose. CVarEditor2DSnapScale is used to retrieve the value of r.Editor.2DSnapScale within the engine’s C++ code.
Developers must be aware that this variable affects the visual representation of the grid in 2D viewports. Changing its value will impact the scale of the grid, which could affect how designers and artists perceive distances and sizes in the 2D view.
Best practices when using this variable include:
- Adjusting it carefully to maintain a balance between visibility and usability of the grid.
- Communicating any changes to the team, as it affects the visual reference for all users of 2D viewports.
- Considering the relationship between this variable and other grid-related settings, such as CVarEditor2DSnapMin, to ensure a consistent and useful grid representation.
Regarding the associated variable CVarEditor2DSnapScale:
The purpose of CVarEditor2DSnapScale is to provide a programmatic interface to access and modify the r.Editor.2DSnapScale value within the engine’s C++ code. It serves as a wrapper for the console variable, allowing easy access to its value in different parts of the editor code.
This variable is used in the UnrealEd module, specifically within the editor components responsible for grid rendering. It’s typically accessed using the GetValueOnGameThread() method to retrieve the current value of r.Editor.2DSnapScale.
The value of CVarEditor2DSnapScale is set indirectly through r.Editor.2DSnapScale, as they share the same underlying value.
Developers should be aware that changes to r.Editor.2DSnapScale will be reflected in CVarEditor2DSnapScale, and vice versa. When using this variable in code, always consider the potential impact on the visual representation of the 2D viewport grid.
Best practices for using CVarEditor2DSnapScale include:
- Using GetValueOnGameThread() to access its value in a thread-safe manner.
- Avoiding frequent changes to this value during performance-critical operations.
- Considering caching the value if it’s accessed frequently in a single frame or update cycle.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:55
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarEditor2DSnapScale(
TEXT("r.Editor.2DSnapScale"),
10.0f,
TEXT("Tweak to define the grid rendering in 2D viewports."),
ECVF_RenderThreadSafe);
static bool IsEditorCompositingMSAAEnabled(ERHIFeatureLevel::Type InFeatureLevel)
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarEditor2DSnapScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:54
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarEditor2DSnapScale(
TEXT("r.Editor.2DSnapScale"),
10.0f,
TEXT("Tweak to define the grid rendering in 2D viewports."),
ECVF_RenderThreadSafe);
static bool IsEditorCompositingMSAAEnabled(ERHIFeatureLevel::Type InFeatureLevel)
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorComponents.cpp:242
Scope (from outer to inner):
file
function void FGridWidget::DrawNewGrid
Source code excerpt:
float Scale = FMath::Min(ScaleX, ScaleY);
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