r.Editor.ArcballDragLimit

r.Editor.ArcballDragLimit

#Overview

name: r.Editor.ArcballDragLimit

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Editor.ArcballDragLimit is to control the behavior of the arcball rotation in the Unreal Editor’s viewport. It determines how long the arcball rotates before switching to a screen space rotate mode.

This setting variable is primarily used in the Unreal Editor’s viewport manipulation system, specifically for the rotation widget. It’s part of the UnrealEd module, which is responsible for the editor’s functionality.

The value of this variable is set through a console variable (CVAR) named CVarArcballLimit. It’s defined in the UnrealWidget.cpp file with a default value of 2.0. The value can be changed at runtime through the console or programmatically.

The CVarArcballLimit interacts directly with this setting variable, as they share the same value. It’s used in the ConvertMouseToAxis_Rotate function of the FWidget class to calculate the maximum difference for arcball rotation.

Developers should be aware that:

  1. This variable affects the user experience when rotating objects in the viewport.
  2. The default value of 2.0 means the arcball rotates for twice the size of the arcball before switching to screen space rotation.
  3. Changing this value will affect all users of the editor, so it should be modified carefully.

Best practices when using this variable include:

  1. Only modify it if there’s a specific need to change the default rotation behavior.
  2. Consider the impact on users who may be accustomed to the default behavior.
  3. If changing the value, document it clearly for other developers and users.

Regarding the associated variable CVarArcballLimit:

The purpose of CVarArcballLimit is to provide a runtime-modifiable way to control the r.Editor.ArcballDragLimit setting. It’s defined as a TAutoConsoleVariable, which allows it to be changed through the console or code during runtime.

CVarArcballLimit is used in the UnrealEd module, specifically in the viewport manipulation system. Its value is set at the same time as r.Editor.ArcballDragLimit, and it’s accessed in the code using GetValueOnGameThread().

The value of CVarArcballLimit is initially set to 2.0, matching the r.Editor.ArcballDragLimit setting. It can be modified at runtime through the console or programmatically.

Developers should be aware that:

  1. Changes to CVarArcballLimit will immediately affect the arcball rotation behavior.
  2. The variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to access from the render thread.

Best practices for using CVarArcballLimit include:

  1. Use GetValueOnGameThread() when accessing the value to ensure thread safety.
  2. Consider exposing this setting in the editor UI if frequent adjustments are needed.
  3. Be cautious when modifying this value during runtime, as it may affect ongoing user interactions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealWidget.cpp:121

Scope: file

Source code excerpt:

//CVAR for the arcball size, so animators can adjust it
static TAutoConsoleVariable<float> CVarArcballLimit(
	TEXT("r.Editor.ArcballDragLimit"),
	2.0,
	TEXT("For how long the arcball rotates until it switches to a screens space rotate, default of 1.0 equals the size of the arcball"),
	ECVF_RenderThreadSafe
);
//function used to find quat between two angles, and works much better, faster and less degenerate, then trying to use cross and dot product
static FQuat FindQuatBetweenNormals(const FVector& A, const FVector& B)

#Associated Variable and Callsites

This variable is associated with another variable named CVarArcballLimit. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealWidget.cpp:120

Scope: file

Source code excerpt:


//CVAR for the arcball size, so animators can adjust it
static TAutoConsoleVariable<float> CVarArcballLimit(
	TEXT("r.Editor.ArcballDragLimit"),
	2.0,
	TEXT("For how long the arcball rotates until it switches to a screens space rotate, default of 1.0 equals the size of the arcball"),
	ECVF_RenderThreadSafe
);
//function used to find quat between two angles, and works much better, faster and less degenerate, then trying to use cross and dot product

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealWidget.cpp:245

Scope (from outer to inner):

file
function     void FWidget::ConvertMouseToAxis_Rotate

Source code excerpt:

			const float ExternalScale = EditorModeTools ? EditorModeTools->GetWidgetScale() : 1.0f;
			const float CircleRadius = OUTER_AXIS_CIRCLE_RADIUS * ExternalScale;
			const float ArcballLimit = CVarArcballLimit.GetValueOnGameThread() * 2.0f;
			const float MaxDiff = ArcballLimit * CircleRadius;
			//If within Arcball do rotate the ball based on angle difference on hit tested sphere 
			if (Distance < CircleRadius)
			{
				const float ScaleInScreen = InView->WorldToScreen(InViewportClient->GetWidgetLocation()).W * (4.0f / InView->UnscaledViewRect.Width() / InView->ViewMatrices.GetProjectionMatrix().M[0][0]);
				const float SphereRadius = CircleRadius * ScaleInScreen  + GetDefault<ULevelEditorViewportSettings>()->TransformWidgetSizeAdjustment;