Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-04-17 21:53:20 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-17 21:53:40 +0400
commit169f8313940e826587fc50b3c4e3b082d15b51e5 (patch)
tree97e968ed2f30d326530d7a666fea3f49b1adc37b /source/blender/blenkernel/intern/pbvh_bmesh.c
parentfe3eb825206c969a2cf333769e6b58f2abec74b1 (diff)
Make sure we invalidate the node ID layer each time the PBVH is reset.
It makes code more tidy (avoids having to call invalidation on a myriad places). Also makes sure other invalidation cases (some mesh change, e.g.) work as expected.
Diffstat (limited to 'source/blender/blenkernel/intern/pbvh_bmesh.c')
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index d316cbba86b..e2e4592403c 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1143,6 +1143,26 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
/***************************** Public API *****************************/
+static void pbvh_bmesh_node_layers_reset(PBVH *bvh)
+{
+ BMFace *f;
+ BMVert *v;
+ BMIter iter;
+ BMesh *bm = bvh->bm;
+ int cd_vert_node_offset = bvh->cd_vert_node_offset;
+ int cd_face_node_offset = bvh->cd_face_node_offset;
+
+ /* clear the elements of the node information */
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ BM_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
+ }
+
+ BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
+ BM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
+ }
+}
+
+
/* Build a PBVH from a BMesh */
void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log,
const int cd_vert_node_offset, const int cd_face_node_offset)
@@ -1167,6 +1187,8 @@ void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, bool smooth_shading, BMLog *log,
if (smooth_shading)
bvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
+ pbvh_bmesh_node_layers_reset(bvh);
+
/* Start with all faces in the root node */
n = bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
bvh->totnode = 1;