From 6f80980847b9f6172608d8067acf560d6d193c39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Mar 2014 01:48:16 +1100 Subject: Debug function to check valid bmesh now detects duplicate edges --- source/blender/bmesh/intern/bmesh_mesh_validate.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source/blender/bmesh') diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index e6eee16e49c..3a7a4f85e99 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -33,6 +33,7 @@ #ifdef DEBUG #include "BLI_utildefines.h" +#include "BLI_edgehash.h" #include "bmesh.h" @@ -53,6 +54,7 @@ */ bool BM_mesh_validate(BMesh *bm) { + EdgeHash *edge_hash = BLI_edgehash_new_ex(__func__, bm->totedge); int errtot; BMIter iter; @@ -84,8 +86,21 @@ bool BM_mesh_validate(BMesh *bm) /* check edges */ BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { - if (e->v1 == e->v2) - ERRMSG("edge %d: duplicate index: %d", i, BM_elem_index_get(e->v1)); + BMEdge *e_other; + + if (e->v1 == e->v2) { + ERRMSG("edge %d: duplicate index: %d", i, BM_elem_index_get(e->v1)); + } + + + /* build edgehash at the same time */ + e_other = BLI_edgehash_lookup(edge_hash, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2)); + if (e_other) { + ERRMSG("edge %d, %d: are duplicates", i, BM_elem_index_get(e_other)); + } + else { + BLI_edgehash_insert(edge_hash, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2), e); + } } /* edge radial structure */ @@ -177,7 +192,7 @@ bool BM_mesh_validate(BMesh *bm) } } - + BLI_edgehash_free(edge_hash, NULL); ERRMSG("Finished - errors %d", errtot); -- cgit v1.2.3