From 2ba2efc29691762d3fb2002f54adafd536b2c37b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 2 Aug 2022 13:32:25 -0500 Subject: Cleanup: Simplify arguments to sculpt draw functions Instead of passing pointers to specific mesh data, rely on retrieving that data from the mesh internally. This makes it easier to support retrieving additional data from Mesh (like active attribute names in D15101 or D15169). It also makes the functions simpler conceptually, because they're drawing a mesh with an acceleration strcture on top. The BKE_id_attribute_copy_domains_temp call was unnecessary because the GPU_pbvh_mesh_buffers_update function was only called when Mesh/PBVH_FACES is used in the first place. Differential Revision: https://developer.blender.org/D15197 --- source/blender/blenkernel/intern/pbvh.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 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 ac3eac70c39..dae9788d21c 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1303,17 +1303,6 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, PBVH *pbvh = data->pbvh; PBVHNode *node = data->nodes[n]; - CustomData *vdata, *ldata; - - if (!pbvh->header.bm) { - vdata = pbvh->vdata; - ldata = pbvh->ldata; - } - else { - vdata = &pbvh->header.bm->vdata; - ldata = &pbvh->header.bm->ldata; - } - if (node->flag & PBVH_RebuildDrawBuffers) { switch (pbvh->header.type) { case PBVH_GRIDS: { @@ -1326,14 +1315,12 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, } case PBVH_FACES: node->draw_buffers = GPU_pbvh_mesh_buffers_build( - pbvh->mpoly, - pbvh->mloop, - pbvh->looptri, + pbvh->mesh, pbvh->verts, - node->prim_indices, + pbvh->looptri, CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS), - node->totprim, - pbvh->mesh); + node->prim_indices, + node->totprim); break; case PBVH_BMESH: node->draw_buffers = GPU_pbvh_bmesh_buffers_build(pbvh->flags & @@ -1360,11 +1347,12 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata, update_flags); break; case PBVH_FACES: { + /* Pass vertices separately because they may be not be the same as the mesh's vertices, + * and pass normals separately because they are managed by the PBVH. */ GPU_pbvh_mesh_buffers_update(pbvh->vbo_id, node->draw_buffers, + pbvh->mesh, pbvh->verts, - vdata, - ldata, CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK), CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS), pbvh->face_sets_color_seed, -- cgit v1.2.3