Commit: b23828f37f2f2057481f09d90678aefd538a599c
Author: Lukas Tönne
Date:   Tue Sep 2 14:10:28 2014 +0200
Branches: hair_immediate_fixes
https://developer.blender.org/rBb23828f37f2f2057481f09d90678aefd538a599c

Hair debugging: use "categories" (strings) for grouping debug elements
and support clearing for categories.

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

M       source/blender/blenkernel/BKE_effect.h
M       source/blender/blenkernel/intern/collision.c
M       source/blender/blenkernel/intern/effect.c
M       source/blender/blenkernel/intern/implicit.c

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

diff --git a/source/blender/blenkernel/BKE_effect.h 
b/source/blender/blenkernel/BKE_effect.h
index 852f9de..04853bb 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -139,8 +139,10 @@ int get_effector_data(struct EffectorCache *eff, struct 
EffectorData *efd, struc
 /* ======== Simulation Debugging ======== */
 
 typedef struct SimDebugElement {
-       int type;
+       int category_hash;
        int hash;
+       
+       int type;
        float color[3];
        
        float v1[3], v2[3];
@@ -157,11 +159,12 @@ typedef struct SimDebugData {
 } SimDebugData;
 
 struct SimDebugData *BKE_sim_debug_data_new(void);
-void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float 
p[3], float r, float g, float b, int hash);
-void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float 
p1[3], const float p2[3], float r, float g, float b, int hash);
-void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const 
float p[3], const float d[3], float r, float g, float b, int hash);
+void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float 
p[3], float r, float g, float b, const char *category, int hash);
+void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float 
p1[3], const float p2[3], float r, float g, float b, const char *category, int 
hash);
+void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const 
float p[3], const float d[3], float r, float g, float b, const char *category, 
int hash);
 void BKE_sim_debug_data_remove(struct SimDebugData *debug_data, int hash);
 void BKE_sim_debug_data_clear(struct SimDebugData *debug_data);
+void BKE_sim_debug_data_clear_category(struct SimDebugData *debug_data, const 
char *category);
 void BKE_sim_debug_data_free(struct SimDebugData *debug_data);
 
 #endif
diff --git a/source/blender/blenkernel/intern/collision.c 
b/source/blender/blenkernel/intern/collision.c
index bb5a94c..4a10512 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1010,10 +1010,10 @@ static bool 
cloth_points_collision_response_static(ClothModifierData *clmd, Coll
 
                /**** DEBUG ****/
                if (clmd->debug_data) {
-                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
collpair->pa, 0.9, 0.2, 0.2, hash_collpair(833, collpair));
-                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
collpair->pb, 0.2, 0.9, 0.2, hash_collpair(834, collpair));
-                       BKE_sim_debug_data_add_line(clmd->debug_data, 
collpair->pa, collpair->pb, 0.8, 0.8, 0.8, hash_collpair(835, collpair));
-                       BKE_sim_debug_data_add_vector(clmd->debug_data, 
collpair->pa, collpair->normal, 1.0, 1.0, 0.0, hash_collpair(836, collpair));
+                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
collpair->pa, 0.9, 0.2, 0.2, "collision", hash_collpair(833, collpair));
+                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
collpair->pb, 0.2, 0.9, 0.2, "collision", hash_collpair(834, collpair));
+                       BKE_sim_debug_data_add_line(clmd->debug_data, 
collpair->pa, collpair->pb, 0.8, 0.8, 0.8, "collision", hash_collpair(835, 
collpair));
+//                     BKE_sim_debug_data_add_vector(clmd->debug_data, 
collpair->pa, collpair->normal, 1.0, 1.0, 0.0, "collision", hash_collpair(836, 
collpair));
                }
                /********/
 
@@ -1046,16 +1046,10 @@ static bool 
cloth_points_collision_response_static(ClothModifierData *clmd, Coll
                                copy_v3_v3(impulse, repulse);
                        }
                        cloth1->verts[collpair->ap1].impulse_count++;
-                       BKE_sim_debug_data_add_vector(clmd->debug_data, 
collpair->pa, impulse, 0.0, 1.0, 0.6, hash_collpair(873, collpair));
+                       BKE_sim_debug_data_add_vector(clmd->debug_data, 
collpair->pa, impulse, 0.0, 1.0, 0.6, "collision", hash_collpair(873, 
collpair));
                        
                        result = true;
                }
-               else {
-                       BKE_sim_debug_data_remove(clmd->debug_data, 
hash_collpair(833, collpair));
-                       BKE_sim_debug_data_remove(clmd->debug_data, 
hash_collpair(834, collpair));
-                       BKE_sim_debug_data_remove(clmd->debug_data, 
hash_collpair(835, collpair));
-                       BKE_sim_debug_data_remove(clmd->debug_data, 
hash_collpair(873, collpair));
-               }
                
                if (result) {
                        int i = 0;
diff --git a/source/blender/blenkernel/intern/effect.c 
b/source/blender/blenkernel/intern/effect.c
index acdc90b..89306bb 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1073,14 +1073,16 @@ static void debug_data_insert(SimDebugData *debug_data, 
SimDebugElement *elem)
                BLI_ghash_insert(debug_data->gh, elem, elem);
 }
 
