RotGridEnabled
RotGridEnabled
#Overview
name: RotGridEnabled
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 13
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of RotGridEnabled is to control whether actor rotations will snap to the grid in the Unreal Engine editor. This setting is primarily used in the level editor and related viewport tools to enhance precision when rotating actors in the scene.
RotGridEnabled is a part of the ULevelEditorViewportSettings class, which is responsible for managing various viewport settings in the Unreal Engine editor. It is primarily used by the level editor subsystem and related tools, such as the GizmoEdMode plugin and the CustomizableObjectEditor.
The value of this variable is typically set through the editor UI or via console commands. For example, it can be toggled using the following console command:
MODE ROTGRID=1
or
MODE ROTGRID=0
Several other variables and functions interact with RotGridEnabled:
- GEditor->GetRotGridSize(): This function returns the rotation grid size, which is used in conjunction with RotGridEnabled.
- CurrentRotGridSize: This variable in ULevelEditorViewportSettings determines the current rotation grid size index.
- SnapScaleEnabled: Another snapping option for actor scaling, often used alongside RotGridEnabled.
Developers should be aware of the following when using this variable:
- RotGridEnabled affects the behavior of rotation tools in the editor, so changes to this setting will impact user experience when rotating actors.
- The setting is stored in the editor configuration, so it persists between editor sessions.
- Various parts of the editor UI (toolbars, checkboxes) reflect and can modify this setting.
Best practices when using this variable include:
- Respect user preferences: Don’t override this setting without user consent.
- Provide clear UI options for users to toggle this setting.
- Consider the interaction between rotation snapping and other snapping options (like position or scale snapping) to ensure a consistent editing experience.
- When implementing custom tools or modes that involve rotation, check this setting to maintain consistent behavior with built-in Unreal Engine tools.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:415, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/GizmoEdMode/Source/GizmoEdMode/Private/GizmoEdMode.cpp:97
Scope (from outer to inner):
file
function void UGizmoEdMode::ModeTick
Source code excerpt:
{
LastFactory->ConfigureGridSnapping(GetDefault<ULevelEditorViewportSettings>()->GridEnabled,
GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled, InteractiveGizmos);
}
}
#undef LOCTEXT_NAMESPACE
#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/SCustomizableObjectEditorViewport.cpp:905
Scope (from outer to inner):
file
function void SCustomizableObjectEditorViewportTabBody::RotationGridSnapClicked
Source code excerpt:
void SCustomizableObjectEditorViewportTabBody::RotationGridSnapClicked()
{
GUnrealEd->Exec(GEditor->GetEditorWorldContext().World(), *FString::Printf(TEXT("MODE ROTGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? 1 : 0));
}
bool SCustomizableObjectEditorViewportTabBody::RotationGridSnapIsChecked() const
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled;
}
void SCustomizableObjectEditorViewportTabBody::SetRotationGridSize(int32 InIndex, ERotationGridMode InGridMode)
{
GEditor->SetRotGridSize(InIndex, InGridMode);
#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/SCustomizableObjectEditorViewportToolBar.cpp:624
Scope (from outer to inner):
file
function ECheckBoxState SCustomizableObjectEditorViewportToolBar::IsRotationGridSnapChecked
Source code excerpt:
ECheckBoxState SCustomizableObjectEditorViewportToolBar::IsRotationGridSnapChecked() const
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
void SCustomizableObjectEditorViewportToolBar::HandleToggleRotationGridSnap(ECheckBoxState InState)
{
GUnrealEd->Exec(GEditor->GetEditorWorldContext().World(), *FString::Printf(TEXT("MODE ROTGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? 1 : 0));
}
FText SCustomizableObjectEditorViewportToolBar::GetRotationGridLabel() const
{
return FText::Format(LOCTEXT("GridRotation - Number - DegreeSymbol", "{0}\u00b0"), FText::AsNumber(GEditor->GetRotGridSize().Pitch));
#Loc: <Workspace>/Engine/Source/Editor/Experimental/EditorInteractiveToolsFramework/Private/EdModeInteractiveToolsContext.cpp:167
Scope (from outer to inner):
file
class class FEdModeToolsContextQueriesImpl : public IToolsContextQueriesAPI
function virtual FToolContextSnappingConfiguration GetCurrentSnappingSettings
Source code excerpt:
float EditorGridSize = GEditor->GetGridSize();
Config.PositionGridDimensions = FVector(EditorGridSize, EditorGridSize, EditorGridSize);
Config.bEnableRotationGridSnapping = (GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled != 0);
Config.RotationGridAngles = GEditor->GetRotGridSize();
Config.bEnableAbsoluteWorldSnapping = ToolsContext->GetAbsoluteWorldSnappingEnabled();
return Config;
}
virtual UMaterialInterface* GetStandardMaterial(EStandardToolContextMaterials MaterialType) const
#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditorActions.cpp:2187
Scope (from outer to inner):
file
function void FLevelEditorActionCallbacks::RotationGridSnap_Clicked
Source code excerpt:
void FLevelEditorActionCallbacks::RotationGridSnap_Clicked()
{
GUnrealEd->Exec( GetWorld(), *FString::Printf( TEXT("MODE ROTGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? 1 : 0 ) );
}
bool FLevelEditorActionCallbacks::RotationGridSnap_IsChecked()
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled;
}
void FLevelEditorActionCallbacks::ScaleGridSnap_Clicked()
{
GUnrealEd->Exec( GetWorld(), *FString::Printf( TEXT("MODE SCALEGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled ? 1 : 0 ) );
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:433
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
/** If enabled, actor rotations will snap to the grid. */
UPROPERTY(EditAnywhere, config, Category=GridSnapping, meta=(DisplayName = "Enable Rotation Snapping"))
uint32 RotGridEnabled:1;
/** If enabled, actor sizes will snap to the grid. */
UPROPERTY(EditAnywhere, config, Category=GridSnapping, meta=(DisplayName = "Enable Scale Snapping"))
uint32 SnapScaleEnabled:1;
/** If enabled, actors will snap to surfaces in the viewport when dragged around */
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EdMode.cpp:327
Scope (from outer to inner):
file
function bool FEdMode::IsSnapRotationEnabled
Source code excerpt:
bool FEdMode::IsSnapRotationEnabled()
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled;
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:983
Scope (from outer to inner):
file
function ECheckBoxState STransformViewportToolBar::IsRotationGridSnapChecked
Source code excerpt:
ECheckBoxState STransformViewportToolBar::IsRotationGridSnapChecked() const
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
ECheckBoxState STransformViewportToolBar::IsLayer2DSnapChecked() const
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
const ULevelEditor2DSettings* Settings2D = GetDefault<ULevelEditor2DSettings>();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:1012
Scope (from outer to inner):
file
function void STransformViewportToolBar::HandleToggleRotationGridSnap
Source code excerpt:
void STransformViewportToolBar::HandleToggleRotationGridSnap(ECheckBoxState InState)
{
GUnrealEd->Exec(GEditor->GetEditorWorldContext().World(), *FString::Printf(TEXT("MODE ROTGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? 1 : 0));
}
void STransformViewportToolBar::HandleToggleLayer2DSnap(ECheckBoxState InState)
{
ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
const ULevelEditor2DSettings* Settings2D = GetDefault<ULevelEditor2DSettings>();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Tools/UEdMode.cpp:278
Scope (from outer to inner):
file
function bool UEdMode::IsSnapRotationEnabled
Source code excerpt:
bool UEdMode::IsSnapRotationEnabled()
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled;
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealEdSrv.cpp:3036
Scope (from outer to inner):
file
function bool UUnrealEdEngine::Exec_Mode
Source code excerpt:
ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
ViewportSettings->RotGridEnabled = DWord1;
ViewportSettings->PostEditChange();
FEditorSupportDelegates::UpdateUI.Broadcast();
}
if( FParse::Value(Str, TEXT("SCALEGRID="), DWord1) )
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealWidgetRender.cpp:1146
Scope (from outer to inner):
file
function void FWidget::DrawRotationArc
Source code excerpt:
FVector SnapLocation = InLocation;
if (GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled)
{
float DeltaAngle = GEditor->GetRotGridSize().Yaw;
//every 22.5 degrees
float TickMarker = 22.5f;
for (float Angle = 0; Angle < 360.f; Angle += DeltaAngle)
{
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorActions.cpp:74
Scope (from outer to inner):
file
function ECheckBoxState FVREditorActionCallbacks::GetRotationSnapState
Source code excerpt:
ECheckBoxState FVREditorActionCallbacks::GetRotationSnapState()
{
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
void FVREditorActionCallbacks::OnRotationSnapSizeButtonClicked()
{
const TArray<float>& GridSizes = GEditor->GetCurrentRotationGridArray();
const int32 CurrentGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentRotGridSize;