DefaultBrushRadius

DefaultBrushRadius

#Overview

name: DefaultBrushRadius

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

#Summary

#Usage in the C++ source code

The purpose of DefaultBrushRadius is to store and manage the default radius of the brush used in the Unreal Engine 5’s mesh painting system. This setting variable is crucial for the mesh painting functionality in the editor, allowing developers to set and retrieve the default brush size for painting on 3D meshes.

The Unreal Engine subsystem that relies on this setting variable is the Mesh Paint module, which is part of the editor tools. This can be seen from the file path “Engine/Source/Editor/MeshPaint/Private/MeshPaintSettings.cpp” where the variable is referenced.

The value of this variable is set in multiple places:

  1. It is initially loaded from the project’s configuration file (GEditorPerProjectIni) in the UPaintBrushSettings constructor.
  2. It can be set programmatically using the SetBrushRadius function.
  3. It is updated when the property is changed in the editor via the PostEditChangeProperty function.

This variable interacts with other variables such as BrushRadiusMin and BrushRadiusMax, which are used to clamp the brush radius within a valid range.

Developers must be aware that:

  1. The brush radius is always clamped between BrushRadiusMin and BrushRadiusMax.
  2. Changes to this variable are persisted in the project’s configuration file.
  3. This variable affects the default brush size for all mesh painting operations in the project.

Best practices when using this variable include:

  1. Use the provided SetBrushRadius function to change the value, as it ensures proper clamping and saves the value to the configuration file.
  2. Be mindful of the performance implications of very large brush sizes, especially when painting on high-resolution meshes.
  3. Consider exposing this setting in user-facing UI to allow artists to adjust the default brush size according to their preferences.
  4. When modifying this value programmatically, ensure it’s done in a thread-safe manner, as it could potentially be accessed from multiple parts of the editor simultaneously.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:775, section: [MeshPaintEdit]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/MeshPaint/Private/MeshPaintSettings.cpp:21

Scope (from outer to inner):

file
function     UPaintBrushSettings::UPaintBrushSettings

Source code excerpt:

		BrushRadiusMax = BrushRadiusProperty->GetFloatMetaData(ClampMax);

		GConfig->GetFloat(TEXT("MeshPaintEdit"), TEXT("DefaultBrushRadius"), BrushRadius, GEditorPerProjectIni);
		BrushRadius = FMath::Clamp(BrushRadius, BrushRadiusMin, BrushRadiusMax);
	}

	{
		const FProperty* BrushStrengthProperty = UPaintBrushSettings::StaticClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UPaintBrushSettings, BrushStrength));
		float BrushStrengthMin = BrushStrengthProperty->GetFloatMetaData(ClampMin);

#Loc: <Workspace>/Engine/Source/Editor/MeshPaint/Private/MeshPaintSettings.cpp:66

Scope (from outer to inner):

file
function     void UPaintBrushSettings::SetBrushRadius

Source code excerpt:

{
	BrushRadius = (float)FMath::Clamp(InRadius, BrushRadiusMin, BrushRadiusMax);
	GConfig->SetFloat(TEXT("MeshPaintEdit"), TEXT("DefaultBrushRadius"), BrushRadius, GEditorPerProjectIni);
}

void UPaintBrushSettings::SetBrushStrength(float InStrength)
{
	BrushStrength = FMath::Clamp(InStrength, 0.f, 1.f);
	GConfig->SetFloat(TEXT("MeshPaintEdit"), TEXT("DefaultBrushStrength"), BrushStrength, GEditorPerProjectIni);

#Loc: <Workspace>/Engine/Source/Editor/MeshPaint/Private/MeshPaintSettings.cpp:91

Scope (from outer to inner):

file
function     void UPaintBrushSettings::PostEditChangeProperty

Source code excerpt:

	if (PropertyName == GET_MEMBER_NAME_CHECKED(UPaintBrushSettings, BrushRadius))
	{
		GConfig->SetFloat(TEXT("MeshPaintEdit"), TEXT("DefaultBrushRadius"), BrushRadius, GEditorPerProjectIni);
	}
	else if (PropertyName == GET_MEMBER_NAME_CHECKED(UPaintBrushSettings, BrushStrength))
	{
		GConfig->SetFloat(TEXT("MeshPaintEdit"), TEXT("DefaultBrushStrength"), BrushStrength, GEditorPerProjectIni);
	}
	else if (PropertyName == GET_MEMBER_NAME_CHECKED(UPaintBrushSettings, BrushFalloffAmount))