[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59306] trunk/blender/source/blender/ blenkernel/intern/pbvh_bmesh.c: Dyntopo:

Antony Riakiotakis kalast at gmail.com
Mon Aug 19 19:37:21 CEST 2013


Revision: 59306
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59306
Author:   psy-fi
Date:     2013-08-19 17:37:21 +0000 (Mon, 19 Aug 2013)
Log Message:
-----------
Dyntopo:

* Actually check if normal recalculation flags exists and set it when
splitting nodes in dyntopo. Right now, nodes that need GPU buffer update
will always get in the list to get their normals generated, but to avoid
a possible future breakage better do it right now.
* Avoid keeping deleted/removed vertices in vertex-to-node and unique
vertex hashes, since some checks rely on those and may go awry if these
still exist. Also they pollute the hashes, and may hurt performance
somewhat.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c

Modified: trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c	2013-08-19 15:02:28 UTC (rev 59305)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c	2013-08-19 17:37:21 UTC (rev 59306)
@@ -92,7 +92,7 @@
 	if (!G.background) {
 		int smooth = bvh->flags & PBVH_DYNTOPO_SMOOTH_SHADING;
 		n->draw_buffers = GPU_build_bmesh_buffers(smooth);
-		n->flag |= PBVH_UpdateDrawBuffers;
+		n->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
 	}
 }
 
@@ -386,6 +386,7 @@
 
 	BLI_assert(BLI_ghash_haskey(bvh->bm_vert_to_node, v));
 	v_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
+	BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
 	BLI_ghash_remove(v_node->bm_unique_verts, v, NULL, NULL);
 	BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
 
@@ -393,7 +394,9 @@
 	BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
 		PBVHNode *f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
 
-		BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
+		/* Remove current ownership */
+		/* Should be handled above by vert_to_node removal, leaving just in case - psy-fi */
+		//BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
 		BLI_ghash_remove(f_node->bm_other_verts, v, NULL, NULL);
 
 		BLI_assert(!BLI_ghash_haskey(f_node->bm_unique_verts, v));
@@ -426,6 +429,9 @@
 
 				if (new_node) {
 					pbvh_bmesh_vert_ownership_transfer(bvh, new_node, v);
+				} else {
+					BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
+					BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
 				}
 			}
 			else {
@@ -686,7 +692,7 @@
 		ni = GET_INT_FROM_POINTER(nip);
 
 		/* Ensure node gets redrawn */
-		bvh->nodes[ni].flag |= PBVH_UpdateDrawBuffers;
+		bvh->nodes[ni].flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
 
 		/* Find the vertex not in the edge */
 		v_opp = l_adj->prev->v;
@@ -1012,25 +1018,29 @@
 	return hit;
 }
 
+
 void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
 {
 	int n;
 
 	for (n = 0; n < totnode; n++) {
 		PBVHNode *node = nodes[n];
-		GHashIterator gh_iter;
 
-		GHASH_ITER (gh_iter, node->bm_faces) {
-			BM_face_normal_update(BLI_ghashIterator_getKey(&gh_iter));
-		}
-		GHASH_ITER (gh_iter, node->bm_unique_verts) {
+		if (node->flag & PBVH_UpdateNormals) {
+			GHashIterator gh_iter;
+
+			GHASH_ITER (gh_iter, node->bm_faces) {
+				BM_face_normal_update(BLI_ghashIterator_getKey(&gh_iter));
+			}
+			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;
 		}
-		/* 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;
 	}
 }
 




More information about the Bf-blender-cvs mailing list