From 756dea7ca1ec31df6ac40e1efc35dd76571bf457 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 1 Nov 2023 18:20:43 +0100 Subject: [PATCH] Cleanup: PBVH: Remove redundant storage of face set metadata These two values are already stored in the mesh, and they have no relation to the PBVH's goal as an acceleration structure. Similar to a6a2af5fdd89793d2fdb, remove the values from the PBVH and just access them from the mesh as necessary. Pair-reviewed in person with Sergey --- source/blender/blenkernel/BKE_pbvh_api.hh | 2 -- source/blender/blenkernel/intern/paint.cc | 2 -- source/blender/blenkernel/intern/pbvh.cc | 13 ++----------- source/blender/blenkernel/intern/pbvh_intern.hh | 2 -- .../blender/editors/sculpt_paint/sculpt_face_set.cc | 9 --------- 5 files changed, 2 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index f1473b8c1c4..e394975a494 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -470,8 +470,6 @@ void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets); */ void BKE_pbvh_update_hide_attributes_from_mesh(PBVH *pbvh); -void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default); - /* Vertex Deformer. */ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], int totvert); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 7868288b442..8b4405fc6de 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1756,8 +1756,6 @@ static void sculpt_update_object( BKE_pbvh_face_sets_set(ss->pbvh, ss->face_sets); BKE_pbvh_update_hide_attributes_from_mesh(ss->pbvh); - BKE_pbvh_face_sets_color_set(ss->pbvh, me->face_sets_color_seed, me->face_sets_color_default); - sculpt_attribute_update_refs(ob); sculpt_update_persistent_base(ob); diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index e7d5e772078..53cb0dda42a 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -665,8 +665,8 @@ static void pbvh_draw_args_init(const Mesh &mesh, PBVH *pbvh, PBVH_GPU_Args *arg args->node = node; args->grid_hidden = pbvh->grid_hidden; - args->face_sets_color_default = pbvh->face_sets_color_default; - args->face_sets_color_seed = pbvh->face_sets_color_seed; + args->face_sets_color_default = mesh.face_sets_color_default; + args->face_sets_color_seed = mesh.face_sets_color_seed; args->vert_positions = pbvh->vert_positions; if (pbvh->mesh) { args->corner_verts = pbvh->corner_verts; @@ -851,9 +851,6 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh) pbvh->faces_num = mesh->faces_num; - pbvh->face_sets_color_seed = mesh->face_sets_color_seed; - pbvh->face_sets_color_default = mesh->face_sets_color_default; - /* For each face, store the AABB and the AABB centroid */ blender::Array prim_bbc(looptri_num); BB cb; @@ -2852,12 +2849,6 @@ void BKE_pbvh_update_normals(PBVH *pbvh, SubdivCCG *subdiv_ccg) } } -void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default) -{ - pbvh->face_sets_color_seed = seed; - pbvh->face_sets_color_default = color_default; -} - /** * PBVH drawing, updating draw buffers as needed and culling any nodes outside * the specified frustum. diff --git a/source/blender/blenkernel/intern/pbvh_intern.hh b/source/blender/blenkernel/intern/pbvh_intern.hh index 3c213b8c202..67c3062faa0 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.hh +++ b/source/blender/blenkernel/intern/pbvh_intern.hh @@ -177,8 +177,6 @@ struct PBVH { CustomData *loop_data; CustomData *face_data; - int face_sets_color_seed; - int face_sets_color_default; int *face_sets; /* Grid Data */ diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 030a26a4462..9466cb690a1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -400,12 +400,6 @@ void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, Span nod SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - if (ss->pbvh) { - Mesh *mesh = BKE_mesh_from_object(ob); - BKE_pbvh_face_sets_color_set( - ss->pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); - } - BKE_curvemapping_init(brush->curve); TaskParallelSettings settings; @@ -534,8 +528,6 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) if (all_visible) { mesh->face_sets_color_default = next_face_set; - BKE_pbvh_face_sets_color_set( - ss->pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); } for (int i = 0; i < tot_vert; i++) { @@ -1110,7 +1102,6 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator * /*op max_ii(0, ss->totfaces - 1)); mesh->face_sets_color_default = ss->face_sets[random_index]; } - BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); Vector nodes = blender::bke::pbvh::search_gather(pbvh, {}); for (PBVHNode *node : nodes) {