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-03-13 22:42:56 +0300
committerHans Goudey <h.goudey@me.com>2022-03-14 00:53:48 +0300
commit25b4e41875bb7c062f14a49849aa43ca079f49ed (patch)
tree498cb738ca2627ebaddfaa6897bc589903138f0c /source/blender/blenkernel/BKE_spline.hh
parent3c8182409c02bfc3a6684a742537947d44e58486 (diff)
Curve: Store NURBS basis cache as a single vector
Instead of allocating a vector of the basis weights cache for each evaluated point, allocate a single vector for all of the weights. This should reduce memory usage by avoiding the overhead of storing many vectors. I noticed a small performance improvement to evaluated position calculation with an order of 5, which is larger than `Vector`'s default inline buffer capacity. This change is possible because of previous commits that made the basis cache for each evaluated point always have the same "order" size.
Diffstat (limited to 'source/blender/blenkernel/BKE_spline.hh')
-rw-r--r--source/blender/blenkernel/BKE_spline.hh11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh
index 1e3134020c6..817bbf60f54 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -453,12 +453,15 @@ class NURBSpline final : public Spline {
KnotsMode knots_mode;
struct BasisCache {
- /** The influence at each control point `i + #start_index`. */
+ /**
+ * For each evaluated point, the weight for alls control points that influences it.
+ * The vector's size is the evaluated point count multiplied by the spline's order.
+ */
blender::Vector<float> weights;
/**
* An offset for the start of #weights: the first control point index with a non-zero weight.
*/
- int start_index;
+ blender::Vector<int> start_indices;
};
private:
@@ -484,7 +487,7 @@ class NURBSpline final : public Spline {
mutable bool knots_dirty_ = true;
/** Cache of control point influences on each evaluated point. */
- mutable blender::Vector<BasisCache> basis_cache_;
+ mutable BasisCache basis_cache_;
mutable std::mutex basis_cache_mutex_;
mutable bool basis_cache_dirty_ = true;
@@ -547,7 +550,7 @@ class NURBSpline final : public Spline {
void reverse_impl() override;
void calculate_knots() const;
- blender::Span<BasisCache> calculate_basis_cache() const;
+ const BasisCache &calculate_basis_cache() const;
};
/**