exit strafe tick early if zero control dir

This commit is contained in:
Quaternions 2023-11-08 20:23:39 -08:00
parent 27a46093ae
commit 053514fa4a

View File

@ -1445,8 +1445,10 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
} }
}, },
PhysicsInstruction::StrafeTick => { PhysicsInstruction::StrafeTick => {
let control_dir=self.style.get_control_dir(self.controls);
if control_dir!=Planar64Vec3::ZERO{
let camera_mat=self.camera.simulate_move_rotation_y(self.camera.mouse.lerp(&self.next_mouse,self.time).x); let camera_mat=self.camera.simulate_move_rotation_y(self.camera.mouse.lerp(&self.next_mouse,self.time).x);
let control_dir=camera_mat*self.style.get_control_dir(self.controls); let control_dir=camera_mat*control_dir;
//normalize but careful for zero //normalize but careful for zero
let d=self.body.velocity.dot(control_dir); let d=self.body.velocity.dot(control_dir);
if d<self.style.mv { if d<self.style.mv {
@ -1458,6 +1460,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
} }
} }
} }
}
PhysicsInstruction::ReachWalkTargetVelocity => { PhysicsInstruction::ReachWalkTargetVelocity => {
match &mut self.move_state{ match &mut self.move_state{
MoveState::Air|MoveState::Water=>(), MoveState::Air|MoveState::Water=>(),