aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArne Dußin2020-11-26 14:57:39 +0100
committerArne Dußin2020-11-26 14:57:39 +0100
commit19a1221c4bb9df34bb0c14746fc5372d07d1c771 (patch)
tree486c8b22ddf5e639db3e02d8fb7c48d52dedf6df /src
parent9d469c353eb179a35fad6d42fa3f6fc985b49188 (diff)
downloadgraf_karto-19a1221c4bb9df34bb0c14746fc5372d07d1c771.tar.gz
graf_karto-19a1221c4bb9df34bb0c14746fc5372d07d1c771.zip
Print polygon that makes the earcutting algo panic
Diffstat (limited to 'src')
-rw-r--r--src/math/polygon/triangulate.rs11
1 files changed, 7 insertions, 4 deletions
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.
{