[Bf-blender-cvs] [22e9f4f] master: Sculpt: dyntopo, avoid redundant gset remove calls
Campbell Barton
noreply at git.blender.org
Tue Oct 7 20:26:42 CEST 2014
Commit: 22e9f4f838fb4f53bafdc05ab88f6aba3405e167
Author: Campbell Barton
Date: Tue Oct 7 19:32:48 2014 +0200
Branches: master
https://developer.blender.org/rB22e9f4f838fb4f53bafdc05ab88f6aba3405e167
Sculpt: dyntopo, avoid redundant gset remove calls
===================================================================
M source/blender/blenkernel/intern/pbvh_bmesh.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 1a0ddac..8940b13 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -274,15 +274,20 @@ static bool pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
/**********************************************************************/
-static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, void *key, const int cd_node_offset)
+static int pbvh_bmesh_node_lookup_index(PBVH *bvh, void *key, const int cd_node_offset)
{
int node_index = BM_ELEM_CD_GET_INT((BMElem *)key, cd_node_offset);
BLI_assert(node_index != DYNTOPO_NODE_NONE);
-
BLI_assert(node_index < bvh->totnode);
+ (void)bvh;
- return &bvh->nodes[node_index];
+ return node_index;
+}
+
+static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, void *key, const int cd_node_offset)
+{
+ return &bvh->nodes[pbvh_bmesh_node_lookup_index(bvh, key, cd_node_offset)];
}
static BMVert *pbvh_bmesh_vert_create(PBVH *bvh, int node_index,
@@ -406,14 +411,25 @@ static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v, const int cd_vert_node_
BMIter bm_iter;
BMFace *f;
+ /* never match for first time */
+ int f_node_index_prev = DYNTOPO_NODE_NONE;
+
v_node = pbvh_bmesh_node_lookup(bvh, v, cd_vert_node_offset);
BLI_gset_remove(v_node->bm_unique_verts, v, NULL);
BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
/* Have to check each neighboring face's node */
BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
- PBVHNode *f_node = pbvh_bmesh_node_lookup(bvh, f, cd_face_node_offset);
+ const int f_node_index = pbvh_bmesh_node_lookup_index(bvh, f, cd_face_node_offset);
+ PBVHNode *f_node;
+
+ /* faces often share the same node,
+ * quick check to avoid redundant #BLI_gset_remove calls */
+ if (f_node_index_prev == f_node_index)
+ continue;
+ f_node_index_prev = f_node_index;
+ f_node = &bvh->nodes[f_node_index];
f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB;
/* Remove current ownership */
More information about the Bf-blender-cvs
mailing list