TreeScale

TreeScale

#Overview

name: TreeScale

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 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of TreeScale is to specify the scale factor for importing SpeedTree assets into Unreal Engine 5. This setting variable is used in the SpeedTree importer system, which is part of the SpeedTreeImporter plugin for the Unreal Engine editor.

The SpeedTreeImporter plugin and module rely on this setting variable, as evidenced by its usage in the SpeedTreeImportData class and SpeedTreeImportFactory.

The value of this variable is set in multiple places:

  1. It has a default value of 30.48f, as seen in the constructor of USpeedTreeImportData.
  2. It can be modified through the editor interface, as it’s declared as an UPROPERTY with EditAnywhere and config attributes.
  3. It can be set programmatically when copying data from another USpeedTreeImportData object.

The TreeScale variable interacts with the SpeedTree::CCore class, where it’s used as a parameter when loading the tree data.

Developers should be aware of the following when using this variable:

  1. It’s specific to SpeedTree version 7 imports, as it’s hidden for SpeedTree 8 imports.
  2. The scale factor directly affects the size of the imported SpeedTree asset in the Unreal Engine environment.
  3. The default value of 30.48f suggests a conversion from feet to centimeters, which is the default unit in Unreal Engine.

Best practices when using this variable include:

  1. Carefully consider the desired scale of the SpeedTree asset in your game world when setting this value.
  2. Ensure consistency in scale across all imported SpeedTree assets for a cohesive environment.
  3. Be aware that changing this value after import may require reimporting the asset to apply the new scale.
  4. When working with SpeedTree 8 assets, use the native scaling options provided by SpeedTree 8 instead of this variable.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:940, section: [/Script/SpeedTreeImporter.SpeedTreeImportData]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Editor/SpeedTreeImporter/Source/SpeedTreeImporter/Classes/SpeedTreeImportData.h:49

Scope (from outer to inner):

file
class        class USpeedTreeImportData : public UAssetImportData

Source code excerpt:

	/** Specify the tree scale */
	UPROPERTY(EditAnywhere, config, Category=Mesh, meta=(DisplayName = "Tree Scale"))
	float TreeScale;

	/** Choose whether to import as a 3D asset, billboard or both */
	UPROPERTY(EditAnywhere, config, Category=Mesh, meta = (DisplayName = "Geometry"))
	TEnumAsByte<enum EImportGeometryType> ImportGeometryType;

	/** Choose whether painted foliage or individual actor */

#Loc: <Workspace>/Engine/Plugins/Editor/SpeedTreeImporter/Source/SpeedTreeImporter/Private/SpeedTreeImportData.cpp:30

Scope (from outer to inner):

file
function     USpeedTreeImportData::USpeedTreeImportData

Source code excerpt:

{
	ImportGeometryType = IGT_3D;
	TreeScale = 30.48f;
	LODType = ILT_PaintedFoliage;
}

void USpeedTreeImportData::CopyFrom(USpeedTreeImportData* Other)
{
	TreeScale = Other->TreeScale;
	ImportGeometryType = Other->ImportGeometryType;
	LODType = Other->LODType;
	IncludeCollision = Other->IncludeCollision;
	MakeMaterialsCheck = Other->MakeMaterialsCheck;
	IncludeNormalMapCheck = Other->IncludeNormalMapCheck;
	IncludeDetailMapCheck = Other->IncludeDetailMapCheck;

#Loc: <Workspace>/Engine/Plugins/Editor/SpeedTreeImporter/Source/SpeedTreeImporter/Private/SpeedTreeImportData.cpp:89

Scope (from outer to inner):

file
function     void FSpeedTreeImportDataDetails::CustomizeDetails

Source code excerpt:

	if (bSpeedTree8)
	{
		DetailLayout.HideProperty(FName(TEXT("TreeScale")));
		DetailLayout.HideProperty(FName(TEXT("ImportGeometryType")));
	}

	//Get the Materials category
	IDetailCategoryBuilder& MaterialsCategoryBuilder = DetailLayout.EditCategory(FName(TEXT("Materials")));
	TArray<TSharedRef<IPropertyHandle>> MaterialCategoryDefaultProperties;

#Loc: <Workspace>/Engine/Plugins/Editor/SpeedTreeImporter/Source/SpeedTreeImporter/Private/SpeedTreeImportFactory.cpp:309

Scope (from outer to inner):

file
function     void ScaleTextCommitted

Source code excerpt:

	void ScaleTextCommitted(const FText& CommentText, ETextCommit::Type CommitInfo)
	{
		TTypeFromString<float>::FromString(SpeedTreeImportData->TreeScale, *(CommentText.ToString()));
	}
};
END_SLATE_FUNCTION_BUILD_OPTIMIZATION


/**

#Loc: <Workspace>/Engine/Plugins/Editor/SpeedTreeImporter/Source/SpeedTreeImporter/Private/SpeedTreeImportFactory.cpp:2003

Scope (from outer to inner):

file
function     UObject* USpeedTreeImportFactory::FactoryCreateBinary7

Source code excerpt:

		
		SpeedTree::CCore SpeedTree;
		if (!SpeedTree.LoadTree(Buffer, BufferEnd - Buffer, false, false, SpeedTreeImportData->TreeScale))
		{
			UE_LOG(LogSpeedTreeImport, Error, TEXT("%s"), ANSI_TO_TCHAR(SpeedTree.GetError( )));
		}
		else
		{
			FSpeedTreeImportContext ImportContext;