From 189fc24f1a96cc7ff2b6d2cd0052e4eeee97df8d Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 24 Jul 2023 14:07:44 -0400 Subject: [PATCH] Cleanup: Simplify removing curves in GP erasor stroke mode Avoid the initial copy, and avoid moving from a const reference. --- .../editors/sculpt_paint/grease_pencil_erase.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc index 07034a569dd..c397c2d939e 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc @@ -455,7 +455,7 @@ struct EraseOperationExecutor { const VArray src_cyclic = src.cyclic(); IndexMaskMemory memory; - IndexMask strokes_to_remove = IndexMask::from_predicate( + const IndexMask strokes_to_keep = IndexMask::from_predicate( src.curves_range(), GrainSize(256), memory, [&](const int64_t src_curve) { const IndexRange src_curve_points = src_points_by_curve[src_curve]; @@ -467,7 +467,7 @@ struct EraseOperationExecutor { screen_space_positions[src_point], screen_space_positions[src_point + 1]); if (dist_to_eraser < this->eraser_radius) { - return true; + return false; } } @@ -477,20 +477,18 @@ struct EraseOperationExecutor { screen_space_positions[src_curve_points.first()], screen_space_positions[src_curve_points.last()]); if (dist_to_eraser < this->eraser_radius) { - return true; + return false; } } - return false; + return true; }); - if (strokes_to_remove.size() == 0) { + if (strokes_to_keep.size() == src.curves_num()) { return false; } - dst = std::move(src); - dst.remove_curves(strokes_to_remove); - + dst = bke::curves_copy_curve_selection(src, strokes_to_keep, {}); return true; }