p.SampleMinParticlesForAcceleration

p.SampleMinParticlesForAcceleration

#Overview

name: p.SampleMinParticlesForAcceleration

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.SampleMinParticlesForAcceleration is to define a threshold for using an acceleration structure when sampling particles in the Chaos physics system of Unreal Engine 5. This setting is primarily used in collision resolution and particle sampling scenarios.

This setting variable is relied upon by the Chaos physics system, which is part of Unreal Engine’s experimental physics module. It’s specifically used in the collision resolution utility 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. The default value is set to 2048 particles.

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

Developers must be aware that this variable affects performance and accuracy trade-offs in particle simulations. When the number of particles exceeds this threshold, the system uses an acceleration structure for sampling, which can improve performance for large particle sets but may introduce some overhead for smaller sets.

Best practices when using this variable include:

  1. Adjusting the value based on the scale and complexity of your particle simulations.
  2. Profiling your game to find the optimal balance between performance and accuracy.
  3. Consider exposing this setting in your game’s advanced options for users with varying hardware capabilities.

Regarding the associated variable SampleMinParticlesForAcceleration:

The purpose of SampleMinParticlesForAcceleration is to serve as the actual integer value used in the code logic for determining when to use acceleration structures in particle sampling.

This variable is used directly in the Chaos physics system, specifically in the CollisionResolutionUtil.cpp file within the Chaos namespace.

The value of this variable is set at the beginning of the file and can be modified through the console variable p.SampleMinParticlesForAcceleration.

It interacts directly with the console variable p.SampleMinParticlesForAcceleration, sharing the same value.

Developers should be aware that this variable is used in conditional statements to determine whether to use acceleration structures for particle sampling. It directly affects the performance and behavior of the collision resolution system.

Best practices for using this variable include:

  1. Avoid modifying it directly in code; instead, use the console variable for runtime adjustments.
  2. Consider the impact on performance when changing this value, as it affects when acceleration structures are used.
  3. Test thoroughly with different particle counts to ensure optimal performance across various scenarios in your game.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:161

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions

Source code excerpt:


		int32 SampleMinParticlesForAcceleration = 2048;
		FAutoConsoleVariableRef CVarSampleMinParticlesForAcceleration(TEXT("p.SampleMinParticlesForAcceleration"), SampleMinParticlesForAcceleration, TEXT("The minimum number of particles needed before using an acceleration structure when sampling"));


#if INTEL_ISPC && 0
		// LWC_TODO: get ISPC levelset collision working again

		template<ECollisionUpdateType UpdateType>

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:160

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions

Source code excerpt:

		FAutoConsoleVariableRef CVarNormalAveraging(TEXT("p.NormalAveraging2"), NormalAveraging, TEXT(""));

		int32 SampleMinParticlesForAcceleration = 2048;
		FAutoConsoleVariableRef CVarSampleMinParticlesForAcceleration(TEXT("p.SampleMinParticlesForAcceleration"), SampleMinParticlesForAcceleration, TEXT("The minimum number of particles needed before using an acceleration structure when sampling"));


#if INTEL_ISPC && 0
		// LWC_TODO: get ISPC levelset collision working again

		template<ECollisionUpdateType UpdateType>

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:190

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

			int32 NumParticles = SampleParticles.Size();

			if (NumParticles > SampleMinParticlesForAcceleration && Object.HasBoundingBox())
			{
				SCOPE_CYCLE_COUNTER(STAT_UpdateLevelsetPartial);
				FAABB3 ImplicitBox = Object.BoundingBox().TransformedAABB(ObjectTransform.GetRelativeTransform(SampleParticlesTransform));
				ImplicitBox.Thicken(CullingDistance);
				TArray<int32> PotentialParticles;
				{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:539

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:


			const FRigidTransform3 & SampleToObjectTM = SampleParticlesTransform.GetRelativeTransform(ObjectTransform);
			if (NumParticles > SampleMinParticlesForAcceleration && Object.HasBoundingBox())
			{
				SCOPE_CYCLE_COUNTER(STAT_UpdateLevelsetPartial);
				FAABB3 ImplicitBox = Object.BoundingBox().TransformedAABB(ObjectTransform.GetRelativeTransform(SampleParticlesTransform));
				ImplicitBox.Thicken(CullingDistance);
				TArray<int32> PotentialParticles;
				{