From 359b6baf325a701328732598ecc04b68a9a335d9 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 12 Apr 2022 14:56:14 -0500 Subject: Fix: Assert when curve has no evaluated points It is valid for NURBS curves to have no evaluated points in some cases. --- source/blender/blenkernel/BKE_curves.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') 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 CurvesGeometry::evaluated_lengths_for_curve(const int curve_index, -- cgit v1.2.3