MinDeltaVelocityForHitEvents
MinDeltaVelocityForHitEvents
#Overview
name: MinDeltaVelocityForHitEvents
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MinDeltaVelocityForHitEvents is to set a threshold for the minimum velocity change required to trigger a hit event in the Chaos physics engine within Unreal Engine 5. This setting is used to filter out minor collisions and optimize performance by reducing the number of unnecessary hit events.
The Chaos physics engine and the PhysicsEngine subsystem rely on this setting variable. It is primarily used in the collision handling and event dispatching systems of the engine.
The value of this variable is set in the UPhysicsSettings class, which is part of the Engine module. It can be configured through the project settings in the Unreal Editor under the “Physics” category.
This variable interacts with the collision detection and event dispatching systems. It is used in conjunction with other physics-related settings in the FChaosPhysicsSettings struct.
Developers must be aware that setting this value too low may result in excessive hit events being generated, potentially impacting performance. Conversely, setting it too high might cause important collisions to be missed, affecting gameplay or simulation accuracy.
Best practices when using this variable include:
- Carefully tuning the value based on the specific needs of your project to balance performance and simulation accuracy.
- Testing the impact of different values on both performance and gameplay to find the optimal setting.
- Considering the scale and typical velocities of objects in your game when setting this value.
- Documenting any changes to this setting and their impacts for future reference and team communication.
- Using this setting in conjunction with other physics optimization techniques to achieve the best overall performance and accuracy in your game’s physics simulations.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:351, section: [/Script/Engine.PhysicsSettings]
- INI Section:
/Script/Engine.PhysicsSettings
- Raw value:
0.000000
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/PhysicsSettings.h:249
Scope (from outer to inner):
file
class class UPhysicsSettings : public UPhysicsSettingsCore
Source code excerpt:
/** Minimum velocity delta required on a collinding object for Chaos to send a hit event */
UPROPERTY(config, EditAnywhere, Category = ChaosPhysics)
float MinDeltaVelocityForHitEvents;
/** Chaos physics engine settings */
UPROPERTY(config, EditAnywhere, Category = ChaosPhysics)
FChaosPhysicsSettings ChaosSettings;
public:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:1013
Scope (from outer to inner):
file
function void FPhysScene_Chaos::HandleCollisionEvents
Source code excerpt:
TMap<IPhysicsProxyBase*, TArray<int32>> const& PhysicsProxyToCollisionIndicesMap = Event.PhysicsProxyToCollisionIndices.PhysicsProxyToIndicesMap;
Chaos::FCollisionDataArray const& CollisionData = Event.CollisionData.AllCollisionsArray;
const Chaos::FReal MinDeltaVelocityThreshold = UPhysicsSettings::Get()->MinDeltaVelocityForHitEvents;
int32 NumCollisions = CollisionData.Num();
if (NumCollisions > 0 && LastEventDispatchTime < Event.CollisionData.TimeCreated)
{
LastEventDispatchTime = Event.CollisionData.TimeCreated;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysLevel.cpp:41
Scope (from outer to inner):
file
class class FEngineChaosSettingsProvider : public IChaosSettingsProvider
function virtual float GetMinDeltaVelocityForHitEvents
Source code excerpt:
virtual float GetMinDeltaVelocityForHitEvents() const override
{
return GetSettings()->MinDeltaVelocityForHitEvents;
}
virtual bool GetPhysicsPredictionEnabled() const override
{
return GetSettings()->PhysicsPrediction.bEnablePhysicsPrediction;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicsSettings.cpp:28
Scope (from outer to inner):
file
function UPhysicsSettings::UPhysicsSettings
Source code excerpt:
, InitialAverageFrameRate(1.f / 60.f)
, PhysXTreeRebuildRate(10)
, MinDeltaVelocityForHitEvents(0.f)
{
}
void UPhysicsSettings::PostInitProperties()
{
Super::PostInitProperties();
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/EventDefaults.cpp:110
Scope (from outer to inner):
file
namespace Chaos
function void FEventDefaults::RegisterCollisionEvent
lambda-function
Source code excerpt:
{
SCOPE_CYCLE_COUNTER(STAT_Events_RegisterCollisionEvent_Filter);
const FReal MinDeltaVelocityForHitEvents = FChaosSolversModule::GetModule()->GetSettingsProvider().GetMinDeltaVelocityForHitEvents();
const FPBDCollisionConstraints::FConstHandles& CollisionHandles = CollisionRule.GetConstConstraintHandles();
TArray<bool> ValidArray;
ValidArray.SetNum(CollisionHandles.Num());
InnerPhysicsParallelForRange(CollisionHandles.Num(), [&](int32 StartRangeIndex, int32 EndRangeIndex)
{
for (int32 Index = StartRangeIndex; Index < EndRangeIndex; ++Index)