From 53d376eaeef991850d35318b147f75c8f103319d Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sun, 27 Dec 2020 21:54:31 +0100 Subject: 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. --- src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 8c1d63e..16afe1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,7 @@ pub mod transformable; use config::Config; use editor::Editor; +use float_cmp::F64Margin; use gui::{DimensionIndicator, ToolSidebar}; use raylib::prelude::*; use std::ffi::CString; @@ -47,6 +48,14 @@ pub const GUI_STYLE: &str = "assets/style/cyber.rgs"; /// Location of the graf karto configuration options file. pub const CONFIG_FILE: &str = "config.ron"; +/// The acceptable error that is used throughout the project for two floats to be considered equal. +/// If it is set too low, the editor might not work properly, if set too high, the granularity may +/// become too low for certain purposes. +pub const FLOAT_MARGIN: F64Margin = F64Margin { + epsilon: 10000. * f64::EPSILON, + ulps: 0, +}; + fn main() { pretty_env_logger::init(); -- cgit v1.2.3-70-g09d2