p.ShowInitialOverlaps
p.ShowInitialOverlaps
#Overview
name: p.ShowInitialOverlaps
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Show initial overlaps when moving a component, including estimated \'exit\' direction.\n 0:off, otherwise on
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ShowInitialOverlaps is to enable debugging visualization of initial overlaps when moving a component in Unreal Engine 5. It’s primarily used for collision detection and debugging purposes.
This setting variable is mainly utilized by the Engine module, specifically within the collision and component movement systems. Based on the callsites, it’s used in PrimitiveComponent.cpp, CharacterMovementComponentAsync.cpp, and CollisionConversions.cpp.
The value of this variable is set through a console command. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime using console commands.
The associated variable CVarShowInitialOverlaps interacts directly with p.ShowInitialOverlaps. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable is only active in non-shipping and non-test builds (defined within #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) blocks). It’s intended for debugging and development purposes, not for use in final game builds.
Best practices for using this variable include:
- Use it temporarily during development for debugging collision issues.
- Be aware that enabling it may impact performance due to additional debug drawing and logging.
- Remember to disable it before creating shipping builds.
Regarding the associated variable CVarShowInitialOverlaps:
The purpose of CVarShowInitialOverlaps is to act as the actual integer storage for the p.ShowInitialOverlaps console variable. It’s used internally by the engine code to check if initial overlap debugging is enabled.
This variable is used in the same subsystems as p.ShowInitialOverlaps, primarily in collision detection and component movement code.
The value of CVarShowInitialOverlaps is set automatically by the FAutoConsoleVariableRef mechanism when p.ShowInitialOverlaps is changed.
CVarShowInitialOverlaps interacts directly with p.ShowInitialOverlaps and is used in conditional statements to determine whether to perform debug drawing and logging.
Developers should be aware that this variable is an implementation detail of the p.ShowInitialOverlaps system and shouldn’t be modified directly. Instead, they should use the p.ShowInitialOverlaps console command to control this functionality.
Best practices for CVarShowInitialOverlaps are the same as for p.ShowInitialOverlaps, as they are effectively two sides of the same coin in terms of functionality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/PrimitiveComponent.cpp:132
Scope: file
Source code excerpt:
int32 CVarShowInitialOverlaps = 0;
FAutoConsoleVariableRef CVarRefShowInitialOverlaps(
TEXT("p.ShowInitialOverlaps"),
CVarShowInitialOverlaps,
TEXT("Show initial overlaps when moving a component, including estimated 'exit' direction.\n")
TEXT(" 0:off, otherwise on"),
ECVF_Cheat);
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
#Associated Variable and Callsites
This variable is associated with another variable named CVarShowInitialOverlaps
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/CharacterMovementComponentAsync.cpp:2961
Scope (from outer to inner):
file
function bool FUpdatedComponentAsyncInput::ShouldIgnoreHitResult
Source code excerpt:
/*#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
{
if (CVarShowInitialOverlaps != 0)
{
UE_LOG(LogTemp, Log, TEXT("Overlapping %s Dir %s Dot %f Normal %s Depth %f"), *GetNameSafe(TestHit.Component.Get()), *MovementDir.ToString(), MoveDot, *TestHit.ImpactNormal.ToString(), TestHit.PenetrationDepth);
DrawDebugDirectionalArrow(InWorld, TestHit.TraceStart, TestHit.TraceStart + 30.f * TestHit.ImpactNormal, 5.f, bMovingOut ? FColor(64, 128, 255) : FColor(255, 64, 64), false, 4.f);
if (TestHit.PenetrationDepth > KINDA_SMALL_NUMBER)
{
DrawDebugDirectionalArrow(InWorld, TestHit.TraceStart, TestHit.TraceStart + TestHit.PenetrationDepth * TestHit.Normal, 5.f, FColor(64, 255, 64), false, 4.f);
}
}
}
#endif*/
// If we are moving out, ignore this result!
if (bMovingOut)
{
return true;
}
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/CollisionConversions.cpp:44
Scope: file
Source code excerpt:
}
extern int32 CVarShowInitialOverlaps;
// Forward declare, I don't want to move the entire function right now or we lose change history.
template <typename THitLocation>
static bool ConvertOverlappedShapeToImpactHit(const UWorld* World, const THitLocation& Hit, const FVector& StartLoc, const FVector& EndLoc, FHitResult& OutResult, const FPhysicsGeometry& Geom, const FTransform& QueryTM, const FCollisionFilterData& QueryFilter, bool bReturnPhysMat);
DECLARE_CYCLE_STAT(TEXT("ConvertQueryHit"), STAT_ConvertQueryImpactHit, STATGROUP_Collision);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/CollisionConversions.cpp:556
Scope (from outer to inner):
file
function static bool ConvertOverlappedShapeToImpactHit
Source code excerpt:
#if DRAW_OVERLAPPING_TRIS
if (CVarShowInitialOverlaps != 0 && World && World->IsGameWorld())
{
DrawOverlappingTris(World, Hit, Geom, QueryTM);
}
#endif
if (bBlockingHit)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/PrimitiveComponent.cpp:130
Scope: file
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
int32 CVarShowInitialOverlaps = 0;
FAutoConsoleVariableRef CVarRefShowInitialOverlaps(
TEXT("p.ShowInitialOverlaps"),
CVarShowInitialOverlaps,
TEXT("Show initial overlaps when moving a component, including estimated 'exit' direction.\n")
TEXT(" 0:off, otherwise on"),
ECVF_Cheat);
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
DEFINE_STAT(STAT_BeginComponentOverlap);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/PrimitiveComponent.cpp:2501
Scope (from outer to inner):
file
function static bool ShouldIgnoreHitResult
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
{
if (CVarShowInitialOverlaps != 0)
{
UE_LOG(LogTemp, Log, TEXT("Overlapping %s Dir %s Dot %f Normal %s Depth %f"), *GetNameSafe(TestHit.Component.Get()), *MovementDir.ToString(), MoveDot, *TestHit.ImpactNormal.ToString(), TestHit.PenetrationDepth);
DrawDebugDirectionalArrow(InWorld, TestHit.TraceStart, TestHit.TraceStart + 30.f * TestHit.ImpactNormal, 5.f, bMovingOut ? FColor(64,128,255) : FColor(255,64,64), false, 4.f);
if (TestHit.PenetrationDepth > UE_KINDA_SMALL_NUMBER)
{
DrawDebugDirectionalArrow(InWorld, TestHit.TraceStart, TestHit.TraceStart + TestHit.PenetrationDepth * TestHit.Normal, 5.f, FColor(64,255,64), false, 4.f);