p.chaos.MinImpulseForStrainEval
p.chaos.MinImpulseForStrainEval
#Overview
name: p.chaos.MinImpulseForStrainEval
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Minimum accumulated impulse before accumulating for strain eval
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.chaos.MinImpulseForStrainEval is to set a minimum threshold for accumulated impulse before it is considered for strain evaluation in Unreal Engine’s Chaos physics system. This setting is specifically used in the rigid clustering module of the Chaos physics engine.
-
The Chaos physics system, particularly the rigid clustering module, relies on this setting variable. It’s part of the Experimental Chaos namespace, indicating it’s an experimental feature of the physics engine.
-
The value of this variable is set initially in the code to 980 * 2 * 1.f / 30.f, which is approximately 65.33. This value is then exposed as a console variable, allowing it to be adjusted at runtime.
-
This variable interacts with other physics-related variables, particularly ‘bUseContactSpeedForStrainThreshold’ and ‘MinContactSpeedForStrainEval’. These variables work together to determine how strain is evaluated in clustered rigid bodies.
-
Developers must be aware that this variable is used to filter out small impulses, particularly those caused by objects resting on the ground. The comment in the code suggests that this is a “hack” and not an ideal solution.
-
Best practices when using this variable include:
- Understanding that it’s part of an experimental system and may change.
- Being cautious when adjusting its value, as it can significantly impact the physics simulation’s behavior.
- Considering it in conjunction with the related variables for contact speed evaluation.
Regarding the associated variable MinImpulseForStrainEval:
- This is the actual variable that holds the value, while p.chaos.MinImpulseForStrainEval is the console variable that allows runtime modification.
- It’s used directly in the ComputeStrainFromCollision function to filter out collision contacts with small accumulated impulses.
- When working with this variable, developers should be aware that it’s part of the strain computation process in rigid clustering, which is likely crucial for breaking or deforming clustered objects under stress.
- Best practices include carefully tuning this value based on the specific requirements of the physics simulation in the game, and potentially exposing it as a tweakable parameter for different types of objects or scenarios in the game.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2214
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FRealSingle MinImpulseForStrainEval = 980 * 2 * 1.f / 30.f; //ignore impulses caused by just keeping object on ground. This is a total hack, we should not use accumulated impulse directly. Instead we need to look at delta v along constraint normal
FAutoConsoleVariableRef CVarMinImpulseForStrainEval(TEXT("p.chaos.MinImpulseForStrainEval"), MinImpulseForStrainEval, TEXT("Minimum accumulated impulse before accumulating for strain eval "));
bool bUseContactSpeedForStrainThreshold = true;
FAutoConsoleVariableRef CVarUseContactSpeedForStrainEval(TEXT("p.chaos.UseContactSpeedForStrainEval"), bUseContactSpeedForStrainThreshold, TEXT("Whether to use contact speed to discard contacts when updating cluster strain (true: use speed, false: use impulse)"));
FRealSingle MinContactSpeedForStrainEval = 1.0f; // Ignore contacts where the two bodies are resting together
FAutoConsoleVariableRef CVarMinContactSpeedForStrainEval(TEXT("p.chaos.MinContactSpeedForStrainEval"), MinContactSpeedForStrainEval, TEXT("Minimum speed at the contact before accumulating for strain eval "));
#Associated Variable and Callsites
This variable is associated with another variable named MinImpulseForStrainEval
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2213
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
}
FRealSingle MinImpulseForStrainEval = 980 * 2 * 1.f / 30.f; //ignore impulses caused by just keeping object on ground. This is a total hack, we should not use accumulated impulse directly. Instead we need to look at delta v along constraint normal
FAutoConsoleVariableRef CVarMinImpulseForStrainEval(TEXT("p.chaos.MinImpulseForStrainEval"), MinImpulseForStrainEval, TEXT("Minimum accumulated impulse before accumulating for strain eval "));
bool bUseContactSpeedForStrainThreshold = true;
FAutoConsoleVariableRef CVarUseContactSpeedForStrainEval(TEXT("p.chaos.UseContactSpeedForStrainEval"), bUseContactSpeedForStrainThreshold, TEXT("Whether to use contact speed to discard contacts when updating cluster strain (true: use speed, false: use impulse)"));
FRealSingle MinContactSpeedForStrainEval = 1.0f; // Ignore contacts where the two bodies are resting together
FAutoConsoleVariableRef CVarMinContactSpeedForStrainEval(TEXT("p.chaos.MinContactSpeedForStrainEval"), MinContactSpeedForStrainEval, TEXT("Minimum speed at the contact before accumulating for strain eval "));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2269
Scope (from outer to inner):
file
namespace Chaos
function void FRigidClustering::ComputeStrainFromCollision
Source code excerpt:
}
}
else if (ContactHandle->GetAccumulatedImpulse().Size() < MinImpulseForStrainEval)
{
continue;
}
auto ComputeStrainLambda = [this, &ContactHandle, &InvDt](
FPBDRigidClusteredParticleHandle* Cluster,