use nalgebra::Vector3;
#[derive(Debug)]
pub struct BoundingBox {
pub width: f32,
pub height: f32,
pub position: Vector3<f32>,
}
impl BoundingBox {
pub fn new(width: f32, height: f32, position: Vector3<f32>) -> Self {
Self {
width,
height,
position,
}
}
pub fn check_collision(&self, other: &BoundingBox) -> bool {
other.position.x >= self.position.x &&
other.position.x <= self.position.x + self.width &&
other.position.y >= self.position.y &&
other.position.y <= self.position.y + self.height &&
other.position.z >= self.position.z
}
}