r.Editor.MaxNumInstancesDetails

r.Editor.MaxNumInstancesDetails

#Overview

name: r.Editor.MaxNumInstancesDetails

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 r.Editor.MaxNumInstancesDetails is to control the maximum number of instances shown in the details panel for Instanced Static Mesh Components in the Unreal Engine editor. This setting is primarily used for performance optimization in the editor’s user interface.

This setting variable is relied upon by the Editor subsystem, specifically within the DetailCustomizations module. It is used in the InstancedStaticMeshComponentDetails class, which is responsible for customizing the details panel for Instanced Static Mesh Components.

The value of this variable is set using a TAutoConsoleVariable, which allows it to be changed at runtime through console commands. By default, it is set to 512 instances.

The associated variable CVarMaxNumInstancesDetails directly interacts with r.Editor.MaxNumInstancesDetails. They share the same value and purpose.

Developers must be aware that:

  1. This variable affects the editor’s UI performance and not the runtime performance of the game.
  2. Setting a value less than 0 means there will be no maximum limit on the number of instances shown.
  3. When the number of instances exceeds the set value, the instances are hidden by default in the details panel.

Best practices when using this variable include:

  1. Adjust the value based on the performance of your development machine. Lower-end machines may benefit from a lower value to maintain editor responsiveness.
  2. Consider the complexity of your scenes and the typical number of instances you work with when setting this value.
  3. Use the console command to experiment with different values to find the right balance between visibility and performance.

Regarding the associated variable CVarMaxNumInstancesDetails: It serves the same purpose as r.Editor.MaxNumInstancesDetails and is used to retrieve the current value of the setting within the C++ code. Developers should use this variable when they need to access the current maximum number of instances to be displayed in C++ code, particularly within the InstancedStaticMeshComponentDetails class.

When working with CVarMaxNumInstancesDetails, developers should:

  1. Use GetValueOnGameThread() to retrieve the current value safely.
  2. Be aware that changes to this value will affect the visibility of instances in the details panel immediately.
  3. Consider providing a way for users to override this setting on a per-component basis if needed, as demonstrated by the bForceShowAllInstances flag in the provided code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/InstancedStaticMeshComponentDetails.cpp:32

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarMaxNumInstancesDetails(
	TEXT("r.Editor.MaxNumInstancesDetails"),
	512,
	TEXT("Maximum number of instances shown in the details panel. Above this value, instances are hidden by default. \n")
	TEXT("< 0 : No maximum\n"),
	ECVF_RenderThreadSafe);

TSharedRef<IDetailCustomization> FInstancedStaticMeshComponentDetails::MakeInstance()

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/InstancedStaticMeshComponentDetails.cpp:31

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "InstancedStaticMeshComponentDetails"

TAutoConsoleVariable<float> CVarMaxNumInstancesDetails(
	TEXT("r.Editor.MaxNumInstancesDetails"),
	512,
	TEXT("Maximum number of instances shown in the details panel. Above this value, instances are hidden by default. \n")
	TEXT("< 0 : No maximum\n"),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/InstancedStaticMeshComponentDetails.cpp:66

Scope (from outer to inner):

file
function     void FInstancedStaticMeshComponentDetails::CustomizeDetails

Source code excerpt:

			bForceShowAllInstances = ComponentBeingCustomized->bForceShowAllInstancesDetails;

			int32 MaxNumInstances = CVarMaxNumInstancesDetails.GetValueOnGameThread();
			bool bTooManyInstances = (MaxNumInstances >= 0) && (NumInstances > MaxNumInstances);
			// If there are too many instances to display, hide the property as it will slow down the UI : 
			if (bTooManyInstances && !bForceShowAllInstances)
			{
				PerInstanceSMDataProperty->MarkHiddenByCustomization();
			}