Fix: Assert in resample curve node with single point curve

This commit is contained in:
Hans Goudey 2022-07-25 11:53:06 -05:00
parent f26aa186b2
commit 739136caca
Notes: blender-bot 2023-10-13 01:54:23 +02:00
Referenced by issue #99533, Geometry Nodes: Hit assert in Resample Curve node
1 changed files with 12 additions and 4 deletions

View File

@ -233,10 +233,18 @@ static Curves *resample_to_uniform(const CurveComponent &src_component,
for (const int i_curve : sliced_selection) {
const bool cyclic = curves_cyclic[i_curve];
const IndexRange dst_points = dst_curves.points_for_curve(i_curve);
length_parameterize::sample_uniform(src_curves.evaluated_lengths_for_curve(i_curve, cyclic),
!curves_cyclic[i_curve],
sample_indices.as_mutable_span().slice(dst_points),
sample_factors.as_mutable_span().slice(dst_points));
const Span<float> lengths = src_curves.evaluated_lengths_for_curve(i_curve, cyclic);
if (lengths.is_empty()) {
/* Handle curves with only one evaluated point. */
sample_indices.as_mutable_span().slice(dst_points).fill(0);
sample_factors.as_mutable_span().slice(dst_points).fill(0.0f);
}
else {
length_parameterize::sample_uniform(lengths,
!curves_cyclic[i_curve],
sample_indices.as_mutable_span().slice(dst_points),
sample_factors.as_mutable_span().slice(dst_points));
}
}
/* For every attribute, evaluate attributes from every curve in the range in the original