p.Chaos.Convex.SimplifyUnion
p.Chaos.Convex.SimplifyUnion
#Overview
name: p.Chaos.Convex.SimplifyUnion
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true replace all the convexes within an implcit hierarchy with a simplified one (kdop18 tribox for now) for collision
It is referenced in 11
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Convex.SimplifyUnion
is to control the simplification of convex shapes within the Chaos physics system in Unreal Engine 5. It is primarily used for collision detection and optimization in the physics simulation.
This setting variable is mainly used by the Chaos physics subsystem, which is part of the Experimental module in Unreal Engine 5. It is specifically utilized in the ConvexOptimizer and GeometryCollection components.
The value of this variable is set through a console variable (CVar) system. It is initialized as false
by default, but can be changed at runtime or through configuration files.
The associated variable bChaosConvexSimplifyUnion
directly interacts with p.Chaos.Convex.SimplifyUnion
. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable is experimental and enabling it will replace all convexes within an implicit hierarchy with a simplified one (currently a kdop18 tribox) for collision detection. This can significantly impact physics performance and accuracy.
Best practices when using this variable include:
- Only enable it if you need to optimize physics performance and are willing to trade some accuracy.
- Test thoroughly after enabling to ensure it doesn’t negatively impact your game’s physics behavior.
- Be cautious when using it in production, as it’s marked as experimental.
Regarding the associated variable bChaosConvexSimplifyUnion
:
- Its purpose is the same as
p.Chaos.Convex.SimplifyUnion
, serving as an internal representation of the console variable. - It is used directly in the Chaos physics code to control the convex simplification behavior.
- It is typically not set directly by developers but rather controlled through the console variable system.
- When using this variable, developers should treat it the same as the console variable, being aware of its experimental nature and potential impact on physics simulations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:13
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Replace all the convexes within an implicit hierarchy with a simplified one (kdop18 tribox for now) for collision
CHAOS_API bool bChaosConvexSimplifyUnion = false;
FAutoConsoleVariableRef CVarChaosSimplifyUnion(TEXT("p.Chaos.Convex.SimplifyUnion"), bChaosConvexSimplifyUnion, TEXT("If true replace all the convexes within an implcit hierarchy with a simplified one (kdop18 tribox for now) for collision"));
// Max number of convex LODs used during simplification for dynamic particles
int32 ChaosConvexKinematicMode = 2;
FAutoConsoleVariableRef CVarChaosConvexKinematicMode(TEXT("p.Chaos.Convex.KinematicMode"), ChaosConvexKinematicMode, TEXT("Simplification mode for the kinematic shapes (0: Single Convex, 1: One convex per children, 2: Merge connected children using the splitting threshold"));
// Max number of convex LODs used during simplification for kinematic particles
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Public/GeometryCollection/GeometryCollectionObject.h:707
Scope (from outer to inner):
file
class class UGeometryCollection : public UObject, public IInterface_AssetUserData
Source code excerpt:
* whether to optimize convexes for collisions. If true the convex optimizer will generate at runtime one
* single convex shape for physics collisions ignoring all the user defined ones.
* Enable p.Chaos.Convex.SimplifyUnion cvar to be able to use it (experimental)
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collisions")
bool bOptimizeConvexes = true;
#if WITH_EDITORONLY_DATA
/**
* Number of particles on the triangulated surface to use for collisions.
*/
UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "This property is deprecated. Use the default SizeSpecificData instead."))
float CollisionParticlesFraction_DEPRECATED;
#Associated Variable and Callsites
This variable is associated with another variable named bChaosConvexSimplifyUnion
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:12
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
{
// Replace all the convexes within an implicit hierarchy with a simplified one (kdop18 tribox for now) for collision
CHAOS_API bool bChaosConvexSimplifyUnion = false;
FAutoConsoleVariableRef CVarChaosSimplifyUnion(TEXT("p.Chaos.Convex.SimplifyUnion"), bChaosConvexSimplifyUnion, TEXT("If true replace all the convexes within an implcit hierarchy with a simplified one (kdop18 tribox for now) for collision"));
// Max number of convex LODs used during simplification for dynamic particles
int32 ChaosConvexKinematicMode = 2;
FAutoConsoleVariableRef CVarChaosConvexKinematicMode(TEXT("p.Chaos.Convex.KinematicMode"), ChaosConvexKinematicMode, TEXT("Simplification mode for the kinematic shapes (0: Single Convex, 1: One convex per children, 2: Merge connected children using the splitting threshold"));
// Max number of convex LODs used during simplification for kinematic particles
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:50
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function void FConvexOptimizer::VisitCollisionObjects
Source code excerpt:
void FConvexOptimizer::VisitCollisionObjects(const FImplicitHierarchyVisitor& VisitorFunc) const
{
if(CVars::bChaosConvexSimplifyUnion)
{
const TArray<Private::FImplicitBVHObject>& ImplicitObjects = BVH.IsValid() ? BVH->GetObjects() : CollisionObjects->ImplicitObjects;
int32 ObjectIndex = 1;
for(const Private::FImplicitBVHObject& CollisionObject : ImplicitObjects)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:66
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function void FConvexOptimizer::VisitOverlappingObjects
Source code excerpt:
void FConvexOptimizer::VisitOverlappingObjects(const FAABB3& LocalBounds, const FImplicitHierarchyVisitor& VisitorFunc) const
{
if(CVars::bChaosConvexSimplifyUnion)
{
int32 ObjectIndex = 1;
if(BVH.IsValid())
{
BVH->VisitAllIntersections(LocalBounds,
[this, &ObjectIndex, &VisitorFunc, &LocalBounds](const FImplicitObject* Implicit, const FRigidTransform3f& RelativeTransformf,
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:121
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function void FConvexOptimizer::SimplifyRootConvexes
Source code excerpt:
SCOPE_CYCLE_COUNTER(STAT_Collisions_SimplifyConvexes);
if(CVars::bChaosConvexSimplifyUnion && UnionGeometry && (UnionShapes.Num() > 0) && (UnionShapes.Num() == bOptimizeConvexes.Num()) &&
(UnionShapes.Num() <= UnionGeometry->GetObjects().Num()))
{
SimplifiedConvexes.Reset();
CollisionObjects->ImplicitObjects.Reset();
ShapesArray.Reset();
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:74
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
namespace CVars
{
extern CHAOS_API bool bChaosConvexSimplifyUnion;
}
template <typename TProxy=FGeometryCollectionPhysicsProxy>
TProxy* GetConcreteProxy(FPBDRigidClusteredParticleHandle* ClusteredParticle)
{
if (ClusteredParticle)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:394
Scope (from outer to inner):
file
namespace Chaos
function void FRigidClustering::BuildConvexOptimizer
Source code excerpt:
{
bool bHasOptimizer = false;
if(Particle && Particle->GetGeometry() && CVars::bChaosConvexSimplifyUnion)
{
if(FImplicitObjectUnion* Union = Particle->GetGeometry()->template AsA<FImplicitObjectUnion>())
{
TBitArray<> bOptimizeConvexes;
bOptimizeConvexes.Init(true, Particle->ShapesArray().Num());
if (FGeometryCollectionPhysicsProxy* ConcreteProxy = GetConcreteProxy(Particle))
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionObject.cpp:72
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
namespace CVars
{
extern CHAOS_API bool bChaosConvexSimplifyUnion;
}
}
#if ENABLE_COOK_STATS
namespace GeometryCollectionCookStats
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionObject.cpp:124
Scope (from outer to inner):
file
function UGeometryCollection::UGeometryCollection
Source code excerpt:
, MinimumMassClamp(0.1f)
, bImportCollisionFromSource(false)
, bOptimizeConvexes(Chaos::CVars::bChaosConvexSimplifyUnion)
, bScaleOnRemoval(true)
, bRemoveOnMaxSleep(false)
, MaximumSleepTime(5.0, 10.0)
, RemovalDuration(2.5, 5.0)
, bSlowMovingAsSleeping(true)
, SlowMovingVelocityThreshold(1)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionObject.cpp:2009
Scope (from outer to inner):
file
function bool UGeometryCollection::CanEditChange
Source code excerpt:
if (Name == GET_MEMBER_NAME_CHECKED(ThisClass, bOptimizeConvexes))
{
return Chaos::CVars::bChaosConvexSimplifyUnion == true;
}
return true;
}
#endif