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-05-09 09:33:34 +0300
committerHans Goudey <h.goudey@me.com>2021-05-09 09:33:34 +0300
commitf694321db073018e6f5bf58bee77a55f2018b369 (patch)
treed6587f7814e2bd92ef96a01e35baf9feb2f73579 /source/blender/blenkernel/intern/spline_base.cc
parent7029cc2f8adf9a5882f247324c59d4c25e18c287 (diff)
Fix: Curve resample duplicates last point for cyclic splines
The last point of the output was at the same location as the first point of a cyclic spline. The fix is simple, just account for the cyclic when choosing the sample edge length, and don't hard code the last sample.
Diffstat (limited to 'source/blender/blenkernel/intern/spline_base.cc')
-rw-r--r--source/blender/blenkernel/intern/spline_base.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index 447e8a5b0a5..11620a30948 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -286,7 +286,7 @@ Array<float> Spline::sample_uniform_index_factors(const int samples_size) const
}
const float total_length = this->length();
- const float sample_length = total_length / (samples_size - 1);
+ const float sample_length = total_length / (samples_size - (is_cyclic_ ? 0 : 1));
/* Store the length at the previous evaluated point in a variable so it can
* start out at zero (the lengths array doesn't contain 0 for the first point). */
@@ -305,7 +305,10 @@ Array<float> Spline::sample_uniform_index_factors(const int samples_size) const
prev_length = length;
}
- samples.last() = lengths.size();
+ if (!is_cyclic_) {
+ /* In rare cases this can prevent overflow of the stored index. */
+ samples.last() = lengths.size();
+ }
return samples;
}