p.ChaosCloth.LegacyDisablesAccurateWind

p.ChaosCloth.LegacyDisablesAccurateWind

#Overview

name: p.ChaosCloth.LegacyDisablesAccurateWind

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.ChaosCloth.LegacyDisablesAccurateWind is to control the interaction between the legacy wind model and the accurate wind model in the Chaos Cloth simulation system of Unreal Engine 5.

This setting variable is primarily used in the Chaos Cloth plugin, which is part of Unreal Engine’s physics simulation system. It specifically affects the cloth simulation and wind interaction.

The value of this variable is set as a console variable, which means it can be changed at runtime. It is initialized with a default value of true in the C++ code.

This variable interacts closely with the point-based wind model. When set to true, it causes the point-based wind model to disable the accurate wind model. When false, both wind models can potentially be used together.

Developers must be aware that this variable can significantly affect the behavior of cloth simulations in their game. Changing this value can alter how cloth reacts to wind forces, potentially affecting both visual quality and performance.

Best practices when using this variable include:

  1. Testing cloth behavior with both true and false settings to determine which provides the best visual results for your specific use case.
  2. Considering performance implications, as using both wind models simultaneously (when set to false) may be more computationally expensive.
  3. Ensuring consistency across different parts of the game to maintain a uniform cloth behavior.

Regarding the associated variable CVarLegacyDisablesAccurateWind:

This is the actual console variable that controls the behavior described above. It is defined in the Chaos namespace, specifically within the ClothingSimulationClothConsoleVariables namespace.

The purpose of CVarLegacyDisablesAccurateWind is to provide a runtime-configurable way to control the wind model interaction in the Chaos Cloth system.

It is used in various parts of the Chaos Cloth simulation code to determine whether to enable or disable the accurate wind model based on the use of the legacy (point-based) wind model.

The value of this variable can be accessed using the GetValueOnAnyThread() method, allowing it to be checked at various points in the simulation process.

Developers should be aware that changing this variable at runtime will immediately affect the cloth simulation behavior. It’s important to consider the potential visual and performance impacts of toggling this setting during gameplay.

Best practices for using CVarLegacyDisablesAccurateWind include:

  1. Using it in conjunction with performance profiling to find the optimal setting for your game.
  2. Documenting any changes to this variable, as it can have significant effects on cloth behavior.
  3. Consider exposing this setting to artists or designers if fine-tuning of cloth behavior is necessary for different game scenarios.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:44

Scope (from outer to inner):

file
namespace    Chaos
namespace    ClothingSimulationClothConsoleVariables

Source code excerpt:

{
	TAutoConsoleVariable<bool> CVarLegacyDisablesAccurateWind(
		TEXT("p.ChaosCloth.LegacyDisablesAccurateWind"),
		true,
		TEXT("Whether using the Legacy wind model switches off the accurate wind model, or adds up to it"));

	TAutoConsoleVariable<float> CVarGravityMultiplier(
		TEXT("p.ChaosCloth.GravityMultiplier"),
		1.f,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothConstraints.cpp:38

Scope (from outer to inner):

file
namespace    Chaos
namespace    ClothingSimulationClothConsoleVariables

Source code excerpt:

{
// These are defined in ChaosClothingSimulationCloth.cpp
extern TAutoConsoleVariable<bool> CVarLegacyDisablesAccurateWind;
extern TAutoConsoleVariable<float> CVarGravityMultiplier;
}

bool bEnableGS = false;

#if !UE_BUILD_SHIPPING

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothConstraints.cpp:2304

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothConstraints::Update

Source code excerpt:

	{
		constexpr FSolverReal WorldScale = 100.f;
		const bool bPointBasedWindDisablesAccurateWind = ClothingSimulationClothConsoleVariables::CVarLegacyDisablesAccurateWind.GetValueOnAnyThread();
		const bool bEnableAerodynamics = !(bUsePointBasedWindModel && bPointBasedWindDisablesAccurateWind);
		VelocityAndPressureField->SetPropertiesAndWind(
			ConfigProperties,
			WeightMaps,
			WorldScale,
			bEnableAerodynamics,

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:43

Scope (from outer to inner):

file
namespace    Chaos
namespace    ClothingSimulationClothConsoleVariables

Source code excerpt:

namespace ClothingSimulationClothConsoleVariables
{
	TAutoConsoleVariable<bool> CVarLegacyDisablesAccurateWind(
		TEXT("p.ChaosCloth.LegacyDisablesAccurateWind"),
		true,
		TEXT("Whether using the Legacy wind model switches off the accurate wind model, or adds up to it"));

	TAutoConsoleVariable<float> CVarGravityMultiplier(
		TEXT("p.ChaosCloth.GravityMultiplier"),

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:1202

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationCloth::Update

Source code excerpt:

			Solver->AddExternalForces(GroupId, bUsePointBasedWindModel);

			const bool bPointBasedWindDisablesAccurateWind = ClothingSimulationClothConsoleVariables::CVarLegacyDisablesAccurateWind.GetValueOnAnyThread();
			const bool bEnableAerodynamics = !(bUsePointBasedWindModel && bPointBasedWindDisablesAccurateWind);
			Solver->SetWindAndPressureProperties(GroupId, ConfigProperties, LODData[LODIndex]->WeightMaps, bEnableAerodynamics);

			constexpr float WorldScale = 100.f;  // VelocityField wind is in m/s in the config (same as the wind unit), but cm/s in the solver  TODO: Cleanup the Solver SetWindVelocity functions to be consistent with the unit
			const FVec3f WindVelocity = ConfigProperties.GetValue<FVector3f>(TEXT("WindVelocity")) * WorldScale;
			Solver->SetWindVelocity(GroupId, WindVelocity + Solver->GetWindVelocity());