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>2021-06-22 19:32:50 +0300
committerHans Goudey <h.goudey@me.com>2021-06-22 19:32:50 +0300
commitf3eecfe386098cf0a18df7ff4d8ffda9a43e9495 (patch)
tree52a9429269c803ae3a4f0bb8a6c235850c12f124 /source/blender/blenkernel/BKE_spline.hh
parent026de343e3528fe2b2f8d8daba7fa2fd4b807337 (diff)
Cleanup: Refactor spline copying functions
Make the virtual functions protected and simpler, so that the logic is better contained in the base class's implementation. Also introduce a `copy_without_attributes` method to be used for realizing instances.
Diffstat (limited to 'source/blender/blenkernel/BKE_spline.hh')
-rw-r--r--source/blender/blenkernel/BKE_spline.hh32
1 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index 38a6d41a4d3..24b5a78e598 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -105,9 +105,9 @@ class Spline {
copy_base_settings(other, *this);
}
- virtual SplinePtr copy() const = 0;
- /** Return a new spline with the same type and settings like "cyclic", but without any data. */
- virtual SplinePtr copy_settings() const = 0;
+ SplinePtr copy() const;
+ SplinePtr copy_only_settings() const;
+ SplinePtr copy_without_attributes() const;
Spline::Type type() const;
@@ -206,12 +206,10 @@ class Spline {
protected:
virtual void correct_end_tangents() const = 0;
- /** Copy settings stored in the base spline class. */
- static void copy_base_settings(const Spline &src, Spline &dst)
- {
- dst.normal_mode = src.normal_mode;
- dst.is_cyclic_ = src.is_cyclic_;
- }
+ virtual void copy_settings(Spline &dst) const = 0;
+ virtual void copy_data(Spline &dst) const = 0;
+
+ static void copy_base_settings(const Spline &src, Spline &dst);
};
/**
@@ -264,8 +262,6 @@ class BezierSpline final : public Spline {
mutable bool mapping_cache_dirty_ = true;
public:
- virtual SplinePtr copy() const final;
- SplinePtr copy_settings() const final;
BezierSpline() : Spline(Type::Bezier)
{
}
@@ -340,8 +336,11 @@ class BezierSpline final : public Spline {
bool segment_is_vector(const int start_index) const;
private:
- void ensure_auto_handles() const;
void correct_end_tangents() const final;
+ void copy_settings(Spline &dst) const final;
+ void copy_data(Spline &dst) const final;
+
+ void ensure_auto_handles() const;
};
/**
@@ -406,8 +405,6 @@ class NURBSpline final : public Spline {
mutable bool position_cache_dirty_ = true;
public:
- SplinePtr copy() const final;
- SplinePtr copy_settings() const final;
NURBSpline() : Spline(Type::NURBS)
{
}
@@ -458,6 +455,9 @@ class NURBSpline final : public Spline {
protected:
void correct_end_tangents() const final;
+ void copy_settings(Spline &dst) const final;
+ void copy_data(Spline &dst) const final;
+
void calculate_knots() const;
blender::Span<BasisCache> calculate_basis_cache() const;
};
@@ -473,8 +473,6 @@ class PolySpline final : public Spline {
blender::Vector<float> tilts_;
public:
- SplinePtr copy() const final;
- SplinePtr copy_settings() const final;
PolySpline() : Spline(Type::Poly)
{
}
@@ -507,6 +505,8 @@ class PolySpline final : public Spline {
protected:
void correct_end_tangents() const final;
+ void copy_settings(Spline &dst) const final;
+ void copy_data(Spline &dst) const final;
};
/**