UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BaseBrushTool.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "InteractiveTool.h"
8#include "Engine/HitResult.h"
9#include "BaseBrushTool.generated.h"
10
13
17UCLASS(MinimalAPI)
19{
21
22public:
24
26 UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Size", UIMin = "0.0", UIMax = "1.0", ClampMin = "0.0", ClampMax = "10.0", DisplayPriority = 1, HideEditConditionToggle, EditCondition = "bSpecifyRadius == false", ModelingQuickSettings = 100))
27 float BrushSize;
28
30 UPROPERTY(EditAnywhere, Category = Brush, AdvancedDisplay)
31 bool bSpecifyRadius;
32
34 UPROPERTY(EditAnywhere, Category = Brush, AdvancedDisplay, meta = (EditCondition = "bSpecifyRadius",
35 DisplayName = "Radius", UIMin = "1.0", UIMax = "1000.0", ClampMin = "0.1", ClampMax = "50000.0"))
36 float BrushRadius;
37
38 //~Set by tool and determines whether the bEnablePressureSensitivity flag below is shown and used.
39 //~ All that a subclass of UBaseBrushTool needs to do to support pressure sensitivity is to call
40 //~ the super OnTick, use the provided radius getters where relevant, and set this to true in setup.
41 //~ Its StylusAPI also should be set via its builder.
42 UPROPERTY()
43 bool bToolSupportsPressureSensitivity = false;
44
46 UPROPERTY(EditAnywhere, Category = Brush, meta = (EditCondition = "bToolSupportsPressureSensitivity", EditConditionHides))
47 bool bEnablePressureSensitivity = false;
48
50 UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Strength",
51 UIMin = "0.0", UIMax = "1.0", ClampMin = "0.0", ClampMax = "1.0",
52 HideEditConditionToggle, EditConditionHides, EditCondition = "bShowStrength", DisplayPriority = 2,
54 float BrushStrength;
55
57 UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Falloff",
58 UIMin = "0.0", UIMax = "1.0", ClampMin = "0.0", ClampMax = "1.0",
59 HideEditConditionToggle, EditConditionHides, EditCondition="bShowFalloff", DisplayPriority = 3,
62
63
65 UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayPriority = 6, HideEditConditionToggle, EditConditionHides, EditCondition = "bShowHitBackFaces"))
66 bool bHitBackFaces = false;
67
70 bool bShowStrength = true;
71
74 bool bShowFalloff = true;
75
78 bool bShowHitBackFaces = false;
79};
80
81
85USTRUCT()
102
112UCLASS()
114{
116
117public:
118
120
122
125
126 void OnDragStart(FVector2D InScreenPosition);
127 void OnDragUpdate(FVector2D InScreenPosition);
128
129 bool IsBrushBeingAdjusted() const { return bAdjustingBrush; };
130
131 // UAnyButtonInputBehavior
132 virtual EInputDevices GetSupportedDevices() override;
133 virtual bool IsPressed(const FInputDeviceState& Input) override;
134 virtual bool IsReleased(const FInputDeviceState& Input) override;
135 virtual FInputCaptureRequest WantsCapture(const FInputDeviceState& Input) override;
136 virtual FInputCaptureUpdate BeginCapture(const FInputDeviceState& Input, EInputCaptureSide eSide) override;
137 virtual FInputCaptureUpdate UpdateCapture(const FInputDeviceState& Input, const FInputCaptureData& data) override;
138 virtual void ForceEndCapture(const FInputCaptureData& data) override;
139 // UAnyButtonInputBehavior end
140
141private:
142
144
145 // true for the duration of the behavior (while hotkey is down)
146 bool bAdjustingBrush = false;
147 // screen coordinate when hotkey pressed (or when re-centered if changing direction)
149 // screen coordinate when hotkey pressed (or when re-centered if changing direction)
151 // the radius of the brush when we started a drag
152 float StartBrushRadius;
153 // the strength of the brush when we started a drag
154 float StartBrushStrength;
155 // supports separate horizontal / vertical adjustments (switching dynamically based on magnitude)
156 bool bAdjustingHorizontally = true;
157
158 // the speed (centimeters per unit of screen coordinate) to adjust brush size when dragging
159 float SizeAdjustSpeed = 0.002f; // sensible default
160 // the speed (in strength per unit of screen coordinate) to adjust brush strength when dragging
161 float StrengthAdjustSpeed = 0.005f; // sensible default
162
163 // the target brush tool to adjust
165};
166
176UCLASS(MinimalAPI)
178{
180
181public:
183
184 INTERACTIVETOOLSFRAMEWORK_API virtual void RegisterActions(FInteractiveToolActionSet& ActionSet) override;
185
186 // UInteractiveTool
187 INTERACTIVETOOLSFRAMEWORK_API virtual void Setup() override;
188 INTERACTIVETOOLSFRAMEWORK_API virtual void Shutdown(EToolShutdownType ShutdownType) override;
189 INTERACTIVETOOLSFRAMEWORK_API virtual void OnTick(float DeltaTime) override;
192
193 INTERACTIVETOOLSFRAMEWORK_API virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
194
195 // IClickDragBehaviorTarget implementation
196 INTERACTIVETOOLSFRAMEWORK_API virtual FInputRayHit CanBeginClickDragSequence(const FInputDeviceRay& PressPos) override;
197
198 // UMeshSurfacePointTool implementation
199 INTERACTIVETOOLSFRAMEWORK_API virtual void OnBeginDrag(const FRay& Ray) override;
200 INTERACTIVETOOLSFRAMEWORK_API virtual void OnUpdateDrag(const FRay& Ray) override;
201 INTERACTIVETOOLSFRAMEWORK_API virtual void OnEndDrag(const FRay& Ray) override;
202 INTERACTIVETOOLSFRAMEWORK_API virtual void OnCancelDrag() override;
203 INTERACTIVETOOLSFRAMEWORK_API virtual bool OnUpdateHover(const FInputDeviceRay& DevicePos) override;
204
205public:
206
208 UPROPERTY()
210
212 UE_DEPRECATED(5.5, "The bInBrushStroke property is deprecated. This will now always be true in OnBeginDrag/OnUpdateDrag/OnEndDrag.")
213 UPROPERTY()
214 bool bInBrushStroke = false;
215
217 UPROPERTY()
218 float WorldToLocalScale = 1.0f;
219
221 UPROPERTY()
222 FBrushStampData LastBrushStamp;
223
224public:
225
226 INTERACTIVETOOLSFRAMEWORK_API virtual void IncreaseBrushSizeAction();
227 INTERACTIVETOOLSFRAMEWORK_API virtual void DecreaseBrushSizeAction();
228 INTERACTIVETOOLSFRAMEWORK_API virtual void IncreaseBrushStrengthAction();
229 INTERACTIVETOOLSFRAMEWORK_API virtual void DecreaseBrushStrengthAction();
230 INTERACTIVETOOLSFRAMEWORK_API virtual void IncreaseBrushFalloffAction();
231 INTERACTIVETOOLSFRAMEWORK_API virtual void DecreaseBrushFalloffAction();
232
234 UE_DEPRECATED(5.5, "The IsInBrushStroke function is deprecated. This will now always be true in OnBeginDrag/OnUpdateDrag/OnEndDrag.")
235 virtual bool IsInBrushStroke() const { return bInBrushStroke; }
237
238 INTERACTIVETOOLSFRAMEWORK_API virtual double GetCurrentBrushRadius() const;
239 virtual double GetCurrentBrushRadiusLocal() const { return GetCurrentBrushRadius() * WorldToLocalScale; }
240
241 INTERACTIVETOOLSFRAMEWORK_API void SetBrushEnabled(bool bIsEnabled);
242
243 // return false to disable the hotkey for adjusting the brush radius and strength in the viewport
244 virtual bool SupportsBrushAdjustmentInput() { return true; };
245
246protected:
247
251 virtual double EstimateMaximumTargetDimension() { return 100.0; }
252
253 virtual double GetActivePressure() const { return ActivePressure; }
254protected:
257 INTERACTIVETOOLSFRAMEWORK_API void RecalculateBrushRadius();
258
259 UPROPERTY()
261
262 //
263 // Brush Indicator support
264 //
266
267 UPROPERTY()
268 TObjectPtr<UBrushStampIndicator> BrushStampIndicator;
269
270 INTERACTIVETOOLSFRAMEWORK_API virtual void SetupBrushStampIndicator();
271 INTERACTIVETOOLSFRAMEWORK_API virtual void UpdateBrushStampIndicator();
272 INTERACTIVETOOLSFRAMEWORK_API virtual void ShutdownBrushStampIndicator();
273
274 // adjusts size and strength properties while holding hotkey during click/drag
276 UE_DEPRECATED(5.5, "BrushAdjusterBehavior is deprecated, use BrushEditBehavior instead.")
279
281
282private:
283 double ActivePressure = 1.0;
284 bool bEnabled = true;
285};
OODEFFUNC typedef const int const char * function
Definition oodle2.h:710
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
EInputCaptureSide
Definition InputBehavior.h:20
EInputDevices
Definition InputState.h:30
EToolShutdownType
Definition InteractiveTool.h:45
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition CanvasTypes.h:211
Definition InteractiveToolActionSet.h:91
Definition UnrealType.h:3087
Definition UnrealType.h:174
Definition ToolContextInterfaces.h:427
Definition SoftObjectPtr.h:763
Definition AnyButtonInputBehavior.h:33
Definition BaseBrushTool.h:178
double CurrentBrushRadius
Definition BaseBrushTool.h:256
virtual bool SupportsBrushAdjustmentInput()
Definition BaseBrushTool.h:244
TInterval< float > BrushRelativeSizeRange
Definition BaseBrushTool.h:255
virtual double EstimateMaximumTargetDimension()
Definition BaseBrushTool.h:251
virtual double GetCurrentBrushRadiusLocal() const
Definition BaseBrushTool.h:239
virtual double GetActivePressure() const
Definition BaseBrushTool.h:253
Definition BaseBrushTool.h:19
Definition BrushStampIndicator.h:27
Definition InteractiveTool.h:257
Definition TwoAxisPropertyEditBehavior.h:87
Definition MeshSurfacePointTool.h:64
Definition Object.h:95
Definition TwoAxisPropertyEditBehavior.h:20
INTERACTIVETOOLSFRAMEWORK_API void DrawHUD(FCanvas *Canvas, IToolsContextRenderAPI *RenderAPI) const
Definition TwoAxisPropertyEditBehavior.cpp:42
@ false
Definition radaudio_common.h:23
Definition BaseBrushTool.h:87
FHitResult HitResult
Definition BaseBrushTool.h:97
float Falloff
Definition BaseBrushTool.h:100
float Radius
Definition BaseBrushTool.h:90
FVector WorldNormal
Definition BaseBrushTool.h:94
FVector WorldPosition
Definition BaseBrushTool.h:92
Definition HitResult.h:21
Definition InputBehavior.h:35
Definition InputBehavior.h:67
Definition InputBehavior.h:132
Definition InputState.h:367
Definition InputState.h:264
Definition InputState.h:52
Definition Interval.h:33
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25