forked from StrafesNET/strafe-project
implement StyleModifiers
This commit is contained in:
parent
c21c587edc
commit
b6b63b4c85
@ -224,6 +224,14 @@ impl std::ops::Div<i64> for Planar64{
|
|||||||
#[derive(Clone,Copy,Hash)]
|
#[derive(Clone,Copy,Hash)]
|
||||||
pub struct Planar64Vec3(glam::I64Vec3);
|
pub struct Planar64Vec3(glam::I64Vec3);
|
||||||
impl Planar64Vec3{
|
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{
|
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))
|
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)
|
Planar64(self.0.z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl std::ops::Add<Planar64Vec3> for Planar64Vec3{
|
||||||
|
type Output=Planar64Vec3;
|
||||||
|
#[inline]
|
||||||
|
fn add(self,rhs:Planar64Vec3) -> Self::Output {
|
||||||
|
Planar64Vec3(self.0+rhs.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::ops::AddAssign<Planar64Vec3> for Planar64Vec3{
|
||||||
|
#[inline]
|
||||||
|
fn add_assign(&mut self,rhs:Planar64Vec3){
|
||||||
|
*self=*self+rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::ops::Sub<Planar64Vec3> for Planar64Vec3{
|
||||||
|
type Output=Planar64Vec3;
|
||||||
|
#[inline]
|
||||||
|
fn sub(self,rhs:Planar64Vec3) -> Self::Output {
|
||||||
|
Planar64Vec3(self.0-rhs.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::ops::SubAssign<Planar64Vec3> for Planar64Vec3{
|
||||||
|
#[inline]
|
||||||
|
fn sub_assign(&mut self,rhs:Planar64Vec3){
|
||||||
|
*self=*self-rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
impl std::ops::Mul<Planar64> for Planar64Vec3{
|
impl std::ops::Mul<Planar64> for Planar64Vec3{
|
||||||
type Output=Planar64Vec3;
|
type Output=Planar64Vec3;
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -251,6 +285,17 @@ impl std::ops::Mul<Planar64> for Planar64Vec3{
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl std::ops::Div<i64> 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]
|
///[-1.0,1.0] = [-2^32,2^32]
|
||||||
#[derive(Clone,Copy)]
|
#[derive(Clone,Copy)]
|
||||||
|
@ -222,10 +222,10 @@ impl std::default::Default for StyleModifiers{
|
|||||||
strafe_tick_num: 100,//100t
|
strafe_tick_num: 100,//100t
|
||||||
strafe_tick_den: 1_000_000_000,
|
strafe_tick_den: 1_000_000_000,
|
||||||
gravity: Planar64Vec3::new(0,100,0),
|
gravity: Planar64Vec3::new(0,100,0),
|
||||||
friction: 1.2,
|
friction: Planar64::new(12)/10,
|
||||||
walk_accel: 90.0,
|
walk_accel: Planar64::new(90),
|
||||||
mv: Planar64::new(27)/10,
|
mv: Planar64::new(27)/10,
|
||||||
walkspeed: 18.0,
|
walkspeed: Planar64::new(18),
|
||||||
hitbox_halfsize: Planar64Vec3::new(2,5,2)/2,
|
hitbox_halfsize: Planar64Vec3::new(2,5,2)/2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,9 +240,9 @@ impl StyleModifiers{
|
|||||||
const CONTROL_JUMP:u32=0b01000000;
|
const CONTROL_JUMP:u32=0b01000000;
|
||||||
const CONTROL_ZOOM:u32=0b10000000;
|
const CONTROL_ZOOM:u32=0b10000000;
|
||||||
|
|
||||||
const FORWARD_DIR:Planar64Vec3 = Planar64Vec3::NEG_Z;
|
|
||||||
const RIGHT_DIR:Planar64Vec3=Planar64Vec3::X;
|
const RIGHT_DIR:Planar64Vec3=Planar64Vec3::X;
|
||||||
const UP_DIR:Planar64Vec3=Planar64Vec3::Y;
|
const UP_DIR:Planar64Vec3=Planar64Vec3::Y;
|
||||||
|
const FORWARD_DIR:Planar64Vec3=Planar64Vec3::NEG_Z;
|
||||||
|
|
||||||
fn get_control(&self,control:u32,controls:u32)->bool{
|
fn get_control(&self,control:u32,controls:u32)->bool{
|
||||||
controls&self.controls_mask&control==control
|
controls&self.controls_mask&control==control
|
||||||
@ -261,10 +261,10 @@ impl StyleModifiers{
|
|||||||
control_dir+=Self::FORWARD_DIR;
|
control_dir+=Self::FORWARD_DIR;
|
||||||
}
|
}
|
||||||
if controls & Self::CONTROL_MOVEBACK == Self::CONTROL_MOVEBACK {
|
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 {
|
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 {
|
if controls & Self::CONTROL_MOVERIGHT == Self::CONTROL_MOVERIGHT {
|
||||||
control_dir+=Self::RIGHT_DIR;
|
control_dir+=Self::RIGHT_DIR;
|
||||||
@ -273,7 +273,7 @@ impl StyleModifiers{
|
|||||||
control_dir+=Self::UP_DIR;
|
control_dir+=Self::UP_DIR;
|
||||||
}
|
}
|
||||||
if controls & Self::CONTROL_MOVEDOWN == Self::CONTROL_MOVEDOWN {
|
if controls & Self::CONTROL_MOVEDOWN == Self::CONTROL_MOVEDOWN {
|
||||||
control_dir+=-Self::UP_DIR;
|
control_dir-=Self::UP_DIR;
|
||||||
}
|
}
|
||||||
return control_dir
|
return control_dir
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user