From 7b697b53f82d07086415b6b70f8f93fc94619d09 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 3 Apr 2021 11:16:25 +0100 Subject: [PATCH] shapelib: Change piece bbox rounding This is causing things not to fit into hands. I don't think this rounding up is actually necessary; it was just an abundance of caution. This deals with a todo. Signed-off-by: Ian Jackson --- src/organise.rs | 1 - src/shapelib.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/organise.rs b/src/organise.rs index 0870c6e6..5032b03a 100644 --- a/src/organise.rs +++ b/src/organise.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // There is NO WARRANTY. -// xxx layout in actual mao resorts to Hanging (in eg mao.game.toml) // xxx mao needs updating so Hang is non-awful use crate::prelude::*; diff --git a/src/shapelib.rs b/src/shapelib.rs index 4514e3bd..db94872c 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -806,7 +806,7 @@ impl OutlineTrait for CircleShape { } #[throws(IE)] fn bbox_approx(&self) -> Rect { - let d = (self.diam * 0.5).ceil() as Coord; + let d = (self.diam * 0.5).round() as Coord; Rect{ corners: [PosC::new(-d,-d), PosC::new(d, d)]} } } @@ -876,7 +876,7 @@ impl OutlineTrait for RectShape { #[throws(IE)] fn bbox_approx(&self) -> Rect { let pos: Pos = self.xy.map( - |v| ((v * 0.5).ceil()) as Coord + |v| ((v * 0.5).round()) as Coord ); let neg = (-pos)?; Rect{ corners: [ neg, pos ] } -- 2.30.2