Editor.AsyncStaticMeshPlayInEditorDistance
Editor.AsyncStaticMeshPlayInEditorDistance
#Overview
name: Editor.AsyncStaticMeshPlayInEditorDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scale applied to the player bounding sphere to determine how far away to force meshes compilation before resuming play.\nThe effect can be seen during play session when Editor.AsyncStaticMeshPlayInEditorDebugDraw = 1.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Editor.AsyncStaticMeshPlayInEditorDistance is to control the distance at which static meshes are forced to compile before resuming play in the Unreal Engine editor. This setting is primarily used in the static mesh compilation system.
This setting variable is relied upon by the Unreal Engine’s static mesh compilation subsystem, which is part of the Engine module. It’s specifically used in the StaticMeshCompiler.cpp file, which handles the compilation of static meshes.
The value of this variable is set as a console variable (CVar) with a default value of 2.0f. It can be modified at runtime through the console or configuration files.
This variable interacts with the player’s bounding sphere to determine the distance at which static meshes should be compiled. It’s used in conjunction with another debug drawing variable (Editor.AsyncStaticMeshPlayInEditorDebugDraw) to visualize its effect.
Developers should be aware that this variable affects performance during Play-In-Editor (PIE) sessions. A higher value will force more distant meshes to compile before play resumes, which could lead to longer load times but potentially smoother gameplay. Conversely, a lower value might result in faster startup times but could cause visible mesh pop-in during gameplay.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your project and target hardware.
- Using it in conjunction with the debug drawing option to visualize its effect.
- Finding a balance between compilation time and smooth gameplay experience.
Regarding the associated variable CVarAsyncStaticMeshPlayInEditorDistance:
This is the actual C++ variable that stores the value of the Editor.AsyncStaticMeshPlayInEditorDistance console variable. It’s defined using the TAutoConsoleVariable template, which automatically registers it with the console variable system.
The purpose of CVarAsyncStaticMeshPlayInEditorDistance is to provide a programmatic way to access and modify the Editor.AsyncStaticMeshPlayInEditorDistance setting within the C++ code.
This variable is used directly in the FStaticMeshCompilingManager::FinishCompilationsForGame() function to determine the radius scale for compiling static meshes before resuming play.
Developers should be aware that changes to this variable will take effect immediately in the running game or editor session. It’s important to use GetValueOnGameThread() when accessing this variable to ensure thread-safe access.
Best practices for using CVarAsyncStaticMeshPlayInEditorDistance include:
- Always access it using GetValueOnGameThread() to ensure thread safety.
- Consider caching its value if used frequently in performance-critical code sections.
- Be cautious when modifying it at runtime, as it can have immediate effects on the static mesh compilation process.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:42
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarAsyncStaticMeshPlayInEditorDistance(
TEXT("Editor.AsyncStaticMeshPlayInEditorDistance"),
2.0f,
TEXT("Scale applied to the player bounding sphere to determine how far away to force meshes compilation before resuming play.\n")
TEXT("The effect can be seen during play session when Editor.AsyncStaticMeshPlayInEditorDebugDraw = 1.\n"),
ECVF_Default);
static TAutoConsoleVariable<bool> CVarAsyncStaticMeshDebugDraw(
#Associated Variable and Callsites
This variable is associated with another variable named CVarAsyncStaticMeshPlayInEditorDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:41
Scope: file
Source code excerpt:
ECVF_Default);
static TAutoConsoleVariable<float> CVarAsyncStaticMeshPlayInEditorDistance(
TEXT("Editor.AsyncStaticMeshPlayInEditorDistance"),
2.0f,
TEXT("Scale applied to the player bounding sphere to determine how far away to force meshes compilation before resuming play.\n")
TEXT("The effect can be seen during play session when Editor.AsyncStaticMeshPlayInEditorDebugDraw = 1.\n"),
ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:441
Scope (from outer to inner):
file
function void FStaticMeshCompilingManager::FinishCompilationsForGame
Source code excerpt:
TMultiMap<const UWorld*, FBoxSphereBounds> WorldActors;
float RadiusScale = CVarAsyncStaticMeshPlayInEditorDistance.GetValueOnGameThread();
for (const FWorldContext& WorldContext : GEngine->GetWorldContexts())
{
if (WorldContext.WorldType == EWorldType::PIE || WorldContext.WorldType == EWorldType::Game)
{
UWorld* World = WorldContext.World();
PIEWorlds.Add(World);