p.ChaosCloth.UseOptimizedTaperedCapsule

p.ChaosCloth.UseOptimizedTaperedCapsule

#Overview

name: p.ChaosCloth.UseOptimizedTaperedCapsule

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.ChaosCloth.UseOptimizedTaperedCapsule is to control the use of optimized tapered capsule collision geometry in the Chaos Cloth simulation system. This setting variable is specifically for the cloth simulation system within Unreal Engine 5.

The Chaos Cloth plugin, which is part of Unreal Engine’s physics and simulation subsystem, relies on this setting variable. It is used in the ChaosClothingSimulationCollider component of the Chaos Cloth system.

The value of this variable is set as a console variable using TAutoConsoleVariable, with a default value of true. This means it can be changed at runtime through console commands or configuration files.

The associated variable CVarUseOptimizedTaperedCapsule directly interacts with p.ChaosCloth.UseOptimizedTaperedCapsule. They share the same value and purpose.

Developers must be aware that this variable affects the collision detection performance and accuracy for cloth simulations. When set to true, it uses an optimized tapered capsule code instead of a combination of a tapered cylinder and two spheres for collision detection.

Best practices when using this variable include:

  1. Keep it enabled (true) for better performance unless specific issues arise.
  2. If encountering unexpected behavior in cloth collision, try disabling it to see if the non-optimized version produces better results.
  3. Profile the performance impact in your specific use case to determine the best setting.

Regarding the associated variable CVarUseOptimizedTaperedCapsule:

This is the actual C++ variable that controls the behavior within the code. It is defined as a TAutoConsoleVariable, which allows it to be changed at runtime.

The purpose of CVarUseOptimizedTaperedCapsule is identical to p.ChaosCloth.UseOptimizedTaperedCapsule - it determines whether to use the optimized tapered capsule code for cloth collision detection.

This variable is used in the FClothingSimulationCollider::FLODData::Add function to decide which collision geometry to set for the solver. When true, it uses a FTaperedCapsule; when false, it likely uses a combination of a tapered cylinder and spheres (although the false case is not shown in the provided code excerpt).

Developers should be aware that changing this variable at runtime will affect ongoing cloth simulations. It might be useful to expose this setting in a user interface for debugging or optimization purposes.

Best practices for using CVarUseOptimizedTaperedCapsule include:

  1. Use it in conjunction with performance profiling tools to measure its impact.
  2. Consider exposing it as a configurable option for different quality settings in your game.
  3. Document its use and effects for other team members working on cloth simulations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCollider.cpp:28

Scope (from outer to inner):

file
namespace    Chaos
namespace    ClothingSimulationColliderConsoleVariables

Source code excerpt:

namespace ClothingSimulationColliderConsoleVariables
{
	TAutoConsoleVariable<bool> CVarUseOptimizedTaperedCapsule(TEXT("p.ChaosCloth.UseOptimizedTaperedCapsule"), true, TEXT("Use the optimized TaperedCapsule code instead of using a tapered cylinder and two spheres"));
}

struct FClothingSimulationCollider::FLODData
{
	FClothCollisionData ClothCollisionData;
	int32 NumGeometries;  // Number of collision bodies

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCollider.cpp:28

Scope (from outer to inner):

file
namespace    Chaos
namespace    ClothingSimulationColliderConsoleVariables

Source code excerpt:

namespace ClothingSimulationColliderConsoleVariables
{
	TAutoConsoleVariable<bool> CVarUseOptimizedTaperedCapsule(TEXT("p.ChaosCloth.UseOptimizedTaperedCapsule"), true, TEXT("Use the optimized TaperedCapsule code instead of using a tapered cylinder and two spheres"));
}

struct FClothingSimulationCollider::FLODData
{
	FClothCollisionData ClothCollisionData;
	int32 NumGeometries;  // Number of collision bodies

#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCollider.cpp:173

Scope (from outer to inner):

file
namespace    Chaos
function     void FClothingSimulationCollider::FLODData::Add

Source code excerpt:

			else
			{
				if (ClothingSimulationColliderConsoleVariables::CVarUseOptimizedTaperedCapsule.GetValueOnAnyThread())
				{
					Solver->SetCollisionGeometry(CollisionRangeId, Index,
						MakeImplicitObjectPtr<FTaperedCapsule>(P0, P1, Radius0, Radius1));
				}
				else
				{