bAutoComputeLodDistances

bAutoComputeLodDistances

#Overview

name: bAutoComputeLodDistances

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 12 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bAutoComputeLodDistances is to control the automatic computation of Level of Detail (LOD) screen size values for static meshes in Unreal Engine 5. This setting is primarily used in the static mesh import and reimport process.

Key points about bAutoComputeLodDistances:

  1. It is part of the Unreal Engine’s FBX import system, specifically for static meshes.

  2. The main subsystem that relies on this variable is the Static Mesh import and LOD management system within the Unreal Editor.

  3. The value of this variable is typically set in the FBX import UI (UFbxImportUI class) and can be modified through the editor interface when importing or reimporting FBX files.

  4. It interacts with other LOD-related variables such as LodNumber, MinimumLodNumber, and individual LodDistance values (e.g., LodDistance0, LodDistance1, etc.).

  5. When set to true, the engine automatically calculates the screen size values for each LOD level of the static mesh. When false, it allows manual setting of these values.

  6. Developers should be aware that this setting affects the LOD behavior of imported static meshes. If set to false, they need to manually provide appropriate screen size values for each LOD level.

  7. Best practices:

    • For most cases, leaving this as true allows the engine to optimize LOD transitions automatically.
    • Set to false only when you need precise control over LOD transitions, such as for hero assets or objects with specific performance requirements.
    • When reimporting assets, consider keeping this value consistent to maintain the existing LOD behavior unless intentionally changing it.
  8. This variable is preserved during reimport operations to maintain consistency in LOD behavior across updates to the asset.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:622, section: [/Script/UnrealEd.FbxImportUI]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:322

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::CustomizeDetails

Source code excerpt:

	ImportMaterialsProp->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FFbxImportUIDetails::ImportMaterialsChanged));

	TSharedRef<IPropertyHandle> ImportAutoComputeLodDistancesProp = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UFbxImportUI, bAutoComputeLodDistances));
	ImportAutoComputeLodDistancesProp->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FFbxImportUIDetails::ImportAutoComputeLodDistancesChanged));

	TSharedPtr<IPropertyHandle> ImportMeshLODsProp = StaticMeshDataProp->GetChildHandle(GET_MEMBER_NAME_CHECKED(UFbxStaticMeshImportData, bImportMeshLODs));
	ImportMeshLODsProp->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FFbxImportUIDetails::RefreshCustomDetail));

	MeshCategory.GetDefaultProperties(CategoryDefaultProperties);

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:371

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::CustomizeDetails

Source code excerpt:

	else
	{
		int32 ShowMaxLodIndex = (ImportUI->bAutoComputeLodDistances ? 0 : ImportUI->LodNumber > 0 ? ImportUI->LodNumber : MAX_STATIC_MESH_LODS) - 1;
		for (int32 LodIndex = 0; LodIndex < MAX_STATIC_MESH_LODS; ++LodIndex)
		{
			if (LodIndex <= ShowMaxLodIndex)
			{
				continue;
			}

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:1183

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::ValidateLodSettingsChanged

Source code excerpt:

	}
	
	if (!ImportUI->bAutoComputeLodDistances && MemberID == LodNumberID)
	{
		RefreshCustomDetail();
	}
}

void FFbxImportUIDetails::ImportMaterialsChanged()

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.h:70

Scope (from outer to inner):

file
class        class FFbxImportUIDetails : public IDetailCustomization, public FEditorUndoClient

Source code excerpt:

	bool IsImportTypeMetaDataValid(EFBXImportType& ImportType, FString& MetaData);
	
	/** Called if the bAutoComputeLodDistances changes */
	void ImportAutoComputeLodDistancesChanged();

	/** Called when the LODSettings changes */
	void ValidateLodSettingsChanged(int32 MemberID);

	/** Called if the bImportMaterials changes */

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Factories/FbxImportUI.h:139

Scope (from outer to inner):

file
class        class UFbxImportUI : public UObject, public IImportSettingsParser

Source code excerpt:

	/** If checked, the editor will automatically compute screen size values for the static mesh's LODs. If unchecked, the user can enter custom screen size values for each LOD. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = LODSettings, meta = (ImportType = "StaticMesh", DisplayName = "Auto Compute LOD Screen Size"))
	uint32 bAutoComputeLodDistances : 1;
	/** Set a screen size value for LOD 0*/
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = LODSettings, meta = (ImportType = "StaticMesh", UIMin = "0.0", DisplayName = "LOD 0 Screen Size"))
	float LodDistance0;
	/** Set a screen size value for LOD 1*/
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = LODSettings, meta = (ImportType = "StaticMesh", UIMin = "0.0", DisplayName = "LOD 1 Screen Size"))
	float LodDistance1;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Factories/EditorFactories.cpp:6204

Scope (from outer to inner):

