r.Test.EditorConstrainedView

r.Test.EditorConstrainedView

#Overview

name: r.Test.EditorConstrainedView

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.Test.EditorConstrainedView is to allow testing of different viewport rectangle configurations in the game view, simulating scenarios that can occur when using cinematics or in the Editor.

This setting variable is primarily used by the Unreal Engine’s editor viewport system, specifically within the UnrealEd module. It’s utilized in the EditorViewportClient, which is responsible for managing editor viewport rendering and interaction.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, which means the feature is off by default. The value can be changed at runtime through console commands or programmatically.

The associated variable CVarEditorViewportTest directly interacts with r.Test.EditorConstrainedView. They share the same value and purpose, with CVarEditorViewportTest being the actual C++ variable used in the code to access the setting.

Developers must be aware that this variable is intended for testing purposes only. It affects the game view, not the editor view, and can alter the viewport’s rendering area. The variable accepts values from 0 to 7, with 0 being off and 1-7 representing various viewport configurations.

Best practices when using this variable include:

  1. Only enable it for testing purposes, not in production builds.
  2. Be cautious when changing the value, as it can significantly alter the game view.
  3. Remember to reset it to 0 after testing to restore normal viewport behavior.
  4. Use it in conjunction with other debugging tools to diagnose viewport-related issues.

Regarding the associated variable CVarEditorViewportTest:

The purpose of CVarEditorViewportTest is to provide a programmatic interface to access and modify the r.Test.EditorConstrainedView setting within the C++ code of the Unreal Engine.

This variable is used directly in the FEditorViewportClient::CalcSceneView function to determine if and how to adjust the viewport’s rendering area. When the value is non-zero, it triggers custom viewport rectangle configurations.

The value of CVarEditorViewportTest is set through the same console variable system as r.Test.EditorConstrainedView. It can be accessed and modified using the GetValueOnGameThread() method.

Developers should be aware that changes to CVarEditorViewportTest will directly affect the game view rendering. It’s important to use this variable cautiously and only for its intended testing purposes.

Best practices for using CVarEditorViewportTest include:

  1. Access the value using GetValueOnGameThread() to ensure thread-safety.
  2. Consider the performance implications of frequently checking this value in performance-critical code paths.
  3. Use preprocessor directives to exclude this code in shipping builds if necessary.
  4. Document any custom viewport configurations implemented using this variable for easier debugging and maintenance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarEditorViewportTest(
	TEXT("r.Test.EditorConstrainedView"),
	0,
	TEXT("Allows to test different viewport rectangle configuations (in game only) as they can happen when using cinematics/Editor.\n")
	TEXT("0: off(default)\n")
	TEXT("1..7: Various Configuations"),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarEditorViewportTest(
	TEXT("r.Test.EditorConstrainedView"),
	0,
	TEXT("Allows to test different viewport rectangle configuations (in game only) as they can happen when using cinematics/Editor.\n")
	TEXT("0: off(default)\n")
	TEXT("1..7: Various Configuations"),
	ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
function     FSceneView* FEditorViewportClient::CalcSceneView

Source code excerpt:

	if (ViewportSize.X > 50 && ViewportSize.Y > 50)
	{
		int32 Value = CVarEditorViewportTest.GetValueOnGameThread();

		if (Value)
		{
			int InsetX = ViewportSize.X / 4;
			int InsetY = ViewportSize.Y / 4;