forked from StrafesNET/strafe-client
do not step physics on mouse input, only update pos (overwriting previous pos)
This commit is contained in:
parent
bd04f680d8
commit
1d9d4efedb
@ -102,7 +102,7 @@ pub struct MouseInterpolationState {
|
|||||||
impl MouseInterpolationState {
|
impl MouseInterpolationState {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
interpolation:MouseInterpolation::Lerp,
|
interpolation:MouseInterpolation::First,
|
||||||
time0:0,
|
time0:0,
|
||||||
time1:1,//ONE NANOSECOND!!!! avoid divide by zero
|
time1:1,//ONE NANOSECOND!!!! avoid divide by zero
|
||||||
mouse0:glam::IVec2::ZERO,
|
mouse0:glam::IVec2::ZERO,
|
||||||
@ -902,6 +902,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
}
|
}
|
||||||
//selectively update body
|
//selectively update body
|
||||||
match &ins.instruction {
|
match &ins.instruction {
|
||||||
|
PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),//dodge time for mouse movement
|
||||||
PhysicsInstruction::Input(_)
|
PhysicsInstruction::Input(_)
|
||||||
|PhysicsInstruction::ReachWalkTargetVelocity
|
|PhysicsInstruction::ReachWalkTargetVelocity
|
||||||
|PhysicsInstruction::CollisionStart(_)
|
|PhysicsInstruction::CollisionStart(_)
|
||||||
|
@ -605,7 +605,6 @@ impl strafe_client::framework::Example for GraphicsData {
|
|||||||
fn device_event(&mut self, event: winit::event::DeviceEvent) {
|
fn device_event(&mut self, event: winit::event::DeviceEvent) {
|
||||||
//there's no way this is the best way get a timestamp.
|
//there's no way this is the best way get a timestamp.
|
||||||
let time=self.start_time.elapsed().as_nanos() as i64;
|
let time=self.start_time.elapsed().as_nanos() as i64;
|
||||||
self.physics.run(time);//call it a day
|
|
||||||
match event {
|
match event {
|
||||||
winit::event::DeviceEvent::Key(winit::event::KeyboardInput {
|
winit::event::DeviceEvent::Key(winit::event::KeyboardInput {
|
||||||
state,
|
state,
|
||||||
@ -629,6 +628,7 @@ impl strafe_client::framework::Example for GraphicsData {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
self.physics.run(time);
|
||||||
self.physics.process_instruction(TimedInstruction{
|
self.physics.process_instruction(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:PhysicsInstruction::Input(input_instruction),
|
instruction:PhysicsInstruction::Input(input_instruction),
|
||||||
@ -638,6 +638,9 @@ impl strafe_client::framework::Example for GraphicsData {
|
|||||||
winit::event::DeviceEvent::MouseMotion {
|
winit::event::DeviceEvent::MouseMotion {
|
||||||
delta,//these (f64,f64) are integers on my machine
|
delta,//these (f64,f64) are integers on my machine
|
||||||
} => {
|
} => {
|
||||||
|
//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
|
||||||
|
//which is fine because they run all the time.
|
||||||
self.physics.process_instruction(TimedInstruction{
|
self.physics.process_instruction(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:PhysicsInstruction::Input(InputInstruction::MoveMouse(glam::ivec2(delta.0 as i32,delta.1 as i32))),
|
instruction:PhysicsInstruction::Input(InputInstruction::MoveMouse(glam::ivec2(delta.0 as i32,delta.1 as i32))),
|
||||||
@ -648,6 +651,7 @@ impl strafe_client::framework::Example for GraphicsData {
|
|||||||
} => {
|
} => {
|
||||||
println!("mousewheel{:?}",delta);
|
println!("mousewheel{:?}",delta);
|
||||||
if true{//self.physics.use_scroll
|
if true{//self.physics.use_scroll
|
||||||
|
self.physics.run(time);
|
||||||
self.physics.process_instruction(TimedInstruction{
|
self.physics.process_instruction(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:PhysicsInstruction::Input(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
|
instruction:PhysicsInstruction::Input(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
|
||||||
|
Loading…
Reference in New Issue
Block a user