Commit: 20721edaefdf4bd081d0ff1339694a58d62b2d29
Author: Lukas Tönne
Date:   Sun Dec 7 13:12:48 2014 +0100
Branches: hair_immediate_fixes
https://developer.blender.org/rB20721edaefdf4bd081d0ff1339694a58d62b2d29

Support for sim_debug drawing in hair edit mode (dev feature).

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/blenkernel/BKE_editstrands.h
M       source/blender/blenkernel/intern/editstrands.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/drawstrands.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 9967da9..c9f4c69 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1826,6 +1826,22 @@ class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
             sub.prop(pe, "fade_frames", slider=True)
 
 
+class VIEW3D_PT_tools_hairmode(View3DPanel, Panel):
+    """Tools for hair mode"""
+    bl_context = "hairmode"
+    bl_label = "Options"
+    bl_category = "Tools"
+
+    def draw(self, context):
+        layout = self.layout
+
+        settings = context.tool_settings.hair_edit
+        ob = context.active_object
+
+        col = layout.column(align=True)
+        col.prop(settings, "show_debug_data", text="Debug")
+
+
 # Grease Pencil drawing tools
 class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
     bl_space_type = 'VIEW_3D'
diff --git a/source/blender/blenkernel/BKE_editstrands.h 
b/source/blender/blenkernel/BKE_editstrands.h
index 309e94c..2768e86 100644
--- a/source/blender/blenkernel/BKE_editstrands.h
+++ b/source/blender/blenkernel/BKE_editstrands.h
@@ -59,6 +59,8 @@ typedef struct BMEditStrands {
        unsigned int vertex_glbuf;
        unsigned int elem_glbuf;
        unsigned int dot_glbuf;
+       
+       struct SimDebugData *debug_data;
 } BMEditStrands;
 
 /* BMEditStrands->flag */
diff --git a/source/blender/blenkernel/intern/editstrands.c 
b/source/blender/blenkernel/intern/editstrands.c
index 0edd9a7..6227161 100644
--- a/source/blender/blenkernel/intern/editstrands.c
+++ b/source/blender/blenkernel/intern/editstrands.c
@@ -42,8 +42,9 @@
 #include "BKE_bvhutils.h"
 #include "BKE_customdata.h"
 #include "BKE_cdderivedmesh.h"
-#include "BKE_editstrands.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+#include "BKE_effect.h"
 #include "BKE_mesh_sample.h"
 #include "BKE_particle.h"
 
@@ -66,6 +67,7 @@ BMEditStrands *BKE_editstrands_copy(BMEditStrands *es)
        
        es_copy->bm = BM_mesh_copy(es->bm);
        es_copy->root_dm = CDDM_copy(es->root_dm);
+       es_copy->debug_data = NULL;
        
        return es_copy;
 }
@@ -97,6 +99,8 @@ void BKE_editstrands_free(BMEditStrands *es)
                BM_mesh_free(es->bm);
        if (es->root_dm)
                es->root_dm->release(es->root_dm);
+       if (es->debug_data)
+               BKE_sim_debug_data_free(es->debug_data);
 }
 
 /* === constraints === */
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index 3b5effc..ecec6c5 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7730,7 +7730,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, const short
                if (ob->mode & OB_MODE_HAIR_EDIT && is_obact) {
                        BMEditStrands *edit = BKE_editstrands_from_object(ob);
                        if (edit) {
-                               draw_strands_edit_hair(scene, v3d, edit);
+                               draw_strands_edit_hair(scene, v3d, ar, edit);
                        }
                }
        }
diff --git a/source/blender/editors/space_view3d/drawstrands.c 
b/source/blender/editors/space_view3d/drawstrands.c
index 45331bb..dc7c9a3 100644
--- a/source/blender/editors/space_view3d/drawstrands.c
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -354,7 +354,7 @@ static void draw_dots(BMEditStrands *edit, const 
StrandsDrawInfo *info, bool sel
                glDrawArrays(GL_POINTS, 0, totelem);
 }
 
