[Bf-blender-cvs] [1d711f5da6d] temp-T97352-3d-texturing-seam-bleeding-b2: Curves: Remove CurveEval and old Spline types

Hans Goudey noreply at git.blender.org
Tue Sep 20 10:32:15 CEST 2022


Commit: 1d711f5da6d6d746d60fc0fd6c6bfd70141cdacb
Author: Hans Goudey
Date:   Sun Sep 18 15:10:04 2022 -0500
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB1d711f5da6d6d746d60fc0fd6c6bfd70141cdacb

Curves: Remove CurveEval and old Spline types

`CurveEval` was added for the first iteration of geometry nodes curve
support. Since then, it has been replaced by the new `Curves` type
which is designed to be much faster for many curves and better
integrated with the rest of Blender. Now that all curve nodes have
been moved to use `Curves` (T95443), the type can be removed,
along with the corresponding geometry component.

===================================================================

M	source/blender/blenkernel/BKE_geometry_set.hh
D	source/blender/blenkernel/BKE_spline.hh
M	source/blender/blenkernel/CMakeLists.txt
D	source/blender/blenkernel/intern/curve_eval.cc
M	source/blender/blenkernel/intern/displist.cc
D	source/blender/blenkernel/intern/geometry_component_curve.cc
D	source/blender/blenkernel/intern/spline_base.cc
D	source/blender/blenkernel/intern/spline_bezier.cc
D	source/blender/blenkernel/intern/spline_nurbs.cc
D	source/blender/blenkernel/intern/spline_poly.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index a5c4d5e1365..dce80373189 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -26,7 +26,6 @@
 struct Curves;
 struct Collection;
 struct Curve;
-struct CurveEval;
 struct Mesh;
 struct Object;
 struct PointCloud;
@@ -464,45 +463,6 @@ class PointCloudComponent : public GeometryComponent {
  private:
 };
 
