Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-09-02 16:10:28 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:29:56 +0300
commitd43f7608923bb3ff84c5eed0631d0457d68416e0 (patch)
tree3c25a4b22faad9ab37832f69723cf05b284610b1 /source/blender/blenkernel
parent70df8f8dd6aae2b861852acf7b758b3224623504 (diff)
Hair debugging: use "categories" (strings) for grouping debug elements
and support clearing for categories.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_effect.h11
-rw-r--r--source/blender/blenkernel/intern/collision.c16
-rw-r--r--source/blender/blenkernel/intern/effect.c32
-rw-r--r--source/blender/blenkernel/intern/implicit.c4
4 files changed, 44 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 852f9de4c09..04853bbb163 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 4f92fdab739..c421296e4eb 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 0cbd7376e4f..82c3ed847a9 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1070,14 +1070,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;
@@ -1087,14 +1089,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;
@@ -1105,14 +1109,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;
@@ -1142,6 +1148,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 d0f0bc9455a..45f210fd89d 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1959,6 +1959,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 */
@@ -1975,7 +1977,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));
}
}