90 curves.ensure_evaluated_lengths();
99 for (const int i_curve : range) {
100 const IndexRange points = points_by_curve[i_curve];
101 const bool is_cyclic = cyclic[i_curve];
102 const Span<float> evaluated_lengths = curves.evaluated_lengths_for_curve(i_curve, is_cyclic);
103 MutableSpan<float> lengths = result.as_mutable_span().slice(points);
104 lengths.first() = 0.0f;
105 const float last_evaluated_length = evaluated_lengths.is_empty() ? 0.0f :
106 evaluated_lengths.last();
109 switch (types[i_curve]) {
110 case CURVE_TYPE_CATMULL_ROM: {
111 const int resolution = resolutions[i_curve];
112 for (const int i : IndexRange(points.size()).drop_back(1)) {
113 lengths[i + 1] = evaluated_lengths[resolution * (i + 1) - 1];
115 total = last_evaluated_length;
118 case CURVE_TYPE_POLY:
119 lengths.drop_front(1).copy_from(evaluated_lengths.take_front(lengths.size() - 1));
120 total = last_evaluated_length;
122 case CURVE_TYPE_BEZIER: {
123 const Span<int> offsets = curves.bezier_evaluated_offsets_for_curve(i_curve);
124 for (const int i : IndexRange(points.size()).drop_back(1)) {
125 lengths[i + 1] = evaluated_lengths[offsets[i + 1] - 1];
127 total = last_evaluated_length;
130 case CURVE_TYPE_NURBS: {
131 const Span<float3> positions = curves.positions().slice(points);
133 for (const int i : positions.index_range().drop_back(1)) {
135 length += math::distance(positions[i], positions[i + 1]);
137 lengths.last() = length;
139 length += math::distance(positions.first(), positions.last());
145 postprocess_lengths_for_curve(lengths, total);