p.EncroachEpsilon

p.EncroachEpsilon

#Overview

name: p.EncroachEpsilon

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.EncroachEpsilon is to provide an epsilon value used during encroachment checking for shape components in Unreal Engine 5. This setting variable is primarily used in the physics and collision detection system.

Based on the callsites, the Engine module relies on this setting variable, specifically within the LevelActor.cpp file. This suggests that it’s used in actor placement and collision detection within levels.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.15f, but can be changed at runtime through console commands or configuration files.

The p.EncroachEpsilon variable interacts directly with its associated variable CVarEncroachEpsilon. They share the same value, with CVarEncroachEpsilon being the actual CVar object that stores and manages the value.

Developers must be aware that this variable affects the behavior of encroachment checking. A value of 0 means the full-sized shape will be used, while values greater than 0 will shrink the shape size by the specified amount in world units. This can have implications for precise collision detection and actor placement.

Best practices when using this variable include:

  1. Be cautious when modifying its value, as it can affect gameplay and physics behavior.
  2. Consider the scale of your game world when adjusting this value.
  3. Test thoroughly after making changes to ensure desired collision behavior.
  4. Document any non-default values used in your project for easier maintenance.

Regarding the associated variable CVarEncroachEpsilon:

The purpose of CVarEncroachEpsilon is to serve as the actual console variable object that stores and manages the p.EncroachEpsilon value. It’s part of the Unreal Engine’s console variable system, which allows for runtime configuration of various engine parameters.

This variable is used in the Engine module, specifically in collision detection and actor placement code within LevelActor.cpp.

The value of CVarEncroachEpsilon is set when it’s declared, with a default value of 0.15f. It can be changed at runtime through console commands or configuration files.

CVarEncroachEpsilon interacts directly with p.EncroachEpsilon, effectively providing the same value to the engine code that uses it.

Developers should be aware that changes to CVarEncroachEpsilon will directly affect the behavior of encroachment checking in the engine. It’s accessed using the GetValueOnGameThread() method in the engine code.

Best practices for using CVarEncroachEpsilon include:

  1. Use the GetValueOnGameThread() method to access its current value in C++ code.
  2. Consider exposing this variable in your game’s debug or configuration UI for easier tuning.
  3. Be mindful of potential performance impacts when frequently accessing this value in performance-critical code.
  4. Use the console variable system’s features for saving and loading configurations to manage different values across different scenarios or build configurations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:33

Scope: file

Source code excerpt:

// CVars
static TAutoConsoleVariable<float> CVarEncroachEpsilon(
	TEXT("p.EncroachEpsilon"),
	0.15f,
	TEXT("Epsilon value used during encroachment checking for shape components\n")
	TEXT("0: use full sized shape. > 0: shrink shape size by this amount (world units)"),
	ECVF_Default);

static TAutoConsoleVariable<int32> CVarAllowDestroyNonNetworkActors(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:32

Scope: file

Source code excerpt:


// CVars
static TAutoConsoleVariable<float> CVarEncroachEpsilon(
	TEXT("p.EncroachEpsilon"),
	0.15f,
	TEXT("Epsilon value used during encroachment checking for shape components\n")
	TEXT("0: use full sized shape. > 0: shrink shape size by this amount (world units)"),
	ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:1211

Scope (from outer to inner):

file
function     static bool ComponentEncroachesBlockingGeometry_NoAdjustment

Source code excerpt:

static bool ComponentEncroachesBlockingGeometry_NoAdjustment(UWorld const* World, AActor const* TestActor, UPrimitiveComponent const* PrimComp, FTransform const& TestWorldTransform, const TArray<AActor*>& IgnoreActors)
{	
	float const Epsilon = CVarEncroachEpsilon.GetValueOnGameThread();
	
	if (World && PrimComp)
	{
		bool bFoundBlockingHit = false;
		
		ECollisionChannel const BlockingChannel = PrimComp->GetCollisionObjectType();

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:1274

Scope (from outer to inner):

file
function     static bool ComponentEncroachesBlockingGeometry_WithAdjustment

Source code excerpt:

	OutProposedAdjustment = FVector::ZeroVector;

	float const Epsilon = CVarEncroachEpsilon.GetValueOnGameThread();

	if (World && PrimComp)
	{
		bool bFoundBlockingHit = false;
		bool bComputePenetrationAdjustment = true;