chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
83c0d76
)
gamestate: Provide bbox_abs
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 23:44:49 +0000
(
00:44
+0100)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Mon, 5 Apr 2021 00:47:26 +0000
(
01:47
+0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
patch
|
blob
|
history
diff --git
a/src/gamestate.rs
b/src/gamestate.rs
index 3f80b31e59de2d27ec3be72dd79366ef69eb17c1..a18c614f081371ca99eb08221bd76306bd171fd5 100644
(file)
--- 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::<Result<ArrayVec<_>,_>>()?
+ .into_inner().unwrap() }
+ }
}
#[typetag::serde]