p.Chaos.Timestep.VariableCapped.Cap

p.Chaos.Timestep.VariableCapped.Cap

#Overview

name: p.Chaos.Timestep.VariableCapped.Cap

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Timestep.VariableCapped.Cap is to set a maximum time step (cap) for the Chaos physics simulation in Unreal Engine 5. This variable is specifically used in the context of variable timesteps for the Chaos physics system.

This setting variable is primarily used by the Chaos physics system, which is part of the Experimental module in Unreal Engine 5. It is referenced in the TimeStep.cpp file within the Chaos namespace, indicating its relevance to the physics simulation timing mechanism.

The value of this variable is set through a console variable (CVarVariableTickCap) with a default value of 0.0667 seconds (approximately 1/15th of a second). This value can be changed at runtime through the console or programmatically.

The associated variable CVarVariableTickCap interacts directly with p.Chaos.Timestep.VariableCapped.Cap. It is used to retrieve the current value of the cap in the Update functions of FVariableMinimumWithCapTimestep and FVariableWithCapTimestep classes.

Developers should be aware that this variable affects the maximum time step for the Chaos physics simulation. A lower value will result in more frequent and potentially more accurate physics updates, but at the cost of increased computational overhead. A higher value may improve performance but could lead to less accurate physics simulations, especially for fast-moving objects or complex interactions.

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of your project, balancing between physics accuracy and performance.
  2. Testing thoroughly with different cap values to ensure stable and visually pleasing physics simulations.
  3. Considering the target frame rate of your game when setting this value, as it directly impacts how often physics calculations are performed.

Regarding the associated variable CVarVariableTickCap:

The purpose of CVarVariableTickCap is to provide a runtime-configurable way to access and modify the p.Chaos.Timestep.VariableCapped.Cap value. It is implemented as a TAutoConsoleVariable, allowing for easy modification through the console or code.

This variable is used within the Chaos namespace, specifically in the Update functions of time-stepping classes. It provides a flexible way to adjust the physics time step cap without recompiling the engine.

The value of CVarVariableTickCap is set initially when the variable is declared, but can be changed at runtime using console commands or through C++ code.

Developers should be aware that changes to CVarVariableTickCap will immediately affect the physics simulation behavior. It’s important to use this variable judiciously and in coordination with other physics settings to maintain a balance between performance and simulation accuracy.

Best practices for using CVarVariableTickCap include:

  1. Using it for experimentation and fine-tuning during development.
  2. Providing a way for advanced users to adjust physics behavior without code changes.
  3. Documenting any custom values used in your project for consistency across development and QA teams.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Framework/TimeStep.cpp:8

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarVariableTickCap(
	TEXT("p.Chaos.Timestep.VariableCapped.Cap"),
	0.0667f,
	TEXT("Time in seconds to set as the cap when using a ranged timestep for Chaos.")
);

namespace Chaos
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Framework/TimeStep.cpp:7

Scope: file

Source code excerpt:

#include "HAL/IConsoleManager.h"

TAutoConsoleVariable<float> CVarVariableTickCap(
	TEXT("p.Chaos.Timestep.VariableCapped.Cap"),
	0.0667f,
	TEXT("Time in seconds to set as the cap when using a ranged timestep for Chaos.")
);

namespace Chaos

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Framework/TimeStep.cpp:106

Scope (from outer to inner):

file
namespace    Chaos
function     void FVariableMinimumWithCapTimestep::Update

Source code excerpt:

		else
		{
			float Cap = CVarVariableTickCap.GetValueOnAnyThread();
			Dt = FMath::Min(ActualDt, Cap);
		}

		LastTime = FPlatformTime::Seconds();
	}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Framework/TimeStep.cpp:141

Scope (from outer to inner):

file
namespace    Chaos
function     void FVariableWithCapTimestep::Update

Source code excerpt:

		ActualDt = static_cast<float>(CurrentTime - LastTime);

		float Cap = CVarVariableTickCap.GetValueOnAnyThread();
		Dt = FMath::Min(ActualDt, Cap);

		LastTime = FPlatformTime::Seconds();
	}

	float FVariableWithCapTimestep::GetCalculatedDt() const