r.PhysicsField.Rendering.TargetType

r.PhysicsField.Rendering.TargetType

#Overview

name: r.PhysicsField.Rendering.TargetType

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.PhysicsField.Rendering.TargetType is to control the physics field target type used in the viewport show options for rendering physics fields in Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for physics field visualization.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evident from the file location (Runtime/Renderer/Private/PhysicsFieldRendering.cpp).

The value of this variable is set through the console variable system using FAutoConsoleVariableRef. It can be changed at runtime using console commands or through configuration files.

This variable interacts directly with its associated variable GPhysicsFieldTargetType. They share the same value, with GPhysicsFieldTargetType being the actual integer variable used in the code logic.

Developers must be aware that:

  1. The variable is render thread safe (ECVF_RenderThreadSafe).
  2. It affects the visualization of physics fields in the viewport.
  3. The valid range for this variable is from 0 to EFieldPhysicsType::Field_PhysicsType_Max - 1.

Best practices when using this variable include:

  1. Use it for debugging and visualization purposes only.
  2. Be cautious when changing its value at runtime, as it may impact performance or visual output.
  3. Consider the relationship between this variable and other physics field rendering settings.

Regarding the associated variable GPhysicsFieldTargetType:

The purpose of GPhysicsFieldTargetType is to store the actual integer value representing the physics field target type used in rendering.

It is used directly in the AddPhysicsFieldRayMarchingPass function to determine which physics fields to render. If GPhysicsFieldTargetType is less than Field_PhysicsType_Max, it renders only that specific type. Otherwise, it renders all types.

The value of GPhysicsFieldTargetType is set through the console variable system and can be modified using the “r.PhysicsField.Rendering.TargetType” console command.

Developers should be aware that:

  1. The default value is EFieldPhysicsType::Field_PhysicsType_Max, which means all types are rendered by default.
  2. Changing this value will directly affect which physics fields are visualized in the viewport.

Best practices for using GPhysicsFieldTargetType include:

  1. Use it in conjunction with other physics field debugging tools.
  2. Reset it to the default value (Field_PhysicsType_Max) when not actively debugging specific field types.
  3. Be mindful of potential performance impacts when rendering all field types simultaneously.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PhysicsFieldRendering.cpp:21

Scope: file

Source code excerpt:

int32 GPhysicsFieldTargetType = EFieldPhysicsType::Field_PhysicsType_Max;
FAutoConsoleVariableRef CVarPhysicsFieldTargetType(
	TEXT("r.PhysicsField.Rendering.TargetType"),
	GPhysicsFieldTargetType,
	TEXT("Physics field target to be used in the viewport show options.\n"),
	ECVF_RenderThreadSafe);

int32 GPhysicsFieldEvalType = 0;
FAutoConsoleVariableRef CVarPhysicsFieldEvalType(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PhysicsFieldRendering.cpp:19

Scope: file

Source code excerpt:


// Console variables
int32 GPhysicsFieldTargetType = EFieldPhysicsType::Field_PhysicsType_Max;
FAutoConsoleVariableRef CVarPhysicsFieldTargetType(
	TEXT("r.PhysicsField.Rendering.TargetType"),
	GPhysicsFieldTargetType,
	TEXT("Physics field target to be used in the viewport show options.\n"),
	ECVF_RenderThreadSafe);

int32 GPhysicsFieldEvalType = 0;
FAutoConsoleVariableRef CVarPhysicsFieldEvalType(
	TEXT("r.PhysicsField.Rendering.EvalType"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PhysicsFieldRendering.cpp:166

Scope (from outer to inner):

file
function     static void AddPhysicsFieldRayMarchingPass

Source code excerpt:


	uint32 PrintOffset = 0;
	if(GPhysicsFieldTargetType < EFieldPhysicsType::Field_PhysicsType_Max)
	{
		RenderPhysicsField(GPhysicsFieldTargetType, true, PrintOffset);
		RenderPhysicsField(GPhysicsFieldTargetType, false, PrintOffset);
	}
	else
	{
		for (int32 TargetType = 0; TargetType < EFieldPhysicsType::Field_PhysicsType_Max; ++TargetType)
		{
			RenderPhysicsField(TargetType, true, PrintOffset);