Paint: pass operator to stroke update function

This allows accessing properties of the operator that the
stroke belongs to.
This commit is contained in:
Jacques Lucke 2022-02-21 16:07:43 +01:00
parent 68586d2c18
commit ed9f763034
6 changed files with 21 additions and 7 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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)
{