[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59368] trunk/blender/source/blender/ blenkernel/intern: Scultping: Growing the pbvh node container should use malloc instead of

Antony Riakiotakis kalast at gmail.com
Wed Aug 21 17:21:57 CEST 2013


Revision: 59368
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59368
Author:   psy-fi
Date:     2013-08-21 15:21:56 +0000 (Wed, 21 Aug 2013)
Log Message:
-----------
Scultping: Growing the pbvh node container should use malloc instead of
calloc. Since we copy the first 1/1.3 part of the new array from the
existing nodes, only the rest 0.3/1.3 should be initialized to zero.
This should in theory cut down the times of occasional hangs with
dyntopo, since my guess is that it is caused by dynamic reallocations.
Maybe a linked list structure would help here? This is a bigger change
though, leaving as is for now.

Also, minor cleanup, delete duplicate ghash deletion and remove unneeded
commented code.

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

Modified: trunk/blender/source/blender/blenkernel/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh.c	2013-08-21 14:53:38 UTC (rev 59367)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh.c	2013-08-21 15:21:56 UTC (rev 59368)
@@ -229,9 +229,10 @@
 		bvh->node_mem_count *= 1.33;
 		if (bvh->node_mem_count < totnode)
 			bvh->node_mem_count = totnode;
-		bvh->nodes = MEM_callocN(sizeof(PBVHNode) * bvh->node_mem_count,
+		bvh->nodes = MEM_mallocN(sizeof(PBVHNode) * bvh->node_mem_count,
 		                         "bvh nodes");
 		memcpy(bvh->nodes, prev, bvh->totnode * sizeof(PBVHNode));
+		memset(bvh->nodes + bvh->totnode, 0, (bvh->node_mem_count - bvh->totnode) * sizeof(PBVHNode));
 		MEM_freeN(prev);
 	}
 

Modified: trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c	2013-08-21 14:53:38 UTC (rev 59367)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c	2013-08-21 15:21:56 UTC (rev 59368)
@@ -365,7 +365,6 @@
 	BLI_assert(current_owner != new_owner);
 
 	/* Remove current ownership */
-	// BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);  // assign handles below
 	BLI_ghash_remove(current_owner->bm_unique_verts, v, NULL, NULL);
 
 	/* Set new ownership */
@@ -384,7 +383,6 @@
 
 	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);
 
@@ -1036,7 +1034,7 @@
 			}
 			/* This should be unneeded normally */
 			GHASH_ITER (gh_iter, node->bm_other_verts) {
-			BM_vert_normal_update(BLI_ghashIterator_getKey(&gh_iter));
+				BM_vert_normal_update(BLI_ghashIterator_getKey(&gh_iter));
 			}
 			node->flag &= ~PBVH_UpdateNormals;
 		}




More information about the Bf-blender-cvs mailing list