p.Cloth.DefaultClothingSimulationFactoryClass

p.Cloth.DefaultClothingSimulationFactoryClass

#Overview

name: p.Cloth.DefaultClothingSimulationFactoryClass

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.Cloth.DefaultClothingSimulationFactoryClass is to specify the default clothing simulation factory class used in Unreal Engine’s cloth simulation system. This setting variable is crucial for the cloth simulation subsystem, which is part of the engine’s physics and animation systems.

This setting variable is primarily used in the ClothingSystemRuntimeInterface module of Unreal Engine. It’s referenced in the ClothingSimulationFactory class, which is responsible for creating cloth simulation objects for skeletal meshes.

The value of this variable is set through a console variable (CVarDefaultClothingSimulationFactoryClass) in the ClothingSimulationFactoryConsoleVariables namespace. By default, it’s set to “ChaosClothingSimulationFactory”, indicating that Chaos is the default provider when Chaos Cloth is enabled.

The associated variable CVarDefaultClothingSimulationFactoryClass interacts directly with p.Cloth.DefaultClothingSimulationFactoryClass. They share the same value and purpose, with CVarDefaultClothingSimulationFactoryClass being the actual console variable implementation.

Developers must be aware that changing this variable will affect the default cloth simulation factory used throughout the engine. It’s important to ensure that the specified class exists and is properly implemented before changing this value.

Best practices when using this variable include:

  1. Only change it if you have a specific need for a different cloth simulation factory.
  2. Ensure that the new factory class is fully implemented and compatible with your project’s requirements.
  3. Test thoroughly after changing this value, as it can have wide-ranging effects on cloth simulation throughout your game.

Regarding the associated variable CVarDefaultClothingSimulationFactoryClass:

The purpose of CVarDefaultClothingSimulationFactoryClass is to provide a console-accessible way to change the default clothing simulation factory class at runtime.

This variable is used in the ClothingSystemRuntimeInterface module, specifically in the ClothingSimulationFactory class’s GetDefaultClothingSimulationFactoryClass() method.

The value of this variable is set when the console variable is created, with “ChaosClothingSimulationFactory” as the default value.

It interacts directly with p.Cloth.DefaultClothingSimulationFactoryClass, effectively implementing the console variable functionality for this setting.

Developers should be aware that this variable can be changed at runtime through the console, which could lead to unexpected behavior if not managed carefully.

Best practices for using this variable include:

  1. Use it for debugging and testing different cloth simulation factories.
  2. Be cautious about changing it in a shipping build, as it could lead to inconsistent behavior across different play sessions.
  3. Ensure that any custom cloth simulation factories are registered properly with the engine before attempting to set this variable to use them.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothingSimulationFactory.cpp:11

Scope (from outer to inner):

file
namespace    ClothingSimulationFactoryConsoleVariables

Source code excerpt:

{
	TAutoConsoleVariable<FString> CVarDefaultClothingSimulationFactoryClass(
		TEXT("p.Cloth.DefaultClothingSimulationFactoryClass"),
		TEXT("ChaosClothingSimulationFactory"),  // Chaos is the default provider when Chaos Cloth is enabled
		TEXT("The class name of the default clothing simulation factory.\n")
		TEXT("Known providers are:\n")
		TEXT("ChaosClothingSimulationFactory\n")
		, ECVF_Cheat);
}

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Public/ClothingSimulationFactory.h:51

Scope (from outer to inner):

file
class        class UClothingSimulationFactory : public UObject

Source code excerpt:

public:
	// Return the default clothing simulation factory class as set by the build or by
	// the p.Cloth.DefaultClothingSimulationFactoryClass console variable if any available.
	// Otherwise return the last registered factory.
	static CLOTHINGSYSTEMRUNTIMEINTERFACE_API TSubclassOf<class UClothingSimulationFactory> GetDefaultClothingSimulationFactoryClass();

	// Create a simulation object for a skeletal mesh to use (see IClothingSimulation)
	CLOTHINGSYSTEMRUNTIMEINTERFACE_API virtual IClothingSimulation* CreateSimulation()
	PURE_VIRTUAL(UClothingSimulationFactory::CreateSimulation, return nullptr;);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothingSimulationFactory.cpp:10

Scope (from outer to inner):

file
namespace    ClothingSimulationFactoryConsoleVariables

Source code excerpt:

namespace ClothingSimulationFactoryConsoleVariables
{
	TAutoConsoleVariable<FString> CVarDefaultClothingSimulationFactoryClass(
		TEXT("p.Cloth.DefaultClothingSimulationFactoryClass"),
		TEXT("ChaosClothingSimulationFactory"),  // Chaos is the default provider when Chaos Cloth is enabled
		TEXT("The class name of the default clothing simulation factory.\n")
		TEXT("Known providers are:\n")
		TEXT("ChaosClothingSimulationFactory\n")
		, ECVF_Cheat);

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothingSimulationFactory.cpp:23

Scope (from outer to inner):

file
function     TSubclassOf<class UClothingSimulationFactory> UClothingSimulationFactory::GetDefaultClothingSimulationFactoryClass

Source code excerpt:

	TSubclassOf<UClothingSimulationFactory> DefaultClothingSimulationFactoryClass = nullptr;

	const FString DefaultClothingSimulationFactoryClassName = ClothingSimulationFactoryConsoleVariables::CVarDefaultClothingSimulationFactoryClass.GetValueOnAnyThread();
	
	IModularFeatures::Get().LockModularFeatureList();
	const TArray<IClothingSimulationFactoryClassProvider*> ClassProviders = IModularFeatures::Get().GetModularFeatureImplementations<IClothingSimulationFactoryClassProvider>(IClothingSimulationFactoryClassProvider::FeatureName);
	IModularFeatures::Get().UnlockModularFeatureList();
	for (const auto& ClassProvider : ClassProviders)
	{