From ec071d5bc677101c0168b5fb3065f2d928234ed9 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 11 Jan 2021 12:10:16 +0100 Subject: Rect rooms are now normal polygon rooms in data Before there was an extra data type for rectangular rooms. This is now changed, with the rectangle tool remaining, to create these often required rooms faster, but the data type is just a normal polygon that is generated from a rect to reduce redundancy. --- src/math/polygon/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/math/polygon/mod.rs') diff --git a/src/math/polygon/mod.rs b/src/math/polygon/mod.rs index bc145ed..02d8abb 100644 --- a/src/math/polygon/mod.rs +++ b/src/math/polygon/mod.rs @@ -58,13 +58,11 @@ impl Polygon { } /// Like new, but does not perform any validity checks, so be careful when using this function. - pub fn new_unchecked(corners: Vec>, t_margin: M) -> Self + pub(crate) fn new_unchecked(corners: Vec>, t_margin: M) -> Self where T: RealField + ApproxEq, M: Copy, { - assert!(Polygon::check_validity(&corners, t_margin).is_ok()); - let corners = if combined_angle(&corners, t_margin) > T::zero() { corners } else { @@ -74,6 +72,12 @@ impl Polygon { Self { corners } } + /// Create a polygon from the sorted vertices. This will create an invalid polygon if the + /// vertices are not sorted so that the edges turn counterclockwise, so use with caution. + pub(crate) fn from_vertices(corners: Vec>) -> Self { + Self { corners } + } + /// Checks if a set of corners can be made into a polygon or not. Returns Ok if they can, or /// the reason they cannot in form of a PolygonError. pub fn check_validity(corners: &[Vec2], t_margin: M) -> Result<(), PolygonError> -- cgit v1.2.3-70-g09d2