diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-06 04:08:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-06 04:39:51 +0300 |
commit | a90bcdf93d82bf5d9964b12bb20af696ca66654e (patch) | |
tree | e57a15e78d957955db370ad8a8591d024de57b8f /source/blender/blenkernel/intern/paint_toolslots.c | |
parent | 29dfe9a61456dba8c8e4cdae0a90cfa3eef1cd2a (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/paint_toolslots.c')
-rw-r--r-- | source/blender/blenkernel/intern/paint_toolslots.c | 13 |
1 files changed, 13 insertions, 0 deletions
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 <limits.h> + #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; +} |