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.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.c')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f12e33344dc..6bc86f75d71 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -79,6 +79,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" +#include "RNA_enum_types.h" + #include "bmesh.h" const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100}; @@ -172,6 +174,28 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode) return NULL; } +const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode) +{ + switch (mode) { + case ePaintSculpt: + return rna_enum_brush_sculpt_tool_items; + case ePaintVertex: + return rna_enum_brush_vertex_tool_items; + case ePaintWeight: + return rna_enum_brush_vertex_tool_items; + case ePaintTextureProjective: + case ePaintTexture2D: + return rna_enum_brush_image_tool_items; + case ePaintSculptUV: + return NULL; + case ePaintGpencil: + return rna_enum_brush_gpencil_types_items; + case ePaintInvalid: + break; + } + return NULL; +} + Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer) { if (sce && view_layer) { @@ -288,6 +312,32 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C) return ePaintInvalid; } +ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref) +{ + if (tref->space_type == SPACE_VIEW3D) { + switch (tref->mode) { + case CTX_MODE_SCULPT: + return ePaintSculpt; + case CTX_MODE_PAINT_VERTEX: + return ePaintVertex; + case CTX_MODE_PAINT_WEIGHT: + return ePaintWeight; + case CTX_MODE_GPENCIL_PAINT: + return ePaintGpencil; + case CTX_MODE_PAINT_TEXTURE: + return ePaintTextureProjective; + } + } + else if (tref->space_type == SPACE_IMAGE) { + switch (tref->mode) { + case SI_MODE_PAINT: + return ePaintTexture2D; + } + } + + return ePaintInvalid; +} + Brush *BKE_paint_brush(Paint *p) { return p ? p->brush : NULL; |