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.
This commit is contained in:
Antony Riakiotakis
2013-08-21 15:21:56 +00:00
parent fca659252f
commit dcddd32c45
2 changed files with 3 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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;
}