fix divide by zero crashes when mouse has not moved
This commit is contained in:
parent
a612d1f864
commit
76bafa4d0a
@ -14,6 +14,7 @@ impl<T> Time<T>{
|
|||||||
pub const MIN:Self=Self::raw(i64::MIN);
|
pub const MIN:Self=Self::raw(i64::MIN);
|
||||||
pub const MAX:Self=Self::raw(i64::MAX);
|
pub const MAX:Self=Self::raw(i64::MAX);
|
||||||
pub const ZERO:Self=Self::raw(0);
|
pub const ZERO:Self=Self::raw(0);
|
||||||
|
pub const EPSILON:Self=Self::raw(1);
|
||||||
pub const ONE_SECOND:Self=Self::raw(1_000_000_000);
|
pub const ONE_SECOND:Self=Self::raw(1_000_000_000);
|
||||||
pub const ONE_MILLISECOND:Self=Self::raw(1_000_000);
|
pub const ONE_MILLISECOND:Self=Self::raw(1_000_000);
|
||||||
pub const ONE_MICROSECOND:Self=Self::raw(1_000);
|
pub const ONE_MICROSECOND:Self=Self::raw(1_000);
|
||||||
|
@ -71,7 +71,7 @@ pub enum InternalInstruction{
|
|||||||
// Water,
|
// Water,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Debug,Default)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct InputState{
|
pub struct InputState{
|
||||||
mouse:MouseState,
|
mouse:MouseState,
|
||||||
next_mouse:MouseState,
|
next_mouse:MouseState,
|
||||||
@ -104,6 +104,15 @@ impl InputState{
|
|||||||
((dm*t)/dt).as_ivec2()
|
((dm*t)/dt).as_ivec2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Default for InputState{
|
||||||
|
fn default()->Self{
|
||||||
|
Self{
|
||||||
|
mouse:MouseState{pos:Default::default(),time:Time::ZERO-Time::EPSILON*2},
|
||||||
|
next_mouse:MouseState{pos:Default::default(),time:Time::ZERO-Time::EPSILON},
|
||||||
|
controls:Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
enum JumpDirection{
|
enum JumpDirection{
|
||||||
Exactly(Planar64Vec3),
|
Exactly(Planar64Vec3),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user