p.Chaos.Simulation.ApplySolverProjectSettings

p.Chaos.Simulation.ApplySolverProjectSettings

#Overview

name: p.Chaos.Simulation.ApplySolverProjectSettings

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.Simulation.ApplySolverProjectSettings is to control whether the Chaos physics solver applies project-specific settings when spawning a new solver instance. This setting variable is part of the Chaos physics simulation system in Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the Chaos physics simulation system, which is part of the PhysicsCore module. This can be seen from the file location “Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp”.

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

This variable interacts with the UPhysicsSettingsCore class, which contains the project-specific physics settings. When the variable is set to a non-zero value, the solver applies these settings during initialization.

Developers must be aware that this variable directly affects the behavior of the physics simulation. If set to 0, the solver will not apply project-specific settings, which could lead to unexpected physics behavior that doesn’t match the project’s configured settings.

Best practices when using this variable include:

  1. Generally, keep it enabled (set to 1) to ensure consistent physics behavior across the project.
  2. Only disable it if you have a specific reason to prevent project settings from being applied, such as for debugging or testing purposes.
  3. If disabled, be aware that the physics simulation may not behave as expected based on the project settings.

Regarding the associated variable CVar_ApplyProjectSettings:

The purpose of CVar_ApplyProjectSettings is the same as p.Chaos.Simulation.ApplySolverProjectSettings. It’s an internal representation of the console variable within the C++ code.

This variable is used directly in the FChaosScene constructor to determine whether to apply the project settings to the solver. If the value is non-zero, it triggers the application of settings from UPhysicsSettingsCore, including solver configuration and determinism settings.

The value of CVar_ApplyProjectSettings is retrieved using the GetValueOnAnyThread() method, indicating that it can be safely accessed from multiple threads.

Developers should be aware that changing this variable at runtime will only affect newly spawned solvers, not existing ones. To ensure consistent behavior, it’s best to set this value before initializing the physics simulation and avoid changing it during gameplay unless absolutely necessary.

Best practices for CVar_ApplyProjectSettings are the same as for p.Chaos.Simulation.ApplySolverProjectSettings, as they represent the same setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:49

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVar_ChaosSimulationEnable(TEXT("P.Chaos.Simulation.Enable"),1,TEXT("Enable / disable chaos simulation. If disabled, physics will not tick."));
TAutoConsoleVariable<int32> CVar_ApplyProjectSettings(TEXT("p.Chaos.Simulation.ApplySolverProjectSettings"), 1, TEXT("Whether to apply the solver project settings on spawning a solver"));

FChaosScene::FChaosScene(
	UObject* OwnerPtr
	, Chaos::FReal InAsyncDt
#if CHAOS_DEBUG_NAME
	, const FName& DebugName

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:49

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVar_ChaosSimulationEnable(TEXT("P.Chaos.Simulation.Enable"),1,TEXT("Enable / disable chaos simulation. If disabled, physics will not tick."));
TAutoConsoleVariable<int32> CVar_ApplyProjectSettings(TEXT("p.Chaos.Simulation.ApplySolverProjectSettings"), 1, TEXT("Whether to apply the solver project settings on spawning a solver"));

FChaosScene::FChaosScene(
	UObject* OwnerPtr
	, Chaos::FReal InAsyncDt
#if CHAOS_DEBUG_NAME
	, const FName& DebugName

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosScene.cpp:89

Scope (from outer to inner):

file
function     FChaosScene::FChaosScene

Source code excerpt:


	// Apply project settings to the solver
	if(CVar_ApplyProjectSettings.GetValueOnAnyThread() != 0)
	{
		UPhysicsSettingsCore* Settings = UPhysicsSettingsCore::Get();
		SceneSolver->RegisterSimOneShotCallback([InSolver = SceneSolver, SolverConfigCopy = Settings->SolverOptions, bIsDeterministic = Settings->bEnableEnhancedDeterminism]()
		{
			InSolver->ApplyConfig(SolverConfigCopy);
			InSolver->SetIsDeterministic(bIsDeterministic);