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-09-20 03:00:50 +0300
committerHans Goudey <h.goudey@me.com>2021-09-20 03:01:24 +0300
commitf973e0b75a79ef6b05677e36d41fdeff70ea6d9d (patch)
treef8897319873ad7bcd286815425746ef94b04680f
parentc9e835fec1bcd8ae42b57feaefaa6f4d946f546f (diff)
Fix: Spline length calculation fails with no evaluated points
The case that checked whether there were evaluated edges was incorrect, since two points are needed for an edge. Then also avoid running the accumulation for an empty span.
-rw-r--r--source/blender/blenkernel/intern/spline_base.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index 807019f60a8..663c1951ba3 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -142,7 +142,8 @@ void Spline::reverse()
int Spline::evaluated_edges_size() const
{
const int eval_size = this->evaluated_points_size();
- if (eval_size == 1) {
+ if (eval_size < 2) {
+ /* Two points are required for an edge. */
return 0;
}
@@ -205,9 +206,10 @@ Span<float> Spline::evaluated_lengths() const
const int total = evaluated_edges_size();
evaluated_lengths_cache_.resize(total);
-
- Span<float3> positions = this->evaluated_positions();
- accumulate_lengths(positions, is_cyclic_, evaluated_lengths_cache_);
+ if (total != 0) {
+ Span<float3> positions = this->evaluated_positions();
+ accumulate_lengths(positions, is_cyclic_, evaluated_lengths_cache_);
+ }
length_cache_dirty_ = false;
return evaluated_lengths_cache_;