From ed9f7630342f4d515b6d77aa1f77722b74676518 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 21 Feb 2022 16:07:43 +0100 Subject: Paint: pass operator to stroke update function This allows accessing properties of the operator that the stroke belongs to. --- source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 7 +++++-- source/blender/editors/sculpt_paint/paint_image.c | 5 ++++- source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_stroke.c | 4 ++-- source/blender/editors/sculpt_paint/paint_vertex.c | 10 ++++++++-- source/blender/editors/sculpt_paint/sculpt.c | 1 + 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index fb5b1d338a6..db81adbbbcd 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -52,9 +52,12 @@ static bool stroke_test_start(bContext *C, struct wmOperator *op, const float mo return true; } -static void stroke_update_step(bContext *C, PaintStroke *stroke, PointerRNA *itemptr) +static void stroke_update_step(bContext *C, + wmOperator *op, + PaintStroke *stroke, + PointerRNA *itemptr) { - UNUSED_VARS(C, stroke, itemptr); + UNUSED_VARS(C, op, stroke, itemptr); } static void stroke_done(const bContext *C, PaintStroke *stroke) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index ad8303418f4..4b8c7ae7808 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -502,7 +502,10 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo return pop; } -static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) +static void paint_stroke_update_step(bContext *C, + wmOperator *UNUSED(op), + struct PaintStroke *stroke, + PointerRNA *itemptr) { PaintOperation *pop = paint_stroke_mode_data(stroke); Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index f7447ec31b8..ba363f687dc 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -49,6 +49,7 @@ typedef struct CoNo { typedef bool (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]); typedef bool (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]); typedef void (*StrokeUpdateStep)(struct bContext *C, + struct wmOperator *op, struct PaintStroke *stroke, struct PointerRNA *itemptr); typedef void (*StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index ebb5db8d712..7c4623dd4b0 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -611,7 +611,7 @@ static void paint_brush_stroke_add_step( RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt); RNA_float_set(&itemptr, "y_tilt", stroke->y_tilt); - stroke->update_step(C, stroke, &itemptr); + stroke->update_step(C, op, stroke, &itemptr); /* don't record this for now, it takes up a lot of memory when doing long * strokes with small brush size, and operators have register disabled */ @@ -1584,7 +1584,7 @@ int paint_stroke_exec(bContext *C, wmOperator *op, PaintStroke *stroke) if (stroke->stroke_started) { RNA_BEGIN (op->ptr, itemptr, "stroke") { - stroke->update_step(C, stroke, &itemptr); + stroke->update_step(C, op, stroke, &itemptr); } RNA_END; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 8373f028109..e2f8d81fe13 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2370,7 +2370,10 @@ static void wpaint_do_symmetrical_brush_actions( cache->is_last_valid = true; } -static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) +static void wpaint_stroke_update_step(bContext *C, + wmOperator *UNUSED(op), + struct PaintStroke *stroke, + PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -3400,7 +3403,10 @@ static void vpaint_do_symmetrical_brush_actions( cache->is_last_valid = true; } -static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) +static void vpaint_stroke_update_step(bContext *C, + wmOperator *UNUSED(op), + struct PaintStroke *stroke, + PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 63611b473cb..919385f82e7 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5186,6 +5186,7 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f } static void sculpt_stroke_update_step(bContext *C, + wmOperator *UNUSED(op), struct PaintStroke *UNUSED(stroke), PointerRNA *itemptr) { -- cgit v1.2.3