CurrentRotGridSize

CurrentRotGridSize

#Overview

name: CurrentRotGridSize

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 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CurrentRotGridSize is to control the rotation grid size in the Unreal Engine editor’s viewport. This setting determines the increments by which objects can be rotated in the level editor.

This setting variable is primarily used by the Unreal Engine’s level editor and viewport system. It is referenced in various modules, including:

  1. The Customizable Object Editor (in the Mutable plugin)
  2. The UnrealEd module
  3. The VR Editor

The value of this variable is set in the ULevelEditorViewportSettings class, which is a configuration class for level editor viewport settings. It can be modified programmatically using the UEditorEngine::SetRotGridSize function.

CurrentRotGridSize interacts with several other variables and systems:

  1. It works in conjunction with CurrentRotGridMode to determine the rotation snapping behavior.
  2. It is used alongside arrays of predefined rotation grid sizes (accessed via GetCurrentRotationGridArray()).
  3. It affects the behavior of rotation controls in both standard and VR editor modes.

Developers should be aware of the following when using this variable:

  1. The value is clamped to the range of available rotation grid sizes.
  2. Changing this value will immediately affect the rotation snapping in the editor viewports.
  3. It is a config property, meaning its value persists between editor sessions.

Best practices when using this variable include:

  1. Use the provided setter functions (like SetRotGridSize) instead of modifying the value directly to ensure proper updating of related systems.
  2. Consider user preferences and workflow when adjusting this value, as it directly impacts the precision of rotation operations in the editor.
  3. Be aware of its interaction with CurrentRotGridMode when implementing rotation snapping functionality.
  4. When creating custom editor tools, respect this setting to maintain consistency with built-in Unreal Engine tools.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:429, section: [/Script/UnrealEd.LevelEditorViewportSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/SCustomizableObjectEditorViewport.cpp:924

Scope (from outer to inner):

file
function     bool SCustomizableObjectEditorViewportTabBody::IsRotationGridSizeChecked

Source code excerpt:

{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	return (ViewportSettings->CurrentRotGridSize == GridSizeIndex) && (ViewportSettings->CurrentRotGridMode == GridMode);
}


void SCustomizableObjectEditorViewportTabBody::OnSetLODModel(int32 LODSelectionType)
{
	LODSelection = LODSelectionType;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:481

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:


	UPROPERTY(config)
	int32 CurrentRotGridSize;

	UPROPERTY(config)
	int32 CurrentScalingGridSize;

	UPROPERTY(config)
	bool PreserveNonUniformScale;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:77

Scope (from outer to inner):

file
function     FRotator UEditorEngine::GetRotGridSize

Source code excerpt:

{
	const TArray<float> RotGridSizes = GetCurrentRotationGridArray();
	const int32 CurrentRotGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentRotGridSize;
	float RotVal = 0.0001f;
	if ( RotGridSizes.IsValidIndex(CurrentRotGridSize) )
	{
		RotVal = RotGridSizes[CurrentRotGridSize];
	}
	return FRotator(RotVal, RotVal, RotVal);
}

void UEditorEngine::SetRotGridSize( int32 InIndex, ERotationGridMode InGridMode )
{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:94

Scope (from outer to inner):

file
function     void UEditorEngine::SetRotGridSize

Source code excerpt:

	ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
	ViewportSettings->CurrentRotGridMode = InGridMode;
	ViewportSettings->CurrentRotGridSize = FMath::Clamp<int32>( InIndex, 0, RotGridSizes.Num() - 1 );
	ViewportSettings->PostEditChange();
	
	RedrawLevelEditingViewports();
	FEditorSupportDelegates::UpdateUI.Broadcast();
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:104

Scope (from outer to inner):

file
function     void UEditorEngine::RotGridSizeIncrement

Source code excerpt:

{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	SetRotGridSize(ViewportSettings->CurrentRotGridSize + 1, ViewportSettings->CurrentRotGridMode );
}

void UEditorEngine::RotGridSizeDecrement( )
{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	SetRotGridSize(ViewportSettings->CurrentRotGridSize - 1, ViewportSettings->CurrentRotGridMode );
}

const TArray<float>& UEditorEngine::GetCurrentRotationGridArray() const
{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:748

Scope (from outer to inner):

file
function     bool STransformViewportToolBar::IsRotationGridSizeChecked

Source code excerpt:

{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	return (ViewportSettings->CurrentRotGridSize == GridSizeIndex) && (ViewportSettings->CurrentRotGridMode == GridMode);
}


/**
	* Checks to see if the specified scale grid size is the current scale grid size
	*

#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorActions.cpp:80

Scope (from outer to inner):

file
function     void FVREditorActionCallbacks::OnRotationSnapSizeButtonClicked

Source code excerpt:

{
	const TArray<float>& GridSizes = GEditor->GetCurrentRotationGridArray();
	const int32 CurrentGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentRotGridSize;
	const ERotationGridMode CurrentGridMode = GetDefault<ULevelEditorViewportSettings>()->CurrentRotGridMode;

	int32 NewGridSize = CurrentGridSize + 1;
	if (NewGridSize >= GridSizes.Num())
	{
		NewGridSize = 0;