diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-18 22:56:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-18 22:56:24 +0300 |
commit | 7536abbe16bd8672ca38e2b866f9a9585d054713 (patch) | |
tree | 0989cabe13fe970eb8b14cdf84ea943bf6aba746 /source/blender/blenkernel | |
parent | cf56b8be37c071f7d7fa22e3ab84029f4c895863 (diff) |
Curves: Port Curve to Points node to the new data-block
This is the last node to use the `CurveEval` type. Since the curve to
points node is basically the same as the resample node, now it just
reuses the resample code and moves the curve point `CustomData` to a
new point cloud at the end. I had to add support for sampling tangents
and normals to the resampling.
There is one behavior change: If the radius attribute doesn't exist,
the node won't set the radius to 1 for the output point cloud anymore.
Instead, the default radius for point clouds will be used.
That issue was similar to T99814.
Differential Revision: https://developer.blender.org/D16008
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_curves_utils.hh | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curves_utils.cc | 15 |
2 files changed, 32 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_curves_utils.hh b/source/blender/blenkernel/BKE_curves_utils.hh index 7d81847f4c1..f9155023db7 100644 --- a/source/blender/blenkernel/BKE_curves_utils.hh +++ b/source/blender/blenkernel/BKE_curves_utils.hh @@ -326,8 +326,8 @@ void copy_point_data(const CurvesGeometry &src_curves, template<typename T> void copy_point_data(const CurvesGeometry &src_curves, const CurvesGeometry &dst_curves, - const IndexMask src_curve_selection, - const Span<T> src, + IndexMask src_curve_selection, + Span<T> src, MutableSpan<T> dst) { copy_point_data(src_curves, dst_curves, src_curve_selection, GSpan(src), GMutableSpan(dst)); @@ -340,13 +340,27 @@ void fill_points(const CurvesGeometry &curves, template<typename T> void fill_points(const CurvesGeometry &curves, - const IndexMask curve_selection, + IndexMask curve_selection, const T &value, MutableSpan<T> dst) { fill_points(curves, curve_selection, &value, dst); } +void fill_points(const CurvesGeometry &curves, + Span<IndexRange> curve_ranges, + GPointer value, + GMutableSpan dst); + +template<typename T> +void fill_points(const CurvesGeometry &curves, + Span<IndexRange> curve_ranges, + const T &value, + MutableSpan<T> dst) +{ + fill_points(curves, curve_ranges, &value, dst); +} + /** * Copy only the information on the point domain, but not the offsets or any point attributes, * meant for operations that change the number of points but not the number of curves. diff --git a/source/blender/blenkernel/intern/curves_utils.cc b/source/blender/blenkernel/intern/curves_utils.cc index d98832e796c..f5a69a995a3 100644 --- a/source/blender/blenkernel/intern/curves_utils.cc +++ b/source/blender/blenkernel/intern/curves_utils.cc @@ -84,6 +84,21 @@ void fill_points(const CurvesGeometry &curves, }); } +void fill_points(const CurvesGeometry &curves, + Span<IndexRange> curve_ranges, + GPointer value, + GMutableSpan dst) +{ + BLI_assert(*value.type() == dst.type()); + const CPPType &type = dst.type(); + threading::parallel_for(curve_ranges.index_range(), 512, [&](IndexRange range) { + for (const IndexRange range : curve_ranges.slice(range)) { + const IndexRange points = curves.points_for_curves(range); + type.fill_assign_n(value.get(), dst.slice(points).data(), points.size()); + } + }); +} + bke::CurvesGeometry copy_only_curve_domain(const bke::CurvesGeometry &src_curves) { bke::CurvesGeometry dst_curves(0, src_curves.curves_num()); |