[Bf-blender-cvs] [f973e0b75a7] master: Fix: Spline length calculation fails with no evaluated points
Hans Goudey
noreply at git.blender.org
Mon Sep 20 02:02:11 CEST 2021
Commit: f973e0b75a79ef6b05677e36d41fdeff70ea6d9d
Author: Hans Goudey
Date: Sun Sep 19 19:00:50 2021 -0500
Branches: master
https://developer.blender.org/rBf973e0b75a79ef6b05677e36d41fdeff70ea6d9d
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.
===================================================================
M source/blender/blenkernel/intern/spline_base.cc
===================================================================
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_;
More information about the Bf-blender-cvs
mailing list