Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-06-08 16:37:46 +0300
committerHans Goudey <h.goudey@me.com>2022-06-08 16:37:46 +0300
commit9e393fc2f12583d32dddf00bad8174d2bb06b61d (patch)
treeb73ae3921fba6d76060ad484d2de87e010f91c9b /source/blender/blenkernel/BKE_curves_utils.hh
parent520be607e8baf4dacfadc1897013c84e77b81b27 (diff)
Curves: Port set type node to new data-block
This commit ports the "Set Spline Type" node to the new curves type. Performance should be improved in similar ways to the other refactors from the conversion task (T95443). Converting to and from Catmull Rom curves is now supported. There are a few cases where a lot of work can be skipped: when the number of points doesn't change, and when the types already match the goal type. The refactor has a few other explicit goals as well: - Don't count on initialization of attribute arrays when they are first allocated. - Avoid copying the entire data-block when possible. - Make decisions about which attributes to copy when changing curves more obvious. - Use higher-level methods to copy data between curve points. - Optimize for the common cases of single types and full selections. - Process selected curves of the same types in the same loop. The Bezier to NURBS conversion is written by Piotr Makal (@pmakal). Differential Revision: https://developer.blender.org/D14769
Diffstat (limited to 'source/blender/blenkernel/BKE_curves_utils.hh')
-rw-r--r--source/blender/blenkernel/BKE_curves_utils.hh58
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_curves_utils.hh b/source/blender/blenkernel/BKE_curves_utils.hh
index 62b060093e9..f223e173ea9 100644
--- a/source/blender/blenkernel/BKE_curves_utils.hh
+++ b/source/blender/blenkernel/BKE_curves_utils.hh
@@ -9,9 +9,53 @@
* \brief Low-level operations for curves.
*/
+#include "BLI_function_ref.hh"
+#include "BLI_generic_pointer.hh"
+
namespace blender::bke::curves {
/**
+ * Copy the provided point attribute values between all curves in the #curve_ranges index
+ * ranges, assuming that all curves have the same number of control points in #src_curves
+ * and #dst_curves.
+ */
+void copy_point_data(const CurvesGeometry &src_curves,
+ const CurvesGeometry &dst_curves,
+ Span<IndexRange> curve_ranges,
+ GSpan src,
+ GMutableSpan dst);
+
+void copy_point_data(const CurvesGeometry &src_curves,
+ const CurvesGeometry &dst_curves,
+ IndexMask src_curve_selection,
+ GSpan src,
+ GMutableSpan dst);
+
+template<typename T>
+void copy_point_data(const CurvesGeometry &src_curves,
+ const CurvesGeometry &dst_curves,
+ const IndexMask src_curve_selection,
+ const Span<T> src,
+ MutableSpan<T> dst)
+{
+ copy_point_data(src_curves, dst_curves, src_curve_selection, GSpan(src), GMutableSpan(dst));
+}
+
+void fill_points(const CurvesGeometry &curves,
+ IndexMask curve_selection,
+ GPointer value,
+ GMutableSpan dst);
+
+template<typename T>
+void fill_points(const CurvesGeometry &curves,
+ const IndexMask curve_selection,
+ const T &value,
+ MutableSpan<T> dst)
+{
+ fill_points(curves, curve_selection, &value, dst);
+}
+
+/**
* Copy the size of every curve in #curve_ranges to the corresponding index in #counts.
*/
void fill_curve_counts(const bke::CurvesGeometry &curves,
@@ -23,4 +67,18 @@ void fill_curve_counts(const bke::CurvesGeometry &curves,
*/
void accumulate_counts_to_offsets(MutableSpan<int> counts_to_offsets, int start_offset = 0);
+IndexMask indices_for_type(const VArray<int8_t> &types,
+ const std::array<int, CURVE_TYPES_NUM> &type_counts,
+ const CurveType type,
+ const IndexMask selection,
+ Vector<int64_t> &r_indices);
+
+void foreach_curve_by_type(const VArray<int8_t> &types,
+ const std::array<int, CURVE_TYPES_NUM> &type_counts,
+ IndexMask selection,
+ FunctionRef<void(IndexMask)> catmull_rom_fn,
+ FunctionRef<void(IndexMask)> poly_fn,
+ FunctionRef<void(IndexMask)> bezier_fn,
+ FunctionRef<void(IndexMask)> nurbs_fn);
+
} // namespace blender::bke::curves