From 0ffb96f701176fe5b3eb03bd90414ed7fd4502cf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 28 Sep 2019 19:15:06 +0200 Subject: Sculpt: minor optimizations for GPU draw buffer filling Ref T70295 --- source/blender/blenkernel/intern/pbvh.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern/pbvh.c') diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 781e7b712d6..c920b80d818 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2260,19 +2260,21 @@ void BKE_pbvh_update_normals(PBVH *bvh, struct SubdivCCG *subdiv_ccg) BKE_pbvh_search_gather( bvh, update_search_cb, POINTER_FROM_INT(PBVH_UpdateNormals), &nodes, &totnode); - if (bvh->type == PBVH_BMESH) { - pbvh_bmesh_normals_update(nodes, totnode); - } - else if (bvh->type == PBVH_FACES) { - pbvh_faces_update_normals(bvh, nodes, totnode); - } - else if (bvh->type == PBVH_GRIDS) { - struct CCGFace **faces; - int num_faces; - BKE_pbvh_get_grid_updates(bvh, true, (void ***)&faces, &num_faces); - if (num_faces > 0) { - BKE_subdiv_ccg_update_normals(subdiv_ccg, faces, num_faces); - MEM_freeN(faces); + if (totnode > 0) { + if (bvh->type == PBVH_BMESH) { + pbvh_bmesh_normals_update(nodes, totnode); + } + else if (bvh->type == PBVH_FACES) { + pbvh_faces_update_normals(bvh, nodes, totnode); + } + else if (bvh->type == PBVH_GRIDS) { + struct CCGFace **faces; + int num_faces; + BKE_pbvh_get_grid_updates(bvh, true, (void ***)&faces, &num_faces); + if (num_faces > 0) { + BKE_subdiv_ccg_update_normals(subdiv_ccg, faces, num_faces); + MEM_freeN(faces); + } } } -- cgit v1.2.3