Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_ops.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c20
1 files 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)
{