p.Chaos.NewtonEvolution.UseSmoothTimeStep

p.Chaos.NewtonEvolution.UseSmoothTimeStep

#Overview

name: p.Chaos.NewtonEvolution.UseSmoothTimeStep

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.NewtonEvolution.UseSmoothTimeStep is to control whether the Chaos physics system in Unreal Engine 5 uses a smooth time step in its Newton evolution calculations.

This setting variable is primarily used in the Chaos physics subsystem, specifically in the Newton evolution module. It is part of the Experimental Chaos runtime in Unreal Engine 5.

The value of this variable is set as a console variable (CVar) with a default value of true. It can be changed at runtime through the console or programmatically.

The associated variable CVarChaosNewtonEvolutionUseSmoothTimeStep directly interacts with it, as they share the same value. This CVar is used to retrieve the current value of the setting in the code.

Developers should be aware that this variable affects the time step calculation in the physics simulation. When enabled, it helps to smooth out time variations and prevent unwanted vibrations, which works best with force calculations.

Best practices for using this variable include:

  1. Keep it enabled (true) for most scenarios, as it helps in achieving more stable simulations.
  2. If precise, unfiltered time steps are required for specific physics calculations, consider disabling it temporarily.
  3. Be cautious when changing this value during runtime, as it may affect the behavior of physics objects in the game.

Regarding the associated variable CVarChaosNewtonEvolutionUseSmoothTimeStep:

This is a TAutoConsoleVariable that directly corresponds to the p.Chaos.NewtonEvolution.UseSmoothTimeStep setting. It’s used to access the current value of the setting within the C++ code.

The variable is defined in the Chaos NewtonEvolution.cpp file and is used in the AdvanceOneTimeStep function of the FNewtonEvolution class. When the variable is true and bSmoothDt is also true, the function applies a smoothing calculation to the delta time (Dt) using a decay factor.

Developers should use CVarChaosNewtonEvolutionUseSmoothTimeStep.GetValueOnAnyThread() to retrieve the current value of the setting in their code. This ensures that any runtime changes to the setting are properly reflected in the physics calculations.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:35

Scope: file

Source code excerpt:

TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseNestedParallelFor(TEXT("p.Chaos.NewtonEvolution.UseNestedParallelFor"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionFastPositionBasedFriction(TEXT("p.Chaos.NewtonEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseSmoothTimeStep(TEXT("p.Chaos.NewtonEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosNewtonEvolutionMinParallelBatchSize(TEXT("p.Chaos.NewtonEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionWriteCCDContacts(TEXT("p.Chaos.NewtonEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionParallelIntegrate(TEXT("p.Chaos.NewtonEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);

//#if INTEL_ISPC && !UE_BUILD_SHIPPING
//bool bChaos_PostIterationUpdates_ISPC_Enabled = true;

#Associated Variable and Callsites

This variable is associated with another variable named CVarChaosNewtonEvolutionUseSmoothTimeStep. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:35

Scope: file

Source code excerpt:

TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseNestedParallelFor(TEXT("p.Chaos.NewtonEvolution.UseNestedParallelFor"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionFastPositionBasedFriction(TEXT("p.Chaos.NewtonEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseSmoothTimeStep(TEXT("p.Chaos.NewtonEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosNewtonEvolutionMinParallelBatchSize(TEXT("p.Chaos.NewtonEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionWriteCCDContacts(TEXT("p.Chaos.NewtonEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionParallelIntegrate(TEXT("p.Chaos.NewtonEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);

//#if INTEL_ISPC && !UE_BUILD_SHIPPING
//bool bChaos_PostIterationUpdates_ISPC_Enabled = true;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:690

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FNewtonEvolution::AdvanceOneTimeStep

Source code excerpt:


		// Filter delta time to smoothen time variations and prevent unwanted vibrations, works best on Forces
		if (bSmoothDt && CVarChaosNewtonEvolutionUseSmoothTimeStep.GetValueOnAnyThread())
		{
			constexpr FSolverReal DeltaTimeDecay = (FSolverReal)0.1;
			MSmoothDt += (Dt - MSmoothDt) * DeltaTimeDecay;
		}
		else
		{