p.MaxBoundsForTree

p.MaxBoundsForTree

#Overview

name: p.MaxBoundsForTree

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 p.MaxBoundsForTree is to define a threshold for the maximum bounds of an object before it is moved into a large objects structure within the physics simulation system. This setting is primarily used in the Chaos physics engine, which is part of Unreal Engine’s experimental physics framework.

This setting variable is relied upon by the Chaos physics subsystem, specifically within the PBDRigidsSolver (Position Based Dynamics Rigid Solver) module. It’s used in the process of registering objects for physics simulation.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through the console. By default, it’s set to 10000.

The associated variable MaxBoundsForTree directly interacts with p.MaxBoundsForTree. They share the same value, with MaxBoundsForTree being the actual variable used in the code logic.

Developers must be aware that this variable only applies when objects are being registered for physics simulation. It’s not a dynamic property that affects objects already in the simulation. The value represents a size threshold in Unreal Engine units (typically centimeters).

Best practices when using this variable include:

  1. Carefully consider the scale of your game world when adjusting this value.
  2. Monitor performance impacts when modifying this value, as it affects how large objects are handled in the physics simulation.
  3. Use the console variable for testing different values before settling on a final value for your project.

Regarding the associated variable MaxBoundsForTree:

By understanding and correctly utilizing this variable, developers can fine-tune the physics simulation for large objects in their Unreal Engine projects using the Chaos physics engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:730

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FRealSingle MaxBoundsForTree = (FRealSingle)10000;
	FAutoConsoleVariableRef CVarMaxBoundsForTree(
		TEXT("p.MaxBoundsForTree"),
		MaxBoundsForTree,
		TEXT("The max bounds before moving object into a large objects structure. Only applies on object registration")
		TEXT(""),
		ECVF_Default);

	void FPBDRigidsSolver::RegisterObject(FSingleParticlePhysicsProxy* Proxy)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:728

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

#endif

	FRealSingle MaxBoundsForTree = (FRealSingle)10000;
	FAutoConsoleVariableRef CVarMaxBoundsForTree(
		TEXT("p.MaxBoundsForTree"),
		MaxBoundsForTree,
		TEXT("The max bounds before moving object into a large objects structure. Only applies on object registration")
		TEXT(""),
		ECVF_Default);

	void FPBDRigidsSolver::RegisterObject(FSingleParticlePhysicsProxy* Proxy)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:749

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::RegisterObject

Source code excerpt:

			RigidBody_External.SetSpatialIdx(Idx);
		}
		else if (RigidBody_External.GetGeometry() && RigidBody_External.GetGeometry()->HasBoundingBox() && RigidBody_External.GetGeometry()->BoundingBox().Extents().Max() >= MaxBoundsForTree)
		{
			RigidBody_External.SetSpatialIdx(FSpatialAccelerationIdx{ 1,0 });
		}
		if (!ensure(Proxy->GetParticle_LowLevel()->IsParticleValid()))
		{
			return;