clarify new as int
This commit is contained in:
parent
54ec21c490
commit
101c92cba4
@ -214,7 +214,7 @@ pub struct Unit64Mat3{
|
||||
pub struct Planar64(i64);
|
||||
impl Planar64{
|
||||
pub const ONE:Self=Self(2<<32);
|
||||
pub fn new(num:i32)->Self{
|
||||
pub fn int(num:i32)->Self{
|
||||
Self(Self::ONE.0*num as i64)
|
||||
}
|
||||
pub fn from_ratio(num:i64,den:std::num::NonZeroU64)->Self{
|
||||
@ -254,6 +254,13 @@ impl std::ops::Div<i64> for Planar64{
|
||||
Planar64(self.0/rhs)
|
||||
}
|
||||
}
|
||||
impl std::ops::Div<Planar64> for Planar64{
|
||||
type Output=Planar64;
|
||||
#[inline]
|
||||
fn div(self, rhs: Planar64) -> Self::Output {
|
||||
Planar64((((self.0 as i128)<<64)/rhs.0 as i128) as i64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///[-1.0,1.0] = [-2^32,2^32]
|
||||
@ -268,7 +275,7 @@ impl Planar64Vec3{
|
||||
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 int(x:i32,y:i32,z:i32)->Self{
|
||||
Self(glam::i64vec3((x as i64)<<32,(y as i64)<<32,(z as i64)<<32))
|
||||
}
|
||||
#[inline]
|
||||
|
@ -219,12 +219,12 @@ impl std::default::Default for StyleModifiers{
|
||||
controls_mask: !0,//&!(Self::CONTROL_MOVEUP|Self::CONTROL_MOVEDOWN),
|
||||
controls_held: 0,
|
||||
strafe_tick_rate:Ratio64::ONE.rhs_div_ratio(100),
|
||||
gravity: Planar64Vec3::new(0,100,0),
|
||||
friction: Planar64::new(12)/10,
|
||||
walk_accel: Planar64::new(90),
|
||||
mv: Planar64::new(27)/10,
|
||||
walkspeed: Planar64::new(18),
|
||||
hitbox_halfsize: Planar64Vec3::new(2,5,2)/2,
|
||||
gravity: Planar64Vec3::int(0,100,0),
|
||||
friction: Planar64::int(12)/10,
|
||||
walk_accel: Planar64::int(90),
|
||||
mv: Planar64::int(27)/10,
|
||||
walkspeed: Planar64::int(18),
|
||||
hitbox_halfsize: Planar64Vec3::int(2,5,2)/2,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -416,8 +416,8 @@ impl Body {
|
||||
impl Default for PhysicsState{
|
||||
fn default() -> Self {
|
||||
Self{
|
||||
spawn_point:Planar64Vec3::new(0,50,0),
|
||||
body: Body::with_pva(Planar64Vec3::new(0,50,0),Planar64Vec3::new(0,0,0),Planar64Vec3::new(0,-100,0)),
|
||||
spawn_point:Planar64Vec3::int(0,50,0),
|
||||
body: Body::with_pva(Planar64Vec3::int(0,50,0),Planar64Vec3::int(0,0,0),Planar64Vec3::int(0,-100,0)),
|
||||
time: Time::ZERO,
|
||||
style:StyleModifiers::default(),
|
||||
grounded: false,
|
||||
@ -426,7 +426,7 @@ impl Default for PhysicsState{
|
||||
models: Vec::new(),
|
||||
bvh:crate::bvh::BvhNode::default(),
|
||||
walk: WalkState::new(),
|
||||
camera: PhysicsCamera::from_offset(Planar64Vec3::new(0,2,0)),//4.5-2.5=2
|
||||
camera: PhysicsCamera::from_offset(Planar64Vec3::int(0,2,0)),//4.5-2.5=2
|
||||
next_mouse: MouseState::default(),
|
||||
controls: 0,
|
||||
world:WorldState{},
|
||||
@ -643,7 +643,7 @@ impl PhysicsState {
|
||||
}
|
||||
fn jump(&mut self){
|
||||
self.grounded=false;//do I need this?
|
||||
let mut v=self.body.velocity+Planar64Vec3::new(0,715588,0)/20000;//0.715588/2.0*100.0
|
||||
let mut v=self.body.velocity+Planar64Vec3::int(0,715588,0)/20000;//0.715588/2.0*100.0
|
||||
self.contact_constrain_velocity(&mut v);
|
||||
self.body.velocity=v;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user