diff --git a/src/integer.rs b/src/integer.rs index 965739a..55ba7ae 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -179,7 +179,7 @@ pub struct Unit64Mat3{ ///[-1.0,1.0] = [-2^32,2^32] -#[derive(Clone,Copy)] +#[derive(Clone,Copy,Hash)] pub struct Planar64(i64); impl Planar64{ pub const ONE:Self=Self(2<<32); @@ -221,7 +221,7 @@ impl std::ops::Div for Planar64{ ///[-1.0,1.0] = [-2^32,2^32] -#[derive(Clone,Copy)] +#[derive(Clone,Copy,Hash)] pub struct Planar64Vec3(glam::I64Vec3); impl Planar64Vec3{ pub fn new(x:i32,y:i32,z:i32)->Self{ diff --git a/src/physics.rs b/src/physics.rs index 2ac74e8..125ef78 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -49,32 +49,13 @@ pub enum InputInstruction { //for interpolation / networking / playback reasons, most playback heads will always want //to be 1 instruction ahead to generate the next state for interpolation. } -#[derive(Clone)] +#[derive(Clone,Hash)] pub struct Body { position: Planar64Vec3,//I64 where 2^32 = 1 u velocity: Planar64Vec3,//I64 where 2^32 = 1 u/s acceleration: Planar64Vec3,//I64 where 2^32 = 1 u/s/s time: TIME,//nanoseconds x xxxxD! } -trait MyHash{ - fn hash(&self) -> u64; -} -impl MyHash for Body { - fn hash(&self) -> u64 { - let mut hasher=std::collections::hash_map::DefaultHasher::new(); - for &el in self.position.as_ref().iter() { - std::hash::Hasher::write(&mut hasher, el.to_ne_bytes().as_slice()); - } - for &el in self.velocity.as_ref().iter() { - std::hash::Hasher::write(&mut hasher, el.to_ne_bytes().as_slice()); - } - for &el in self.acceleration.as_ref().iter() { - std::hash::Hasher::write(&mut hasher, el.to_ne_bytes().as_slice()); - } - std::hash::Hasher::write(&mut hasher, self.time.to_ne_bytes().as_slice()); - return std::hash::Hasher::finish(&hasher);//hash check to see if walk target is valid - } -} pub enum MoveRestriction { Air,