r.Editor.AlignedOrthoZoom

r.Editor.AlignedOrthoZoom

#Overview

name: r.Editor.AlignedOrthoZoom

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.AlignedOrthoZoom is to control the zoom behavior of orthographic viewports in the Unreal Engine editor. It specifically affects how the zoom factor is calculated and applied across different orthographic viewports.

This setting variable is primarily used by the Unreal Engine’s editor subsystem, particularly in the viewport management and rendering modules. It’s referenced in the EditorViewportClient.cpp file, which is part of the UnrealEd module responsible for managing editor viewports.

The value of this variable is set using a TAutoConsoleVariable, which means it can be changed at runtime through console commands. By default, it’s set to 1.

The associated variable CVarAlignedOrthoZoom directly interacts with r.Editor.AlignedOrthoZoom. They share the same value and purpose.

Developers must be aware that this variable has two possible states: 0: Each orthographic viewport’s zoom is defined by the viewport width independently. 1 (default): All orthographic viewport zooms are locked to each other, allowing axis lines to be aligned across viewports.

Best practices when using this variable include:

  1. Consider the impact on workflow when changing this setting. The default (1) provides consistency across viewports, which can be beneficial for many tasks.
  2. Be aware that changing this setting may affect how users interact with multiple viewports simultaneously.
  3. If precise control over individual viewport zoom is needed, consider setting this to 0.
  4. Remember that this setting only affects orthographic viewports in the editor, not perspective views or in-game views.

Regarding the associated variable CVarAlignedOrthoZoom:

The purpose of CVarAlignedOrthoZoom is identical to r.Editor.AlignedOrthoZoom. It’s the actual console variable that controls the orthographic zoom behavior in the editor.

This variable is used in the UnrealEd module, specifically in the EditorViewportClient class, which manages editor viewports.

The value is set when the TAutoConsoleVariable is initialized, but can be changed at runtime through console commands.

CVarAlignedOrthoZoom directly interacts with the ComputeOrthoZoomFactor function, which calculates the zoom factor for orthographic viewports based on this setting.

Developers should be aware that changes to CVarAlignedOrthoZoom will immediately affect all orthographic viewports in the editor.

Best practices include:

  1. Use the console variable name “r.Editor.AlignedOrthoZoom” when referring to this setting in documentation or user instructions.
  2. When programmatically checking or changing this value, use CVarAlignedOrthoZoom.GetValueOnGameThread() to ensure thread-safe access.
  3. Consider the performance implications of frequently changing this value, as it affects viewport rendering.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:83

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAlignedOrthoZoom(
	TEXT("r.Editor.AlignedOrthoZoom"),
	1,
	TEXT("Only affects the editor ortho viewports.\n")
	TEXT(" 0: Each ortho viewport zoom in defined by the viewport width\n")
	TEXT(" 1: All ortho viewport zoom are locked to each other to allow axis lines to be aligned with each other."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:82

Scope: file

Source code excerpt:

const EViewModeIndex FEditorViewportClient::DefaultOrthoViewMode = VMI_Lit;

static TAutoConsoleVariable<int32> CVarAlignedOrthoZoom(
	TEXT("r.Editor.AlignedOrthoZoom"),
	1,
	TEXT("Only affects the editor ortho viewports.\n")
	TEXT(" 0: Each ortho viewport zoom in defined by the viewport width\n")
	TEXT(" 1: All ortho viewport zoom are locked to each other to allow axis lines to be aligned with each other."),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:117

Scope (from outer to inner):

file
function     float ComputeOrthoZoomFactor

Source code excerpt:

	float Ret = 1.0f;

	if(CVarAlignedOrthoZoom.GetValueOnGameThread())
	{
		// We want to have all ortho view ports scale the same way to have the axis aligned with each other.
		// So we take out the usual scaling of a view based on it's width.
		// That means when a view port is resized in x or y it shows more content, not the same content larger (for x) or has no effect (for y).
		// 500 is to get good results with existing view port settings.
		Ret = ViewportWidth / 500.0f;