diff --git a/src/integer.rs b/src/integer.rs index 55ba7ae..d5c6879 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -224,6 +224,14 @@ impl std::ops::Div for Planar64{ #[derive(Clone,Copy,Hash)] pub struct Planar64Vec3(glam::I64Vec3); impl Planar64Vec3{ + pub const ZERO:Self=Planar64Vec3(glam::I64Vec3::ZERO); + pub const ONE:Self=Planar64Vec3(glam::I64Vec3::ONE); + pub const X:Self=Planar64Vec3(glam::I64Vec3::X); + pub const Y:Self=Planar64Vec3(glam::I64Vec3::Y); + pub const Z:Self=Planar64Vec3(glam::I64Vec3::Z); + pub const NEG_X:Self=Planar64Vec3(glam::I64Vec3::NEG_X); + pub const NEG_Y:Self=Planar64Vec3(glam::I64Vec3::NEG_Y); + pub const NEG_Z:Self=Planar64Vec3(glam::I64Vec3::NEG_Z); pub fn new(x:i32,y:i32,z:i32)->Self{ Self(glam::i64vec3((x as i64)<<32,(y as i64)<<32,(z as i64)<<32)) } @@ -240,6 +248,32 @@ impl Planar64Vec3{ Planar64(self.0.z) } } +impl std::ops::Add for Planar64Vec3{ + type Output=Planar64Vec3; + #[inline] + fn add(self,rhs:Planar64Vec3) -> Self::Output { + Planar64Vec3(self.0+rhs.0) + } +} +impl std::ops::AddAssign for Planar64Vec3{ + #[inline] + fn add_assign(&mut self,rhs:Planar64Vec3){ + *self=*self+rhs + } +} +impl std::ops::Sub for Planar64Vec3{ + type Output=Planar64Vec3; + #[inline] + fn sub(self,rhs:Planar64Vec3) -> Self::Output { + Planar64Vec3(self.0-rhs.0) + } +} +impl std::ops::SubAssign for Planar64Vec3{ + #[inline] + fn sub_assign(&mut self,rhs:Planar64Vec3){ + *self=*self-rhs + } +} impl std::ops::Mul for Planar64Vec3{ type Output=Planar64Vec3; #[inline] @@ -251,6 +285,17 @@ impl std::ops::Mul for Planar64Vec3{ )) } } +impl std::ops::Div for Planar64Vec3{ + type Output=Planar64Vec3; + #[inline] + fn div(self,rhs:i64)->Self::Output{ + Planar64Vec3(glam::i64vec3( + self.0.x/rhs, + self.0.y/rhs, + self.0.z/rhs, + )) + } +} ///[-1.0,1.0] = [-2^32,2^32] #[derive(Clone,Copy)] diff --git a/src/physics.rs b/src/physics.rs index 125ef78..33986ba 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -222,27 +222,27 @@ impl std::default::Default for StyleModifiers{ strafe_tick_num: 100,//100t strafe_tick_den: 1_000_000_000, gravity: Planar64Vec3::new(0,100,0), - friction: 1.2, - walk_accel: 90.0, + friction: Planar64::new(12)/10, + walk_accel: Planar64::new(90), mv: Planar64::new(27)/10, - walkspeed: 18.0, + walkspeed: Planar64::new(18), hitbox_halfsize: Planar64Vec3::new(2,5,2)/2, } } } impl StyleModifiers{ - const CONTROL_MOVEFORWARD:u32 = 0b00000001; - const CONTROL_MOVEBACK:u32 = 0b00000010; - const CONTROL_MOVERIGHT:u32 = 0b00000100; - const CONTROL_MOVELEFT:u32 = 0b00001000; - const CONTROL_MOVEUP:u32 = 0b00010000; - const CONTROL_MOVEDOWN:u32 = 0b00100000; - const CONTROL_JUMP:u32 = 0b01000000; - const CONTROL_ZOOM:u32 = 0b10000000; + const CONTROL_MOVEFORWARD:u32=0b00000001; + const CONTROL_MOVEBACK:u32=0b00000010; + const CONTROL_MOVERIGHT:u32=0b00000100; + const CONTROL_MOVELEFT:u32=0b00001000; + const CONTROL_MOVEUP:u32=0b00010000; + const CONTROL_MOVEDOWN:u32=0b00100000; + const CONTROL_JUMP:u32=0b01000000; + const CONTROL_ZOOM:u32=0b10000000; - const FORWARD_DIR:Planar64Vec3 = Planar64Vec3::NEG_Z; - const RIGHT_DIR:Planar64Vec3 = Planar64Vec3::X; - const UP_DIR:Planar64Vec3 = Planar64Vec3::Y; + const RIGHT_DIR:Planar64Vec3=Planar64Vec3::X; + const UP_DIR:Planar64Vec3=Planar64Vec3::Y; + const FORWARD_DIR:Planar64Vec3=Planar64Vec3::NEG_Z; fn get_control(&self,control:u32,controls:u32)->bool{ controls&self.controls_mask&control==control @@ -261,10 +261,10 @@ impl StyleModifiers{ control_dir+=Self::FORWARD_DIR; } if controls & Self::CONTROL_MOVEBACK == Self::CONTROL_MOVEBACK { - control_dir+=-Self::FORWARD_DIR; + control_dir-=Self::FORWARD_DIR; } if controls & Self::CONTROL_MOVELEFT == Self::CONTROL_MOVELEFT { - control_dir+=-Self::RIGHT_DIR; + control_dir-=Self::RIGHT_DIR; } if controls & Self::CONTROL_MOVERIGHT == Self::CONTROL_MOVERIGHT { control_dir+=Self::RIGHT_DIR; @@ -273,7 +273,7 @@ impl StyleModifiers{ control_dir+=Self::UP_DIR; } if controls & Self::CONTROL_MOVEDOWN == Self::CONTROL_MOVEDOWN { - control_dir+=-Self::UP_DIR; + control_dir-=Self::UP_DIR; } return control_dir }