Open 3D Engine AzFramework API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzFramework::PaintBrush Class Reference

#include <PaintBrush.h>

Public Member Functions

 AZ_RTTI (PaintBrush, "{D003175F-12BF-4E7E-BD51-2F4B010C9B5E}")
 
 AZ_CLASS_ALLOCATOR (PaintBrush, AZ::SystemAllocator)
 
 PaintBrush (const PaintBrush &)=delete
 
PaintBrushoperator= (const PaintBrush &)=delete
 
 PaintBrush (const AZ::EntityComponentIdPair &entityComponentIdPair)
 
void BeginPaintMode ()
 Tell the PaintBrush to begin paint mode, which will send out the proper notifications to any listeners.
 
void EndPaintMode ()
 Tell the PaintBrush to end paint mode, which will send out the proper notifications to any listeners.
 
bool IsInPaintMode () const
 
void BeginBrushStroke (const PaintBrushSettings &brushSettings)
 Start a brush stroke with the given brush settings for color/intensity/opacity.
 
void EndBrushStroke ()
 End the current brush stroke.
 
bool IsInBrushStroke () const
 
void ResetBrushStrokeTracking ()
 
void PaintToLocation (const AZ::Vector3 &brushCenter, const PaintBrushSettings &brushSettings)
 
void SmoothToLocation (const AZ::Vector3 &brushCenter, const PaintBrushSettings &brushSettings)
 
AZ::Color UseEyedropper (const AZ::Vector3 &brushCenter)
 

Detailed Description

PaintBrush contains the core logic for painting functionality. It handles all of the specific calculations for determining the correct values to paint or smooth as a brush moves across the world in a generic way. It relies on a listener to the PaintBrushNotificationBus to provide the other half of the logic for fetching and applying the values themselves.

The general painting flow consists of the following:

  1. For each brush movement, the paintbrush sends OnPaint messages with the AABB of the region that has changed and a callback for getting paint values for specific world positions.
  2. The listener calls the callback for each position in the region that it cares about.
  3. The paintbrush responds with the specific painted values for each of those positions based on the brush shape and settings. This back-and-forth is needed so that we can keep a clean separation between the paintbrush and the listener. The paintbrush doesn't have knowledge of which points in the world (or at which resolution) the listener needs, and the listener doesn't have knowledge of the exact shape, size, and hardness of the paintbrush. The separation allows the paintbrush to add features over time without having to change the listeners, and it enables more systems to use the paintbrush without requiring specialized logic inside the paintbrush itself.

Member Function Documentation

◆ IsInBrushStroke()

bool AzFramework::PaintBrush::IsInBrushStroke ( ) const

Returns whether or not the brush is currently in a brush stroke.

Returns
True if a brush stroke has been started, false if not.

◆ IsInPaintMode()

bool AzFramework::PaintBrush::IsInPaintMode ( ) const

Returns whether or not the paint mode is currently active.

Returns
True if paint mode is active, false if it isn't.

◆ PaintToLocation()

void AzFramework::PaintBrush::PaintToLocation ( const AZ::Vector3 &  brushCenter,
const PaintBrushSettings brushSettings 
)

Apply a paint color to the underlying data based on brush movement and settings.

Parameters
brushCenterThe current center of the paintbrush.
brushSettingsThe current paintbrush settings.

◆ ResetBrushStrokeTracking()

void AzFramework::PaintBrush::ResetBrushStrokeTracking ( )

Reset the brush tracking so that the next action will be considered the start of a stroke movement instead of a continuation. This is useful for handling discontinuous movement (like moving off the edge of the surface on one side and back on from a different side).

◆ SmoothToLocation()

void AzFramework::PaintBrush::SmoothToLocation ( const AZ::Vector3 &  brushCenter,
const PaintBrushSettings brushSettings 
)

Smooth the underlying data based on brush movement and settings.

Parameters
brushCenterThe current center of the paintbrush.
brushSettingsThe current paintbrush settings.

◆ UseEyedropper()

AZ::Color AzFramework::PaintBrush::UseEyedropper ( const AZ::Vector3 &  brushCenter)

Get the color from the underlying data that's located at the brush center

Parameters
brushCenterThe current center of the paintbrush.

The documentation for this class was generated from the following file: