[Bf-blender-cvs] [359b6baf325] master: Fix: Assert when curve has no evaluated points

Hans Goudey noreply at git.blender.org
Tue Apr 12 21:56:23 CEST 2022


Commit: 359b6baf325a701328732598ecc04b68a9a335d9
Author: Hans Goudey
Date:   Tue Apr 12 14:56:14 2022 -0500
Branches: master
https://developer.blender.org/rB359b6baf325a701328732598ecc04b68a9a335d9

Fix: Assert when curve has no evaluated points

It is valid for NURBS curves to have no evaluated points in some cases.

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

M	source/blender/blenkernel/BKE_curves.hh

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

diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index 9fd023edcf2..9dafe2095e7 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -377,6 +377,7 @@ namespace curves {
  */
 inline int curve_segment_size(const int points_num, const bool cyclic)
 {
+  BLI_assert(points_num > 0);
   return cyclic ? points_num : points_num - 1;
 }
 
@@ -681,8 +682,7 @@ inline IndexRange CurvesGeometry::lengths_range_for_curve(const int curve_index,
   BLI_assert(cyclic == this->cyclic()[curve_index]);
   const IndexRange points = this->evaluated_points_for_curve(curve_index);
   const int start = points.start() + curve_index;
-  const int size = curves::curve_segment_size(points.size(), cyclic);
-  return {start, size};
+  return {start, points.is_empty() ? 0 : curves::curve_segment_size(points.size(), cyclic)};
 }
 
 inline Span<float> CurvesGeometry::evaluated_lengths_for_curve(const int curve_index,



More information about the Bf-blender-cvs mailing list