[Bf-blender-cvs] [7029cc2f8ad] master: Fix T88126: Curve resample crash for single point input
Hans Goudey
noreply at git.blender.org
Sun May 9 08:13:12 CEST 2021
Commit: 7029cc2f8adf9a5882f247324c59d4c25e18c287
Author: Hans Goudey
Date: Sun May 9 01:13:06 2021 -0500
Branches: master
https://developer.blender.org/rB7029cc2f8adf9a5882f247324c59d4c25e18c287
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.
===================================================================
M source/blender/blenkernel/intern/spline_base.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
===================================================================
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);
More information about the Bf-blender-cvs
mailing list