aboutsummaryrefslogtreecommitdiff
path: root/src/math/polygon/polygon_graph.rs
diff options
context:
space:
mode:
authorArne Dußin2020-11-25 21:38:38 +0100
committerArne Dußin2020-11-25 21:38:38 +0100
commit77f2d35cb52d9443e9a0e9250aa941fc3d7610b6 (patch)
tree55b48a4cb84d1fc057240919735ce5d2b59bca6e /src/math/polygon/polygon_graph.rs
parent58ca28d4b21667e9b86939ad574f477e02f2b290 (diff)
downloadgraf_karto-77f2d35cb52d9443e9a0e9250aa941fc3d7610b6.tar.gz
graf_karto-77f2d35cb52d9443e9a0e9250aa941fc3d7610b6.zip
Add polygon rooms that can actually kind of be used
It's still kind of strange to use the polygon tool, but at least it seems stable enough so I'm confident enough (and sick enough of it) to release it into the wild.
Diffstat (limited to 'src/math/polygon/polygon_graph.rs')
-rw-r--r--src/math/polygon/polygon_graph.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/math/polygon/polygon_graph.rs b/src/math/polygon/polygon_graph.rs
index 6fdb6cd..5a730b0 100644
--- a/src/math/polygon/polygon_graph.rs
+++ b/src/math/polygon/polygon_graph.rs
@@ -291,7 +291,7 @@ impl<T: Scalar + Copy + PartialOrd> PolygonGraph<T> {
.expect("Failure to find node that should be inside list.")];
}
- Polygon::new(bounding_corners)
+ Polygon::new(bounding_corners).expect("PolygonGraph produced invalid polygon")
}
}
@@ -311,7 +311,7 @@ mod test {
let b = Vec2::new(0., 1.);
let c = Vec2::new(0.5, 1.);
- let triangle = Polygon::new(vec![a, b, c]);
+ let triangle = Polygon::new(vec![a, b, c]).unwrap();
let graph = PolygonGraph::from_polygon(&triangle);
assert_eq!(graph.num_edges(), 3);
@@ -333,9 +333,9 @@ mod test {
let bot_left = Vec2::new(0., 1.);
let bot_right = Vec2::new(1., 1.);
- let triangle = Polygon::new(vec![top_left, bot_right, top_right]);
+ let triangle = Polygon::new(vec![top_left, bot_right, top_right]).unwrap();
- let square = Polygon::new(vec![bot_left, bot_right, top_right, top_left]);
+ let square = Polygon::new(vec![bot_left, bot_right, top_right, top_left]).unwrap();
let mut graph = PolygonGraph::new();
graph.add_all(&triangle);
@@ -368,7 +368,8 @@ mod test {
Vec2::new(2., 2.),
Vec2::new(3., 1.),
Vec2::new(2., 0.),
- ]);
+ ])
+ .unwrap();
let second = Polygon::new(vec![
Vec2::new(2.5, -0.5),
@@ -376,7 +377,8 @@ mod test {
Vec2::new(2., 2.),
Vec2::new(2., 0.5),
Vec2::new(2.5, 0.),
- ]);
+ ])
+ .unwrap();
let mut graph = PolygonGraph::from_polygon(&first);
graph.add_all(&second);
@@ -406,7 +408,8 @@ mod test {
Vec2::new(2., 2.),
Vec2::new(3., 1.),
Vec2::new(2., 0.),
- ]);
+ ])
+ .unwrap();
let second = Polygon::new(vec![
Vec2::new(2.5, -0.5),
@@ -414,7 +417,8 @@ mod test {
Vec2::new(2., 2.),
Vec2::new(2., 0.5),
Vec2::new(2.5, 0.),
- ]);
+ ])
+ .unwrap();
let mut graph = PolygonGraph::from_polygon(&first);
graph.add_all(&second);