From: Ian Jackson Date: Sat, 3 Apr 2021 10:16:25 +0000 (+0100) Subject: shapelib: Change piece bbox rounding X-Git-Tag: otter-0.5.0~270 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7b697b53f82d07086415b6b70f8f93fc94619d09;p=otter.git 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 --- 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 ] }