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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user