diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 949e7d056aa..f6a9c12634d 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -319,8 +319,6 @@ Span node_face_indices_calc_grids(const PBVH &pbvh, const PBVHNode &node, V } // namespace blender::bke::pbvh -blender::Vector BKE_pbvh_node_calc_face_indices(const PBVH &pbvh, const PBVHNode &node); - blender::Bounds BKE_pbvh_node_get_BB(const PBVHNode *node); blender::Bounds BKE_pbvh_node_get_original_BB(const PBVHNode *node); diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 21af091b062..41397dbcbc3 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -1834,26 +1834,6 @@ Span node_face_indices_calc_grids(const PBVH &pbvh, const PBVHNode &node, V } // namespace blender::bke::pbvh -blender::Vector BKE_pbvh_node_calc_face_indices(const PBVH &pbvh, const PBVHNode &node) -{ - using namespace blender::bke::pbvh; - Vector faces; - switch (pbvh.header.type) { - case PBVH_FACES: { - node_face_indices_calc_mesh(pbvh, node, faces); - break; - } - case PBVH_GRIDS: { - node_face_indices_calc_grids(pbvh, node, faces); - break; - } - case PBVH_BMESH: - BLI_assert_unreachable(); - break; - } - return faces; -} - int BKE_pbvh_node_num_unique_verts(const PBVH &pbvh, const PBVHNode &node) { switch (pbvh.header.type) { diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 8bf3fb12bd9..960c3392ab8 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -539,7 +539,7 @@ static void clear_face_sets(Object &object, const Span nodes) Vector &face_indices = all_face_indices.local(); for (PBVHNode *node : nodes.slice(range)) { const Span faces = - (BKE_pbvh_type(&pbvh) == PBVH_FACES) ? + BKE_pbvh_type(&pbvh) == PBVH_FACES ? bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, face_indices) : bke::pbvh::node_face_indices_calc_grids(pbvh, *node, face_indices); if (std::any_of(faces.begin(), faces.end(), [&](const int face) { @@ -1000,7 +1000,7 @@ static void face_hide_update(Object &object, TLS &tls = all_tls.local(); for (PBVHNode *node : nodes.slice(range)) { const Span faces = - (BKE_pbvh_type(&pbvh) == PBVH_FACES) ? + BKE_pbvh_type(&pbvh) == PBVH_FACES ? bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, tls.face_indices) : bke::pbvh::node_face_indices_calc_grids(pbvh, *node, tls.face_indices); @@ -1686,12 +1686,22 @@ static void face_set_gesture_apply_mesh(gesture::GestureData &gesture_data, const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); bke::SpanAttributeWriter face_sets = face_set::ensure_face_sets_mesh(object); + struct TLS { + Vector face_indices; + }; + + threading::EnumerableThreadSpecific all_tls; threading::parallel_for(gesture_data.nodes.index_range(), 1, [&](const IndexRange range) { + TLS &tls = all_tls.local(); for (PBVHNode *node : nodes.slice(range)) { undo::push_node(gesture_data.vc.obact, node, undo::Type::FaceSet); + const Span node_faces = + BKE_pbvh_type(&pbvh) == PBVH_FACES ? + bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, tls.face_indices) : + bke::pbvh::node_face_indices_calc_grids(pbvh, *node, tls.face_indices); bool any_updated = false; - for (const int face : BKE_pbvh_node_calc_face_indices(pbvh, *node)) { + for (const int face : node_faces) { if (!hide_poly.is_empty() && hide_poly[face]) { continue; } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 88208815fc3..40f05790512 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -1213,7 +1213,12 @@ static Node *alloc_node(Object *ob, PBVHNode *node, Type type) } if (need_faces) { - unode->face_indices = BKE_pbvh_node_calc_face_indices(*ss->pbvh, *node); + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + bke::pbvh::node_face_indices_calc_mesh(*ss->pbvh, *node, unode->face_indices); + } + else { + bke::pbvh::node_face_indices_calc_grids(*ss->pbvh, *node, unode->face_indices); + } usculpt->undo_size += unode->face_indices.as_span().size_in_bytes(); }