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
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-05-09 09:13:06 +0300
committerHans Goudey <h.goudey@me.com>2021-05-09 09:13:06 +0300
commit7029cc2f8adf9a5882f247324c59d4c25e18c287 (patch)
tree9b784cc26124ff1f19ca73a6ca5f3bdbfa7ebae4 /source
parent518c5ce4cd75aabcc649efb9e118d18622b5ea70 (diff)
Fix T88126: Curve resample crash for single point input
The spline `length` function assumed that the curve always had evaluated edges. That is clearly false. This commit adds a check to `length` and a special case for a single point in the curve resample node.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/spline_base.cc3
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc7
2 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/spline_base.cc b/source/blender/blenkernel/intern/spline_base.cc
index e2b1118a0b2..447e8a5b0a5 100644
--- a/source/blender/blenkernel/intern/spline_base.cc
+++ b/source/blender/blenkernel/intern/spline_base.cc
@@ -61,7 +61,8 @@ int Spline::evaluated_edges_size() const
float Spline::length() const
{
- return this->evaluated_lengths().last();
+ Span<float> lengths = this->evaluated_lengths();
+ return (lengths.size() == 0) ? 0 : this->evaluated_lengths().last();
}
int Spline::segments_size() const
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
index 9c7b036bda0..c8733955a32 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
@@ -99,6 +99,13 @@ static SplinePtr resample_spline(const Spline &input_spline, const int count)
std::unique_ptr<PolySpline> output_spline = std::make_unique<PolySpline>();
output_spline->set_cyclic(input_spline.is_cyclic());
output_spline->normal_mode = input_spline.normal_mode;
+
+ if (input_spline.evaluated_edges_size() < 1) {
+ output_spline->resize(1);
+ output_spline->positions().first() = input_spline.positions().first();
+ return output_spline;
+ }
+
output_spline->resize(count);
Array<float> uniform_samples = input_spline.sample_uniform_index_factors(count);