From 19a1221c4bb9df34bb0c14746fc5372d07d1c771 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Thu, 26 Nov 2020 14:57:39 +0100 Subject: Print polygon that makes the earcutting algo panic --- src/math/polygon/triangulate.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/math/polygon/triangulate.rs') diff --git a/src/math/polygon/triangulate.rs b/src/math/polygon/triangulate.rs index 4c7d952..8a18cd7 100644 --- a/src/math/polygon/triangulate.rs +++ b/src/math/polygon/triangulate.rs @@ -75,10 +75,13 @@ where */ while polygon.corners.len() > 3 { // Find the ear with the highest index. - let ear = flags - .iter() - .rposition(|&x| (x & FLAG_EAR) != 0) - .expect("Polygon has more than three vertices, but no ear."); + let ear = match flags.iter().rposition(|&x| (x & FLAG_EAR) != 0) { + Some(pos) => pos, + None => panic!( + "Polygon has more than three vertices, but no ear: {:?}", + polygon + ), + }; // Add the ear's triangle to the list. { -- cgit v1.2.3-70-g09d2