p.DisableQueryOnlyActors

p.DisableQueryOnlyActors

#Overview

name: p.DisableQueryOnlyActors

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.DisableQueryOnlyActors is to control the behavior of actors marked as “Query Only” in the physics simulation. This setting is related to the physics engine in Unreal Engine 5.

This setting variable is primarily used in the Engine module, specifically within the physics engine subsystem. It is referenced in the BodyInstance.cpp file, which is part of the core physics implementation in Unreal Engine.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0 and can be changed at runtime through the console or configuration files.

The associated variable CDisableQueryOnlyActors directly interacts with p.DisableQueryOnlyActors. They share the same value, with CDisableQueryOnlyActors being the actual implementation of the console variable.

Developers must be aware that when this setting is enabled (set to a non-zero value), actors marked as “Query Only” will be disabled for simulation. This has important implications for physics interactions and performance.

A crucial point to note is that this setting is not compatible with origin shifting at the moment. Origin shifting is a technique used in large world scenarios, so developers working on such projects should be cautious when using this setting.

Best practices when using this variable include:

  1. Only enable it when necessary, as it can affect physics behavior significantly.
  2. Be aware of its incompatibility with origin shifting for large world scenarios.
  3. Test thoroughly when changing this setting, as it can have wide-ranging effects on physics interactions in the game.

Regarding the associated variable CDisableQueryOnlyActors:

The purpose of CDisableQueryOnlyActors is to provide a programmatic interface to the p.DisableQueryOnlyActors setting. It allows C++ code to read and potentially modify the setting at runtime.

This variable is used in the same Engine module and physics subsystem as p.DisableQueryOnlyActors. It’s defined and used in the BodyInstance.cpp file.

The value of CDisableQueryOnlyActors is set when it’s declared, mirroring the value of p.DisableQueryOnlyActors. It can be accessed in C++ code using the GetValueOnGameThread() method.

CDisableQueryOnlyActors directly interacts with p.DisableQueryOnlyActors, effectively serving as its C++ representation.

Developers should be aware that changes to CDisableQueryOnlyActors will affect the behavior of “Query Only” actors in the physics simulation. They should also note that this variable is used to initialize other local variables in physics-related functions.

Best practices for using CDisableQueryOnlyActors include:

  1. Use GetValueOnGameThread() to read its current value in game code.
  2. Be cautious about changing its value at runtime, as it can have immediate effects on physics behavior.
  3. Consider the performance implications when frequently accessing this variable in performance-critical code paths.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:1098

Scope: file

Source code excerpt:

}

TAutoConsoleVariable<int32> CDisableQueryOnlyActors(TEXT("p.DisableQueryOnlyActors"), 0, TEXT("If QueryOnly is used, actors are marked as simulation disabled. This is NOT compatible with origin shifting at the moment."));

#if USE_BODYINSTANCE_DEBUG_NAMES
TSharedPtr<TArray<ANSICHAR>> GetDebugDebugName(const UPrimitiveComponent* PrimitiveComp, const UBodySetup* BodySetup, FString& DebugName)
{
	// Setup names
	// Make the debug name for this geometry...

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:1098

Scope: file

Source code excerpt:

}

TAutoConsoleVariable<int32> CDisableQueryOnlyActors(TEXT("p.DisableQueryOnlyActors"), 0, TEXT("If QueryOnly is used, actors are marked as simulation disabled. This is NOT compatible with origin shifting at the moment."));

#if USE_BODYINSTANCE_DEBUG_NAMES
TSharedPtr<TArray<ANSICHAR>> GetDebugDebugName(const UPrimitiveComponent* PrimitiveComp, const UBodySetup* BodySetup, FString& DebugName)
{
	// Setup names
	// Make the debug name for this geometry...

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:1184

Scope (from outer to inner):

file
function     FInitBodiesHelperBase::FInitBodiesHelperBase

Source code excerpt:

	, SkelMeshComp(nullptr)
	, SpawnParams(InSpawnParams)
	, DisableQueryOnlyActors(!!CDisableQueryOnlyActors.GetValueOnGameThread())
{
#if USE_BODYINSTANCE_DEBUG_NAMES
	PhysXName = GetDebugDebugName(PrimitiveComp, BodySetup, *DebugName);
#endif
}