diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-08-19 18:08:59 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-08-19 18:08:59 +0400 |
commit | 6f88dca9c34b70905930067055935dea18757fec (patch) | |
tree | 1d6fa82b3b13c8942128cdf0e7a3c98615c1b672 /source/blender/blenkernel | |
parent | cbfd2a8e62835544db750d8be834096e4e4f3a9d (diff) |
Dyntopo:
Turn off pbvh normal update flag after recalculation, saves
recalculating normals every frame when not stroking the mesh.
For this to work reliably with undo we need to support original normals
in the bm_log (was marked as a TODO already in the code), so that
undoing avoids having invalid normals in the mesh (since we don't update
every frame anymore). This was added in this commit as well.
Also added some (disabled) quite paranoid checks in the bmesh valication
code for dyntopo hoping to catch the real normal update issue. No luck
there yet.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index c70b1fd11bf..e5cbe64abc0 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -1026,9 +1026,11 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode) GHASH_ITER (gh_iter, node->bm_unique_verts) { BM_vert_normal_update(BLI_ghashIterator_getKey(&gh_iter)); } + /* This should be unneeded normally */ GHASH_ITER (gh_iter, node->bm_other_verts) { BM_vert_normal_update(BLI_ghashIterator_getKey(&gh_iter)); } + node->flag &= ~PBVH_UpdateNormals; } } @@ -1365,7 +1367,9 @@ void print_flag_factors(int flag) void pbvh_bmesh_verify(PBVH *bvh) { GHashIterator gh_iter; - int i; + int i, vert_count = 0; + BMIter iter; + BMVert *vi; /* Check faces */ BLI_assert(bvh->bm->totface == BLI_ghash_size(bvh->bm_face_to_node)); @@ -1431,8 +1435,37 @@ void pbvh_bmesh_verify(PBVH *bvh) } } BLI_assert(found); + + #if 0 + /* total freak stuff, check if node exists somewhere else */ + /* Slow */ + for (i = 0; i < bvh->totnode; i++) { + PBVHNode *n = &bvh->nodes[i]; + if (i != ni && n->bm_unique_verts) + BLI_assert(!BLI_ghash_haskey(n->bm_unique_verts, v)); + } + + #endif } + #if 0 + /* check that every vert belongs somewhere */ + /* Slow */ + BM_ITER_MESH (vi, &iter, bvh->bm, BM_VERTS_OF_MESH) { + bool has_unique = false; + for (i = 0; i < bvh->totnode; i++) { + PBVHNode *n = &bvh->nodes[i]; + if ((n->bm_unique_verts != NULL) && BLI_ghash_haskey(n->bm_unique_verts, vi)) + has_unique = true; + } + BLI_assert(has_unique); + vert_count++; + } + + /* if totvert differs from number of verts inside the hash. hash-totvert is checked above */ + BLI_assert(vert_count == bvh->bm->totvert); + #endif + /* Check that node elements are recorded in the top level */ for (i = 0; i < bvh->totnode; i++) { PBVHNode *n = &bvh->nodes[i]; |