p.Chaos.Collision.UnionBVH.SplitBias

p.Chaos.Collision.UnionBVH.SplitBias

#Overview

name: p.Chaos.Collision.UnionBVH.SplitBias

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Collision.UnionBVH.SplitBias is to control the splitting behavior in the Bounding Volume Hierarchy (BVH) used for collision detection in the Chaos physics system of Unreal Engine 5. Specifically, it affects how objects are partitioned when building the BVH tree structure.

This setting variable is primarily used by the Chaos physics subsystem, which is part of Unreal Engine’s experimental features. It is referenced in the ImplicitObjectUnion and ImplicitObjectBVH modules of the Chaos namespace.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. Its default value is 0.1f.

The associated variable ChaosUnionBVHSplitBias interacts directly with p.Chaos.Collision.UnionBVH.SplitBias. They share the same value, and ChaosUnionBVHSplitBias is used in the actual implementation of the BVH partitioning algorithm.

Developers must be aware that this variable affects the performance and accuracy of collision detection. A higher value may result in more balanced BVH trees but could potentially increase computation time.

Best practices when using this variable include:

  1. Only modify it if you understand the implications on collision detection performance.
  2. Test thoroughly after changing the value to ensure it doesn’t negatively impact your specific use case.
  3. Consider using different values for different scenarios or object types if necessary.

Regarding the associated variable ChaosUnionBVHSplitBias:

The purpose of ChaosUnionBVHSplitBias is to provide a small offset when calculating the split point in the BVH partitioning algorithm. This helps prevent objects exactly in the middle of a cell’s bounds from being assigned to a random child node.

It is used directly in the FImplicitBVH::Partition function to calculate the split point:

const FVec3f SplitPoint = MeanCenter + FVec3(CVars::ChaosUnionBVHSplitBias);

This variable is set in the Chaos::CVars namespace and is used in the ImplicitObjectBVH module.

Developers should be aware that changing this value will affect how objects are distributed in the BVH tree, which can impact both performance and the accuracy of collision detection.

Best practices for ChaosUnionBVHSplitBias include:

  1. Keep the value small to avoid significantly skewing the BVH structure.
  2. If collision detection issues arise with objects at the boundaries of BVH nodes, consider adjusting this value slightly.
  3. Always profile and test thoroughly after making changes to ensure overall system performance is not negatively affected.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ImplicitObjectUnion.cpp:31

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// a random child. See FImplicitBVH::Partition.
		FRealSingle ChaosUnionBVHSplitBias = 0.1f;
		FAutoConsoleVariableRef CVarChaosUnionBVHSplitBias(TEXT("p.Chaos.Collision.UnionBVH.SplitBias"), ChaosUnionBVHSplitBias, TEXT(""));

		// Use the new FImplicitObject::CountLeafObjectsInHierarchy to count leaf objects
		// @todo: remove this when tested
		bool bChaosImplicitBVHOptimizedCountLeafObjects = true;
		FAutoConsoleVariableRef CVarChaosImplicitBVHOptimizedCountLeafObjects(TEXT("p.Chaos.Collision.UnionBVH.UseOptimizedCountLeafObjects"), bChaosImplicitBVHOptimizedCountLeafObjects, TEXT(""));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ImplicitObjectBVH.cpp:7

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	namespace CVars
	{
		extern FRealSingle ChaosUnionBVHSplitBias;

		extern bool bChaosImplicitBVHOptimizedCountLeafObjects;
	}

	namespace Private
	{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ImplicitObjectBVH.cpp:228

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     bool FImplicitBVH::Partition

Source code excerpt:

			}
			MeanCenter /= FRealSingle(NumNodeObjects);
			const FVec3f SplitPoint = MeanCenter + FVec3(CVars::ChaosUnionBVHSplitBias);

			// Determine the split axis based on how many objects are exclusively one one side of the split
			// @todo(chaos): look at how much volume we add to each side of the split bounds instead?
			TVec3<int32> RejectLeft = TVec3<int32>(0);
			TVec3<int32> RejectRight = TVec3<int32>(0);
			for (int32 NodeObjectIndex = ObjectBeginIndex; NodeObjectIndex < ObjectEndIndex; ++NodeObjectIndex)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ImplicitObjectUnion.cpp:30

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// This prevents objects exactly in the middle of the bounds of a cell from being assigned to 
		// a random child. See FImplicitBVH::Partition.
		FRealSingle ChaosUnionBVHSplitBias = 0.1f;
		FAutoConsoleVariableRef CVarChaosUnionBVHSplitBias(TEXT("p.Chaos.Collision.UnionBVH.SplitBias"), ChaosUnionBVHSplitBias, TEXT(""));

		// Use the new FImplicitObject::CountLeafObjectsInHierarchy to count leaf objects
		// @todo: remove this when tested
		bool bChaosImplicitBVHOptimizedCountLeafObjects = true;
		FAutoConsoleVariableRef CVarChaosImplicitBVHOptimizedCountLeafObjects(TEXT("p.Chaos.Collision.UnionBVH.UseOptimizedCountLeafObjects"), bChaosImplicitBVHOptimizedCountLeafObjects, TEXT(""));