foliage.OffGroundThreshold

foliage.OffGroundThreshold

#Overview

name: foliage.OffGroundThreshold

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 foliage.OffGroundThreshold is to define the maximum distance from the base component (in local space) at which a foliage instance is still considered valid. This setting is primarily used in the foliage editing system of Unreal Engine 5.

This setting variable is primarily used in the FoliageEdit module, which is part of the Editor subsystem in Unreal Engine. Specifically, it’s used in the FEdModeFoliage class, which handles foliage editing functionality.

The value of this variable is set as a console variable (CVar) with a default value of 5.0f. It can be modified at runtime through the console or programmatically.

The associated variable CVarOffGroundTreshold interacts directly with foliage.OffGroundThreshold. It’s used to retrieve the current value of the setting in the game thread.

Developers must be aware that this threshold affects how the engine determines the validity of foliage instances. A higher value will allow instances to be further from the ground while still being considered valid, while a lower value will be more strict.

Best practices when using this variable include:

  1. Adjusting it based on the scale and nature of your foliage assets.
  2. Testing different values to find the right balance between performance and visual quality.
  3. Considering the impact on performance when selecting invalid instances, especially in scenes with large amounts of foliage.

Regarding the associated variable CVarOffGroundTreshold:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/FoliageEdit/Private/FoliageEdMode.cpp:2141

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarOffGroundTreshold(
	TEXT("foliage.OffGroundThreshold"),
	5.0f,
	TEXT("Maximum distance from base component (in local space) at which instance is still considered as valid"));

void FEdModeFoliage::SelectInvalidInstances(const TArray<const UFoliageType *>& FoliageTypes)
{
	FEdModeFoliageSelectionUpdate Scope(this);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/FoliageEdit/Private/FoliageEdMode.cpp:2140

Scope: file

Source code excerpt:

}

TAutoConsoleVariable<float> CVarOffGroundTreshold(
	TEXT("foliage.OffGroundThreshold"),
	5.0f,
	TEXT("Maximum distance from base component (in local space) at which instance is still considered as valid"));

void FEdModeFoliage::SelectInvalidInstances(const TArray<const UFoliageType *>& FoliageTypes)
{

#Loc: <Workspace>/Engine/Source/Editor/FoliageEdit/Private/FoliageEdMode.cpp:2163

Scope (from outer to inner):

file
function     void FEdModeFoliage::SelectInvalidInstances

Source code excerpt:

	FCollisionShape SphereShape;
	SphereShape.SetSphere(0.f);
	float InstanceOffGroundLocalThreshold = CVarOffGroundTreshold.GetValueOnGameThread();

	for (FFoliageInfoIterator It(InWorld, Settings); It; ++It)
	{
		FFoliageInfo* FoliageInfo = (*It);
		AInstancedFoliageActor* IFA = It.GetActor();
		int32 NumInstances = FoliageInfo->Instances.Num();