GPv3: Cyclical set operator #111904
@ -23,8 +23,7 @@
|
||||
|
||||
namespace blender::ed::curves {
|
||||
|
||||
static IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves,
|
||||
IndexMaskMemory &memory)
|
||||
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
|
||||
{
|
||||
const IndexRange curves_range = curves.curves_range();
|
||||
const bke::AttributeAccessor attributes = curves.attributes();
|
||||
|
@ -951,39 +951,35 @@ static int grease_pencil_cyclical_set_exec(bContext *C, wmOperator *op)
|
||||
if (curves.points_num() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ed::curves::has_anything_selected(curves)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MutableSpan<bool> cyclic = curves.cyclic_for_write();
|
||||
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
|
||||
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
|
||||
".selection", ATTR_DOMAIN_POINT, true);
|
||||
|
||||
threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) {
|
||||
for (const int curve_i : range) {
|
||||
if (!ed::curves::has_anything_selected(selection, points_by_curve[curve_i])) {
|
||||
continue;
|
||||
}
|
||||
IndexMaskMemory memory;
|
||||
casey-bianco-davis marked this conversation as resolved
Outdated
|
||||
const IndexMask curve_selection = ed::curves::retrieve_selected_curves(curves, memory);
|
||||
|
||||
if (mode == CyclicalMode::CLOSE) {
|
||||
cyclic[curve_i] = true;
|
||||
}
|
||||
else if (mode == CyclicalMode::OPEN) {
|
||||
cyclic[curve_i] = false;
|
||||
}
|
||||
else if (mode == CyclicalMode::TOGGLE) {
|
||||
cyclic[curve_i] ^= true;
|
||||
}
|
||||
curve_selection.foreach_index([&](const int64_t curve_i) {
|
||||
if (mode == CyclicalMode::CLOSE) {
|
||||
cyclic[curve_i] = true;
|
||||
}
|
||||
else if (mode == CyclicalMode::OPEN) {
|
||||
cyclic[curve_i] = false;
|
||||
}
|
||||
else if (mode == CyclicalMode::TOGGLE) {
|
||||
cyclic[curve_i] ^= true;
|
||||
}
|
||||
});
|
||||
|
||||
if (add_geometry) {
|
||||
IndexMaskMemory memory;
|
||||
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
|
||||
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
|
||||
".selection", ATTR_DOMAIN_POINT, true);
|
||||
IndexMaskMemory memory2;
|
||||
/* Determine which curves are now closed. */
|
||||
const IndexMask curves_to_close = IndexMask::from_predicate(
|
||||
curves.curves_range(), GrainSize(512), memory, [&](const int64_t curve_i) {
|
||||
curves.curves_range(), GrainSize(512), memory2, [&](const int64_t curve_i) {
|
||||
const bool selected = ed::curves::has_anything_selected(selection,
|
||||
points_by_curve[curve_i]);
|
||||
return cyclic[curve_i] && selected;
|
||||
|
@ -134,6 +134,7 @@ bool has_anything_selected(const VArray<bool> &varray, IndexRange range_to_check
|
||||
* Find curves that have any point selected (a selection factor greater than zero),
|
||||
* or curves that have their own selection factor greater than zero.
|
||||
*/
|
||||
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory);
|
||||
IndexMask retrieve_selected_curves(const Curves &curves_id, IndexMaskMemory &memory);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user
I think it would be better to use
retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
and then do aIndexMask.foreach_index(...)
.