Sculpt: Improve Expand performance #120125

Closed
Raul Fernandez Hernandez wants to merge 181 commits from farsthary/blender:improve-expand-perf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit afa8fbfd8e - Show all commits

View File

@ -609,24 +609,27 @@ void PAINT_OT_hide_show_all(wmOperatorType *ot)
static void invert_visibility_mesh(Object &object, const Span<PBVHNode *> nodes) static void invert_visibility_mesh(Object &object, const Span<PBVHNode *> nodes)
{ {
PBVH &pbvh = *object.sculpt->pbvh;
Mesh &mesh = *static_cast<Mesh *>(object.data); Mesh &mesh = *static_cast<Mesh *>(object.data);
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write(); bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>( bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>(
".hide_vert", bke::AttrDomain::Point); ".hide_poly", bke::AttrDomain::Face);
threading::EnumerableThreadSpecific<Vector<int>> all_index_data;
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
Vector<int> &faces = all_index_data.local();
for (PBVHNode *node : nodes.slice(range)) { for (PBVHNode *node : nodes.slice(range)) {
undo::push_node(&object, node, undo::Type::HideVert); undo::push_node(&object, node, undo::Type::HideFace);
for (const int vert : BKE_pbvh_node_get_unique_vert_indices(node)) { bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, faces);
hide_vert.span[vert] = !hide_vert.span[vert]; for (const int face : faces) {
hide_poly.span[face] = !hide_poly.span[face];
} }
BKE_pbvh_node_mark_update_visibility(node); BKE_pbvh_node_mark_update_visibility(node);
bke::pbvh::node_update_visibility_mesh(hide_vert.span, *node);
} }
}); });
hide_vert.finish(); hide_poly.finish();
bke::mesh_hide_vert_flush(mesh); bke::mesh_hide_face_flush(mesh);
} }
static void invert_visibility_grids(Depsgraph &depsgraph, static void invert_visibility_grids(Depsgraph &depsgraph,