-void draw_strands_edit_hair(Scene *scene, View3D *v3d, BMEditStrands *edit)
+void draw_strands_edit_hair(Scene *scene, View3D *v3d, ARegion *ar, 
BMEditStrands *edit)
 {
        HairEditSettings *settings = &scene->toolsettings->hair_edit;
        
@@ -376,4 +376,10 @@ void draw_strands_edit_hair(Scene *scene, View3D *v3d, 
BMEditStrands *edit)
        unbind_gpu_buffers_dots();
        
        restore_opengl_state(&info);
+       
+       /* debugging */
+       if (edit->debug_data) {
+               Base *base = BASACT;
+               draw_sim_debug_data(scene, v3d, ar, base, edit->debug_data);
+       }
 }
diff --git a/source/blender/editors/space_view3d/view3d_intern.h 
b/source/blender/editors/space_view3d/view3d_intern.h
index 3b9ae75..6024523 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -185,7 +185,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
 void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar, Base *base, 
struct SimDebugData *debug_data);
 
 /* drawstrands.c */
-void draw_strands_edit_hair(Scene *scene, View3D *v3d, struct BMEditStrands 
*edit);
+void draw_strands_edit_hair(Scene *scene, View3D *v3d, ARegion *ar, struct 
BMEditStrands *edit);
 
 /* view3d_draw.c */
 void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar);
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index c5fac47..890fb50 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -889,12 +889,18 @@ typedef struct ParticleEditSettings {
 /* ------------------------------------------- */
 /* Hair Edit */
 
+/* HairEditSettings->select_mode */
 typedef enum HairEditSelectMode {
        HAIR_SELECT_STRAND  = 0,
        HAIR_SELECT_VERTEX  = 1,
        HAIR_SELECT_TIP     = 2,
 } HairEditSelectMode;
 
+/* HairEditSettings->flag */
+typedef enum HairEditFlag {
+       HAIR_EDIT_SHOW_DEBUG    = (1 << 16),
+} HairEditFlag;
+
 typedef struct HairEditSettings {
        int flag;
        int select_mode;
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c 
b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 896a2a1..4e31045 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -77,6 +77,8 @@ EnumPropertyItem symmetrize_direction_items[] = {
 
 #include "BKE_context.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+#include "BKE_effect.h"
 #include "BKE_pointcache.h"
 #include "BKE_particle.h"
 #include "BKE_depsgraph.h"
@@ -372,7 +374,30 @@ static void rna_HairEdit_update(Main *UNUSED(bmain), Scene 
*scene, PointerRNA *U
                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 }
 
-static void rna_Hair_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *ptr)
+static void rna_HairEdit_show_debug_data_update(Main *bmain, Scene *scene, 
PointerRNA *ptr)
+{
+       HairEditSettings *settings = ptr->data;
+       Object *ob = OBACT;
+       
+       if (ob) {
+               BMEditStrands *edit = BKE_editstrands_from_object(ob);
+               if (edit) {
+                       if (edit->debug_data) {
+                               /* always free debug data, that way resetting 
acts as a forced clear */
+                               BKE_sim_debug_data_free(edit->debug_data);
+                               edit->debug_data = NULL;
+                       }
+                       
+                       if (settings->flag & HAIR_EDIT_SHOW_DEBUG) {
+                               edit->debug_data = BKE_sim_debug_data_new();
+                       }
+               }
+       }
+       
+       rna_HairEdit_update(bmain, scene, ptr);
+}
+
+static void rna_HairEdit_brush_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerRNA *ptr)
 {
        HairEditSettings *settings = ptr->data;
        Brush *brush = settings->brush;
@@ -984,7 +1009,7 @@ static void rna_def_hair_edit(BlenderRNA *brna)
        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");
+       RNA_def_property_update(prop, 0, "rna_HairEdit_brush_update");
 
        prop = RNA_def_property(srna, "select_mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "select_mode");
@@ -996,6 +1021,11 @@ static void rna_def_hair_edit(BlenderRNA *brna)
        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");
+
+       prop = RNA_def_property(srna, "show_debug_data", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", HAIR_EDIT_SHOW_DEBUG);
+       RNA_def_property_ui_text(prop, "Show Debug Data", "");
+       RNA_def_property_update(prop, 0, "rna_HairEdit_show_debug_data_update");
 }
 
 void RNA_def_sculpt_paint(BlenderRNA *brna)

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

Reply via email to