-void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float 
p[3], float r, float g, float b, int hash)
+void BKE_sim_debug_data_add_dot(struct SimDebugData *debug_data, const float 
p[3], float r, float g, float b, const char *category, int hash)
 {
+       int category_hash = (int)BLI_ghashutil_strhash_p(category);
        SimDebugElement *elem;
        if (!debug_data)
                return;
        
        elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
        elem->type = SIM_DEBUG_ELEM_DOT;
+       elem->category_hash = category_hash;
        elem->hash = hash;
        elem->color[0] = r;
        elem->color[1] = g;
@@ -1090,14 +1092,16 @@ void BKE_sim_debug_data_add_dot(struct SimDebugData 
*debug_data, const float p[3
        debug_data_insert(debug_data, elem);
 }
 
-void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float 
p1[3], const float p2[3], float r, float g, float b, int hash)
+void BKE_sim_debug_data_add_line(struct SimDebugData *debug_data, const float 
p1[3], const float p2[3], float r, float g, float b, const char *category, int 
hash)
 {
+       int category_hash = (int)BLI_ghashutil_strhash_p(category);
        SimDebugElement *elem;
        if (!debug_data)
                return;
        
        elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
        elem->type = SIM_DEBUG_ELEM_LINE;
+       elem->category_hash = category_hash;
        elem->hash = hash;
        elem->color[0] = r;
        elem->color[1] = g;
@@ -1108,14 +1112,16 @@ void BKE_sim_debug_data_add_line(struct SimDebugData 
*debug_data, const float p1
        debug_data_insert(debug_data, elem);
 }
 
-void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const 
float p[3], const float d[3], float r, float g, float b, int hash)
+void BKE_sim_debug_data_add_vector(struct SimDebugData *debug_data, const 
float p[3], const float d[3], float r, float g, float b, const char *category, 
int hash)
 {
+       int category_hash = (int)BLI_ghashutil_strhash_p(category);
        SimDebugElement *elem;
        if (!debug_data)
                return;
        
        elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
        elem->type = SIM_DEBUG_ELEM_VECTOR;
+       elem->category_hash = category_hash;
        elem->hash = hash;
        elem->color[0] = r;
        elem->color[1] = g;
@@ -1145,6 +1151,26 @@ void BKE_sim_debug_data_clear(SimDebugData *debug_data)
                BLI_ghash_clear(debug_data->gh, NULL, debug_element_free);
 }
 
+void BKE_sim_debug_data_clear_category(SimDebugData *debug_data, const char 
*category)
+{
+       int category_hash = (int)BLI_ghashutil_strhash_p(category);
+       
+       if (!debug_data)
+               return;
+       
+       if (debug_data->gh) {
+               GHashIterator iter;
+               BLI_ghashIterator_init(&iter, debug_data->gh);
+               while(!BLI_ghashIterator_done(&iter)) {
+                       SimDebugElement *elem = 
BLI_ghashIterator_getValue(&iter);
+                       BLI_ghashIterator_step(&iter); /* removing invalidates 
the current iterator, so step before removing */
+                       
+                       if (elem->category_hash == category_hash)
+                               BLI_ghash_remove(debug_data->gh, elem, NULL, 
debug_element_free);
+               }
+       }
+}
+
 void BKE_sim_debug_data_free(SimDebugData *debug_data)
 {
        if (!debug_data)
diff --git a/source/blender/blenkernel/intern/implicit.c 
b/source/blender/blenkernel/intern/implicit.c
index 7113063..aa09d39 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -2153,6 +2153,8 @@ int implicit_solver(Object *ob, float frame, 
ClothModifierData *clmd, ListBase *
        /*float (*initial_cos)[3] = 
MEM_callocN(sizeof(float)*3*cloth->numverts, "initial_cos implicit.c");*/ /* 
UNUSED */
        Implicit_Data *id = cloth->implicit;
 
+       BKE_sim_debug_data_clear_category(clmd->debug_data, "collision");
+
        if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal 
stuff */
                
                /* Update vertex constraints for pinned vertices */
@@ -2169,7 +2171,7 @@ int implicit_solver(Object *ob, float frame, 
ClothModifierData *clmd, ListBase *
        
        if (clmd->debug_data) {
                for (i = 0; i < numverts; i++) {
-                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
verts[i].x, 1.0f, 0.1f, 1.0f, hash_vertex(583, i));
+                       BKE_sim_debug_data_add_dot(clmd->debug_data, 
verts[i].x, 1.0f, 0.1f, 1.0f, "points", hash_vertex(583, i));
                }
        }

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

Reply via email to