p.CollisionParticlesBVHDepth
p.CollisionParticlesBVHDepth
#Overview
name: p.CollisionParticlesBVHDepth
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum depth for collision particles bvh
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.CollisionParticlesBVHDepth
is to control the maximum depth for the Bounding Volume Hierarchy (BVH) used in collision detection for particles in Unreal Engine’s Chaos physics system.
-
This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics framework.
-
Based on the callsites, this variable is utilized in the Chaos namespace, specifically in the PBDCollisionConstraints and BVHParticles modules.
-
The value of this variable is set using an
FAutoConsoleVariableRef
, which allows it to be modified at runtime through the console. Its default value is 4. -
This variable interacts closely with the
CollisionParticlesBVHDepth
variable, which shares the same value. It’s used in the construction ofTBoundingVolumeHierarchy
objects within theFBVHParticles
class. -
Developers should be aware that modifying this value affects the performance and accuracy of collision detection for particles. A higher value may increase accuracy but at the cost of performance, while a lower value may improve performance but potentially reduce collision accuracy.
-
Best practices when using this variable include:
- Experimenting with different values to find the optimal balance between performance and collision accuracy for your specific use case.
- Monitoring performance metrics when adjusting this value, especially in scenes with many particles.
- Considering the complexity of your scene and the number of particles when setting this value.
Regarding the associated variable CollisionParticlesBVHDepth
:
-
It serves the same purpose as
p.CollisionParticlesBVHDepth
, controlling the maximum depth of the BVH for collision particles. -
This variable is used directly in the Chaos physics system, particularly in the
FBVHParticles
class constructor and when rebuilding the BVH. -
Its value is set by the console variable
p.CollisionParticlesBVHDepth
. -
It’s used as a parameter when constructing
TBoundingVolumeHierarchy
objects, which are crucial for efficient collision detection. -
Developers should be aware that this variable directly affects the structure of the BVH used for collision detection, impacting both performance and accuracy.
-
Best practices include:
- Ensuring that any changes to
p.CollisionParticlesBVHDepth
are reflected in the behavior of systems usingCollisionParticlesBVHDepth
. - Considering the impact on memory usage when adjusting this value, as deeper BVHs will consume more memory.
- Testing thoroughly after making changes, as this variable can significantly affect collision behavior throughout the physics simulation.
- Ensuring that any changes to
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:37
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
int32 CollisionParticlesBVHDepth = 4;
FAutoConsoleVariableRef CVarCollisionParticlesBVHDepth(TEXT("p.CollisionParticlesBVHDepth"), CollisionParticlesBVHDepth, TEXT("The maximum depth for collision particles bvh"));
int32 ConstraintBPBVHDepth = 2;
FAutoConsoleVariableRef CVarConstraintBPBVHDepth(TEXT("p.ConstraintBPBVHDepth"), ConstraintBPBVHDepth, TEXT("The maximum depth for constraint bvh"));
int32 BPTreeOfGrids = 1;
FAutoConsoleVariableRef CVarBPTreeOfGrids(TEXT("p.BPTreeOfGrids"), BPTreeOfGrids, TEXT("Whether to use a seperate tree of grids for bp"));
#Associated Variable and Callsites
This variable is associated with another variable named CollisionParticlesBVHDepth
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/BVHParticles.cpp:7
Scope (from outer to inner):
file
namespace Chaos
function FBVHParticles::FBVHParticles
Source code excerpt:
FBVHParticles::FBVHParticles()
: FParticles()
, MBVH(new TBoundingVolumeHierarchy<FParticles, TArray<int32>>(*this, CollisionParticlesBVHDepth))
{}
FBVHParticles::FBVHParticles(FBVHParticles&& Other)
: FParticles(MoveTemp(Other))
, MBVH(new TBoundingVolumeHierarchy<FParticles, TArray<int32>>(MoveTemp(*Other.MBVH)))
{}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/BVHParticles.cpp:17
Scope (from outer to inner):
file
namespace Chaos
function FBVHParticles::FBVHParticles
Source code excerpt:
FBVHParticles::FBVHParticles(FParticles&& Other)
: FParticles(MoveTemp(Other))
, MBVH(new TBoundingVolumeHierarchy<FParticles, TArray<int32>>(*this, CollisionParticlesBVHDepth))
{}
FBVHParticles::~FBVHParticles()
{
delete MBVH;
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/BVHParticles.cpp:46
Scope (from outer to inner):
file
namespace Chaos
function FBVHParticles::FBVHParticles
Source code excerpt:
SetX(i, Other.GetX(i));
}
MBVH = new TBoundingVolumeHierarchy<FParticles, TArray<int32>>(*this, CollisionParticlesBVHDepth);
}
void FBVHParticles::UpdateAccelerationStructures()
{
MBVH->UpdateHierarchy();
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:36
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
}
int32 CollisionParticlesBVHDepth = 4;
FAutoConsoleVariableRef CVarCollisionParticlesBVHDepth(TEXT("p.CollisionParticlesBVHDepth"), CollisionParticlesBVHDepth, TEXT("The maximum depth for collision particles bvh"));
int32 ConstraintBPBVHDepth = 2;
FAutoConsoleVariableRef CVarConstraintBPBVHDepth(TEXT("p.ConstraintBPBVHDepth"), ConstraintBPBVHDepth, TEXT("The maximum depth for constraint bvh"));
int32 BPTreeOfGrids = 1;
FAutoConsoleVariableRef CVarBPTreeOfGrids(TEXT("p.BPTreeOfGrids"), BPTreeOfGrids, TEXT("Whether to use a seperate tree of grids for bp"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/BVHParticles.h:8
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
namespace Chaos
{
extern int32 CHAOS_API CollisionParticlesBVHDepth;
template<class OBJECT_ARRAY, class LEAF_TYPE, class T, int d>
class TBoundingVolumeHierarchy;
template<class OBJECT_ARRAY, class LEAF_TYPE, class T, int d>