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