refactor: decouple sim from framework, remove voxel geometry
This commit is contained in:
parent
c538641ec8
commit
5a565844dd
41 changed files with 477 additions and 2407 deletions
|
|
@ -4,55 +4,38 @@ pub mod stream;
|
|||
|
||||
use crate::bsp::Bsp;
|
||||
use crate::math::Vec3;
|
||||
use crate::pxl8::pxl8_vxl_trace;
|
||||
use crate::voxel::VoxelChunk;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub enum ChunkId {
|
||||
Bsp(u32),
|
||||
Vxl(i32, i32, i32),
|
||||
}
|
||||
|
||||
pub enum Chunk {
|
||||
Bsp { id: u32, bsp: Bsp, version: u32 },
|
||||
Vxl { cx: i32, cy: i32, cz: i32, data: VoxelChunk, version: u32 },
|
||||
}
|
||||
|
||||
impl Chunk {
|
||||
pub fn id(&self) -> ChunkId {
|
||||
match self {
|
||||
Chunk::Bsp { id, .. } => ChunkId::Bsp(*id),
|
||||
Chunk::Vxl { cx, cy, cz, .. } => ChunkId::Vxl(*cx, *cy, *cz),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn version(&self) -> u32 {
|
||||
match self {
|
||||
Chunk::Bsp { version, .. } => *version,
|
||||
Chunk::Vxl { version, .. } => *version,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trace(&self, from: Vec3, to: Vec3, radius: f32) -> Vec3 {
|
||||
match self {
|
||||
Chunk::Bsp { bsp, .. } => bsp.trace(from, to, radius),
|
||||
Chunk::Vxl { cx, cy, cz, data, .. } => unsafe {
|
||||
pxl8_vxl_trace(data.chunk, *cx, *cy, *cz, from, to, radius)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_bsp(&self) -> Option<&Bsp> {
|
||||
match self {
|
||||
Chunk::Bsp { bsp, .. } => Some(bsp),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_vxl(&self) -> Option<&VoxelChunk> {
|
||||
match self {
|
||||
Chunk::Vxl { data, .. } => Some(data),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue