Curves: Add support for proportional editing #104620

Closed
Falk David wants to merge 15 commits from filedescriptor:curves-proportional-editing into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 11 additions and 13 deletions
Showing only changes of commit b9580ee13e - Show all commits

View File

@ -123,7 +123,7 @@ void fill_selection_true(GMutableSpan selection)
}
}
static bool contains(const VArray<bool> &varray, const bool value)
static bool contains(const VArray<bool> &varray, const IndexRange range_to_check, const bool value)
{
const CommonVArrayInfo info = varray.common_info();
if (info.type == CommonVArrayInfo::Type::Single) {
@ -132,7 +132,7 @@ static bool contains(const VArray<bool> &varray, const bool value)
if (info.type == CommonVArrayInfo::Type::Span) {
const Span<bool> span(static_cast<const bool *>(info.data), varray.size());
return threading::parallel_reduce(
span.index_range(),
range_to_check,
4096,
false,
[&](const IndexRange range, const bool init) {
@ -141,7 +141,7 @@ static bool contains(const VArray<bool> &varray, const bool value)
[&](const bool a, const bool b) { return a || b; });
}
return threading::parallel_reduce(
varray.index_range(),
range_to_check,
2048,
false,
[&](const IndexRange range, const bool init) {
@ -159,10 +159,15 @@ static bool contains(const VArray<bool> &varray, const bool value)
[&](const bool a, const bool b) { return a || b; });
}
bool has_anything_selected(const VArray<bool> &varray, const IndexRange range_to_check)
{
return contains(varray, range_to_check, true);
}
bool has_anything_selected(const bke::CurvesGeometry &curves)
{
const VArray<bool> selection = curves.attributes().lookup<bool>(".selection");
return !selection || contains(selection, true);
return !selection || contains(selection, curves.curves_range(), true);
}
bool has_anything_selected(const GSpan selection)

View File

@ -93,6 +93,7 @@ bool has_anything_selected(const bke::CurvesGeometry &curves);
* Return true if any element in the span is selected, on either domain with either type.
*/
bool has_anything_selected(GSpan selection);
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),

View File

@ -105,16 +105,8 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t)
".selection", ATTR_DOMAIN_POINT, true);
threading::parallel_for(curves.curves_range(), 512, [&](const IndexRange range) {
for (const int curve_i : range) {
bool has_any_selected = false;
const IndexRange points = points_by_curve[curve_i];
for (const int i : IndexRange(points.size())) {
const int point_i = points[i];
if (selection[point_i]) {
has_any_selected = true;
break;
}
}
const bool has_any_selected = ed::curves::has_anything_selected(selection, points);
if (!has_any_selected) {
for (const int point_i : points) {
TransData &td = tc.data[point_i];