r.PhysicsField.EnableCulling

r.PhysicsField.EnableCulling

#Overview

name: r.PhysicsField.EnableCulling

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.EnableCulling is to control the spatial culling functionality for physics field nodes based on their bounds. This setting is part of the physics simulation system in Unreal Engine 5.

This setting variable is primarily used in the Engine module, specifically within the physics field component implementation. It’s part of the physics simulation subsystem of Unreal Engine.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files. Its default value is 1, indicating that culling is enabled by default.

The associated variable GPhysicsFieldEnableCulling directly interacts with r.PhysicsField.EnableCulling. They share the same value, with GPhysicsFieldEnableCulling being the actual integer variable used in the code logic.

Developers should be aware that this variable affects performance and accuracy of physics simulations involving field nodes. When enabled (set to 1), it allows for spatial culling based on the field nodes’ bounds, which can improve performance by reducing unnecessary calculations for out-of-bounds nodes.

Best practices when using this variable include:

  1. Keep it enabled (set to 1) for better performance in most scenarios.
  2. Consider disabling it (set to 0) only if you notice issues with physics field behavior that might be caused by overzealous culling.
  3. Profile your game with both settings to determine the optimal configuration for your specific use case.

Regarding the associated variable GPhysicsFieldEnableCulling:

#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:101

Scope: file

Source code excerpt:

int32 GPhysicsFieldEnableCulling = 1;
FAutoConsoleVariableRef CVarPhysicsFieldEnableCulling(
	TEXT("r.PhysicsField.EnableCulling"),
	GPhysicsFieldEnableCulling,
	TEXT("Enable the spatial culling based on the field nodes bounds"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


/** Spatial culling */
int32 GPhysicsFieldEnableCulling = 1;
FAutoConsoleVariableRef CVarPhysicsFieldEnableCulling(
	TEXT("r.PhysicsField.EnableCulling"),
	GPhysicsFieldEnableCulling,
	TEXT("Enable the spatial culling based on the field nodes bounds"),
	ECVF_RenderThreadSafe
);


/**

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

Scope (from outer to inner):

file
function     void FPhysicsFieldResource::UpdateBounds

Source code excerpt:

	FieldInfos.CellsMax.Init(FIntVector4(FieldInfos.ClipmapResolution), CellsCount);

	if(GPhysicsFieldEnableCulling == 1)
	{ 
		FieldInfos.ValidCount = 0;
		for (auto& TargetType : FieldInfos.TargetTypes)
		{
			if((TargetOffsets[TargetType+1]- TargetOffsets[TargetType]) > 0)
			{