diff options
-rw-r--r-- | server/src/lib.rs | 1 | ||||
-rw-r--r-- | server/src/spatial_index.rs | 52 |
2 files changed, 0 insertions, 53 deletions
diff --git a/server/src/lib.rs b/server/src/lib.rs index b87f1cb9..93218a9e 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -20,7 +20,6 @@ pub mod data; pub mod entity; pub mod server; pub mod interaction; -pub mod spatial_index; pub mod state; use hurrycurry_protocol::glam::Vec2; diff --git a/server/src/spatial_index.rs b/server/src/spatial_index.rs deleted file mode 100644 index d4bd1776..00000000 --- a/server/src/spatial_index.rs +++ /dev/null @@ -1,52 +0,0 @@ -/* - Hurry Curry! - a game about cooking - Copyright 2024 metamuffin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, version 3 of the License only. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -*/ -use hurrycurry_protocol::glam::Vec2; -use std::{collections::HashMap, hash::Hash}; - -// TODO stub implementation. please implement -pub struct SpatialIndex<T> { - entries: HashMap<T, Vec2>, -} - -impl<T: Eq + Hash + Copy> SpatialIndex<T> { - pub fn update_entry(&mut self, id: T, position: Vec2) { - self.entries.insert(id, position); - } - pub fn remove_entry(&mut self, id: T) { - self.entries.remove(&id); - } - pub fn all(&self, mut cb: impl FnMut(T, Vec2)) { - for (&e, &pos) in &self.entries { - cb(e, pos) - } - } - 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> { - fn default() -> Self { - Self { - entries: Default::default(), - } - } -} |