GPv3: Cyclical set operator #111904

Merged
Falk David merged 16 commits from casey-bianco-davis/blender:GPv3-cyclical-set-operator into main 2023-10-20 10:12:34 +02:00
3 changed files with 17 additions and 11 deletions
Showing only changes of commit 441ae81f88 - Show all commits

View File

@ -179,6 +179,7 @@ void copy_group_to_group(OffsetIndices<int> src_offsets,
void count_indices(Span<int> indices, MutableSpan<int> counts);
void invert_booleans(MutableSpan<bool> span);
void invert_booleans(MutableSpan<bool> span, const IndexMask &mask);
enum class BooleanMix {
None,

View File

@ -85,6 +85,11 @@ void invert_booleans(MutableSpan<bool> span)
});
}
void invert_booleans(MutableSpan<bool> span, const IndexMask &mask)
{
mask.foreach_index_optimized<int64_t>([&](const int64_t i) { span[i] = !span[i]; });
}
BooleanMix booleans_mix_calc(const VArray<bool> &varray, const IndexRange range_to_check)
{
if (varray.is_empty()) {

View File

@ -846,17 +846,17 @@ static int grease_pencil_cyclical_set_exec(bContext *C, wmOperator *op)
IndexMaskMemory memory;
const IndexMask curve_selection = ed::curves::retrieve_selected_curves(curves, memory);
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;
}
});
switch (mode) {
case CyclicalMode::CLOSE:
casey-bianco-davis marked this conversation as resolved Outdated
switch (mode) {
  case CyclicalMode::CLOSE:
    index_mask::masked_fill(cyclic, true, curve_selection);
    break;
  case CyclicalMode::OPEN:
    index_mask::masked_fill(cyclic, false, curve_selection);
    break;
  case CyclicalMode::TOGGLE:
    array_utils::invert_booleans(cyclic, curve_selection);
    break;
}
``` switch (mode) { case CyclicalMode::CLOSE: index_mask::masked_fill(cyclic, true, curve_selection); break; case CyclicalMode::OPEN: index_mask::masked_fill(cyclic, false, curve_selection); break; case CyclicalMode::TOGGLE: array_utils::invert_booleans(cyclic, curve_selection); break; } ```
index_mask::masked_fill(cyclic, true, curve_selection);
break;
case CyclicalMode::OPEN:
index_mask::masked_fill(cyclic, false, curve_selection);
break;
case CyclicalMode::TOGGLE:
array_utils::invert_booleans(cyclic, curve_selection);
break;
}
changed = true;
});