Commit: 3ad6349e48e87a68d5212b580b8805e50d949b89
Author: Lukas Tönne
Date:   Mon Dec 1 20:25:28 2014 +0100
Branches: hair_immediate_fixes
https://developer.blender.org/rB3ad6349e48e87a68d5212b580b8805e50d949b89

Define hair edit settings and brush types in the RNA, similar to paint
and sculpt settings.

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

M       release/scripts/startup/bl_ui/properties_paint_common.py
M       source/blender/editors/screen/screen_context.c
M       source/blender/makesdna/DNA_brush_types.h
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_scene.c
M       source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index f104285..f33825b 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -38,10 +38,10 @@ class UnifiedPaintPanel():
         elif context.image_paint_object:
             if (toolsettings.image_paint and 
toolsettings.image_paint.detect_data()):
                 return toolsettings.image_paint
-
-            return None
         elif context.particle_edit_object:
             return toolsettings.particle_edit
+        elif context.hair_edit_object:
+            return toolsettings.hair_edit
 
         return None
 
diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index ce9c608..25146bf 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -67,7 +67,7 @@ const char *screen_context_dir[] = {
        "visible_pose_bones", "selected_pose_bones", "active_bone", 
"active_pose_bone",
        "active_base", "active_object", "object", "edit_object",
        "sculpt_object", "vertex_paint_object", "weight_paint_object",
-       "image_paint_object", "particle_edit_object",
+       "image_paint_object", "particle_edit_object", "hair_edit_object",
        "sequences", "selected_sequences", "selected_editable_sequences", /* 
sequencer */
        "gpencil_data", "gpencil_data_owner", /* grease pencil data */
        "visible_gpencil_layers", "editable_gpencil_layers", 
"editable_gpencil_strokes",
@@ -362,6 +362,12 @@ int ed_screen_context(const bContext *C, const char 
*member, bContextDataResult
 
                return 1;
        }
+       else if (CTX_data_equals(member, "hair_edit_object")) {
+               if (obact && (obact->mode & OB_MODE_HAIR_EDIT))
+                       CTX_data_id_pointer_set(result, &obact->id);
+
+               return 1;
+       }
        else if (CTX_data_equals(member, "sequences")) {
                Editing *ed = BKE_sequencer_editing_get(scene, false);
                if (ed) {
diff --git a/source/blender/makesdna/DNA_brush_types.h 
b/source/blender/makesdna/DNA_brush_types.h
index 24c90c8..1349408 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -93,7 +93,6 @@ typedef struct Brush {
 
        float plane_offset;     /* offset for plane brushes (clay, flatten, 
fill, scrape) */
 
-       float pad;
        int gradient_spacing;
        int gradient_stroke_mode; /* source for stroke color gradient 
application */
        int gradient_fill_mode;   /* source for fill tool color gradient 
application */
@@ -102,6 +101,8 @@ typedef struct Brush {
        char vertexpaint_tool;  /* active vertex/weight paint blend mode 
(poorly named) */
        char imagepaint_tool;   /* active image paint tool */
        char mask_tool;         /* enum BrushMaskTool, only used if sculpt_tool 
is SCULPT_TOOL_MASK */
+       char hair_tool;         /* active hair tool */
+       char pad2[3];
        
        float autosmooth_factor;
 
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index 91c70de..3d47b71 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -887,6 +887,17 @@ typedef struct ParticleEditSettings {
 } ParticleEditSettings;
 
 /* ------------------------------------------- */
+/* Hair Edit */
+
+typedef struct HairEditSettings {
+       int flag;
+       int select_mode;
+       
+       struct Brush *brush;
+       struct Object *shape_object;
+} HairEditSettings;
+
+/* ------------------------------------------- */
 /* Sculpt */
 
 /* Sculpt */
@@ -1105,7 +1116,10 @@ typedef struct ToolSettings {
 
        /* Particle Editing */
        struct ParticleEditSettings particle;
-       
+
+       /* Hair Editing */
+       struct HairEditSettings hair_edit;
+
        /* Transform Proportional Area of Effect */
        float proportional_size;
 
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 18c0490..1f39444 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1851,6 +1851,10 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_pointer_sdna(prop, NULL, "particle");
        RNA_def_property_ui_text(prop, "Particle Edit", "");
 
+       prop = RNA_def_property(srna, "hair_edit", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "hair_edit");
+       RNA_def_property_ui_text(prop, "Hair Edit", "");
+
        prop = RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1);
        RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV 
sculpting");
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c 
b/source/blender/makesrna/intern/rna_sculpt_paint.c
index fa35077..6496154 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -221,6 +221,8 @@ static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA 
value)
                mode = OB_MODE_VERTEX_PAINT;
        else if (ptr->data == ts->wpaint)
                mode = OB_MODE_WEIGHT_PAINT;
+       else if (ptr->data == &ts->hair_edit)
+               mode = OB_MODE_HAIR_EDIT;
 
        return brush->ob_mode & mode;
 }
@@ -354,6 +356,30 @@ static int rna_ImaPaint_detect_data(ImagePaintSettings 
*imapaint)
 {
        return imapaint->missing_data == 0;
 }
+
+/* ==== Hair Edit ==== */
+
+static char *rna_HairEdit_path(PointerRNA *UNUSED(ptr))
+{
+       return BLI_strdup("tool_settings.hair_edit");
+}
+
+static void rna_HairEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA 
*UNUSED(ptr))
+{
+       Object *ob = OBACT;
+
+       if (ob)
+               DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+}
+
+static void rna_Hair_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *ptr)
+{
+       HairEditSettings *settings = ptr->data;
+       Brush *brush = settings->brush;
+       BKE_paint_invalidate_overlay_all();
+       WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
+}
+
 #else
 
 static void rna_def_palettecolor(BlenderRNA *brna)
@@ -937,6 +963,41 @@ static void rna_def_particle_edit(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Curve", "");
 }
 
+static void rna_def_hair_edit(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       static EnumPropertyItem select_mode_items[] = {
+               {SCE_SELECT_PATH, "PATH", ICON_PARTICLE_PATH, "Path", "Path 
edit mode"},
+               {SCE_SELECT_POINT, "POINT", ICON_PARTICLE_POINT, "Point", 
"Point select mode"},
+               {SCE_SELECT_END, "TIP", ICON_PARTICLE_TIP, "Tip", "Tip select 
mode"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       srna = RNA_def_struct(brna, "HairEdit", NULL);
+       RNA_def_struct_sdna(srna, "HairEditSettings");
+       RNA_def_struct_path_func(srna, "rna_HairEdit_path");
+       RNA_def_struct_ui_text(srna, "Hair Edit", "Settings for hair editing 
mode");
+
+       prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, 
"rna_Brush_mode_poll");
+       RNA_def_property_ui_text(prop, "Brush", "Active Brush");
+       RNA_def_property_update(prop, 0, "rna_Hair_brush_update");
+
+       prop = RNA_def_property(srna, "select_mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "select_mode");
+       RNA_def_property_enum_items(prop, select_mode_items);
+       RNA_def_property_ui_text(prop, "Selection Mode", "Hair selection mode");
+       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, 
"rna_HairEdit_update");
+
+       prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for 
tools");
+       RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, 
"rna_HairEdit_update");
+}
+
 void RNA_def_sculpt_paint(BlenderRNA *brna)
 {
        /* *** Non-Animated *** */
@@ -950,6 +1011,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna)
        rna_def_vertex_paint(brna);
        rna_def_image_paint(brna);
        rna_def_particle_edit(brna);
+       rna_def_hair_edit(brna);
        RNA_define_animate_sdna(true);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to