diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-08-21 19:21:56 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-08-21 19:21:56 +0400 |
commit | dcddd32c4553d5096f376434cd426f987ec3dd2e (patch) | |
tree | 4ce64a772e1bc8e0996317c8747284f8f14a1511 | |
parent | fca659252f56d3487cf64fe702cb96c379cc89c6 (diff) |
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.
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 205159c94a1..4f8536e8962 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -229,9 +229,10 @@ void pbvh_grow_nodes(PBVH *bvh, int totnode) 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); } diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index c9b68931142..bc2a47a540b 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -365,7 +365,6 @@ static void pbvh_bmesh_vert_ownership_transfer(PBVH *bvh, PBVHNode *new_owner, 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 @@ static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v) 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 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode) } /* 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; } |