r.PhysicsField.ClipmapDistance

r.PhysicsField.ClipmapDistance

#Overview

name: r.PhysicsField.ClipmapDistance

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.ClipmapDistance is to set the maximum distance from the clipmap center in the physics field system. This setting is part of Unreal Engine’s physics simulation, specifically related to the physics field component.

The Unreal Engine subsystem that relies on this setting variable is the Physics Field system, which is part of the Engine module. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Engine/Private/PhysicsField/PhysicsFieldComponent.cpp.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console. The default value is 10000 units.

This variable interacts with GPhysicsFieldClipmapDistance, which is the associated C++ variable that shares the same value. They are used together to define the maximum distance for the physics field clipmap.

Developers must be aware that this variable affects the range of the physics field simulation. Changing this value will impact the area in which physics fields are calculated and applied.

Best practices when using this variable include:

  1. Adjusting it based on the scale of your game world and the desired range of physics field effects.
  2. Balancing between performance and simulation range, as larger values may increase computational cost.
  3. Testing different values to find the optimal setting for your specific use case.

Regarding the associated variable GPhysicsFieldClipmapDistance:

The purpose of GPhysicsFieldClipmapDistance is to store the actual value of the clipmap distance in the C++ code. It’s used directly in the physics field calculations, specifically when initializing the FPhysicsFieldResource.

This variable is set at the file scope in PhysicsFieldComponent.cpp and is used within the FPhysicsFieldResource constructor to initialize the FieldInfos structure.

GPhysicsFieldClipmapDistance interacts with other physics field parameters such as GPhysicsFieldClipmapExponent, GPhysicsFieldClipmapCount, and GPhysicsFieldClipmapResolution to define the overall behavior of the physics field system.

Developers should be aware that modifying GPhysicsFieldClipmapDistance directly in the code will change the default value for the console variable r.PhysicsField.ClipmapDistance.

Best practices for using GPhysicsFieldClipmapDistance include:

  1. Avoid modifying it directly in the code unless absolutely necessary; prefer using the console variable for runtime adjustments.
  2. Consider its relationship with other physics field parameters when making changes.
  3. Use it in conjunction with the console variable for debugging and fine-tuning physics field behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsField/PhysicsFieldComponent.cpp:56

Scope: file

Source code excerpt:

float GPhysicsFieldClipmapDistance = 10000;
FAutoConsoleVariableRef CVarPhysicsFieldClipmapDistance(
	TEXT("r.PhysicsField.ClipmapDistance"),
	GPhysicsFieldClipmapDistance,
	TEXT("Max distance from the clipmap center"),
	ECVF_RenderThreadSafe
);

/** Number of used clipmaps */

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsField/PhysicsFieldComponent.cpp:54

Scope: file

Source code excerpt:


/** Clipmap max disatnce */
float GPhysicsFieldClipmapDistance = 10000;
FAutoConsoleVariableRef CVarPhysicsFieldClipmapDistance(
	TEXT("r.PhysicsField.ClipmapDistance"),
	GPhysicsFieldClipmapDistance,
	TEXT("Max distance from the clipmap center"),
	ECVF_RenderThreadSafe
);

/** Number of used clipmaps */
int32 GPhysicsFieldClipmapCount = 4;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsField/PhysicsFieldComponent.cpp:403

Scope (from outer to inner):

file
function     FPhysicsFieldResource::FPhysicsFieldResource

Source code excerpt:

	FieldInfos.ClipmapExponent = GPhysicsFieldClipmapExponent;
	FieldInfos.ClipmapCount = GPhysicsFieldClipmapCount;
	FieldInfos.ClipmapDistance = GPhysicsFieldClipmapDistance;
	FieldInfos.ClipmapResolution = GPhysicsFieldClipmapResolution;

	const uint32 CellsCount = FieldInfos.ClipmapCount * EFieldPhysicsType::Field_PhysicsType_Max;
	FieldInfos.CellsOffsets.Init(0, CellsCount + 1);
	FieldInfos.CellsMin.Init(FIntVector4(0), CellsCount);
	FieldInfos.CellsMax.Init(FIntVector4(FieldInfos.ClipmapResolution), CellsCount);