p.RestoreBreakingMomentumPercent
p.RestoreBreakingMomentumPercent
#Overview
name: p.RestoreBreakingMomentumPercent
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When a rigid cluster is broken, objects that its in contact with will receive an impulse to restore this percent of their momentum prior to the break.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.RestoreBreakingMomentumPercent is to control the amount of momentum restored to objects in contact with a rigid cluster when it breaks. This setting variable is part of the physics simulation system in Unreal Engine 5, specifically related to the Chaos physics engine’s rigid body clustering functionality.
This setting variable is primarily used in the Chaos experimental module, which is part of Unreal Engine’s physics system. It’s referenced in the PBDRigidClustering.cpp file, indicating its relevance to the Position Based Dynamics (PBD) rigid clustering system.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. Its default value is 0.5 (50%).
The associated variable RestoreBreakingMomentumPercent interacts directly with p.RestoreBreakingMomentumPercent, as they share the same value. This variable is used in the actual physics calculations within the FRigidClustering class.
Developers must be aware that this variable affects the behavior of objects after a rigid cluster breaks. A higher value will result in more momentum being restored to objects in contact with the broken cluster, potentially leading to more dynamic and energetic simulations. Conversely, a lower value will result in less momentum restoration, potentially creating calmer simulations.
Best practices when using this variable include:
- Experimenting with different values to achieve the desired physical behavior in your simulation.
- Consider the performance implications of higher values, as they may lead to more complex physical interactions.
- Use in conjunction with other clustering and physics settings for a balanced simulation.
Regarding the associated variable RestoreBreakingMomentumPercent:
- It’s used directly in the physics calculations within the FRigidClustering class.
- It’s checked in multiple places to determine if momentum restoration should occur.
- When non-zero, it triggers the RestoreBreakingMomentum() function and affects the velocity calculations of rigid bodies.
- Developers should be aware that changing this variable will directly impact the physical behavior of breaking clusters in the simulation.
#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:64
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
float RestoreBreakingMomentumPercent = .5;
FAutoConsoleVariableRef CVarRestoreBreakingMomentumPercent(TEXT("p.RestoreBreakingMomentumPercent"), RestoreBreakingMomentumPercent, TEXT("When a rigid cluster is broken, objects that its in contact with will receive an impulse to restore this percent of their momentum prior to the break."));
int32 ClusteringParticleReleaseThrottlingMinCount = INDEX_NONE;
FAutoConsoleVariableRef CVarClusteringParticleReleaseThrottlingMinCount(TEXT("p.Clustering.ParticleReleaseThrottlingMinCount"), ClusteringParticleReleaseThrottlingMinCount, TEXT("Minimum number of active geometry collection to reach before clustering start to disable a percentage of the released particle per cluster"));
int32 ClusteringParticleReleaseThrottlingMaxCount = INDEX_NONE;
FAutoConsoleVariableRef CVarClusteringParticleReleaseThrottlingMaxCount(TEXT("p.Clustering.ParticleReleaseThrottlingMaxCount"), ClusteringParticleReleaseThrottlingMaxCount, TEXT("Maximum number of active geometry collection to reach before all released clustering disable all released particle instantly"));
#Associated Variable and Callsites
This variable is associated with another variable named RestoreBreakingMomentumPercent
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:63
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarGraphPropagationBasedCollisionFactor(TEXT("p.GraphPropagationBasedCollisionFactor"), GraphPropagationBasedCollisionFactor, TEXT("when p.GraphPropagationBasedCollisionImpulseProcessing is on, the percentage [0-1] of remaining damage that is distributed to the connected pieces"));
float RestoreBreakingMomentumPercent = .5;
FAutoConsoleVariableRef CVarRestoreBreakingMomentumPercent(TEXT("p.RestoreBreakingMomentumPercent"), RestoreBreakingMomentumPercent, TEXT("When a rigid cluster is broken, objects that its in contact with will receive an impulse to restore this percent of their momentum prior to the break."));
int32 ClusteringParticleReleaseThrottlingMinCount = INDEX_NONE;
FAutoConsoleVariableRef CVarClusteringParticleReleaseThrottlingMinCount(TEXT("p.Clustering.ParticleReleaseThrottlingMinCount"), ClusteringParticleReleaseThrottlingMinCount, TEXT("Minimum number of active geometry collection to reach before clustering start to disable a percentage of the released particle per cluster"));
int32 ClusteringParticleReleaseThrottlingMaxCount = INDEX_NONE;
FAutoConsoleVariableRef CVarClusteringParticleReleaseThrottlingMaxCount(TEXT("p.Clustering.ParticleReleaseThrottlingMaxCount"), ClusteringParticleReleaseThrottlingMaxCount, TEXT("Maximum number of active geometry collection to reach before all released clustering disable all released particle instantly"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:743
Scope (from outer to inner):
file
namespace Chaos
function void FRigidClustering::RestoreBreakingMomentum
Source code excerpt:
// Update linear and angular impulses for the body, to be integrated next solve
const float RestorationPercent = RestoreBreakingMomentumPercent;
Rigid.SetV(Rigid.GetV() + ImpulseVelocity * RestorationPercent);
Rigid.SetW(Rigid.GetW() + AngularImpulseVelocity * RestorationPercent);
}
}
void FRigidClustering::SendBreakingEvent(FPBDRigidClusteredParticleHandle* ClusteredParticle, bool bFromCrumble)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:1190
Scope (from outer to inner):
file
namespace Chaos
function TSet<FPBDRigidParticleHandle*> FRigidClustering::ReleaseClusterParticlesImpl
Source code excerpt:
// in FClusterUnionManager::UpdateAllClusterUnionProperties, the particle is
// invalidated with MEvolution.InvalidateParticle, which clears its contacts
if (RestoreBreakingMomentumPercent > 0.f)
{
if (Parent)
{
TrackBreakingCollision(Parent);
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:1992
Scope (from outer to inner):
file
namespace Chaos
function bool FRigidClustering::BreakingModel
Source code excerpt:
ClusterUnionManager.HandleDeferredClusterUnionUpdateProperties();
// Restore some of the momentum of objects that were touching rigid clusters that broke
if (RestoreBreakingMomentumPercent > 0.f)
{
RestoreBreakingMomentum();
}
}
return bHasReleasedParticles;
}