p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold

p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold

#Overview

name: p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold

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.Collision.Manifold.SphereCapsuleSizeThreshold is to determine when to create a single-point or three-point manifold in sphere-capsule collision detection within the Chaos physics engine.

This setting variable is primarily used by the Chaos physics engine, which is part of Unreal Engine’s experimental physics system. It’s specifically utilized in the collision detection and manifold generation subsystem.

The value of this variable is set to 0.5f by default, as seen in the source code. It’s defined as a console variable, which means it can be modified at runtime through the console or configuration files.

The variable interacts closely with Chaos_Collision_Manifold_SphereCapsuleSizeThreshold, which is its associated C++ variable. They share the same value and purpose.

Developers must be aware that this threshold affects the precision and performance of sphere-capsule collision detection. A lower value will result in more three-point manifolds being generated, potentially increasing accuracy but also computational cost.

Best practices when using this variable include:

  1. Only modify it if you understand the implications for collision detection accuracy and performance.
  2. Test thoroughly after any changes, as it can affect the behavior of physics simulations involving spheres and capsules.
  3. Consider the scale of your game objects when adjusting this value, as it’s relative to the size of the colliding shapes.

Regarding the associated variable Chaos_Collision_Manifold_SphereCapsuleSizeThreshold:

This is the C++ variable that directly stores the value set by the console variable. It’s used in the actual collision detection code to determine when to create a single-point or three-point manifold.

The purpose of this variable is the same as p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold - it’s used to decide whether to create a single-point or three-point manifold based on the relative sizes of a sphere and a capsule in a collision.

This variable is used within the Chaos namespace, specifically in the collision manifold generation code for sphere-capsule collisions.

The value is set initially to 0.5f and can be modified through the associated console variable.

Developers should be aware that this variable is used directly in the collision detection code, so any changes to it will immediately affect the behavior of sphere-capsule collisions in the Chaos physics system.

Best practices for this variable are similar to those for the console variable:

  1. Modify with caution and only when necessary.
  2. Thoroughly test any changes in various collision scenarios.
  3. Consider the performance implications of changes, especially in scenes with many sphere-capsule collisions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:22

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	// If a sphere is this much smaller than a capsule, we create a single-point manifold. Otherwise a three-point manifold
	FRealSingle Chaos_Collision_Manifold_SphereCapsuleSizeThreshold = 0.5f;
	FAutoConsoleVariableRef CVarChaos_Manifold_SphereCapsuleSizeThreshold(TEXT("p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold"), Chaos_Collision_Manifold_SphereCapsuleSizeThreshold, TEXT(""));

	// When two capsule axes are aligned more than this, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold = 0.8f;	// About 30deg
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleAxisAlignedThreshold(TEXT("p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold"), Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold, TEXT(""));

	// When two capsules penetrate by more than this fraction of the radius, generate a multi-point manifold

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifolds.cpp:21

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

{
	// If a sphere is this much smaller than a capsule, we create a single-point manifold. Otherwise a three-point manifold
	FRealSingle Chaos_Collision_Manifold_SphereCapsuleSizeThreshold = 0.5f;
	FAutoConsoleVariableRef CVarChaos_Manifold_SphereCapsuleSizeThreshold(TEXT("p.Chaos.Collision.Manifold.SphereCapsuleSizeThreshold"), Chaos_Collision_Manifold_SphereCapsuleSizeThreshold, TEXT(""));

	// When two capsule axes are aligned more than this, generate a multi-point manifold
	FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold = 0.8f;	// About 30deg
	FAutoConsoleVariableRef CVarChaos_Manifold_CapsuleAxisAlignedThreshold(TEXT("p.Chaos.Collision.Manifold.CapsuleAxisAlignedThreshold"), Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold, TEXT(""));

	// When two capsules penetrate by more than this fraction of the radius, generate a multi-point manifold

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionOneShotManifoldsMiscShapes.cpp:21

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

namespace Chaos
{
	extern FRealSingle Chaos_Collision_Manifold_SphereCapsuleSizeThreshold;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleAxisAlignedThreshold;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleDeepPenetrationFraction;
	extern FRealSingle Chaos_Collision_Manifold_CapsuleRadialContactFraction;

	namespace Collisions
	{

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     void ConstructSphereCapsuleOneShotManifold

Source code excerpt:


					// If we have a small sphere, just stick with the 1-point manifold
					const FReal SphereCapsuleSizeThreshold = FReal(Chaos_Collision_Manifold_SphereCapsuleSizeThreshold);
					if (Sphere.GetRadius() < SphereCapsuleSizeThreshold * (Capsule.GetHeight() + Capsule.GetRadius()))
					{
						return;
					}

					// If the capsule is non-dynamic there's no point in creating the multipoint manifold