p.GeometryCollectionDisableGravity
p.GeometryCollectionDisableGravity
#Overview
name: p.GeometryCollectionDisableGravity
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Disable gravity for geometry collections
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.GeometryCollectionDisableGravity is to provide a console variable that allows developers to disable gravity for geometry collections in Unreal Engine 5. This setting is primarily used in the physics simulation system, specifically for the Chaos physics engine’s geometry collection functionality.
This setting variable is utilized in the Experimental Chaos module of Unreal Engine 5, which is part of the physics simulation system. The code references are found in the GeometryCollectionPhysicsProxy.cpp file, indicating that it’s specifically used for handling the physics of geometry collections.
The value of this variable is set through the console variable system (CVarGeometryCollectionDisableGravity). It can be changed at runtime using console commands or through configuration files.
The p.GeometryCollectionDisableGravity variable interacts directly with the DisableGeometryCollectionGravity boolean variable. They share the same value, with the console variable acting as an interface to modify the boolean.
Developers should be aware that this variable affects all geometry collections in the scene when enabled. It’s a global setting that can have a significant impact on the physics simulation of geometry collections.
Best practices for using this variable include:
- Use it primarily for debugging or specific gameplay scenarios where gravity-free geometry collections are desired.
- Be cautious when enabling this in a production environment, as it can lead to unrealistic behavior.
- Consider creating more granular control mechanisms if you need to disable gravity for specific geometry collections rather than all of them.
Regarding the associated variable DisableGeometryCollectionGravity:
The purpose of DisableGeometryCollectionGravity is to store the actual boolean value that determines whether gravity is disabled for geometry collections.
This variable is used directly in the physics simulation code, specifically in the FGeometryCollectionPhysicsProxy::InitializeBodiesPT function. It’s combined with the Parameters.EnableGravity value to determine if gravity should be applied to geometry collection particles.
The value of this variable is set by the console variable system through p.GeometryCollectionDisableGravity.
DisableGeometryCollectionGravity interacts with the Parameters.EnableGravity variable in the physics simulation code. The final gravity state for geometry collections is determined by the combination of these two variables.
Developers should be aware that this variable’s value is used directly in the physics simulation logic. Changing it will immediately affect the behavior of all geometry collections in the scene.
Best practices for using this variable include:
- Avoid modifying it directly in code; instead, use the console variable p.GeometryCollectionDisableGravity to change its value.
- When debugging physics issues related to geometry collections, check the state of this variable to ensure gravity is behaving as expected.
- Consider adding logging or visualization tools to track when this variable is affecting the simulation, especially if it’s being toggled frequently during gameplay.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:79
Scope: file
Source code excerpt:
bool DisableGeometryCollectionGravity = false;
FAutoConsoleVariableRef CVarGeometryCollectionDisableGravity(
TEXT("p.GeometryCollectionDisableGravity"),
DisableGeometryCollectionGravity,
TEXT("Disable gravity for geometry collections"));
bool GeometryCollectionCollideAll = false;
FAutoConsoleVariableRef CVarGeometryCollectionCollideAll(
TEXT("p.GeometryCollectionCollideAll"),
#Associated Variable and Callsites
This variable is associated with another variable named DisableGeometryCollectionGravity
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:77
Scope: file
Source code excerpt:
TEXT("Fraction of verts"));
bool DisableGeometryCollectionGravity = false;
FAutoConsoleVariableRef CVarGeometryCollectionDisableGravity(
TEXT("p.GeometryCollectionDisableGravity"),
DisableGeometryCollectionGravity,
TEXT("Disable gravity for geometry collections"));
bool GeometryCollectionCollideAll = false;
FAutoConsoleVariableRef CVarGeometryCollectionCollideAll(
TEXT("p.GeometryCollectionCollideAll"),
GeometryCollectionCollideAll,
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1654
Scope (from outer to inner):
file
function void FGeometryCollectionPhysicsProxy::InitializeBodiesPT
Source code excerpt:
// apply various features on the handles
const bool bEnableGravity = Parameters.EnableGravity && !DisableGeometryCollectionGravity;
const TManagedArray<int32>& Level = PhysicsThreadCollection.GetInitialLevels().Get();
for (int32 ParticleIndex = 0; ParticleIndex < SolverParticleHandles.Num(); ++ParticleIndex)
{
if (Chaos::FPBDRigidParticleHandle* Handle = SolverParticleHandles[ParticleIndex])
{
const bool bIsOneWayInteraction = (Parameters.OneWayInteractionLevel >= 0) && (Level[ParticleIndex] >= Parameters.OneWayInteractionLevel);