p.DefaultCollisionFriction

p.DefaultCollisionFriction

#Overview

name: p.DefaultCollisionFriction

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.DefaultCollisionFriction is to set the default collision friction value in the Chaos physics system when no materials are found. This setting variable is part of the collision handling system in Unreal Engine 5’s experimental Chaos physics module.

The Unreal Engine subsystem that relies on this setting variable is the Chaos physics system, specifically the collision constraint component. This can be seen from the file path “Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp”.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. The initial value is set to 0.

This variable interacts with another variable named DefaultCollisionFriction. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable serves as a fallback value when no specific material properties are found for colliding objects. It affects the friction calculation in collision responses.

Best practices when using this variable include:

  1. Ensure it’s set to an appropriate default value that suits the general physics behavior of your game.
  2. Use it as a baseline, but prefer setting specific material properties for objects when possible for more accurate physics simulation.
  3. Be cautious when changing this value at runtime, as it could significantly affect the physics behavior of your game.

Regarding the associated variable DefaultCollisionFriction:

The purpose of DefaultCollisionFriction is the same as p.DefaultCollisionFriction - it provides a default friction value for collision calculations when no specific material properties are available.

This variable is used directly in the Chaos physics system, specifically in the FPBDCollisionConstraints::UpdateConstraintMaterialProperties function.

The value of DefaultCollisionFriction is set by the console variable p.DefaultCollisionFriction, allowing for runtime adjustments.

It interacts with MaterialDynamicFriction and MaterialStaticFriction, providing default values for these properties when no material-specific values are found.

Developers should be aware that this variable affects both dynamic and static friction calculations in the absence of material-specific properties.

Best practices for using DefaultCollisionFriction include:

  1. Ensure it’s set to a value that provides realistic physics behavior for the majority of objects in your game.
  2. Use it as a fallback, but define specific material properties for objects whenever possible for more accurate and varied physics interactions.
  3. Consider the impact on both dynamic and static friction when adjusting this value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:61

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	
	FRealSingle DefaultCollisionFriction = 0;
	FAutoConsoleVariableRef CVarDefaultCollisionFriction(TEXT("p.DefaultCollisionFriction"), DefaultCollisionFriction, TEXT("Collision friction default value if no materials are found."));

	FRealSingle DefaultCollisionRestitution = 0;
	FAutoConsoleVariableRef CVarDefaultCollisionRestitution(TEXT("p.DefaultCollisionRestitution"), DefaultCollisionRestitution, TEXT("Collision restitution default value if no materials are found."));

	FRealSingle CollisionRestitutionThresholdOverride = -1.0f;
	FAutoConsoleVariableRef CVarDefaultCollisionRestitutionThreshold(TEXT("p.CollisionRestitutionThreshold"), CollisionRestitutionThresholdOverride, TEXT("Collision restitution threshold override if >= 0 (units of acceleration)"));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:60

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarEnableCollisions(TEXT("p.EnableCollisions"), EnableCollisions, TEXT("Enable/Disable collisions on the Chaos solver."));
	
	FRealSingle DefaultCollisionFriction = 0;
	FAutoConsoleVariableRef CVarDefaultCollisionFriction(TEXT("p.DefaultCollisionFriction"), DefaultCollisionFriction, TEXT("Collision friction default value if no materials are found."));

	FRealSingle DefaultCollisionRestitution = 0;
	FAutoConsoleVariableRef CVarDefaultCollisionRestitution(TEXT("p.DefaultCollisionRestitution"), DefaultCollisionRestitution, TEXT("Collision restitution default value if no materials are found."));

	FRealSingle CollisionRestitutionThresholdOverride = -1.0f;
	FAutoConsoleVariableRef CVarDefaultCollisionRestitutionThreshold(TEXT("p.CollisionRestitutionThreshold"), CollisionRestitutionThresholdOverride, TEXT("Collision restitution threshold override if >= 0 (units of acceleration)"));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionConstraints.cpp:498

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDCollisionConstraints::UpdateConstraintMaterialProperties

Source code excerpt:

		else
		{
			MaterialDynamicFriction = DefaultCollisionFriction;
			MaterialStaticFriction = DefaultCollisionFriction;
			MaterialRestitution = DefaultCollisionRestitution;
		}

		MaterialRestitutionThreshold = RestitutionThreshold;

		// Overrides for testing