chiark / gitweb /
shapelib: Change piece bbox rounding
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 10:16:25 +0000 (11:16 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 15:41:44 +0000 (16:41 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/organise.rs
src/shapelib.rs

index 0870c6e600ed918241fbd2bf2094018ed95d678e..5032b03ab00c74b3ad3ab715bfe21a7fa671bd60 100644 (file)
@@ -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::*;
index 4514e3bdd13cdf56589bfd2f9a8120d22e14e032..db94872c4d7a5b528e4f3fa9ba2e380a59676f7a 100644 (file)
@@ -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 ] }