bUseSlopeFlatten

bUseSlopeFlatten

#Overview

name: bUseSlopeFlatten

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

#Summary

#Usage in the C++ source code

The purpose of bUseSlopeFlatten is to control the behavior of the Flatten tool in the Landscape Editor of Unreal Engine 5. This setting variable is specifically used for the terrain editing system, particularly in the context of flattening landscapes.

The Unreal Engine subsystem that relies on this setting variable is the Landscape Editor, which is part of the Editor module. It’s primarily used in the LandscapeEditor subsystem, specifically in the Flatten tool functionality.

The value of this variable is set in the ULandscapeEditorObject constructor and can be modified through the Landscape Editor user interface. It’s also loaded from and saved to the project’s configuration file (GEditorPerProjectIni) when the editor starts up or when settings are saved.

This variable interacts with other variables such as bUseFlattenTarget, bPickValuePerApply, and FlattenMode. These variables collectively control the behavior of the Flatten tool.

Developers must be aware that:

  1. This variable only affects heightmap editing, not other landscape layers.
  2. It’s used in conjunction with the Flatten tool and has no effect when other tools are active.
  3. It changes the flattening behavior from horizontal to matching the slope of the clicked point.

Best practices when using this variable include:

  1. Use it when you want to maintain the general slope of an area while smoothing it out.
  2. Combine it with bPickValuePerApply for more dynamic flattening results.
  3. Be cautious when using it on complex terrains, as it might produce unexpected results in areas with rapidly changing slopes.
  4. Test the results with different brush sizes and strengths to achieve the desired effect.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:737, section: [LandscapeEdit]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdModePaintTools.cpp:894

Scope (from outer to inner):

file
class        class FLandscapeToolStrokeFlatten : public FLandscapeToolStrokePaintBase<ToolTarget>
function     void Apply

Source code excerpt:


		// Can't use slope if use Flatten Target because no normal is provided
		bool bUseSlopeFlatten = UISettings->bUseSlopeFlatten && !UISettings->bUseFlattenTarget;

		if (!bInitializedFlattenValue || (UISettings->bPickValuePerApply && bTargetIsHeightmap))
		{
			bInitializedFlattenValue = false;
			float FlattenX = static_cast<float>(InteractorPositions[0].Position.X);
			float FlattenY = static_cast<float>(InteractorPositions[0].Position.Y);

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdModePaintTools.cpp:935

Scope (from outer to inner):

file
class        class FLandscapeToolStrokeFlatten : public FLandscapeToolStrokePaintBase<ToolTarget>
function     void Apply

Source code excerpt:

			FlattenValue = static_cast<ValueType>(InterpolatedValue);

			if (bUseSlopeFlatten && bTargetIsHeightmap)
			{
				if (bCombinedLayerOperation)
				{
					// Can't rely on cache in this mode
					FVector Vert00 = FVector(0.0f, 0.0f, V00);
					FVector Vert01 = FVector(0.0f, 1.0f, V01);

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEdModePaintTools.cpp:1002

Scope (from outer to inner):

file
class        class FLandscapeToolStrokeFlatten : public FLandscapeToolStrokePaintBase<ToolTarget>
function     void Apply

Source code excerpt:

					float Strength = FMath::Clamp<float>(BrushValue * PaintStrength * Pressure, 0.0f, 1.0f);

					if (!(bUseSlopeFlatten && bTargetIsHeightmap))
					{
						int32 Delta = DataScanline[X] - FlattenValue;
						switch (UISettings->FlattenMode)
						{
						case ELandscapeToolFlattenMode::Terrace:
							if (bTargetIsHeightmap)

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:39

Scope (from outer to inner):

file
function     ULandscapeEditorObject::ULandscapeEditorObject

Source code excerpt:


	, FlattenMode(ELandscapeToolFlattenMode::Both)
	, bUseSlopeFlatten(false)
	, bPickValuePerApply(false)
	, bUseFlattenTarget(false)
	, FlattenTarget(0)
	, bShowFlattenTargetPreview(true)
	
	, TerraceInterval(1.0f)

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:248

Scope (from outer to inner):

file
function     void ULandscapeEditorObject::Load

Source code excerpt:

	FlattenMode = (ELandscapeToolFlattenMode)InFlattenMode;

	bool InbUseSlopeFlatten = bUseSlopeFlatten;
	GConfig->GetBool(TEXT("LandscapeEdit"), TEXT("bUseSlopeFlatten"), InbUseSlopeFlatten, GEditorPerProjectIni);
	bUseSlopeFlatten = InbUseSlopeFlatten;

	bool InbPickValuePerApply = bPickValuePerApply;
	GConfig->GetBool(TEXT("LandscapeEdit"), TEXT("bPickValuePerApply"), InbPickValuePerApply, GEditorPerProjectIni);
	bPickValuePerApply = InbPickValuePerApply;

	bool InbUseFlattenTarget = bUseFlattenTarget;

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Private/LandscapeEditorObject.cpp:409

Scope (from outer to inner):

file
function     void ULandscapeEditorObject::Save

Source code excerpt:


	GConfig->SetInt(TEXT("LandscapeEdit"), TEXT("FlattenMode"), (int32)FlattenMode, GEditorPerProjectIni);
	GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bUseSlopeFlatten"), bUseSlopeFlatten, GEditorPerProjectIni);
	GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bPickValuePerApply"), bPickValuePerApply, GEditorPerProjectIni);
	GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bUseFlattenTarget"), bUseFlattenTarget, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("FlattenTarget"), FlattenTarget, GEditorPerProjectIni);

	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("TerraceSmooth"), TerraceSmooth, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("TerraceInterval"), TerraceInterval, GEditorPerProjectIni);

#Loc: <Workspace>/Engine/Source/Editor/LandscapeEditor/Public/LandscapeEditorObject.h:313

Scope (from outer to inner):

file
class        class ULandscapeEditorObject : public UObject

Source code excerpt:

	// Flattens to the angle of the clicked point, instead of horizontal
	UPROPERTY(Category="Tool Settings", EditAnywhere, NonTransactional, meta=(ShowForTools="Flatten", ShowForTargetTypes="Heightmap"))
	bool bUseSlopeFlatten;

	// Constantly picks new values to flatten towards when dragging around, instead of only using the first clicked point
	UPROPERTY(Category="Tool Settings", EditAnywhere, NonTransactional, meta=(ShowForTools="Flatten", ShowForTargetTypes="Heightmap"))
	bool bPickValuePerApply;

	// Enable to flatten towards a target height