r.Test.ConstrainedView
r.Test.ConstrainedView
#Overview
name: r.Test.ConstrainedView
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to test different viewport rectangle configuations (in game only) as they can happen when using cinematics/Editor.\n0: off(default)\n1..7: Various Configuations
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Test.ConstrainedView is to test different viewport rectangle configurations in the game environment, simulating scenarios that might occur when using cinematics or the Editor. This setting variable is primarily used for debugging and testing purposes in the rendering system.
The Unreal Engine subsystems that rely on this setting variable are:
- The rendering system, particularly in the Editor and viewport management.
- The Local Player system, which handles player-specific viewports.
The value of this variable is set through a console variable, which can be modified at runtime. It is initialized with a default value of 0 (off) and can be set to values between 1 and 7 to test various viewport configurations.
The associated variable CVarViewportTest interacts directly with r.Test.ConstrainedView. They share the same value and are used interchangeably in the code.
Developers must be aware of the following when using this variable:
- It is only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
- It affects the viewport rectangle configuration, which can impact the visual output of the game.
- Different values (1-7) correspond to various viewport configurations, but the exact configurations are not specified in the provided code.
Best practices when using this variable include:
- Use it only for testing and debugging purposes, not in production code.
- Be aware of its impact on performance and visual output when enabled.
- Reset the value to 0 (off) when not actively testing to ensure normal viewport behavior.
Regarding the associated variable CVarViewportTest:
The purpose of CVarViewportTest is to provide a convenient way to access and modify the r.Test.ConstrainedView setting through C++ code. It is defined as a TAutoConsoleVariable, which allows it to be easily accessed and modified at runtime.
CVarViewportTest is used in the Local Player system to determine if and how the viewport should be constrained. It is checked in the GetProjectionData function of the ULocalPlayer class, which is responsible for calculating the player’s view projection.
The value of CVarViewportTest is set through the same console variable as r.Test.ConstrainedView. It can be accessed in C++ code using the GetValueOnGameThread() method.
Developers should be aware that modifying CVarViewportTest will directly affect the r.Test.ConstrainedView setting and vice versa. They should use CVarViewportTest when they need to access or modify the setting within C++ code, particularly in the Local Player and rendering systems.
Best practices for using CVarViewportTest include:
- Use GetValueOnGameThread() to retrieve its current value in a thread-safe manner.
- Only modify its value for testing and debugging purposes.
- Be cautious when using it in performance-critical code, as accessing console variables can have a small performance cost.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LocalPlayer.cpp:45
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarViewportTest(
TEXT("r.Test.ConstrainedView"),
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:1279
Scope (from outer to inner):
file
function FSceneView* FEditorViewportClient::CalcSceneView
Source code excerpt:
#if !UE_BUILD_SHIPPING
{
static const auto CVarVSync = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Test.ConstrainedView"));
int32 Value = CVarVSync->GetValueOnGameThread();
if (Value)
{
const FIntRect& ViewRect = ViewInitOptions.GetViewRect();
FIntRect ConstrainedViewRect = ViewInitOptions.GetConstrainedViewRect();
#Associated Variable and Callsites
This variable is associated with another variable named CVarViewportTest
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LocalPlayer.cpp:44
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarViewportTest(
TEXT("r.Test.ConstrainedView"),
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/Runtime/Engine/Private/LocalPlayer.cpp:1172
Scope (from outer to inner):
file
function bool ULocalPlayer::GetProjectionData
Source code excerpt:
if(SizeX > 50 && SizeY > 50)
{
int32 Value = CVarViewportTest.GetValueOnGameThread();
if(Value)
{
int InsetX = SizeX / 4;
int InsetY = SizeY / 4;