p.ForceNoCollisionIntoSQ
p.ForceNoCollisionIntoSQ
#Overview
name: p.ForceNoCollisionIntoSQ
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled, all particles end up in sq structure, even ones with no collision
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ForceNoCollisionIntoSQ
is to control the inclusion of particles in the spatial query (SQ) structure within the Unreal Engine’s Chaos physics system. This setting variable is primarily used in the physics simulation and collision detection subsystems.
The Chaos physics system, which is part of Unreal Engine’s Experimental module, relies on this setting variable. It’s specifically used in the particle simulation and spatial query operations.
The value of this variable is set as a console variable, which means it can be modified at runtime. It’s initialized to 0 (disabled) by default:
CHAOS_API int32 ForceNoCollisionIntoSQ = 0;
FAutoConsoleVariableRef CVarForceNoCollisionIntoSQ(TEXT("p.ForceNoCollisionIntoSQ"), ForceNoCollisionIntoSQ, TEXT("When enabled, all particles end up in sq structure, even ones with no collision"));
This variable interacts with the particle collision system. When enabled (set to a non-zero value), it forces all particles to be included in the spatial query structure, even those that don’t have collision properties.
Developers must be aware that enabling this variable can potentially impact performance, as it increases the number of particles in the spatial query structure. This could lead to more computation time for spatial queries and collision detection.
Best practices when using this variable include:
- Keep it disabled (0) by default for optimal performance.
- Enable it only when debugging collision issues or when you specifically need all particles in the spatial query structure.
- Monitor performance when enabling this variable, especially in scenes with many particles.
The associated variable ForceNoCollisionIntoSQ
is the actual int32 variable that stores the value. It’s used in the same way as p.ForceNoCollisionIntoSQ
, but it’s the internal representation of the console variable. This variable is used directly in the code to check the setting’s value:
if (Particle.HasCollision() || ForceNoCollisionIntoSQ)
{
// Add particle to spatial query structure
}
When working with this variable, developers should use the console command p.ForceNoCollisionIntoSQ
to modify its value during runtime, and use ForceNoCollisionIntoSQ
in C++ code to check its current state.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/SingleParticlePhysicsProxy.cpp:48
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
CHAOS_API int32 ForceNoCollisionIntoSQ = 0;
FAutoConsoleVariableRef CVarForceNoCollisionIntoSQ(TEXT("p.ForceNoCollisionIntoSQ"), ForceNoCollisionIntoSQ, TEXT("When enabled, all particles end up in sq structure, even ones with no collision"));
template <Chaos::EParticleType ParticleType>
void PushToPhysicsStateImp(const Chaos::FDirtyPropertiesManager& Manager, Chaos::FGeometryParticleHandle* Handle, int32 DataIdx, const Chaos::FDirtyProxy& Dirty, Chaos::FShapeDirtyData* ShapesData, Chaos::FPBDRigidsSolver& Solver, bool bResimInitialized, Chaos::FReal ExternalDt)
{
using namespace Chaos;
constexpr bool bHasKinematicData = ParticleType != EParticleType::Static;
#Associated Variable and Callsites
This variable is associated with another variable named ForceNoCollisionIntoSQ
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/SingleParticlePhysicsProxy.cpp:47
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
}
CHAOS_API int32 ForceNoCollisionIntoSQ = 0;
FAutoConsoleVariableRef CVarForceNoCollisionIntoSQ(TEXT("p.ForceNoCollisionIntoSQ"), ForceNoCollisionIntoSQ, TEXT("When enabled, all particles end up in sq structure, even ones with no collision"));
template <Chaos::EParticleType ParticleType>
void PushToPhysicsStateImp(const Chaos::FDirtyPropertiesManager& Manager, Chaos::FGeometryParticleHandle* Handle, int32 DataIdx, const Chaos::FDirtyProxy& Dirty, Chaos::FShapeDirtyData* ShapesData, Chaos::FPBDRigidsSolver& Solver, bool bResimInitialized, Chaos::FReal ExternalDt)
{
using namespace Chaos;
constexpr bool bHasKinematicData = ParticleType != EParticleType::Static;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/SingleParticlePhysicsProxy.cpp:159
Scope (from outer to inner):
file
namespace Chaos
function void PushToPhysicsStateImp
Source code excerpt:
}
if(bUpdateCollisionData && !ForceNoCollisionIntoSQ)
{
//Some shapes were not dirty and may have collision - so have to iterate them all. TODO: find a better way to handle this case
if(!bHasCollision && Dirty.ShapeDataIndices.Num() != Handle->ShapesArray().Num())
{
for (const TUniquePtr<FPerShapeData>& Shape : Handle->ShapesArray())
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsEvolution.h:31
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
namespace Chaos
{
extern CHAOS_API int32 ForceNoCollisionIntoSQ;
struct FBroadPhaseConfig
{
enum
{
Grid = 0,
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsEvolution.h:545
Scope (from outer to inner):
file
namespace Chaos
class class FPBDRigidsEvolutionBase
function void DirtyParticle
Source code excerpt:
//only add to acceleration structure if it has collision
if (Particle.HasCollision() || ForceNoCollisionIntoSQ)
{
//TODO: distinguish between new particles and dirty particles - Adds and updates are treated the same right now
const FUniqueIdx UniqueIdx = Particle.UniqueIdx();
FPendingSpatialData& SpatialData = InternalAccelerationQueue.FindOrAdd(UniqueIdx);
ensure(SpatialData.Operation != EPendingSpatialDataOperation::Delete);