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-04-14 01:13:30 +0300
committerHans Goudey <h.goudey@me.com>2022-04-14 01:13:30 +0300
commit5a98e3827559c9363c2e942daf05c09a8f0f7863 (patch)
tree00cb5d6aa5a57641705e99f871699f3a55422280 /source/blender
parent078aa677b69216d5a222a927d52e0f011b416bef (diff)
Curves: Avoid duplicating evaluated positions with all poly curves
If all of the curves are poly curves, the evaluated positions are the same as the original positions. In this case just reuse the original positions span as the evaluated positions.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_curves.hh5
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc13
2 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index 9dafe2095e7..06971a2243a 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -76,6 +76,11 @@ class CurvesGeometryRuntime {
mutable Vector<float3> evaluated_position_cache;
mutable std::mutex position_cache_mutex;
mutable bool position_cache_dirty = true;
+ /**
+ * The evaluated positions result, using a separate span in case all curves are poly curves,
+ * in which case a separate array of evaluated positions is unnecessary.
+ */
+ mutable Span<float3> evaluated_positions_span;
/**
* Cache of lengths along each evaluated curve for for each evaluated point. If a curve is
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index 5c89dfd4df5..bdd8b3fc3d0 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -577,18 +577,25 @@ void CurvesGeometry::ensure_nurbs_basis_cache() const
Span<float3> CurvesGeometry::evaluated_positions() const
{
if (!this->runtime->position_cache_dirty) {
- return this->runtime->evaluated_position_cache;
+ return this->runtime->evaluated_positions_span;
}
/* A double checked lock. */
std::scoped_lock lock{this->runtime->position_cache_mutex};
if (!this->runtime->position_cache_dirty) {
- return this->runtime->evaluated_position_cache;
+ return this->runtime->evaluated_positions_span;
}
threading::isolate_task([&]() {
+ if (this->is_single_type(CURVE_TYPE_POLY)) {
+ this->runtime->evaluated_positions_span = this->positions();
+ this->runtime->evaluated_position_cache.clear_and_make_inline();
+ return;
+ }
+
this->runtime->evaluated_position_cache.resize(this->evaluated_points_num());
MutableSpan<float3> evaluated_positions = this->runtime->evaluated_position_cache;
+ this->runtime->evaluated_positions_span = evaluated_positions;
VArray<int8_t> types = this->curve_types();
VArray<bool> cyclic = this->cyclic();
@@ -645,7 +652,7 @@ Span<float3> CurvesGeometry::evaluated_positions() const
});
this->runtime->position_cache_dirty = false;
- return this->runtime->evaluated_position_cache;
+ return this->runtime->evaluated_positions_span;
}
Span<float3> CurvesGeometry::evaluated_tangents() const