Sculpt: Improve Expand performance #120125
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user