bUseWeightTargetValue

bUseWeightTargetValue

#Overview

name: bUseWeightTargetValue

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

#Summary

#Usage in the C++ source code

The purpose of bUseWeightTargetValue is to control the behavior of weight painting tools in the Unreal Engine 5 Landscape system. It determines whether the painting tools should blend towards a specific target value when modifying weightmaps.

This setting variable is primarily used in the Landscape Editor module, specifically in the painting and noise tools for landscape editing. It is part of the LandscapeEditor subsystem.

The value of this variable is set in the ULandscapeEditorObject class, which is responsible for storing and managing various landscape editing settings. It can be modified through the Unreal Engine editor interface or programmatically.

bUseWeightTargetValue interacts closely with the WeightTargetValue variable, which defines the target value to blend towards when bUseWeightTargetValue is true.

Developers should be aware that this variable significantly changes the behavior of weight painting tools. When enabled, it causes the tools to blend towards a specific target value (WeightTargetValue) instead of simply adding or subtracting weight.

Best practices for using this variable include:

  1. Use it when you want more precise control over the final weight values in your landscape layers.
  2. Adjust the WeightTargetValue in conjunction with this setting to achieve the desired result.
  3. Be mindful of how it affects the painting behavior, especially when switching between different landscape editing tasks.
  4. Consider disabling it when you want more traditional additive or subtractive painting behavior.
  5. Remember that this setting is saved and loaded with other landscape editing preferences, so it may persist between editor sessions.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:725, 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:225

Scope (from outer to inner):

file
class        class FLandscapeToolStrokePaint : public FLandscapeToolStrokePaintBase<FWeightmapToolTarget>
function     void Apply

Source code excerpt:

		float Pressure = ViewportClient->Viewport->IsPenActive() ? ViewportClient->Viewport->GetTabletPressure() : 1.0f;

		const bool bUseWeightTargetValue = UISettings->bUseWeightTargetValue;
		const bool bCacheOriginalData = !bUseWeightTargetValue;

		this->Cache.CacheData(X1, Y1, X2, Y2, bCacheOriginalData);

		// The data we'll be writing to
		TArray<ValueType> Data;
		this->Cache.GetCachedData(X1, Y1, X2, Y2, Data);

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

Scope (from outer to inner):

file
class        class FLandscapeToolStrokePaint : public FLandscapeToolStrokePaintBase<FWeightmapToolTarget>
function     void Apply

Source code excerpt:

		TArray<ValueType> OriginalData;

		if (!bUseWeightTargetValue)
		{
			// When painting weights (and not using target value mode), we use a source value that tends more
			// to the current value as we paint over the same region multiple times.
			// TODO: Make this frame-rate independent
			this->Cache.GetOriginalData(X1, Y1, X2, Y2, OriginalData);
			SourceDataArrayPtr = &OriginalData;

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

Scope (from outer to inner):

file
class        class FLandscapeToolStrokePaint : public FLandscapeToolStrokePaintBase<FWeightmapToolTarget>
function     void Apply

Source code excerpt:

		}

		if (!bUseWeightTargetValue)
		{
			PaintStrength = FMath::Max(PaintStrength, 1.0f);
		}

		// Apply the brush
		for (int32 Y = BrushInfo.GetBounds().Min.Y; Y < BrushInfo.GetBounds().Max.Y; Y++)

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

Scope (from outer to inner):

file
class        class FLandscapeToolStrokePaint : public FLandscapeToolStrokePaintBase<FWeightmapToolTarget>
function     void Apply

