diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-24 20:17:22 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-24 20:22:26 +0300 |
commit | 4c66bd5da256779ef5a308d86abfe9b88f4a039b (patch) | |
tree | dae4da78ad582b11769e5c26ca81ff88389d8ec4 /source/blender/blenkernel/intern/geometry_component_curve.cc | |
parent | f4d80ecdfd3137693f7c00c4d3db6f9f8743a6bd (diff) |
Curves: Use simpler "set" behavior for postion attribute
This is similar to f8fe0e831ec14cc521e03df, which made the change to the
handle position attributes. This commit removes the way that setting the
`position` attribute also changes the handle position attributes. Now,
the "Set Position" node still has this behavior, but changing the
attribute directly (with the modifier's output attributes) does not.
The previous behavior was a relic of the geometry nodes design
from before fields and the set position node existed.
This makes the transition to the new curves data structure simpler.
There is more room for optimizing the Bezier case of the set position
node in the future.
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_curve.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_curve.cc | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index 9116ffc63a8..c22b6ff07ec 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -880,15 +880,7 @@ class VArrayImpl_For_SplinePosition final : public VMutableArrayImpl<float3> { { const PointIndices indices = lookup_point_indices(offsets_, index); Spline &spline = *splines_[indices.spline_index]; - if (BezierSpline *bezier_spline = dynamic_cast<BezierSpline *>(&spline)) { - const float3 delta = value - bezier_spline->positions()[indices.point_index]; - bezier_spline->handle_positions_left()[indices.point_index] += delta; - bezier_spline->handle_positions_right()[indices.point_index] += delta; - bezier_spline->positions()[indices.point_index] = value; - } - else { - spline.positions()[indices.point_index] = value; - } + spline.positions()[indices.point_index] = value; } void set_all(Span<float3> src) final @@ -897,20 +889,7 @@ class VArrayImpl_For_SplinePosition final : public VMutableArrayImpl<float3> { Spline &spline = *splines_[spline_index]; const int offset = offsets_[spline_index]; const int next_offset = offsets_[spline_index + 1]; - if (BezierSpline *bezier_spline = dynamic_cast<BezierSpline *>(&spline)) { - MutableSpan<float3> positions = bezier_spline->positions(); - MutableSpan<float3> handle_positions_left = bezier_spline->handle_positions_left(); - MutableSpan<float3> handle_positions_right = bezier_spline->handle_positions_right(); - for (const int i : IndexRange(next_offset - offset)) { - const float3 delta = src[offset + i] - positions[i]; - handle_positions_left[i] += delta; - handle_positions_right[i] += delta; - positions[i] = src[offset + i]; - } - } - else { - spline.positions().copy_from(src.slice(offset, next_offset - offset)); - } + spline.positions().copy_from(src.slice(offset, next_offset - offset)); } } |