accumulate mouse_pos as float
This commit is contained in:
parent
405cba3549
commit
0d9c6648e2
@ -14,7 +14,7 @@ pub enum Instruction{
|
|||||||
//holds thread handles to dispatch to
|
//holds thread handles to dispatch to
|
||||||
struct WindowContext<'a>{
|
struct WindowContext<'a>{
|
||||||
manual_mouse_lock:bool,
|
manual_mouse_lock:bool,
|
||||||
mouse:strafesnet_common::mouse::MouseState<SessionTimeInner>,//std::sync::Arc<std::sync::Mutex<>>
|
mouse_pos:glam::DVec2,
|
||||||
screen_size:glam::UVec2,
|
screen_size:glam::UVec2,
|
||||||
window:&'a winit::window::Window,
|
window:&'a winit::window::Window,
|
||||||
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<PhysicsWorkerInstruction,SessionTimeInner>>,
|
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<PhysicsWorkerInstruction,SessionTimeInner>>,
|
||||||
@ -103,7 +103,7 @@ impl WindowContext<'_>{
|
|||||||
"Z"|"z"=>Some(OtherInstruction::SetZoom(s)),
|
"Z"|"z"=>Some(OtherInstruction::SetZoom(s)),
|
||||||
"R"|"r"=>if s{
|
"R"|"r"=>if s{
|
||||||
//mouse needs to be reset since the position is absolute
|
//mouse needs to be reset since the position is absolute
|
||||||
self.mouse=strafesnet_common::mouse::MouseState::default();
|
self.mouse_pos=glam::DVec2::ZERO;
|
||||||
Some(OtherInstruction::ResetAndRestart)
|
Some(OtherInstruction::ResetAndRestart)
|
||||||
}else{None},
|
}else{None},
|
||||||
"F"|"f"=>if s{Some(OtherInstruction::PracticeFly)}else{None},
|
"F"|"f"=>if s{Some(OtherInstruction::PracticeFly)}else{None},
|
||||||
@ -126,7 +126,7 @@ impl WindowContext<'_>{
|
|||||||
fn device_event(&mut self,time:SessionTime,event: winit::event::DeviceEvent){
|
fn device_event(&mut self,time:SessionTime,event: winit::event::DeviceEvent){
|
||||||
match event{
|
match event{
|
||||||
winit::event::DeviceEvent::MouseMotion{
|
winit::event::DeviceEvent::MouseMotion{
|
||||||
delta,//these (f64,f64) are integers on my machine
|
delta,
|
||||||
}=>{
|
}=>{
|
||||||
if self.manual_mouse_lock{
|
if self.manual_mouse_lock{
|
||||||
match self.window.set_cursor_position(self.get_middle_of_screen()){
|
match self.window.set_cursor_position(self.get_middle_of_screen()){
|
||||||
@ -137,11 +137,10 @@ impl WindowContext<'_>{
|
|||||||
//do not step the physics because the mouse polling rate is higher than the physics can run.
|
//do not step the physics because the mouse polling rate is higher than the physics can run.
|
||||||
//essentially the previous input will be overwritten until a true step runs
|
//essentially the previous input will be overwritten until a true step runs
|
||||||
//which is fine because they run all the time.
|
//which is fine because they run all the time.
|
||||||
let delta=glam::ivec2(delta.0 as i32,delta.1 as i32);
|
self.mouse_pos+=glam::dvec2(delta.0,delta.1);
|
||||||
self.mouse.pos+=delta;
|
|
||||||
self.physics_thread.send(TimedInstruction{
|
self.physics_thread.send(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:PhysicsWorkerInstruction::Input(UnbufferedInstruction::MoveMouse(self.mouse.pos)),
|
instruction:PhysicsWorkerInstruction::Input(UnbufferedInstruction::MoveMouse(self.mouse_pos.as_ivec2())),
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
},
|
},
|
||||||
winit::event::DeviceEvent::MouseWheel {
|
winit::event::DeviceEvent::MouseWheel {
|
||||||
@ -174,7 +173,7 @@ pub fn worker<'a>(
|
|||||||
let graphics_thread=crate::graphics_worker::new(graphics,setup_context.config,setup_context.surface,setup_context.device,setup_context.queue);
|
let graphics_thread=crate::graphics_worker::new(graphics,setup_context.config,setup_context.surface,setup_context.device,setup_context.queue);
|
||||||
let mut window_context=WindowContext{
|
let mut window_context=WindowContext{
|
||||||
manual_mouse_lock:false,
|
manual_mouse_lock:false,
|
||||||
mouse:strafesnet_common::mouse::MouseState::default(),
|
mouse_pos:glam::DVec2::ZERO,
|
||||||
//make sure to update this!!!!!
|
//make sure to update this!!!!!
|
||||||
screen_size,
|
screen_size,
|
||||||
window,
|
window,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user