Blender V5.3
blender::ed::sculpt_paint::PaintStroke Struct Referenceabstract

#include <paint_intern.hh>

Inherits blender::blender::NonCopyable, and blender::blender::NonMovable.

Inherited by blender::VertexPaintStroke, blender::WeightPaintStroke, blender::ed::sculpt_paint::GreasePencilPaintStroke, blender::ed::sculpt_paint::SculptCurvesBrushStroke, blender::ed::sculpt_paint::SculptPaintStroke, blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke, blender::ed::sculpt_paint::image::ops::paint::ImagePaintStroke, and blender::ed::sculpt_paint::image::ops::paint::TexturePaintStroke.

Classes

struct  StrokeStep

Public Member Functions

 PaintStroke ()=delete
virtual ~PaintStroke ()=default
wmOperatorStatus modal (bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus exec (bContext *C, wmOperator *op)
void cancel (bContext *C)
void finish (bContext *C)
bool stroke_flipped () const
bool stroke_inverted () const
float stroke_distance () const
Public Member Functions inherited from blender::blender::NonCopyable
 NonCopyable (const NonCopyable &other)=delete
NonCopyable & operator= (const NonCopyable &other)=delete
 NonCopyable ()=default
 NonCopyable (NonCopyable &&other)=default
NonCopyable & operator= (NonCopyable &&other)=default
Public Member Functions inherited from blender::blender::NonMovable
 NonMovable (NonMovable &&other)=delete
NonMovable & operator= (NonMovable &&other)=delete
 NonMovable ()=default
 NonMovable (const NonMovable &other)=default
NonMovable & operator= (const NonMovable &other)=default

Public Attributes

bContext * evil_C = nullptr
ViewContext vc = {}
Depsgraph * depsgraph = nullptr
Object * object = nullptr
Scene * scene = nullptr
Paint * paint = nullptr
PaintMode paint_mode = PaintMode::Invalid
Brush * brush = nullptr
UnifiedPaintSettings * ups = nullptr
float2 last_mouse_position = float2(0.0f, 0.0f)
bool constrain_line = false
float2 constrained_pos = float2(0.0f, 0.0f)

Protected Member Functions

 PaintStroke (bContext *C, wmOperator *op, const wmEvent *event, PaintMode mode)
virtual std::optional< float3 > get_location (float2 mouse, bool force_original)=0
virtual bool test_start (wmOperator *op, float2 mouse)=0
virtual void update_step (wmOperator *op, const StrokeStep &stroke_step)=0
virtual void redraw (bool final)=0
virtual bool test_cancel ()=0
virtual void done (bool is_cancel, bool stroke_started)=0

Protected Attributes

std::unique_ptr< PaintModeData > mode_data_ = nullptr

Detailed Description

Common structure for various paint operators (e.g. Sculpt, Grease Pencil, Curves Sculpt)

Callback functions defined and stored on this struct (e.g. StrokeGetLocation) allow each of these modes to customize specific behavior while still sharing other common handing.

See #paint_stroke_modal for the majority of the paint operator logic.

Definition at line 111 of file paint_intern.hh.

Constructor & Destructor Documentation

◆ PaintStroke() [1/2]

◆ ~PaintStroke()

virtual blender::ed::sculpt_paint::PaintStroke::~PaintStroke ( )
virtualdefault

References C, cancel(), exec(), finish(), and modal().

◆ PaintStroke() [2/2]

blender::ed::sculpt_paint::PaintStroke::PaintStroke ( bContext * C,
wmOperator * op,
const wmEvent * event,
PaintMode mode )
protected

Definition at line 882 of file paint_stroke.cc.

References blender::bke::PaintRuntime::average_stroke_accum, blender::bke::PaintRuntime::average_stroke_counter, blender::BKE_brush_radius_get(), blender::BKE_curvemapping_init(), blender::BKE_image_acquire_ibuf(), blender::BKE_image_release_ibuf(), blender::BKE_paint_brush(), blender::BKE_paint_get_active_from_context(), blender::BKE_paintmode_get_active_from_context(), blender::BRUSH_STROKE_CURVE, blender::ImBuf::byte_buffer, C, blender::Paint::cavity_curve, blender::bke::PaintRuntime::colorspace, blender::ImBufByteBuffer::colorspace, blender::bke::brush::common_pressure_curves_init(), blender::CTX_data_active_object(), blender::CTX_data_ensure_evaluated_depsgraph(), blender::CTX_data_scene(), blender::CTX_wm_region_view3d(), depsgraph, blender::bke::PaintRuntime::do_linear_conversion, blender::ED_view3d_viewcontext_init(), evil_C, blender::Paint::flags, blender::ImBuf::float_data(), blender::get_imapaint_zoom(), blender::Tex::ima, blender::Invert, blender::Brush::mtex, blender::mul_v3_fl(), blender::Normal, blender::bke::PaintRuntime::overlap_factor, blender::Brush::overlay_flags, paint, blender::ed::sculpt_paint::paint_brush_type_raycast_original(), paint_mode, blender::PAINT_USE_CAVITY_MASK, blender::wmOperator::ptr, blender::RegionView3D::rflag, blender::RNA_boolean_get(), blender::RNA_boolean_set(), blender::RNA_enum_get(), blender::RNA_enum_set(), blender::Paint::runtime, blender::RV3D_PAINTING, blender::bke::paint::set_overlay_brush_override(), blender::bke::PaintRuntime::start_pixel_radius, blender::bke::PaintRuntime::stroke_active, blender::Brush::stroke_method, blender::MTex::tex, blender::TEX_IMAGE, blender::Tex::type, blender::Paint::unified_paint_settings, ups, vc, and blender::WM_event_tablet_data().

Member Function Documentation

◆ cancel()

◆ done()

virtual void blender::ed::sculpt_paint::PaintStroke::done ( bool is_cancel,
bool stroke_started )
protectedpure virtual

Callback function for cleaning up and finalizing data after a stroke has finished.

Parameters
is_cancelSome paint modes support cancelling a stroke and returning to the initial state. This parameter indicates this case so that appropriate cleanup actions can be taken.
stroke_startedWhether the stroke started. Subclasses can use this to determine if undo steps should be created. See \test_start.

Implemented in blender::ed::sculpt_paint::GreasePencilPaintStroke, blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke, blender::ed::sculpt_paint::image::ops::paint::ImagePaintStroke, blender::ed::sculpt_paint::image::ops::paint::TexturePaintStroke, blender::ed::sculpt_paint::SculptCurvesBrushStroke, blender::ed::sculpt_paint::SculptPaintStroke, blender::VertexPaintStroke, and blender::WeightPaintStroke.

References average(), brush, C, done(), blender::x, and y.

Referenced by cancel(), done(), exec(), finish(), and modal().

◆ exec()

◆ finish()

void blender::ed::sculpt_paint::PaintStroke::finish ( bContext * C)

Finish a stroke, performing any necessary cleanup actions.

Note
Typically handled as part of modal operator actions. Consumers of this API may need to call this if returning OPERATOR_FINISHED during the invoke operator callback.

Definition at line 1710 of file paint_stroke.cc.

References C, done(), blender::Editor, and PRF_scope.

Referenced by blender::ed::sculpt_paint::image::ops::paint::paint_invoke(), blender::ed::sculpt_paint::sculpt_brush_stroke_invoke(), blender::ed::sculpt_paint::sculpt_curves_stroke_invoke(), blender::vpaint_invoke(), blender::wpaint_invoke(), and ~PaintStroke().

◆ get_location()

virtual std::optional< float3 > blender::ed::sculpt_paint::PaintStroke::get_location ( float2 mouse,
bool force_original )
protectedpure virtual

◆ modal()

wmOperatorStatus blender::ed::sculpt_paint::PaintStroke::modal ( bContext * C,
wmOperator * op,
const wmEvent * event )

The main modal callback shared by any custom operator that implements a form of painting.

At a high level, this function performs the following steps for interactive stroke types:

  1. Initialization of necessary common PaintStroke values.
  2. Custom paint initialization via test_start>
  3. Create an OperatorStrokeElement for a given mouse position by calling get_location to potentially turn screen space coordinates into object space coordinates.
  4. Call update_step to perform custom paint operation on the most recent OperatorStrokeElement data.
  5. Tag extra redraws if necessary via redraw.
  6. Return to step 3 while stroke is ongoing.
  7. Call done when finished to perform any cleanup or finalization.

Definition at line 1405 of file paint_stroke.cc.

References blender::BKE_brush_input_samples_get(), blender::BKE_paint_brush(), blender::BKE_paint_calculate_rake_rotation(), blender::BKE_paint_get_active_from_context(), blender::BKE_paintmode_get_active_from_context(), blender::BKE_report(), blender::BLI_assert(), blender::MTex::brush_angle_mode, blender::BRUSH_SMOOTH_STROKE, blender::BRUSH_STROKE_AIRBRUSH, blender::BRUSH_STROKE_ANCHORED, blender::BRUSH_STROKE_DRAG_DOT, blender::BRUSH_STROKE_LINE, C, blender::wmOperatorType::cancel, constrain_line, constrained_pos, blender::copy_v2_v2(), blender::CTX_wm_manager(), blender::CTX_wm_region(), blender::CTX_wm_window(), blender::wmEvent::customdata, done(), blender::ED_workspace_status_text(), blender::Editor, ELEM, evil_C, blender::EVT_MODAL_MAP, blender::EVT_RETKEY, blender::EVT_SPACEKEY, blender::Brush::flag, blender::Paint::flags, float, get_location(), blender::GPencil, blender::INBETWEEN_MOUSEMOVE, ISMOUSE_MOTION, blender::KM_ALT, blender::KM_RELEASE, blender::KM_SHIFT, blender::bke::PaintRuntime::last_rake, blender::math::length(), blender::Brush::mask_mtex, blender::wmEvent::modifier, blender::ed::sculpt_paint::PaintSample::mouse, blender::Brush::mtex, blender::MTEX_ANGLE_RAKE, blender::wmEvent::mval, blender::NDOF_MOTION, blender::Normal, blender::ViewContext::obact, blender::OPERATOR_CANCELLED, blender::OPERATOR_FINISHED, blender::OPERATOR_PASS_THROUGH, blender::OPERATOR_RUNNING_MODAL, blender::bke::PaintRuntime::overlap_factor, paint, blender::ed::sculpt_paint::paint_brush_cursor_poll(), blender::ed::sculpt_paint::paint_brush_type_require_inbetween_mouse_events(), blender::ed::sculpt_paint::paint_draw_line_cursor(), blender::ed::sculpt_paint::paint_draw_smooth_cursor(), blender::PAINT_SHOW_BRUSH, blender::ed::sculpt_paint::paint_smooth_stroke(), blender::ed::sculpt_paint::paint_space_stroke_enabled(), blender::ed::sculpt_paint::paint_stroke_integrate_overlap(), blender::ed::sculpt_paint::paint_stroke_line_constrain(), PAINT_STROKE_MODAL_CANCEL, blender::ed::sculpt_paint::paint_stroke_use_scene_spacing(), blender::ed::sculpt_paint::paint_supports_smooth_stroke(), blender::ed::sculpt_paint::PaintSample::pressure, PRF_scope, blender::ed::sculpt_paint::print_pressure_status_enabled(), blender::wmOperator::ptr, redraw(), blender::wmOperator::reports, RGN_TYPE_ANY, blender::RNA_boolean_get(), blender::RPT_WARNING, blender::Paint::runtime, blender::Smooth, SPACE_TYPE_ANY, blender::Brush::stroke_method, test_cancel(), test_start(), blender::Texture2D, blender::TIMER, blender::math::transform_point(), blender::wmEvent::type, blender::wmOperator::type, blender::wmEvent::val, vc, blender::WM_event_is_tablet(), blender::WM_event_tablet_data(), blender::WM_event_timer_add(), blender::WM_paint_cursor_activate(), blender::WM_paint_cursor_end(), and blender::WM_paint_cursor_tag_redraw().

Referenced by blender::ed::sculpt_paint::brush_stroke_modal(), blender::ed::sculpt_paint::grease_pencil_brush_stroke_modal(), blender::ed::sculpt_paint::grease_pencil_sculpt_paint_modal(), blender::ed::sculpt_paint::grease_pencil_vertex_brush_stroke_modal(), blender::ed::sculpt_paint::grease_pencil_weight_brush_stroke_modal(), blender::ed::sculpt_paint::image::ops::paint::paint_modal(), blender::ed::sculpt_paint::sculpt_curves_stroke_modal(), blender::vpaint_modal(), blender::wpaint_modal(), and ~PaintStroke().

◆ redraw()

◆ stroke_distance()

◆ stroke_flipped()

bool blender::ed::sculpt_paint::PaintStroke::stroke_flipped ( ) const
inline

Definition at line 227 of file paint_intern.hh.

◆ stroke_inverted()

bool blender::ed::sculpt_paint::PaintStroke::stroke_inverted ( ) const
inline

◆ test_cancel()

◆ test_start()

virtual bool blender::ed::sculpt_paint::PaintStroke::test_start ( wmOperator * op,
float2 mouse )
protectedpure virtual

◆ update_step()

Member Data Documentation

◆ brush

Brush* blender::ed::sculpt_paint::PaintStroke::brush = nullptr

Definition at line 132 of file paint_intern.hh.

Referenced by blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke::done(), blender::ed::sculpt_paint::image::ops::paint::ImagePaintStroke::done(), blender::ed::sculpt_paint::image::ops::paint::TexturePaintStroke::done(), done(), blender::ed::sculpt_paint::SculptPaintStroke::done(), blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke::ExperimentalTexturePaintStroke(), blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke::get_location(), blender::ed::sculpt_paint::SculptPaintStroke::get_location(), blender::VertexPaintStroke::get_location(), blender::WeightPaintStroke::get_location(), blender::ed::sculpt_paint::SculptPaintStroke::test_cancel(), blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke::test_start(), blender::ed::sculpt_paint::image::ops::paint::ImagePaintStroke::test_start(), blender::ed::sculpt_paint::image::ops::paint::TexturePaintStroke::test_start(), blender::ed::sculpt_paint::SculptPaintStroke::test_start(), blender::VertexPaintStroke::test_start(), blender::WeightPaintStroke::test_start(), blender::ed::sculpt_paint::vwpaint::update_cache_invariants(), blender::ed::sculpt_paint::image::ops::paint::ExperimentalTexturePaintStroke::update_step(), blender::ed::sculpt_paint::image::ops::paint::ImagePaintStroke::update_step(), blender::ed::sculpt_paint::image::ops::paint::TexturePaintStroke::update_step(), blender::ed::sculpt_paint::SculptPaintStroke::update_step(), blender::VertexPaintStroke::update_step(), and blender::WeightPaintStroke::update_step().

◆ constrain_line

bool blender::ed::sculpt_paint::PaintStroke::constrain_line = false

Definition at line 137 of file paint_intern.hh.

Referenced by modal(), and blender::ed::sculpt_paint::paint_draw_line_cursor().

◆ constrained_pos

float2 blender::ed::sculpt_paint::PaintStroke::constrained_pos = float2(0.0f, 0.0f)

Definition at line 138 of file paint_intern.hh.

Referenced by modal(), and blender::ed::sculpt_paint::paint_draw_line_cursor().

◆ depsgraph

◆ evil_C

◆ last_mouse_position

float2 blender::ed::sculpt_paint::PaintStroke::last_mouse_position = float2(0.0f, 0.0f)

Definition at line 136 of file paint_intern.hh.

Referenced by blender::ed::sculpt_paint::paint_draw_line_cursor().

◆ mode_data_

◆ object

◆ paint

◆ paint_mode

PaintMode blender::ed::sculpt_paint::PaintStroke::paint_mode = PaintMode::Invalid

◆ scene

◆ ups

UnifiedPaintSettings* blender::ed::sculpt_paint::PaintStroke::ups = nullptr

Definition at line 133 of file paint_intern.hh.

Referenced by PaintStroke().

◆ vc


The documentation for this struct was generated from the following files: