From 74fb8de441c68fff92680a48352f6b9b0f6e9271 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 23 Jul 2024 21:27:25 +0200 Subject: add player portals --- server/src/spatial_index.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server/src/spatial_index.rs') 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 SpatialIndex { 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 Default for SpatialIndex { -- cgit v1.2.3-70-g09d2