.cargo
engine
integration-testing
lib
bsp_loader
common
src
aabb.rs
bvh.rs
controls_bitflag.rs
gameplay_attributes.rs
gameplay_modes.rs
gameplay_style.rs
instruction.rs
integer.rs
lib.rs
map.rs
model.rs
mouse.rs
physics.rs
run.rs
session.rs
timer.rs
updatable.rs
.gitignore
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md
deferred_loader
fixed_wide
linear_ops
ratio_ops
rbx_loader
rbxassetid
roblox_emulator
snf
README.md
map-tool
strafe-client
tools
.gitignore
Cargo.lock
Cargo.toml
README.md
logo.png
29 lines
594 B
Rust
29 lines
594 B
Rust
use crate::integer::Time;
|
|
|
|
#[derive(Clone,Debug)]
|
|
pub struct MouseState<T>{
|
|
pub pos:glam::IVec2,
|
|
pub time:Time<T>,
|
|
}
|
|
impl<T> Default for MouseState<T>{
|
|
fn default()->Self{
|
|
Self{
|
|
time:Time::ZERO,
|
|
pos:glam::IVec2::ZERO,
|
|
}
|
|
}
|
|
}
|
|
impl<T> MouseState<T>
|
|
where Time<T>:Copy,
|
|
{
|
|
pub fn lerp(&self,target:&MouseState<T>,time:Time<T>)->glam::IVec2{
|
|
let m0=self.pos.as_i64vec2();
|
|
let m1=target.pos.as_i64vec2();
|
|
//these are deltas
|
|
let t1t=(target.time-time).nanos();
|
|
let tt0=(time-self.time).nanos();
|
|
let dt=(target.time-self.time).nanos();
|
|
((m0*t1t+m1*tt0)/dt).as_ivec2()
|
|
}
|
|
}
|