file
function     EReimportResult::Type UReimportFbxStaticMeshFactory::Reimport

Source code excerpt:

	}
	ImportOptions->bCanShowDialog = !IsUnattended;
	//We do not touch bAutoComputeLodDistances when we re-import, setting it to true will make sure we do not change anything.
	//We set the LODDistance only when the value is false.
	ImportOptions->bAutoComputeLodDistances = true;
	ImportOptions->LodNumber = 0;
	ImportOptions->MinimumLodNumber = 0;
	//Make sure the LODGroup do not change when re-importing a mesh
	ImportOptions->StaticMeshLODGroup = Mesh->LODGroup;

	if( !bOperationCanceled && ensure(ImportData) )

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/FbxMainImport.cpp:358

Scope (from outer to inner):

file
namespace    UnFbx
function     void ApplyImportUIToImportOptions

Source code excerpt:


		InOutImportOptions.bResetToFbxOnMaterialConflict = ImportUI->bResetToFbxOnMaterialConflict;
		InOutImportOptions.bAutoComputeLodDistances	= ImportUI->bAutoComputeLodDistances;
		InOutImportOptions.LodDistances.Empty(8);
		InOutImportOptions.LodDistances.Add(ImportUI->LodDistance0);
		InOutImportOptions.LodDistances.Add(ImportUI->LodDistance1);
		InOutImportOptions.LodDistances.Add(ImportUI->LodDistance2);
		InOutImportOptions.LodDistances.Add(ImportUI->LodDistance3);
		InOutImportOptions.LodDistances.Add(ImportUI->LodDistance4);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/FbxMainImport.cpp:1772

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

						auto AddSMAnalytic = [&Attribs, &CaptureImportOptions]()
						{
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt AutoComputeLodDistances"), CaptureImportOptions->bAutoComputeLodDistances));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt LodNumber"), CaptureImportOptions->LodNumber));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt BuildReversedIndexBuffer"), CaptureImportOptions->bBuildReversedIndexBuffer));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt GenerateLightmapUVs"), CaptureImportOptions->bGenerateLightmapUVs));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt ImportStaticMeshLODs"), CaptureImportOptions->bImportStaticMeshLODs));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt RemoveDegenerates"), CaptureImportOptions->bRemoveDegenerates));
							Attribs.Add(FAnalyticsEventAttribute(TEXT("StaticMeshOpt MinimumLodNumber"), CaptureImportOptions->MinimumLodNumber));

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/FbxStaticMeshImport.cpp:2387

Scope (from outer to inner):

file
function     void UnFbx::FFbxImporter::PostImportStaticMesh

Source code excerpt:


	//Set the specified LOD distances for every LODs we have to do this after the build in case there is a specified Lod Group
	if (!ImportOptions->bAutoComputeLodDistances && !ImportOptions->bImportScene)
	{
		StaticMesh->bAutoComputeLODScreenSize = false;

		for (int32 LodIndex = 0; LodIndex < StaticMesh->GetNumSourceModels(); ++LodIndex)
		{
			FStaticMeshSourceModel& StaticMeshSourceModel = StaticMesh->GetSourceModel(LodIndex);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/ReimportFbxSceneFactory.cpp:242

Scope (from outer to inner):

file
function     bool GetFbxSceneReImportOptions

Source code excerpt:

	GlobalImportSettings->bKeepSectionsSeparate = false;
	//Make sure we do not mess with AutoComputeLodDistances when re-importing
	GlobalImportSettings->bAutoComputeLodDistances = true;
	GlobalImportSettings->LodNumber = 0;
	GlobalImportSettings->MinimumLodNumber = 0;

	GlobalImportSettings->ImportTranslation = FVector(0);
	GlobalImportSettings->ImportRotation = FRotator(0);
	GlobalImportSettings->ImportUniformScale = 1.0f;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/FbxMeshUtils.cpp:90

Scope (from outer to inner):

file
namespace    FbxMeshUtils
namespace    Private
function     void SetupFbxImportOptions

Source code excerpt:

			ImportOptions->bImportTextures = false;

			ImportOptions->bAutoComputeLodDistances = true; //Setting auto compute distance to true will avoid changing the staticmesh flag
		}

		bool CopyHighResMeshDescription(UStaticMesh* SrcStaticMesh, UStaticMesh* BaseStaticMesh)
		{
			if (!SrcStaticMesh || !SrcStaticMesh->IsSourceModelValid(0))
			{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/FbxImporter.h:157

Scope (from outer to inner):

file
namespace    UnFbx

Source code excerpt:

	FName StaticMeshLODGroup;
	bool bImportStaticMeshLODs;
	bool bAutoComputeLodDistances;
	TArray<float> LodDistances;
	int32 MinimumLodNumber;
	int32 LodNumber;
	// Material import options
	class UMaterialInterface *BaseMaterial;
	FString BaseColorName;