[Bf-blender-cvs] [739136caca5] master: Fix: Assert in resample curve node with single point curve

Hans Goudey noreply at git.blender.org
Mon Jul 25 18:55:17 CEST 2022


Commit: 739136caca5cbe73d0478583d44a3d0d36137b42
Author: Hans Goudey
Date:   Mon Jul 25 11:53:06 2022 -0500
Branches: master
https://developer.blender.org/rB739136caca5cbe73d0478583d44a3d0d36137b42

Fix: Assert in resample curve node with single point curve

===================================================================

M	source/blender/geometry/intern/resample_curves.cc

===================================================================

diff --git a/source/blender/geometry/intern/resample_curves.cc b/source/blender/geometry/intern/resample_curves.cc
index 29e358cc3f4..86c1980d9ee 100644
--- a/source/blender/geometry/intern/resample_curves.cc
+++ b/source/blender/geometry/intern/resample_curves.cc
@@ -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



More information about the Bf-blender-cvs mailing list