aboutsummaryrefslogtreecommitdiff
path: root/stockton-levels/src/q3/planes.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:23 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:23 +0100
commit439219e74090c7158f8dbc33fed4107a5eb7c003 (patch)
tree7ba62254b2d888578ff6c1c8de4f0f35c01c75dd /stockton-levels/src/q3/planes.rs
parent04f17923d38171f07f72603a54237f20ca3572dd (diff)
refactor(levels): no longer q3 specific
Diffstat (limited to 'stockton-levels/src/q3/planes.rs')
-rw-r--r--stockton-levels/src/q3/planes.rs40
1 files changed, 0 insertions, 40 deletions
diff --git a/stockton-levels/src/q3/planes.rs b/stockton-levels/src/q3/planes.rs
deleted file mode 100644
index b4d3217..0000000
--- a/stockton-levels/src/q3/planes.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-const PLANE_SIZE: usize = (4 * 3) + 4;
-
-use super::Q3BspFile;
-use crate::coords::CoordSystem;
-use crate::helpers::{slice_to_f32, slice_to_vec3};
-use crate::traits::planes::*;
-use crate::types::{ParseError, Result};
-
-/// Parse a lump of planes.
-/// A lump is (data length / plane size) planes long
-pub fn from_data(data: &[u8]) -> Result<Box<[Plane]>> {
- let length = data.len() / PLANE_SIZE;
- if data.is_empty() || data.len() % PLANE_SIZE != 0 || length % 2 != 0 {
- return Err(ParseError::Invalid);
- }
-
- let mut planes = Vec::with_capacity(length / 2);
- for n in 0..length {
- let offset = n * PLANE_SIZE;
- let plane = &data[offset..offset + PLANE_SIZE];
- planes.push(Plane {
- normal: slice_to_vec3(&plane[0..12]),
- dist: slice_to_f32(&plane[12..16]),
- });
- }
-
- Ok(planes.into_boxed_slice())
-}
-
-impl<T: CoordSystem> HasPlanes<T> for Q3BspFile<T> {
- type PlanesIter<'a> = std::slice::Iter<'a, Plane>;
-
- fn planes_iter(&self) -> Self::PlanesIter<'_> {
- self.planes.iter()
- }
-
- fn get_plane(&self, idx: u32) -> &Plane {
- &self.planes[idx as usize]
- }
-}