diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-29 00:32:51 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-29 16:04:10 +0300 |
commit | c31a849a1474ef1d96805b67ad12c9be2173e003 (patch) | |
tree | cb93ca48d866bde34755ed282dfaf7bf9caefb2d | |
parent | ba90d2efa58fe23a87f98e014bcc02ea951a6a49 (diff) |
Fix wrong sculpt cursor drawing when using "ignore_background_click"
Not all the necessary state got restored.
5 files changed, 30 insertions, 27 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index e066e101410..54531139616 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -700,7 +700,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_data_free(op); + paint_stroke_free(C, op); return OPERATOR_FINISHED; } /* add modal handler */ diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 8be474880a5..abfa4331952 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -70,7 +70,7 @@ struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeRedraw redraw, StrokeDone done, int event_type); -void paint_stroke_data_free(struct wmOperator *op); +void paint_stroke_free(struct bContext *C, struct wmOperator *op); bool paint_space_stroke_enabled(struct Brush *br, enum ePaintMode mode); bool paint_supports_dynamic_size(struct Brush *br, enum ePaintMode mode); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 51296fa5d44..137d7bd9d6c 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -901,20 +901,37 @@ PaintStroke *paint_stroke_new(bContext *C, return stroke; } -void paint_stroke_data_free(struct wmOperator *op) +void paint_stroke_free(bContext *C, wmOperator *op) { + PaintStroke *stroke = op->customdata; + UnifiedPaintSettings *ups = stroke->ups; + + ups->draw_anchored = false; + ups->stroke_active = false; + + if (stroke->timer) { + WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer); + } + + if (stroke->rng) { + BLI_rng_free(stroke->rng); + } + + if (stroke->stroke_cursor) { + WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor); + } + + BLI_freelistN(&stroke->line); + BKE_paint_set_overlay_override(0); MEM_SAFE_FREE(op->customdata); } -static void stroke_done(struct bContext *C, struct wmOperator *op) +static void stroke_done(bContext *C, wmOperator *op) { - struct PaintStroke *stroke = op->customdata; + PaintStroke *stroke = op->customdata; UnifiedPaintSettings *ups = stroke->ups; - ups->draw_anchored = false; - ups->stroke_active = false; - /* reset rotation here to avoid doing so in cursor display */ if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { ups->brush_rotation = 0.0f; @@ -934,21 +951,7 @@ static void stroke_done(struct bContext *C, struct wmOperator *op) } } - if (stroke->timer) { - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer); - } - - if (stroke->rng) { - BLI_rng_free(stroke->rng); - } - - if (stroke->stroke_cursor) { - WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor); - } - - BLI_freelistN(&stroke->line); - - paint_stroke_data_free(op); + paint_stroke_free(C, op); } /* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index a171caeca6a..9887f598f42 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2439,7 +2439,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) event->type); if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { - paint_stroke_data_free(op); + paint_stroke_free(C, op); return OPERATOR_FINISHED; } /* add modal handler */ @@ -3381,7 +3381,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) event->type); if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { - paint_stroke_data_free(op); + paint_stroke_free(C, op); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2309f151fee..51ca0ec3403 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7004,12 +7004,12 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent ignore_background_click = RNA_boolean_get(op->ptr, "ignore_background_click"); if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) { - paint_stroke_data_free(op); + paint_stroke_free(C, op); return OPERATOR_PASS_THROUGH; } if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { - paint_stroke_data_free(op); + paint_stroke_free(C, op); return OPERATOR_FINISHED; } /* add modal handler */ |