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>2022-04-07 00:13:06 +0300
committerHans Goudey <h.goudey@me.com>2022-04-07 00:13:06 +0300
commit74db0f3d5fa18e1992a716e2e38e910965dab28f (patch)
tree18d6fe1db54a9fdeea6e3aa82162b5618ccc2d7b
parenteb470bfbfe0a3f3e17176f320487f0caa299459e (diff)
Fix: Curve parameter node broken for Bezier curves after refactor
The last length value was not initialized, and all length values were moved one position towards the front of each curve incorrectly. Also fix an assert when a curve only had a single point.
-rw-r--r--source/blender/blenkernel/BKE_curves.hh4
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc8
2 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index b233a89c56d..4117f8b9bdc 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -643,7 +643,9 @@ inline Span<float> CurvesGeometry::evaluated_lengths_for_curve(const int curve_i
inline float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index,
const bool cyclic) const
{
- return this->evaluated_lengths_for_curve(curve_index, cyclic).last();
+ const Span<float> lengths = this->evaluated_lengths_for_curve(curve_index, cyclic);
+ /* Check for curves that have no evaluated segments. */
+ return lengths.is_empty() ? 0.0f : lengths.last();
}
/** \} */
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
index 62fae8b8eca..be17918609f 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
@@ -75,8 +75,8 @@ static Array<float> curve_length_point_domain(const bke::CurvesGeometry &curves)
switch (types[i_curve]) {
case CURVE_TYPE_CATMULL_ROM: {
const int resolution = resolutions[i_curve];
- for (const int i : IndexRange(points.size()).drop_front(1).drop_back(1)) {
- lengths[i] = evaluated_lengths[resolution * i - 1];
+ for (const int i : IndexRange(points.size()).drop_back(1)) {
+ lengths[i + 1] = evaluated_lengths[resolution * i - 1];
}
break;
}
@@ -85,8 +85,8 @@ static Array<float> curve_length_point_domain(const bke::CurvesGeometry &curves)
break;
case CURVE_TYPE_BEZIER: {
const Span<int> offsets = curves.bezier_evaluated_offsets_for_curve(i_curve);
- for (const int i : IndexRange(points.size()).drop_front(1).drop_back(1)) {
- lengths[i] = evaluated_lengths[offsets[i] - 1];
+ for (const int i : IndexRange(points.size()).drop_back(1)) {
+ lengths[i + 1] = evaluated_lengths[offsets[i] - 1];
}
break;
}