au.ActorSoundParameterInterface.GatherImplementers

au.ActorSoundParameterInterface.GatherImplementers

#Overview

name: au.ActorSoundParameterInterface.GatherImplementers

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 au.ActorSoundParameterInterface.GatherImplementers is to control whether the ActorSoundParameterInterface should search for attached components and actors that implement the interface. This setting variable is primarily used for the audio system in Unreal Engine 5.

This setting variable is relied upon by the Engine module, specifically within the audio subsystem. It’s used in the implementation of the ActorSoundParameterInterface, which is part of Unreal Engine’s audio framework.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.

The associated variable bGatherImplementers directly interacts with this console variable. They share the same value, with bGatherImplementers being the actual boolean flag used in the code logic.

Developers must be aware that enabling this variable (setting it to true) can be performance-intensive. The code comments indicate that searching for implementers of the interface across all attached actors and components can be “prohibitively expensive”.

Best practices when using this variable include:

  1. Keeping it disabled (false) by default for better performance.
  2. Only enabling it when necessary for debugging or specific audio implementation needs.
  3. Being cautious about enabling it in production builds due to its potential performance impact.
  4. If enabled, consider optimizing the actor and component structure to minimize the search scope.

Regarding the associated variable bGatherImplementers:

This is a boolean flag used directly in the code logic of the Fill function in UActorSoundParameterInterface. When true, it triggers a search for components and actors that implement the IActorSoundParameterInterface. This search is performed by the GetImplementers function.

Developers should be aware that this flag directly controls a potentially expensive operation. It’s important to use it judiciously and consider the performance implications, especially in scenarios with complex actor hierarchies or numerous components.

Best practices for bGatherImplementers include:

  1. Keeping it false by default to avoid unnecessary performance overhead.
  2. Only setting it to true when you specifically need to gather parameters from attached actors and components.
  3. If set to true, ensure that the actor hierarchy is optimized and that unnecessary attachments are avoided.
  4. Consider caching the results of the implementer search if it’s needed frequently, rather than performing the search every time the Fill function is called.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio/ActorSoundParameterInterface.cpp:12

Scope (from outer to inner):

file
namespace    ActorSoundParameterInterfaceConsoleVariables

Source code excerpt:

	bool bGatherImplementers = false;
	FAutoConsoleVariableRef CVarGatherImplementers(
		TEXT("au.ActorSoundParameterInterface.GatherImplementers"),
		bGatherImplementers,
		TEXT("When true, allows the interface to search for attached components and actors that implement the interface."),
		ECVF_Default);

} // namespace ActorSoundParameterInterfaceConsoleVariables

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio/ActorSoundParameterInterface.cpp:10

Scope (from outer to inner):

file
namespace    ActorSoundParameterInterfaceConsoleVariables

Source code excerpt:

namespace ActorSoundParameterInterfaceConsoleVariables
{
	bool bGatherImplementers = false;
	FAutoConsoleVariableRef CVarGatherImplementers(
		TEXT("au.ActorSoundParameterInterface.GatherImplementers"),
		bGatherImplementers,
		TEXT("When true, allows the interface to search for attached components and actors that implement the interface."),
		ECVF_Default);

} // namespace ActorSoundParameterInterfaceConsoleVariables

void UActorSoundParameterInterface::Fill(const AActor* OwningActor, TArray<FAudioParameter>& OutParams)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Audio/ActorSoundParameterInterface.cpp:24

Scope (from outer to inner):

file
function     void UActorSoundParameterInterface::Fill

Source code excerpt:

	TArray<const UActorComponent*> Components;

	if (ActorSoundParameterInterfaceConsoleVariables::bGatherImplementers)
	{
		// This is prohibitively expensive, as it goes through our owning actor and all attached actors, looking for 
		// components that implement the IActorSoundParameterInterface
		GetImplementers(OwningActor, Actors, Components);
	}
	else