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:
authorCampbell Barton <ideasman42@gmail.com>2018-11-06 04:08:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-06 04:39:51 +0300
commita90bcdf93d82bf5d9964b12bb20af696ca66654e (patch)
treee57a15e78d957955db370ad8a8591d024de57b8f /source/blender/windowmanager
parent29dfe9a61456dba8c8e4cdae0a90cfa3eef1cd2a (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/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 565fade50bb..04a3da5f01f 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -41,6 +41,7 @@
#include "DNA_workspace_types.h"
#include "DNA_object_types.h"
+#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -242,19 +243,28 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
else {
- struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block);
- if (brush) {
+ const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
+ BLI_assert(paint_mode != ePaintInvalid);
+ const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
+ BLI_assert(items != NULL);
+
+ const int i = items ? RNA_enum_from_identifier(items, tref_rt->data_block) : -1;
+ if (i != -1) {
+ const int slot_index = items[i].value;
wmWindowManager *wm = bmain->wm.first;
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (workspace == WM_window_get_active_workspace(win)) {
Scene *scene = WM_window_get_active_scene(win);
- ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- Paint *paint = BKE_paint_get_active(scene, view_layer);
- if (paint) {
- if (brush) {
- BKE_paint_brush_set(paint, brush);
- }
+ Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
+ struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
+ if (brush == NULL) {
+ /* Could make into a function. */
+ brush = BKE_brush_add(bmain, items[i].name, paint->runtime.ob_mode);
+ char *tool_type = (char *)POINTER_OFFSET(brush, paint->runtime.tool_offset);
+ *tool_type = slot_index;
+ BKE_paint_brush_set(paint, brush);
}
+ BKE_paint_brush_set(paint, brush);
}
}
}