Commit: cd02cb389180cef5b73a21a0e2ff813b1af73d47
Author: Lukas Tönne
Date:   Fri Aug 8 17:57:55 2014 +0200
Branches: hair_system
https://developer.blender.org/rBcd02cb389180cef5b73a21a0e2ff813b1af73d47

Debugging UI for enabling debug draw options directly without build
options.

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

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/blenkernel/BKE_hair.h
M       source/blender/blenkernel/intern/hair.c
M       source/blender/blenkernel/intern/object.c
M       source/blender/editors/space_view3d/drawhair.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/hair/intern/HAIR_solver.cpp
M       source/blender/makesdna/DNA_hair_types.h
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/intern/MOD_hair.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 7d36122..d9b11f7 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1258,6 +1258,18 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         
         col.operator("hair.reset to rest location")
         col.operator("hair.copy_from_particles")
+        
+        col.separator()
+        
+        col.prop(md, "show_debug")
+        col2 = col.column()
+        col2.active = md.show_debug
+        col2.prop(md, "show_debug_contacts")
+        col2.prop(md, "show_debug_size")
+        col2.prop(md, "show_debug_cylinders")
+        col2.prop(md, "show_debug_roots")
+        col2.prop(md, "show_debug_frames")
+        col2.prop(md, "show_debug_smoothing")
 
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/blenkernel/BKE_hair.h 
b/source/blender/blenkernel/BKE_hair.h
index ae0b8b7..0cc463b 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -34,6 +34,7 @@
 struct HairSystem;
 struct HairCurve;
 struct HairPoint;
+struct HairDebugData;
 
 struct HairSystem *BKE_hairsys_new(void);
 void BKE_hairsys_free(struct HairSystem *hsys);
