use core::ops::ControlFlow;
use axiolid_core::{Aabb, Ray3, Scalar};
#[derive(Debug, Clone, PartialEq)]
pub struct SpatialItem<K> {
pub key: K,
pub bounds: Aabb,
}
impl<K> SpatialItem<K> {
pub const fn new(key: K, bounds: Aabb) -> Self {
Self { key, bounds }
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct RayHit<K> {
pub key: K,
pub distance: Scalar,
}
pub trait SpatialIndex<K>: core::fmt::Debug + Send + Sync {
fn visit_aabb(&self, query: &Aabb, visitor: &mut dyn FnMut(&K) -> ControlFlow<()>);
fn visit_ray(&self, ray: &Ray3, visitor: &mut dyn FnMut(RayHit<&K>) -> ControlFlow<()>);
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
}