diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-23 21:27:25 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-25 11:21:48 +0200 |
commit | 74fb8de441c68fff92680a48352f6b9b0f6e9271 (patch) | |
tree | 88e59c1043ac5de7379986eadc7f574e27f6c085 /server/src/spatial_index.rs | |
parent | 149c58d54bf9c0eda6e3d978984e5e0365b7395d (diff) | |
download | hurrycurry-74fb8de441c68fff92680a48352f6b9b0f6e9271.tar hurrycurry-74fb8de441c68fff92680a48352f6b9b0f6e9271.tar.bz2 hurrycurry-74fb8de441c68fff92680a48352f6b9b0f6e9271.tar.zst |
add player portals
Diffstat (limited to 'server/src/spatial_index.rs')
-rw-r--r-- | server/src/spatial_index.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/server/src/spatial_index.rs b/server/src/spatial_index.rs index a62c80e0..d4bd1776 100644 --- a/server/src/spatial_index.rs +++ b/server/src/spatial_index.rs @@ -35,8 +35,12 @@ impl<T: Eq + Hash + Copy> SpatialIndex<T> { cb(e, pos) } } - pub fn query(&self, _position: Vec2, _radius: f32, cb: impl FnMut(T, Vec2)) { - self.all(cb) + pub fn query(&self, position: Vec2, radius: f32, mut cb: impl FnMut(T, Vec2)) { + self.all(|pl, p| { + if p.distance(position) < radius { + cb(pl, p) + } + }) } } impl<T> Default for SpatialIndex<T> { |