Source code excerpt:

				const ValueType& SourceValue = SourceDataScanline[X];

				if (bUseWeightTargetValue)
				{
					CurrentValue = FMath::Lerp(CurrentValue, DestValue, PaintAmount / AdjustedStrength);
				}
				else
				{
					const int32 IntPaintAmount = FMath::RoundToInt(PaintAmount);

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

Scope (from outer to inner):

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

Source code excerpt:


		CA_SUPPRESS(6326);
		bool bUseWeightTargetValue = UISettings->bUseWeightTargetValue && ToolTarget::TargetType == ELandscapeToolTargetType::Weightmap;

		const float PaintStrength = this->GetStrength(UISettings, /* bInIsHeighthMap = */ false);

		// Apply the brush
		for (int32 Y = BrushInfo.GetBounds().Min.Y; Y < BrushInfo.GetBounds().Max.Y; Y++)
		{

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

Scope (from outer to inner):

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

Source code excerpt:

				{
					float OriginalValue = DataScanline[X];
					if (bUseWeightTargetValue)
					{
						FNoiseParameter NoiseParam(0, UISettings->NoiseScale, 255.0f / 2.0f);
						float DestValue = NoiseModeConversion(ELandscapeToolNoiseMode::Add, NoiseParam.NoiseAmount, NoiseParam.Sample(X, Y)) * UISettings->WeightTargetValue;
						switch (UISettings->NoiseMode)
						{
						case ELandscapeToolNoiseMode::Add:

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

Scope (from outer to inner):

file
function     ULandscapeEditorObject::ULandscapeEditorObject

Source code excerpt:

	, ToolStrength(0.3f)
    , PaintToolStrength(0.3f)
	, bUseWeightTargetValue(false)
	, WeightTargetValue(1.0f)
	, MaximumValueRadius(10000.0f)
	, bCombinedLayersOperation(true)

	, FlattenMode(ELandscapeToolFlattenMode::Both)
	, bUseSlopeFlatten(false)

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

Scope (from outer to inner):

file
function     void ULandscapeEditorObject::Load

Source code excerpt:

	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("PaintToolStrength"), PaintToolStrength, GEditorPerProjectIni);
	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("WeightTargetValue"), WeightTargetValue, GEditorPerProjectIni);
	bool InbUseWeightTargetValue = bUseWeightTargetValue;
	GConfig->GetBool(TEXT("LandscapeEdit"), TEXT("bUseWeightTargetValue"), InbUseWeightTargetValue, GEditorPerProjectIni);
	bUseWeightTargetValue = InbUseWeightTargetValue;

	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("BrushRadius"), BrushRadius, GEditorPerProjectIni);
	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("PaintBrushRadius"), PaintBrushRadius, GEditorPerProjectIni);
	GConfig->GetInt(TEXT("LandscapeEdit"), TEXT("BrushComponentSize"), BrushComponentSize, GEditorPerProjectIni);
	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("BrushFalloff"), BrushFalloff, GEditorPerProjectIni);
	GConfig->GetFloat(TEXT("LandscapeEdit"), TEXT("PaintBrushFalloff"), PaintBrushFalloff, GEditorPerProjectIni);

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

Scope (from outer to inner):

file
function     void ULandscapeEditorObject::Save

Source code excerpt:

	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("PaintToolStrength"), PaintToolStrength, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("WeightTargetValue"), WeightTargetValue, GEditorPerProjectIni);
	GConfig->SetBool(TEXT("LandscapeEdit"), TEXT("bUseWeightTargetValue"), bUseWeightTargetValue, GEditorPerProjectIni);

	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("BrushRadius"), BrushRadius, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("PaintBrushRadius"), PaintBrushRadius, GEditorPerProjectIni);
	GConfig->SetInt(TEXT("LandscapeEdit"), TEXT("BrushComponentSize"), BrushComponentSize, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("BrushFalloff"), BrushFalloff, GEditorPerProjectIni);
	GConfig->SetFloat(TEXT("LandscapeEdit"), TEXT("PaintBrushFalloff"), PaintBrushFalloff, GEditorPerProjectIni);

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

Scope (from outer to inner):

file
class        class ULandscapeEditorObject : public UObject

Source code excerpt:

	// Enable to make tools blend towards a target value
	UPROPERTY(Category = "Tool Settings", NonTransactional, EditAnywhere, meta = (InlineEditConditionToggle))
	bool bUseWeightTargetValue;

	// Enable to make tools blend towards a target value
	UPROPERTY(Category="Tool Settings", EditAnywhere, NonTransactional, meta=(DisplayName="Use Target Value", EditCondition="bUseWeightTargetValue", ShowForTools="Paint,Sculpt,Noise", ShowForTargetTypes = "Weightmap", ClampMin="0", ClampMax="10", UIMin="0", UIMax="1"))
	float WeightTargetValue;

	// I have no idea what this is for but it's used by the noise and erosion tools, and isn't exposed to the UI