p.Chaos.MaxInflationScale
p.Chaos.MaxInflationScale
#Overview
name: p.Chaos.MaxInflationScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
A limit on the bounds used to detect collisions when CCD is disabled. The bounds limit is this scale multiplied by the object\'s max dimension
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.MaxInflationScale is to limit the bounds used to detect collisions when Continuous Collision Detection (CCD) is disabled in Unreal Engine’s Chaos physics system. It is used to calculate a maximum inflation scale for bounding volumes, which helps prevent objects from passing through each other during physics simulations.
This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics module. Based on the callsites, it is utilized in the BoundingVolumeHierarchy and BoundingVolumeUtilities components of the Chaos system.
The value of this variable is set through a console variable (CVar) named “p.Chaos.MaxInflationScale”. It is initialized with a default value of 2.0f but can be modified at runtime through the console or configuration files.
The associated variable Chaos_Bounds_MaxInflationScale directly interacts with p.Chaos.MaxInflationScale. They share the same value, with Chaos_Bounds_MaxInflationScale being the actual variable used in the code, while p.Chaos.MaxInflationScale is the console variable name used to modify it.
Developers must be aware that this variable only affects objects with CCD disabled. It’s crucial to understand that increasing this value will make collision detection more conservative but may impact performance, while decreasing it might lead to objects passing through each other more easily.
Best practices when using this variable include:
- Carefully balancing between collision accuracy and performance.
- Testing thoroughly with different values to find the optimal setting for your specific use case.
- Considering enabling CCD for fast-moving objects instead of relying solely on this inflation scale.
Regarding the associated variable Chaos_Bounds_MaxInflationScale:
- Its purpose is the same as p.Chaos.MaxInflationScale, serving as the actual variable used in the code.
- It is used in the Chaos physics system, specifically in bounding volume calculations.
- Its value is set through the p.Chaos.MaxInflationScale console variable.
- It directly interacts with p.Chaos.MaxInflationScale and is used in calculations for bounding volume thickness and extents.
- Developers should be aware that modifying this variable will affect all non-CCD objects in the Chaos physics simulation.
- Best practices include monitoring its impact on both collision accuracy and performance when adjusting its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/BoundingVolumeHierarchy.cpp:16
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// NOTE: This is only used by objects that have CCD disabled.
FRealSingle Chaos_Bounds_MaxInflationScale = 2.f;
FAutoConsoleVariableRef CVarBoundsMaxInflatiuonScale(TEXT("p.Chaos.MaxInflationScale"), Chaos_Bounds_MaxInflationScale, TEXT("A limit on the bounds used to detect collisions when CCD is disabled. The bounds limit is this scale multiplied by the object's max dimension"));
template<class OBJECT_ARRAY, class LEAF_TYPE, class T, int d>
TBoundingVolumeHierarchy<OBJECT_ARRAY, LEAF_TYPE, T, d>::TBoundingVolumeHierarchy(const OBJECT_ARRAY& Objects, const int32 MaxLevels, const bool bUseVelocity, const T Dt)
: MObjects(&Objects), MMaxLevels(MaxLevels)
{
#Associated Variable and Callsites
This variable is associated with another variable named Chaos_Bounds_MaxInflationScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/BoundingVolumeHierarchy.cpp:15
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// problems when colliding against zero-thickness surfaces such as tri meshes, regardless of the bounds size.
// NOTE: This is only used by objects that have CCD disabled.
FRealSingle Chaos_Bounds_MaxInflationScale = 2.f;
FAutoConsoleVariableRef CVarBoundsMaxInflatiuonScale(TEXT("p.Chaos.MaxInflationScale"), Chaos_Bounds_MaxInflationScale, TEXT("A limit on the bounds used to detect collisions when CCD is disabled. The bounds limit is this scale multiplied by the object's max dimension"));
template<class OBJECT_ARRAY, class LEAF_TYPE, class T, int d>
TBoundingVolumeHierarchy<OBJECT_ARRAY, LEAF_TYPE, T, d>::TBoundingVolumeHierarchy(const OBJECT_ARRAY& Objects, const int32 MaxLevels, const bool bUseVelocity, const T Dt)
: MObjects(&Objects), MMaxLevels(MaxLevels)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/BoundingVolumeUtilities.h:16
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
namespace Chaos
{
extern float Chaos_Bounds_MaxInflationScale;
inline FVec3 ComputeBoundsThickness(FVec3 Vel, FReal Dt, FReal MinBoundsThickness, FReal MaxBoundsThickness, FReal BoundsVelocityInflation)
{
for (int i = 0; i < 3; ++i)
{
const FReal BoundsThickness = FMath::Abs(Vel[i]) * Dt * BoundsVelocityInflation;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/BoundingVolumeUtilities.h:48
Scope (from outer to inner):
file
namespace Chaos
function inline FVec3 ComputeBoundsThickness
Source code excerpt:
else
{
MaxBoundsThickness = Chaos_Bounds_MaxInflationScale * InParticles.LocalBounds(BodyIndex).Extents().GetMax();
}
}
return ComputeBoundsThickness(InParticles.GetV(BodyIndex), Dt, MinBoundsThickness, MaxBoundsThickness, BoundsVelocityInflation);
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/BoundingVolumeUtilities.h:80
Scope (from outer to inner):
file
namespace Chaos
function FVec3 ComputeBoundsThickness
Source code excerpt:
else
{
MaxBoundsThickness = Chaos_Bounds_MaxInflationScale * ParticleHandle.LocalBounds().Extents().GetMax();
}
}
FVec3 Vel(0);
if (KinematicParticle != nullptr)
{