diff options
| author | Arne Dußin | 2020-12-27 21:54:31 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-27 21:54:31 +0100 |
| commit | 53d376eaeef991850d35318b147f75c8f103319d (patch) | |
| tree | 7e95a1666818dc7a804b145f263bdb4b76fef83a /src/map | |
| parent | 2d2f45df9d47db25ac5a91c8f926a025c3a5dc7a (diff) | |
| download | graf_karto-53d376eaeef991850d35318b147f75c8f103319d.tar.gz graf_karto-53d376eaeef991850d35318b147f75c8f103319d.zip | |
Change to polygongraph instead of polygon in roomtool
The polygon room tool used a convoluted process for determining what the
user actually wants to draw. I have changed to the polygon graph
instead, which makes the checks easier and restricts the user a bit
less. In the process however I found a serious problem with my handling
float, so everything needed to change to margin compares (which I of
course should have done in the beginning. Guys, take the warning
seriously and don't ignore it for ten years like I did. It will come
back to haunt you.. apparently) instead of direct equality.
Diffstat (limited to 'src/map')
| -rw-r--r-- | src/map/polygon_room.rs | 5 | ||||
| -rw-r--r-- | src/map/rect_room.rs | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/map/polygon_room.rs b/src/map/polygon_room.rs index fd4122e..ead4e76 100644 --- a/src/map/polygon_room.rs +++ b/src/map/polygon_room.rs @@ -6,6 +6,7 @@ use crate::colours::DEFAULT_COLOURS; use crate::math::{self, Polygon, Rect, Triangle}; use crate::transform::Transform; use crate::transformable::NonRigidTransformable; +use crate::FLOAT_MARGIN; use nalgebra::{Matrix3, Point2}; use raylib::drawing::{RaylibDraw, RaylibDrawHandle}; @@ -25,7 +26,7 @@ impl PolygonRoom { pub fn from_data(data: PolygonRoomData) -> Self { Self { data: data.clone(), - triangulated: math::triangulate(data), + triangulated: math::triangulate(data, FLOAT_MARGIN), selected: false, } } @@ -33,7 +34,7 @@ impl PolygonRoom { // When the internal polygon changes, it must be retriangulated to be drawn on the screen // properly, so this function must be called any time that happens. fn retriangulate(&mut self) { - self.triangulated = math::triangulate(self.data.clone()); + self.triangulated = math::triangulate(self.data.clone(), FLOAT_MARGIN); } } diff --git a/src/map/rect_room.rs b/src/map/rect_room.rs index 6ed3ed6..ae10327 100644 --- a/src/map/rect_room.rs +++ b/src/map/rect_room.rs @@ -49,7 +49,7 @@ impl Mappable for RectRoom { } fn bounding_rect(&self) -> Rect<f64> { - self.data.clone() + self.data } } |