-/**
- * Legacy runtime-only curves type.
- * These curves are stored differently than other geometry components, because the data structure
- * used here does not correspond exactly to the #Curve DNA data structure. A #CurveEval is stored
- * here instead, though the component does give access to a #Curve for interfacing with render
- * engines and other areas of Blender that expect to use a data-block with an #ID.
- */
-class CurveComponentLegacy : public GeometryComponent {
- private:
-  CurveEval *curve_ = nullptr;
-  GeometryOwnershipType ownership_ = GeometryOwnershipType::Owned;
-
- public:
-  CurveComponentLegacy();
-  ~CurveComponentLegacy();
-  GeometryComponent *copy() const override;
-
-  void clear();
-  bool has_curve() const;
-  /**
-   * Clear the component and replace it with the new curve.
-   */
-  void replace(CurveEval *curve, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
-  CurveEval *release();
-
-  const CurveEval *get_for_read() const;
-  CurveEval *get_for_write();
-
-  bool is_empty() const final;
-
-  bool owns_direct_data() const override;
-  void ensure_owns_direct_data() override;
-
-  std::optional<blender::bke::AttributeAccessor> attributes() const final;
-  std::optional<blender::bke::MutableAttributeAccessor> attributes_for_write() final;
-
-  static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_CURVE;
-};
-
 /**
  * A geometry component that stores a group of curves, corresponding the #Curves data-block type
  * and the #CurvesGeometry type. Attributes are stored on the control point domain and the
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
deleted file mode 100644
index 27542aa3586..00000000000
--- a/source/blender/blenkernel/BKE_spline.hh
+++ /dev/null
@@ -1,688 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#pragma once
-
-/** \file
- * \ingroup bke
- */
-
-#include <mutex>
-
-#include "DNA_curves_types.h"
-
-#include "BLI_float4x4.hh"
-#include "BLI_generic_virtual_array.hh"
-#include "BLI_math_vec_types.hh"
-#include "BLI_vector.hh"
-
-#include "BKE_attribute.hh"
-#include "BKE_attribute_math.hh"
-
-struct Curve;
-struct Curves;
-struct ListBase;
-
-class Spline;
-using SplinePtr = std::unique_ptr<Spline>;
-
-/**
- * A spline is an abstraction of a single branch-less curve section, its evaluation methods,
- * and data. The spline data itself is just control points and a set of attributes by the set
- * of "evaluated" data is often used instead. Conceptually, the derived vs. original data is
- * an essential distinction. Derived data is usually calculated lazily and cached on the spline.
- *
- * Any derived class of Spline has to manage two things:
- *  1. Interpolating arbitrary attribute data from the control points to evaluated points.
- *  2. Evaluating the positions based on the stored control point data.
- *
- * Beyond that, everything is the base class's responsibility, with minor exceptions. Further
- * evaluation happens in a layer on top of the evaluated points generated by the derived types.
- *
- * There are a few methods to evaluate a spline:
- *  1. #evaluated_positions and #interpolate_to_evaluated give data for the initial
- *     evaluated points, depending on the resolution.
- *  2. #lookup_evaluated_factor and #lookup_evaluated_factor are meant for one-off lookups
- *     along the length of a curve.
- *  3. #sample_uniform_index_factors returns an array that stores uniform-length samples
- *     along the spline which can be used to interpolate data from method 1.
- *
- * Commonly used evaluated data is stored in caches on the spline itself so that operations on
- * splines don't need to worry about taking ownership of evaluated data when they don't need to.
- */
-class Spline {
- public:
-  NormalMode normal_mode = NORMAL_MODE_MINIMUM_TWIST;
-
-  blender::bke::CustomDataAttributes attributes;
-
- protected:
-  CurveType type_;
-  bool is_cyclic_ = false;
-
-  /** Direction of the spline at each evaluated point. */
-  mutable blender::Vector<blender::float3> evaluated_tangents_cache_;
-  mutable std::mutex tangent_cache_mutex_;
-  mutable bool tangent_cache_dirty_ = true;
-
-  /** Normal direction vectors for each evaluated point. */
-  mutable blender::Vector<blender::float3> evaluated_normals_cache_;
-  mutable std::mutex normal_cache_mutex_;
-  mutable bool normal_cache_dirty_ = true;
-
-  /** Accumulated lengths along the evaluated points. */
-  mutable blender::Vector<float> evaluated_lengths_cache_;
-  mutable std::mutex length_cache_mutex_;
-  mutable bool length_cache_dirty_ = true;
-
- public:
-  virtual ~Spline() = default;
-  Spline(const CurveType type) : type_(type)
-  {
-  }
-  Spline(Spline &other) : attributes(other.attributes), type_(other.type_)
-  {
-    copy_base_settings(other, *this);
-  }
-
-  /**
-   * Return a new spline with the same data, settings, and attributes.
-   */
-  SplinePtr copy() const;
-  /**
-   * Return a new spline with the same type and settings like "cyclic", but without any data.
-   */
-  SplinePtr copy_only_settings() const;
-  /**
-   * The same as #copy, but skips copying dynamic attributes to the new spline.
-   */
-  SplinePtr copy_without_attributes() const;
-  static void copy_base_settings(const Spline &src, Spline &dst);
-
-  CurveType type() const;
-
-  /** Return the number of control points. */
-  virtual int size() const = 0;
-  int segments_num() const;
-  bool is_cyclic() const;
-  void set_cyclic(bool value);
-
-  virtual void resize(int size) = 0;
-  virtual blender::MutableSpan<blender::float3> positions() = 0;
-  virtual blender::Span<blender::float3> positions() const = 0;
-  virtual blender::MutableSpan<float> radii() = 0;
-  virtual blender::Span<float> radii() const = 0;
-  virtual blender::MutableSpan<float> tilts() = 0;
-  virtual blender::Span<float> tilts() const = 0;
-
-  virtual void translate(const blender::float3 &translation);
-  virtual void transform(const blender::float4x4 &matrix);
-
-  /**
-   * Change the direction of the spline (switch the start and end) without changing its shape.
-   */
-  void reverse();
-
-  /**
-   * Mark all caches for re-computation. This must be called after any operation that would
-   * change the generated positions, tangents, normals, mapping, etc. of the evaluated points.
-   */
-  virtual void mark_cache_invalid() = 0;
-  virtual int evaluated_points_num() const = 0;
-  int evaluated_edges_num() const;
-
-  float length() const;
-
-  virtual blender::Span<blender::float3> evaluated_positions() const = 0;
-
-  /**
-   * Return non-owning access to the cache of accumulated lengths along the spline. Each item is
-   * the length of the subsequent segment, i.e. the first value is the length of the first segment
-   * rather than 0. This calculation is rather trivial, and only depends on the evaluated
-   * positions. However, the results are used often, and it is necessarily single threaded, so it
-   * is cached.
-   */
-  blender::Span<float> evaluated_lengths() const;
-  /**
-   * Return non-owning access to the direction of the curve at each evaluated point.
-   */
-  blender::Span<blender::float3> evaluated_tangents() const;
-  /**
-   * Return non-owning access to the direction vectors perpendicular to the tangents at every
-   * evaluated point. The method used to generate the normal vectors depends on Spline.normal_mode.
-   */
-  blender::Span<blender::float3> evaluated_normals() const;
-
-  void bounds_min_max(blender::float3 &min, blender::float3 &max, bool use_evaluated) const;
-
-  struct LookupResult {
-    /**
-     * The index of the evaluated point before the result location. In other words, the index of
-     * the edge that the result lies on. If the sampled factor/length is the very end of the
-     * spline, this will be the second to last index, if it's the very beginning, this will be 0.
-     */
-    int evaluated_index;
-    /**
-     * The index of the evaluated point after the result location, accounting for wrapping when
-     * the spline is cyclic. If the sampled factor/length is the very end of the spline, this will
-     * be the last index (#evaluated_points_num - 1).
-     */
-    int next_evaluated_index;
-    /**
-     * The portion of the way from the evaluated point at #evaluated_index to the next point.
-     * If the sampled factor/length is the very end of the spline, this will be the 1.0f
-     */
-    float factor;
-  };
-  /**
-   * Find the position on the evaluated spline at the given portion of the total length.
-   * The return value is the indices of the two neighboring points at that location and the
-   * factor between them, which can be used to look up any attribute on the evaluated points.
-   * \note This does not support extrapolation.
-   */
-  LookupResult lookup_evaluated_factor(float factor) const;
-  /**
-   * The same as #lookup_evaluated_factor, but looks up a length directly instead of
-   * a portion of the total.
-   */
-  LookupResult lookup_evaluated_length(float length) const;
-
-  /**
-   * Return an array of evenly spaced samples along the length of the spline. The samples are
-   * indices and factors to the next index encoded in floats. The logic for converting from the
-   * float values to interpolation data is in #lookup_data_from_index_factor.
-   */
-  blender::Array<float> sample_uniform_index_factors(int samples_num) const;
-  LookupResult lookup_data_from_index_factor(float index_factor) const;
-
-  /**
-   * Sample any input data with a value for each evaluated point (already interpolated to evaluated
-   * points) to arbitrary parameters in between the evaluated points. The interpolation is quite
-   * simple, but t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list