Commit: 96e40fef46b923625c419bf2aa687c8bd25260da
Author: Lukas Toenne
Date:   Thu Dec 20 13:29:01 2018 +0000
Branches: hair_object
https://developer.blender.org/rB96e40fef46b923625c419bf2aa687c8bd25260da

Fix tool system integration of hair edit brushes.

===================================================================

M       source/blender/makesrna/RNA_enum_types.h
M       source/blender/makesrna/intern/rna_sculpt_paint.c
M       source/blender/windowmanager/intern/wm_toolsystem.c

===================================================================

diff --git a/source/blender/makesrna/RNA_enum_types.h 
b/source/blender/makesrna/RNA_enum_types.h
index f2eaa9d075f..735dca17822 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -128,6 +128,7 @@ extern const EnumPropertyItem 
rna_enum_brush_image_tool_items[];
 
 extern const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[];
 extern const EnumPropertyItem 
rna_enum_particle_edit_disconnected_hair_brush_items[];
+extern const EnumPropertyItem rna_enum_hair_edit_brush_items[];
 extern const EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[];
 extern const EnumPropertyItem rna_enum_gpencil_weight_brush_items[];
 
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c 
b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 08248d8542a..f19a30d66a3 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -65,6 +65,11 @@ const EnumPropertyItem 
rna_enum_particle_edit_hair_brush_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
+const EnumPropertyItem rna_enum_hair_edit_brush_items[] = {
+       {HAIR_BRUSH_ADD, "ADD", 0, "Add", "Add hairs"},
+       {0, NULL, 0, NULL, NULL}
+};
+
 const EnumPropertyItem rna_enum_gpencil_sculpt_brush_items[] = {
        {GP_SCULPT_TYPE_SMOOTH, "SMOOTH", ICON_GPBRUSH_SMOOTH, "Smooth", 
"Smooth stroke points"},
        {GP_SCULPT_TYPE_THICKNESS, "THICKNESS", ICON_GPBRUSH_THICKNESS, 
"Thickness", "Adjust thickness of strokes"},
@@ -1216,11 +1221,6 @@ static void rna_def_hair_edit_settings(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
-       static const EnumPropertyItem hair_brush_items[] = {
-               {HAIR_BRUSH_ADD, "ADD", 0, "Add", "Add hairs"},
-               {0, NULL, 0, NULL, NULL}
-       };
-
        static const EnumPropertyItem select_mode_items[] = {
            {HAIR_SELECT_FOLLICLES, "FOLLICLES", ICON_NONE, "Follicles", 
"Select hair follicles"},
            {HAIR_SELECT_VERTICES, "VERTICES", ICON_NONE, "Vertices", "Select 
hair curve vertices"},
@@ -1242,7 +1242,7 @@ static void rna_def_hair_edit_settings(BlenderRNA *brna)
 
        prop = RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "brushtype");
-       RNA_def_property_enum_items(prop, hair_brush_items);
+       RNA_def_property_enum_items(prop, rna_enum_hair_edit_brush_items);
        RNA_def_property_ui_text(prop, "Tool", "");
 
        prop = RNA_def_property(srna, "select_mode", PROP_ENUM, PROP_NONE);
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c 
b/source/blender/windowmanager/intern/wm_toolsystem.c
index ef8a57a1255..49d4b4e52cb 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -255,6 +255,23 @@ static void toolsystem_ref_link(bContext *C, WorkSpace 
*workspace, bToolRef *tre
                                }
                        }
                }
+               else if ((tref->space_type == SPACE_VIEW3D) &&
+                        (tref->mode == CTX_MODE_EDIT_HAIR))
+               {
+                       const EnumPropertyItem *items = 
rna_enum_hair_edit_brush_items;
+                       const int i = RNA_enum_from_identifier(items, 
tref_rt->data_block);
+                       if (i != -1) {
+                               const int value = 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);
+                                               ToolSettings *ts = 
scene->toolsettings;
+                                               ts->hair_edit.brushtype = value;
+                                       }
+                               }
+                       }
+               }
                else if ((tref->space_type == SPACE_IMAGE) &&
                         (tref->mode == SI_MODE_UV))
                {
@@ -509,6 +526,19 @@ void WM_toolsystem_ref_sync_from_context(
                                }
                        }
                }
+               else if ((tref->space_type == SPACE_VIEW3D) &&
+                        (tref->mode == CTX_MODE_EDIT_HAIR))
+               {
+                       if (ob->mode & OB_MODE_EDIT) {
+                               const EnumPropertyItem *items = 
rna_enum_hair_edit_brush_items;
+                               const int i = RNA_enum_from_value(items, 
ts->hair_edit.brushtype);
+                               const EnumPropertyItem *item = &items[i];
+                               if (!STREQ(tref_rt->data_block, 
item->identifier)) {
+                                       STRNCPY(tref_rt->data_block, 
item->identifier);
+                                       STRNCPY(tref->idname, item->name);
+                               }
+                       }
+               }
                else if ((tref->space_type == SPACE_IMAGE) &&
                         (tref->mode == SI_MODE_UV))
                {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to