CurrentPosGridSize
CurrentPosGridSize
#Overview
name: CurrentPosGridSize
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of CurrentPosGridSize is to control the grid size for positioning objects in the Unreal Engine 5 level editor viewports. It determines the snap interval for translating (moving) objects in the 3D space.
This setting variable is primarily used by the Unreal Engine’s level editor and viewport systems. It is part of the ULevelEditorViewportSettings class, which suggests it’s a core part of the editor’s configuration.
The value of this variable is set in several places:
- It can be configured through the engine’s configuration files (as indicated by the UPROPERTY(config) decorator).
- It’s modified programmatically in the SetGridSize function of the UEditorEngine class.
- It can be incremented or decremented using the GridSizeIncrement and GridSizeDecrement functions.
CurrentPosGridSize interacts with other variables, notably:
- It’s used as an index to access values in the PosGridSizes array, which contains the actual grid size values.
- It’s related to CurrentRotGridSize and CurrentScalingGridSize, which likely control rotation and scaling snap intervals respectively.
Developers should be aware that:
- This variable is an index, not the actual grid size value. The actual grid size is retrieved from an array using this index.
- Changing this value will affect the snapping behavior in the level editor viewports.
- It’s clamped to valid array indices when set, to prevent out-of-bounds access.
Best practices when using this variable include:
- Use the provided setter functions (like SetGridSize) rather than modifying the value directly, as these functions ensure the value is clamped and trigger necessary updates.
- Be aware that changing this value will affect all users of the editor, so it should typically be changed through user interface actions rather than programmatically.
- When retrieving the actual grid size, always use the GetGridSize function rather than accessing the array directly, as it includes safeguards against invalid indices.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:428, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
2
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:478
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
UPROPERTY(config)
int32 CurrentPosGridSize;
UPROPERTY(config)
int32 CurrentRotGridSize;
UPROPERTY(config)
int32 CurrentScalingGridSize;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:14
Scope (from outer to inner):
file
function float UEditorEngine::GetGridSize
Source code excerpt:
{
const TArray<float>& PosGridSizes = GetCurrentPositionGridArray();
const int32 CurrentPosGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentPosGridSize;
float PosVal = 0.0001f;
if ( PosGridSizes.IsValidIndex(CurrentPosGridSize) )
{
PosVal = PosGridSizes[CurrentPosGridSize];
}
return PosVal;
}
bool UEditorEngine::IsGridSizePowerOfTwo() const
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:35
Scope (from outer to inner):
file
function void UEditorEngine::SetGridSize
Source code excerpt:
ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
ViewportSettings->CurrentPosGridSize = FMath::Clamp<int32>( InIndex, 0, GetCurrentPositionGridArray().Num() - 1 );
ViewportSettings->PostEditChange();
FEditorDelegates::OnGridSnappingChanged.Broadcast(GetDefault<ULevelEditorViewportSettings>()->GridEnabled, GetGridSize());
RedrawLevelEditingViewports();
FEditorSupportDelegates::UpdateUI.Broadcast();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:47
Scope (from outer to inner):
file
function void UEditorEngine::GridSizeIncrement
Source code excerpt:
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
SetGridSize(ViewportSettings->CurrentPosGridSize + 1);
}
void UEditorEngine::GridSizeDecrement( )
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
SetGridSize(ViewportSettings->CurrentPosGridSize - 1);
}
const TArray<float>& UEditorEngine::GetCurrentPositionGridArray() const
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:149
Scope (from outer to inner):
file
function float UEditorEngine::GetGridInterval
Source code excerpt:
const TArray<float>& GridIntervals = GetCurrentIntervalGridArray();
int32 CurrentIndex = GetDefault<ULevelEditorViewportSettings>()->CurrentPosGridSize;
if (CurrentIndex >= GridIntervals.Num())
{
CurrentIndex = GridIntervals.Num() - 1;
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:733
Scope (from outer to inner):
file
function bool STransformViewportToolBar::IsGridSizeChecked
Source code excerpt:
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
return (ViewportSettings->CurrentPosGridSize == GridSizeIndex);
}
/**
* Checks to see if the specified rotation grid angle is the current rotation grid angle
*
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealEdSrv.cpp:825
Scope (from outer to inner):
file
function bool UUnrealEdEngine::Exec
Source code excerpt:
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
TArray<float>& PosGridSizes = const_cast<TArray<float>&>(GetCurrentPositionGridArray());
float& CurGridSize = PosGridSizes[ViewportSettings->CurrentPosGridSize];
const float OldGridSize = CurGridSize;
if ( bSnap )
{
CurGridSize = NewGridSize;
}
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorActions.cpp:52
Scope (from outer to inner):
file
function void FVREditorActionCallbacks::OnTranslationSnapSizeButtonClicked
Source code excerpt:
{
const TArray<float>& GridSizes = GEditor->GetCurrentPositionGridArray();
const int32 CurrentGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentPosGridSize;
int32 NewGridSize = CurrentGridSize + 1;
if (NewGridSize >= GridSizes.Num())
{
NewGridSize = 0;
}