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

PaintBrushNotificationBus is used to send out notifications whenever anything about the paintbrush has changed. More...

#include <PaintBrushNotificationBus.h>

Inherits AZ::EBusTraits.

Public Types

using BusIdType = AZ::EntityComponentIdPair
 
using ValueLookupFn = AZStd::function< void(AZStd::span< const AZ::Vector3 > points, AZStd::vector< AZ::Vector3 > &validPoints, AZStd::vector< float > &opacities)>
 
using BlendFn = AZStd::function< float(float baseValue, float intensity, float opacity)>
 
using SmoothFn = AZStd::function< float(float baseValue, AZStd::span< float > kernelValues, float opacity)>
 

Public Member Functions

virtual void OnPaintModeBegin ()
 Notifies listeners that the paint mode has been entered.
 
virtual void OnPaintModeEnd ()
 Notifies listeners that the paint mode is exiting.
 
virtual void OnBrushStrokeBegin (const AZ::Color &color)
 
virtual void OnBrushStrokeEnd ()
 Notifies listeners that a brush stroke has ended.
 
virtual void OnPaint (const AZ::Color &color, const AZ::Aabb &dirtyArea, ValueLookupFn &valueLookupFn, BlendFn &blendFn)
 
virtual AZ::Color OnGetColor (const AZ::Vector3 &brushCenterPoint) const
 
virtual void OnSmooth (const AZ::Color &color, const AZ::Aabb &dirtyArea, ValueLookupFn &valueLookupFn, AZStd::span< const AZ::Vector3 > valuePointOffsets, SmoothFn &smoothFn)
 

Static Public Attributes

static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple
 
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById
 

Detailed Description

PaintBrushNotificationBus is used to send out notifications whenever anything about the paintbrush has changed.

Member Typedef Documentation

◆ BlendFn

using AzFramework::PaintBrushNotifications::BlendFn = AZStd::function<float(float baseValue, float intensity, float opacity)>

Returns the base value blended with the paint brush intensity / opacity based on paint brush blend mode. This should get called in response to receiving a PaintBrushNotificationBus::OnPaint(dirtyRegion, valueLookupFn, blendFn) event to blend a base value with a paintbrush value. @baseValue The input base value from whatever data is being painted (0-1). @intensity The paint brush intensity at this position (0-1). @opacity The paint brush opacity at this position (0-1).

Returns
The blended value from 0-1.

◆ SmoothFn

using AzFramework::PaintBrushNotifications::SmoothFn = AZStd::function<float(float baseValue, AZStd::span<float> kernelValues, float opacity)>

Returns the NxN kernel values smoothed together and combined with the base value using the opacity setting. This should get called in response to receiving a PaintBrushNotificationBus::OnSmooth(dirtyRegion, valueLookupFn, smoothFn) event to smooth the base values together. @baseValue The input base value from whatever data is being painted (0-1). @kernelValues The NxN kernel input base values (with baseValue at the center) from whatever data is being painted (0-1). These values may get sorted and/or modified. @opacity The paint brush opacity at this position (0-1).

Returns
The smoothed value from 0-1.

◆ ValueLookupFn

using AzFramework::PaintBrushNotifications::ValueLookupFn = AZStd::function<void( AZStd::span<const AZ::Vector3> points, AZStd::vector<AZ::Vector3>& validPoints, AZStd::vector<float>& opacities)>

Returns the set of current painted values at the requested positions. This should get called in response to receiving a PaintBrushNotificationBus::OnPaint(dirtyRegion, valueLookupFn, blendFn) event to get the specific painted values at every position the listener cares about within the dirtyRegion. @points The input world space positions to query. @validPoints [out] The output positions that are valid for this paintbrush. @opacities [out] The output per-pixel opacities of the paintbrush that have been painted at this position (0-1 range).

Member Function Documentation

◆ OnBrushStrokeBegin()

virtual void AzFramework::PaintBrushNotifications::OnBrushStrokeBegin ( const AZ::Color &  color)
inlinevirtual

Notifies listeners that a brush stroke has begun.

Parameters
colorThe color of the paint stroke, including opacity

◆ OnGetColor()

virtual AZ::Color AzFramework::PaintBrushNotifications::OnGetColor ( const AZ::Vector3 &  brushCenterPoint) const
inlinevirtual

Notifies listeners that the paintbrush eyedropper has requested a color from a point. This will get called in each frame that the paintbrush continues its brush stroke and the brush has moved.

Parameters
brushCenterPointthe point to get the color from.
Returns
The color stored in the data source at that point.

◆ OnPaint()

virtual void AzFramework::PaintBrushNotifications::OnPaint ( const AZ::Color &  color,
const AZ::Aabb &  dirtyArea,
ValueLookupFn valueLookupFn,
BlendFn blendFn 
)
inlinevirtual

Notifies listeners that the paintbrush has painted in a region. This will get called in each frame that the paintbrush continues to paint and the brush has moved. Since the paintbrush doesn't know how it's being used, and the system using a paintbrush doesn't know the specifics of the paintbrush shape and pattern, this works through a back-and-forth handshake.

  1. The paintbrush sends the OnPaint message with the AABB of the region that has changed and a paintbrush value callback.
  2. The listener calls the paintbrush value 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.
  4. The listener uses the blendFn to blend values together using the paint brush blending method.
    Parameters
    colorThe color of the paint stroke, including opacity
    dirtyAreaThe AABB of the area that has been painted in.
    valueLookupFnThe paintbrush value callback to use to get the intensities / opacities / valid flags for specific positions.
    blendFnThe paintbrush callback to use to blend values together.

◆ OnSmooth()

virtual void AzFramework::PaintBrushNotifications::OnSmooth ( const AZ::Color &  color,
const AZ::Aabb &  dirtyArea,
ValueLookupFn valueLookupFn,
AZStd::span< const AZ::Vector3 >  valuePointOffsets,
SmoothFn smoothFn 
)
inlinevirtual

Notifies listeners that the paintbrush is smoothing a region. This will get called in each frame that the paintbrush continues to smooth and the brush has moved. Since the paintbrush doesn't know how it's being used, and the system using a paintbrush doesn't know the specifics of the paintbrush shape and pattern, this works through a back-and-forth handshake.

  1. The paintbrush sends the OnSmooth message with the AABB of the region that has changed and a paintbrush value callback.
  2. The listener calls the paintbrush value callback for each position in the region that it cares about.
  3. The paintbrush responds with the specific brush values for each of those positions based on the brush shape and settings.
  4. The listener gets an NxN set of values around each valid brush position.
  1. The listener uses the smoothFn to smooth those values together using the paint brush smoothing method.
    Parameters
    colorThe color of the paint stroke, including opacity
    dirtyAreaThe AABB of the area that has been painted in.
    valueLookupFnThe paintbrush value callback to use to get the intensities / opacities / valid flags for specific positions.
    valuePointOffsetsA vector of relative positional offsets to use for looking up all the values to pass into smoothFn
    smoothFnThe paintbrush callback to use to smooth values together.

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