diff options
-rw-r--r-- | shared/src/graphics.rs | 22 | ||||
-rw-r--r-- | shared/src/store.rs | 8 |
2 files changed, 25 insertions, 5 deletions
diff --git a/shared/src/graphics.rs b/shared/src/graphics.rs index ae4ee58..5ba0d99 100644 --- a/shared/src/graphics.rs +++ b/shared/src/graphics.rs @@ -39,6 +39,7 @@ pub enum GraphicsCommand { Line(Vec3), Close, + Point(Vec3), Unknown, } @@ -68,11 +69,8 @@ impl<'a> Iterator for CommandIter<'a> { f32::from_le_bytes([data[0], data[1], data[2], data[3]]), f32::from_le_bytes([data[4], data[5], data[6], data[7]]), ), - (4, 12) => Line(vec3( - f32::from_le_bytes([data[0], data[1], data[2], data[3]]), - f32::from_le_bytes([data[4], data[5], data[6], data[7]]), - f32::from_le_bytes([data[8], data[9], data[10], data[11]]), - )), + (4, 12) => Line(get_vec3(data)), + (6, 12) => Point(get_vec3(data)), (5, 0) => Close, _ => Unknown, }) @@ -100,12 +98,26 @@ impl GraphicsPart { self.0.extend(p.y.to_le_bytes()); self.0.extend(p.z.to_le_bytes()); } + GraphicsCommand::Point(p) => { + self.0.extend([12, 6]); + self.0.extend(p.x.to_le_bytes()); + self.0.extend(p.y.to_le_bytes()); + self.0.extend(p.z.to_le_bytes()); + } GraphicsCommand::Close => self.0.extend([0, 5]), GraphicsCommand::Unknown => self.0.extend([0, 255]), } } } +fn get_vec3(data: &[u8]) -> Vec3 { + vec3( + f32::from_le_bytes([data[0], data[1], data[2], data[3]]), + f32::from_le_bytes([data[4], data[5], data[6], data[7]]), + f32::from_le_bytes([data[8], data[9], data[10], data[11]]), + ) +} + #[test] #[cfg(test)] fn test_ser() { diff --git a/shared/src/store.rs b/shared/src/store.rs index 61b5dee..960d641 100644 --- a/shared/src/store.rs +++ b/shared/src/store.rs @@ -185,6 +185,14 @@ impl ResourceStore { ResourceStore::Respack(r) => Ok(r.lock().unwrap().iter(cb)), } } + pub fn count(&self) -> Result<usize> { + match self { + ResourceStore::Redb(_database) => todo!(), + ResourceStore::Filesystem(_path) => todo!(), + ResourceStore::Memory(map) => Ok(map.lock().unwrap().len()), + ResourceStore::Respack(_pack) => todo!(), + } + } } pub fn resource_hash(x: &[u8]) -> [u8; 32] { |