camera pausing, weird resizing crashes. Not sure what to tackle next.
This commit is contained in:
@@ -73,7 +73,7 @@ pub struct CameraController {
|
||||
scroll: f32,
|
||||
speed: f32,
|
||||
sensitivity: f32,
|
||||
last_frame: Instant,
|
||||
active: bool,
|
||||
}
|
||||
|
||||
impl CameraController {
|
||||
@@ -90,7 +90,7 @@ impl CameraController {
|
||||
scroll: 0.0,
|
||||
speed,
|
||||
sensitivity,
|
||||
last_frame: Instant::now(),
|
||||
active: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,38 +100,53 @@ impl CameraController {
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match key {
|
||||
VirtualKeyCode::W | VirtualKeyCode::Up => {
|
||||
self.amount_forward = amount;
|
||||
true
|
||||
let active = match key {
|
||||
VirtualKeyCode::P => {
|
||||
if state == ElementState::Pressed {
|
||||
self.active = !self.active;
|
||||
}
|
||||
self.active
|
||||
},
|
||||
_ => {self.active}
|
||||
};
|
||||
if active {
|
||||
match key {
|
||||
VirtualKeyCode::W | VirtualKeyCode::Up => {
|
||||
self.amount_forward = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::S | VirtualKeyCode::Down => {
|
||||
self.amount_backward = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::A | VirtualKeyCode::Left => {
|
||||
self.amount_left = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::D | VirtualKeyCode::Right => {
|
||||
self.amount_right = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::Space => {
|
||||
self.amount_up = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::LShift => {
|
||||
self.amount_down = amount;
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
VirtualKeyCode::S | VirtualKeyCode::Down => {
|
||||
self.amount_backward = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::A | VirtualKeyCode::Left => {
|
||||
self.amount_left = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::D | VirtualKeyCode::Right => {
|
||||
self.amount_right = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::Space => {
|
||||
self.amount_up = amount;
|
||||
true
|
||||
}
|
||||
VirtualKeyCode::LShift => {
|
||||
self.amount_down = amount;
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_mouse(&mut self, mouse_dx: f64, mouse_dy: f64) {
|
||||
self.rotate_horizontal = -mouse_dx as f32;
|
||||
self.rotate_vertical = mouse_dy as f32;
|
||||
if self.active {
|
||||
self.rotate_horizontal = -mouse_dx as f32;
|
||||
self.rotate_vertical = mouse_dy as f32;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_camera(&mut self, camera: &mut Camera, dt: f32) {
|
||||
|
||||
Reference in New Issue
Block a user