From 4443c4082ed094baf11b5c6cff280582776466b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Jun 2021 01:55:44 +1000 Subject: Cleanup: remove redundant checks which have already been tested Note that these changes are limited simple cases as these kinds of changes could allow for errors when refactoring code when the known state is not so obvious. --- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/editors/gpencil/gpencil_primitive.c | 30 ++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'source/blender/editors/gpencil') diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 993065a3a70..e40748e5f6e 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -3287,7 +3287,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event gpencil_guide_event_handling(C, op, event, p); } - if (ob && (ob->type == OB_GPENCIL) && ((p->gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)) { + if ((ob->type == OB_GPENCIL) && ((p->gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)) { /* FIXME: use the mode switching operator, this misses notifiers, messages. */ /* Just set paintmode flag... */ p->gpd->flag |= GP_DATA_STROKE_PAINTMODE; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 1b0a40b1be1..5f02bbf0a77 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1536,24 +1536,22 @@ static void gpencil_primitive_strength(tGPDprimitive *tgpi, bool reset) Brush *brush = tgpi->brush; BrushGpencilSettings *brush_settings = brush->gpencil_settings; - if (brush) { - if (reset) { - brush_settings->draw_strength = tgpi->brush_strength; - tgpi->brush_strength = 0.0f; - } - else { - if (tgpi->brush_strength == 0.0f) { - tgpi->brush_strength = brush_settings->draw_strength; - } - float move[2]; - sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo); - float adjust = (move[1] > 0.0f) ? 0.01f : -0.01f; - brush_settings->draw_strength += adjust * fabsf(len_manhattan_v2(move)); + if (reset) { + brush_settings->draw_strength = tgpi->brush_strength; + tgpi->brush_strength = 0.0f; + } + else { + if (tgpi->brush_strength == 0.0f) { + tgpi->brush_strength = brush_settings->draw_strength; } - - /* limit low limit because below 0.2f the stroke is invisible */ - CLAMP(brush_settings->draw_strength, 0.2f, 1.0f); + float move[2]; + sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo); + float adjust = (move[1] > 0.0f) ? 0.01f : -0.01f; + brush_settings->draw_strength += adjust * fabsf(len_manhattan_v2(move)); } + + /* limit low limit because below 0.2f the stroke is invisible */ + CLAMP(brush_settings->draw_strength, 0.2f, 1.0f); } /* brush size */ -- cgit v1.2.3