From a90bcdf93d82bf5d9964b12bb20af696ca66654e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Nov 2018 12:08:39 +1100 Subject: Tool System: use tool type enum to access brushes Previously the brush names were used which had the limit that: - Brush names that were deleted wouldn't show up in the toolbar. - Naming collisions between user defined brushes and existing tools broke tool selection. Now brushes are created as needed when tools are selected. Note, vertex/weight paint combine tool and blend modes, this should be split out into a separate enum. --- source/blender/blenkernel/intern/paint_toolslots.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/blender/blenkernel/intern/paint_toolslots.c') diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c index 61e0f03ce9e..c0f26c1c9c1 100644 --- a/source/blender/blenkernel/intern/paint_toolslots.c +++ b/source/blender/blenkernel/intern/paint_toolslots.c @@ -22,6 +22,8 @@ * \ingroup bke */ +#include + #include "MEM_guardedalloc.h" #include "DNA_modifier_types.h" @@ -36,6 +38,8 @@ void BKE_paint_toolslots_len_ensure(Paint *paint, int len) { + /* Tool slots are 'uchar'. */ + BLI_assert(len <= UCHAR_MAX); if (paint->tool_slots_len < len) { paint->tool_slots = MEM_recallocN(paint->tool_slots, sizeof(*paint->tool_slots) * len); paint->tool_slots_len = len; @@ -122,3 +126,12 @@ void BKE_paint_toolslots_brush_validate(Main *bmain, Paint *paint) /* Fill slots from brushes. */ paint_toolslots_init(bmain, paint); } + +Brush *BKE_paint_toolslots_brush_get(Paint *paint, int slot_index) +{ + if (slot_index < paint->tool_slots_len) { + PaintToolSlot *tslot = &paint->tool_slots[slot_index]; + return tslot->brush; + } + return NULL; +} -- cgit v1.2.3