summaryrefslogtreecommitdiff
path: root/shared/src/graphics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/graphics.rs')
-rw-r--r--shared/src/graphics.rs22
1 files changed, 17 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() {