Fix T102003: Spline parameter length wrong for NURBS

The node has always be a bit confusing for the NURBS case, since it
uses the distance between control points since the evaluated/control
point mapping isn't obvious, but it also went above 1, which wasn't
correct.

Instead, retrieve the total length from the point lengths calculated
in the previous step. The results should be the same for other curve
types.
This commit is contained in:
Hans Goudey 2022-11-08 12:31:11 -06:00
parent fd35216025
commit 66dda2b902
Notes: blender-bot 2023-02-22 19:36:23 +01:00
Referenced by issue #102003, Geometry nodes: Spline parameter length works wrong for NURBS
Referenced by issue #104842, Regression: Geometry Node: Incorrect cyclic curve factor parameter
Referenced by pull request #105079, Fix #104842: Incorrect cyclic curve parameter node factor
Referenced by commit 11766574a4, Fix #104842: Incorrect cyclic curve parameter node factor
1 changed files with 1 additions and 2 deletions

View File

@ -117,9 +117,8 @@ static VArray<float> construct_curve_parameter_varray(const bke::CurvesGeometry
threading::parallel_for(curves.curves_range(), 1024, [&](IndexRange range) {
for (const int i_curve : range) {
const float total_length = curves.evaluated_length_total_for_curve(i_curve,
cyclic[i_curve]);
MutableSpan<float> curve_lengths = lengths.slice(curves.points_for_curve(i_curve));
const float total_length = curve_lengths.last();
if (total_length > 0.0f) {
const float factor = 1.0f / total_length;
for (float &value : curve_lengths) {