diff options
author | Jacques Lucke <jacques@blender.org> | 2022-02-21 13:52:46 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-02-21 13:52:46 +0300 |
commit | 141d5851d7d240dbe96854553c7a2c076a1b68bd (patch) | |
tree | 5be034d7e8dd01091b23d7704ff4c3bf4b54ef4c /source/blender/editors/sculpt_paint/paint_image.c | |
parent | 5be74160c06a51fa61dce6293ddbd538562e766b (diff) |
Paint: decouple op->customdata from PaintStroke
Previously, all operators using `PaintStroke` would have to store
the stroke in `op->customdata`. That made it impossible to store
other operator specific data in `op->customdata` that was unrelated
to the stroke.
This patch changes it so that the `PaintStroke` is passed to api
functions as a separate argument, which allows storing the stroke
as a subfield of some other struct in `op->customdata`.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index df9e2cf136f..ad8303418f4 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -685,7 +685,7 @@ static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event) event->type); if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { - paint_stroke_free(C, op); + paint_stroke_free(C, op, op->customdata); return OPERATOR_FINISHED; } /* add modal handler */ @@ -720,7 +720,17 @@ static int paint_exec(bContext *C, wmOperator *op) paint_stroke_done, 0); /* frees op->customdata */ - return paint_stroke_exec(C, op); + return paint_stroke_exec(C, op, op->customdata); +} + +static int paint_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + return paint_stroke_modal(C, op, event, op->customdata); +} + +static void paint_cancel(bContext *C, wmOperator *op) +{ + paint_stroke_cancel(C, op, op->customdata); } void PAINT_OT_image_paint(wmOperatorType *ot) @@ -732,10 +742,10 @@ void PAINT_OT_image_paint(wmOperatorType *ot) /* api callbacks */ ot->invoke = paint_invoke; - ot->modal = paint_stroke_modal; + ot->modal = paint_modal; ot->exec = paint_exec; ot->poll = image_paint_poll; - ot->cancel = paint_stroke_cancel; + ot->cancel = paint_cancel; /* flags */ ot->flag = OPTYPE_BLOCKING; |