From: Ian Jackson Date: Sun, 4 Apr 2021 23:44:49 +0000 (+0100) Subject: gamestate: Provide bbox_abs X-Git-Tag: otter-0.5.0~195 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=33608b22f279c7f5c67a2350fdcb6ce22eda3fdb;p=otter.git gamestate: Provide bbox_abs Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index 3f80b31e..a18c614f 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -214,6 +214,15 @@ pub trait PieceTrait: OutlineTrait + Send + Debug + 'static { fn occultation_notify_hook(&self, _piece: PieceId) -> UnpreparedUpdates { None } + + #[throws(IE)] + fn abs_bbox(&self, p: &GPiece) -> Rect { + Rect { corners: self.bbox_approx()?.corners.iter().map( + |c| *c + p.pos + ) + .collect::,_>>()? + .into_inner().unwrap() } + } } #[typetag::serde]