@@ -50,4 +51,6 @@ struct HairPoint *BKE_hair_point_insert_multi(struct 
HairSystem *hsys, struct Ha
 void BKE_hair_point_remove(struct HairSystem *hsys, struct HairCurve *hair, 
struct HairPoint *point);
 void BKE_hair_point_remove_position(struct HairSystem *hsys, struct HairCurve 
*hair, int pos);
 
+void BKE_hair_debug_data_free(struct HairDebugData *debug_data);
+
 #endif
diff --git a/source/blender/blenkernel/intern/hair.c 
b/source/blender/blenkernel/intern/hair.c
index 548637b..3f86e84 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -191,3 +191,14 @@ void BKE_hair_point_remove_position(HairSystem 
*UNUSED(hsys), HairCurve *hair, i
        hair->points = npoints;
        hair->totpoints = ntotpoints;
 }
+
+void BKE_hair_debug_data_free(HairDebugData *debug_data)
+{
+       if (debug_data) {
+               if (debug_data->points)
+                       MEM_freeN(debug_data->points);
+               if (debug_data->contacts)
+                       MEM_freeN(debug_data->contacts);
+               MEM_freeN(debug_data);
+       }
+}
diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index e3f6e7a..02140df 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3124,28 +3124,26 @@ void BKE_object_sim_tick(Scene *UNUSED(scene), Object 
*ob, float ctime, float ti
                if (md->type == eModifierType_Hair) {
                        HairModifierData *hmd = (HairModifierData*) md;
                        
-#if 0
-                       HAIR_solver_step(hmd->solver, ctime, timestep);
-#else
-                       /* Debug Version
-                        * WARNING: Debugging is not threadsafe atm, crashes 
with large hair numbers (>1024)!
-                        */
-                       float imat[4][4];
-                       
-                       invert_m4_m4(imat, ob->obmat);
-                       
-                       if (hmd->debug_data) {
-                               if (hmd->debug_data->points)
-                                       MEM_freeN(hmd->debug_data->points);
-                               if (hmd->debug_data->contacts)
-                                       MEM_freeN(hmd->debug_data->contacts);
+                       if (!(hmd->debug_flag & MOD_HAIR_DEBUG_SHOW)) {
+                               HAIR_solver_step(hmd->solver, ctime, timestep);
                        }
                        else {
-                               hmd->debug_data = 
MEM_callocN(sizeof(HairDebugData), "hair debug data");
+                               float imat[4][4];
+                               
+                               invert_m4_m4(imat, ob->obmat);
+                               
+                               if (hmd->debug_data) {
+                                       if (hmd->debug_data->points)
+                                               
MEM_freeN(hmd->debug_data->points);
+                                       if (hmd->debug_data->contacts)
+                                               
MEM_freeN(hmd->debug_data->contacts);
+                               }
+                               else {
+                                       hmd->debug_data = 
MEM_callocN(sizeof(HairDebugData), "hair debug data");
+                               }
+                               
+                               HAIR_solver_step_debug(hmd->solver, ctime, 
timestep, imat, &hmd->debug_data->points, &hmd->debug_data->totpoints, 
&hmd->debug_data->contacts, &hmd->debug_data->totcontacts);
                        }
-                       
-                       HAIR_solver_step_debug(hmd->solver, ctime, timestep, 
imat, &hmd->debug_data->points, &hmd->debug_data->totpoints, 
&hmd->debug_data->contacts, &hmd->debug_data->totcontacts);
-#endif
                }
        }
 }
diff --git a/source/blender/editors/space_view3d/drawhair.c 
b/source/blender/editors/space_view3d/drawhair.c
index 4e046a5..012d73e 100644
--- a/source/blender/editors/space_view3d/drawhair.c
+++ b/source/blender/editors/space_view3d/drawhair.c
@@ -104,12 +104,12 @@ bool draw_hair_system(Scene *UNUSED(scene), View3D 
*UNUSED(v3d), ARegion *ar, Ba
 
 /* ---------------- debug drawing ---------------- */
 
-//#define SHOW_POINTS
-//#define SHOW_SIZE
-//#define SHOW_ROOTS
-//#define SHOW_FRAMES
+#define SHOW_POINTS
+#define SHOW_SIZE
+#define SHOW_ROOTS
+#define SHOW_FRAMES
 //#define SHOW_SMOOTHING
-//#define SHOW_CYLINDERS
+#define SHOW_CYLINDERS
 #define SHOW_CONTACTS
 
 static void draw_hair_debug_points(HairSystem *hsys, HAIR_SolverDebugPoint 
*dpoints, int dtotpoints)
@@ -542,6 +542,7 @@ void draw_hair_debug_info(Scene *UNUSED(scene), View3D 
*UNUSED(v3d), ARegion *ar
        RegionView3D *rv3d = ar->regiondata;
        Object *ob = base->object;
        HairSystem *hsys = hmd->hairsys;
+       int debug_flag = hmd->debug_flag;
        HairCurve *hair;
        int i;
        int tot_points = 0;
@@ -553,22 +554,28 @@ void draw_hair_debug_info(Scene *UNUSED(scene), View3D 
*UNUSED(v3d), ARegion *ar
        glLoadMatrixf(rv3d->viewmat);
        glMultMatrixf(ob->obmat);
        
-       draw_hair_debug_size(hsys, imat);
-       draw_hair_debug_roots(hsys, ob->derivedFinal);
+       if (debug_flag & MOD_HAIR_DEBUG_SIZE)
+               draw_hair_debug_size(hsys, imat);
+       if (debug_flag & MOD_HAIR_DEBUG_ROOTS)
+               draw_hair_debug_roots(hsys, ob->derivedFinal);
        
        for (hair = hsys->curves, i = 0; i < hsys->totcurves; ++hair, ++i) {
-               draw_hair_curve_debug_smoothing(hsys, hair);
+               if (debug_flag & MOD_HAIR_DEBUG_SMOOTHING)
+                       draw_hair_curve_debug_smoothing(hsys, hair);
                if (hair->totpoints > 1) {
                        tot_points += hair->totpoints;
                        valid_points++;
                }
        }
        
-       draw_hair_debug_cylinders(hsys, tot_points, valid_points);
+       if (debug_flag & MOD_HAIR_DEBUG_CYLINDERS)
+               draw_hair_debug_cylinders(hsys, tot_points, valid_points);
        
        if (hmd->debug_data) {
-               draw_hair_debug_frames(hsys, hmd->debug_data->points, 
hmd->debug_data->totpoints);
-               draw_hair_debug_points(hsys, hmd->debug_data->points, 
hmd->debug_data->totpoints);
-               draw_hair_debug_contacts(hsys, hmd->debug_data->contacts, 
hmd->debug_data->totcontacts);
+               if (debug_flag & MOD_HAIR_DEBUG_FRAMES)
+                       draw_hair_debug_frames(hsys, hmd->debug_data->points, 
hmd->debug_data->totpoints);
+//             draw_hair_debug_points(hsys, hmd->debug_data->points, 
hmd->debug_data->totpoints);
+               if (debug_flag & MOD_HAIR_DEBUG_CONTACTS)
+                       draw_hair_debug_contacts(hsys, 
hmd->debug_data->contacts, hmd->debug_data->totcontacts);
        }
 }
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index 72306e8..7268b39 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7649,9 +7649,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, const short
                HairModifierData *hmd = (HairModifierData 
*)modifiers_findByType(ob, eModifierType_Hair);
                if (hmd) {
                        draw_hair_system(scene, v3d, ar, base, hmd->hairsys);
-#ifndef NDEBUG
-                       draw_hair_debug_info(scene, v3d, ar, base, hmd);
-#endif
+                       if (hmd->debug_flag & MOD_HAIR_DEBUG_SHOW)
+                               draw_hair_debug_info(scene, v3d, ar, base, hmd);
                }
        }
 
diff --git a/source/blender/hair/intern/HAIR_solver.cpp 
b/source/blender/hair/intern/HAIR_solver.cpp
index e96be0c..09fe365 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAIR_solver.cpp
@@ -488,7 +488,7 @@ void Solver::step_threaded(float time, float timestep, 
DebugThreadDataVector *de
        /* filter and cache Bullet contact information */
        PointContactCache contacts;
        cache_point_contacts(contacts);
-       {
+       if (debug_thread_data) {
                debug_thread_data->push_back(DebugThreadData());
                DebugThreadData *thread_data = &debug_thread_data->back();
                for (int i = 0; i < contacts.size(); ++i) {
diff --git a/source/blender/makesdna/DNA_hair_types.h 
b/source/blender/makesdna/DNA_hair_types.h
index 023ee5b..3f5d878 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -81,4 +81,11 @@ typedef struct HairSystem {
        HairParams params;
 } HairSystem;
 
+typedef struct HairDebugData {
+       struct HAIR_SolverDebugContact *contacts;
+       struct HAIR_SolverDebugPoint *points;
+       int totcontacts;
+       int totpoints;
+} HairDebugData;
+
 #endif
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 73116d3..4ac7cd8 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1366,13 +1366,6 @@ enum {
        MOD_WIREFRAME_CREASE        = (1 << 5),
 };
 
-typedef struct HairDebugData {
-       struct HAIR_SolverDebugContact *contacts;
-       struct HAIR_SolverDebugPoint *points;
-       int totcontacts;
-       int totpoints;
-} HairDebugData;
-
 typedef struct HairModifierData {
        ModifierData modifier;
        
@@ -1381,8 +1374,8 @@ typedef struct HairModifierData {
        struct HAIR_Solver *solver;     /* runtime instance */
        
        int flag;
-       int pad;
-       
+
+       int debug_flag;
        struct HairDebugData *debug_data;
 } HairModifierData;
 
@@ -1390,5 +1383,15 @@ enum {
        MOD_HAIR_SOLVER_DATA_VALID  = (1 << 0),
 };
 
+enum {
+       MOD_HAIR_DEBUG_SHOW         = (1 << 0),
+       MOD_HAIR_DEBUG_CONTACTS     = (1 << 1),
+       MOD_HAIR_DEBUG_SIZE         = (1 << 2),
+       MOD_HAIR_DEBUG_ROOTS        = (1 << 3),
+       MOD_HAIR_DEBUG_CYLINDERS    = (1 << 4),
+       MOD_HAIR_DEBUG_SMOOTHING    = (1 << 5),
+       MOD_HAIR_DEBUG_FRAMES       = (1 << 6),
+};
+
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 0bc4ed8..7e2af33 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -135,6 +135,7 @@ EnumPropertyItem modifier_triangulate_ngon_method_items[] = 
{
 
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
+#include "BKE_hair.h"
 #include 

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to