p.Chaos.ImmPhys.FixedStepTolerance
p.Chaos.ImmPhys.FixedStepTolerance
#Overview
name: p.Chaos.ImmPhys.FixedStepTolerance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Time remainder required to add a new step (fraction of FixedStepTime)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.ImmPhys.FixedStepTolerance is to control the time remainder threshold for adding a new step in the fixed-step physics simulation mode of Unreal Engine’s Chaos physics system, specifically in the Immediate Physics module.
This setting variable is primarily used by the Chaos Immediate Physics subsystem, which is part of Unreal Engine’s physics simulation capabilities. It’s utilized in the ImmediatePhysicsChaos module, as evident from the file path.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. Its default value is 0.05f, as seen in the source code.
This variable interacts closely with two other variables: ChaosImmediate_Evolution_MinStepTime and ChaosImmediate_Evolution_FixedStepTime. Together, these three variables control the fixed-step simulation behavior.
Developers must be aware that this variable affects the precision and performance of the physics simulation. A lower value will result in more precise simulations but may impact performance, while a higher value might improve performance at the cost of some precision.
Best practices when using this variable include:
- Adjusting it in tandem with the FixedStepTime for optimal results.
- Testing different values to find the right balance between precision and performance for your specific use case.
- Using it in conjunction with profiling tools to ensure it’s not negatively impacting performance.
The associated variable ChaosImmediate_Evolution_FixedStepTolerance serves the same purpose and is directly linked to the console variable. It’s used in the actual simulation logic to determine whether to add an additional step based on the remaining time after dividing the delta time by the step time.
When using ChaosImmediate_Evolution_FixedStepTolerance, developers should:
- Be aware that it’s used in the core simulation loop and can significantly affect simulation behavior.
- Understand that it’s a fraction of the FixedStepTime, so its effect scales with the step time.
- Consider the implications on stability and energy conservation in the physics simulation when adjusting this value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:65
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CVarChaosImmPhysMinStepTime(TEXT("p.Chaos.ImmPhys.MinStepTime"), ChaosImmediate_Evolution_MinStepTime, TEXT("If non-zero, then if step time is lower than this, go into fixed step mode with this timestep."));
FAutoConsoleVariableRef CVarChaosImmPhysFixedStepTime(TEXT("p.Chaos.ImmPhys.FixedStepTime"), ChaosImmediate_Evolution_FixedStepTime, TEXT("Override fixed step time mode: fixed step time (if positive); variable time mode (if zero); asset defined (if negative)"));
FAutoConsoleVariableRef CVarChaosImmPhysFixedStepTolerance(TEXT("p.Chaos.ImmPhys.FixedStepTolerance"), ChaosImmediate_Evolution_FixedStepTolerance, TEXT("Time remainder required to add a new step (fraction of FixedStepTime)"));
int32 ChaosImmediate_Collision_Enabled = 1;
int32 ChaosImmediate_Collision_NumPositionFrictionIterations = 0; // No static friction for RBAN
int32 ChaosImmediate_Collision_NumVelocityFrictionIterations = 1; // Dynamic friction for RBAN in velocity solve
int32 ChaosImmediate_Collision_NumPositionShockPropagationIterations = 0;
int32 ChaosImmediate_Collision_NumVelocityShockPropagationIterations = 0;
#Associated Variable and Callsites
This variable is associated with another variable named ChaosImmediate_Evolution_FixedStepTolerance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:62
Scope: file
Source code excerpt:
Chaos::FRealSingle ChaosImmediate_Evolution_MinStepTime = 0.01f;
Chaos::FRealSingle ChaosImmediate_Evolution_FixedStepTime = -1.0f;
Chaos::FRealSingle ChaosImmediate_Evolution_FixedStepTolerance = 0.05f;
FAutoConsoleVariableRef CVarChaosImmPhysMinStepTime(TEXT("p.Chaos.ImmPhys.MinStepTime"), ChaosImmediate_Evolution_MinStepTime, TEXT("If non-zero, then if step time is lower than this, go into fixed step mode with this timestep."));
FAutoConsoleVariableRef CVarChaosImmPhysFixedStepTime(TEXT("p.Chaos.ImmPhys.FixedStepTime"), ChaosImmediate_Evolution_FixedStepTime, TEXT("Override fixed step time mode: fixed step time (if positive); variable time mode (if zero); asset defined (if negative)"));
FAutoConsoleVariableRef CVarChaosImmPhysFixedStepTolerance(TEXT("p.Chaos.ImmPhys.FixedStepTolerance"), ChaosImmediate_Evolution_FixedStepTolerance, TEXT("Time remainder required to add a new step (fraction of FixedStepTime)"));
int32 ChaosImmediate_Collision_Enabled = 1;
int32 ChaosImmediate_Collision_NumPositionFrictionIterations = 0; // No static friction for RBAN
int32 ChaosImmediate_Collision_NumVelocityFrictionIterations = 1; // Dynamic friction for RBAN in velocity solve
int32 ChaosImmediate_Collision_NumPositionShockPropagationIterations = 0;
int32 ChaosImmediate_Collision_NumVelocityShockPropagationIterations = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsSimulation_Chaos.cpp:943
Scope (from outer to inner):
file
namespace ImmediatePhysics_Chaos
function void FSimulation::Simulate
Source code excerpt:
NumSteps = FMath::FloorToInt(DeltaTime / StepTime);
FReal RemainderTime = DeltaTime - NumSteps * StepTime;
if (RemainderTime > ChaosImmediate_Evolution_FixedStepTolerance * StepTime)
{
++NumSteps;
RewindTime = StepTime - RemainderTime;
}
NumSteps = FMath::Max(1, NumSteps);
}