pxl8/pxl8d/src/chunk.rs

42 lines
817 B
Rust
Raw Normal View History

2026-01-25 09:26:30 -06:00
extern crate alloc;
pub mod stream;
use crate::bsp::Bsp;
use crate::math::Vec3;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum ChunkId {
Bsp(u32),
}
pub enum Chunk {
Bsp { id: u32, bsp: Bsp, version: u32 },
}
impl Chunk {
pub fn id(&self) -> ChunkId {
match self {
Chunk::Bsp { id, .. } => ChunkId::Bsp(*id),
}
}
pub fn version(&self) -> u32 {
match self {
Chunk::Bsp { version, .. } => *version,
}
}
pub fn trace(&self, from: Vec3, to: Vec3, radius: f32) -> Vec3 {
match self {
Chunk::Bsp { bsp, .. } => bsp.trace(from, to, radius),
}
}
pub fn as_bsp(&self) -> Option<&Bsp> {
match self {
Chunk::Bsp { bsp, .. } => Some(bsp),
}
}
}