aboutsummaryrefslogtreecommitdiff
path: root/stockton-levels/src/helpers.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/helpers.rs
parent04f17923d38171f07f72603a54237f20ca3572dd (diff)
refactor(levels): no longer q3 specific
Diffstat (limited to 'stockton-levels/src/helpers.rs')
-rw-r--r--stockton-levels/src/helpers.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/stockton-levels/src/helpers.rs b/stockton-levels/src/helpers.rs
deleted file mode 100644
index 0fe3e96..0000000
--- a/stockton-levels/src/helpers.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-//! Helper functions for parsing
-
-use na::{Vector2, Vector3};
-use std::convert::TryInto;
-
-/// Turn a slice into a le i32, the int datatype in a bsp file.
-/// # Panics
-/// If slice is not 4 bytes long
-pub fn slice_to_i32(slice: &[u8]) -> i32 {
- i32::from_le_bytes(slice.try_into().unwrap())
-}
-
-/// Turn a slice into a le u32, used for some bitflags.
-/// # Panics
-/// If slice is not 4 bytes long.
-pub fn slice_to_u32(slice: &[u8]) -> u32 {
- u32::from_le_bytes(slice.try_into().unwrap())
-}
-
-/// Turn a slice into a le f32, the float datatype in a bsp file.
-/// # Panics
-/// If slice is not 4 bytes long
-pub fn slice_to_f32(slice: &[u8]) -> f32 {
- f32::from_bits(u32::from_le_bytes(slice.try_into().unwrap()))
-}
-
-/// Turn a slice of floats into a 3D vector
-/// # Panics
-/// If slice isn't 12 bytes long.
-pub fn slice_to_vec3(slice: &[u8]) -> Vector3<f32> {
- Vector3::new(
- slice_to_f32(&slice[0..4]),
- slice_to_f32(&slice[4..8]),
- slice_to_f32(&slice[8..12]),
- )
-}
-
-/// Turn a slice of i32s into a 3D vector
-/// # Panics
-/// If slice isn't 12 bytes long.
-pub fn slice_to_vec3i(slice: &[u8]) -> Vector3<i32> {
- Vector3::new(
- slice_to_i32(&slice[0..4]),
- slice_to_i32(&slice[4..8]),
- slice_to_i32(&slice[8..12]),
- )
-}
-
-/// Turn a slice of u32s into a 2D vector
-/// # Panics
-/// If slice isn't 8 bytes long.
-pub fn slice_to_vec2ui(slice: &[u8]) -> Vector2<u32> {
- Vector2::new(slice_to_u32(&slice[0..4]), slice_to_u32(&slice[4..8]))
-}