From e1cb4aade83dbee536e75fb15d64905c918d045d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 15 May 2013 11:10:59 +0000 Subject: [PATCH] Fix #35364: sculpting - D shortcut inconsistency Switching to tool will cycle via all brushes with given type only in case current brush tool matches requested one. This means, when user requests brush with different type, first brush of that tool will be activated. But further toggling to the same tool will cycle via all acceptable brushes. --- .../blender/editors/sculpt_paint/paint_ops.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index a838a9c26cb..a30566d5b3f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -248,14 +248,30 @@ static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool) /* generic functions for setting the active brush based on the tool */ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) { - Brush *brush; + Brush *brush, *first_brush; if (!brush_orig && !(brush_orig = bmain->brush.first)) { return NULL; } + if (brush_tool(brush_orig, tool_offset) != tool) { + /* If current brush's tool is different from what we need, + * start cycling from the beginning of the list. + * Such logic will activate the same exact brush not relating from + * which tool user requests other tool. + */ + first_brush = bmain->brush.first; + } + else { + /* If user wants to switch to brush with the same tool as + * currently active brush do a cycling via all possible + * brushes with requested tool. + */ + first_brush = brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; + } + /* get the next brush with the active tool */ - for (brush = brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; + for (brush = first_brush; brush != brush_orig; brush = brush->id.next ? brush->id.next : bmain->brush.first) {