Clean up some things

This commit is contained in:
Marco Thomas
2021-08-28 15:15:04 +02:00
parent 9476eca47c
commit a85500236d
3 changed files with 8 additions and 23 deletions

View File

@@ -2,6 +2,8 @@ use cgmath::Vector2;
use cgmath::Point3; use cgmath::Point3;
use winit::{dpi::PhysicalPosition, event::*}; use winit::{dpi::PhysicalPosition, event::*};
const MOUSE_SLOWDOWN: f32 = 100.0;
#[derive(Debug)] #[derive(Debug)]
enum ButtonPress { enum ButtonPress {
Up(ElementState), Up(ElementState),
@@ -80,6 +82,7 @@ impl CameraController {
/// Vectors are casted from (0, 0, 0) to both the target and the eye /// Vectors are casted from (0, 0, 0) to both the target and the eye
pub fn update_camera(&mut self, camera: &mut crate::camera::Camera) { pub fn update_camera(&mut self, camera: &mut crate::camera::Camera) {
// TODO what about delta time? // TODO what about delta time?
// TODO this still feels a bit chunky...
use cgmath::InnerSpace; use cgmath::InnerSpace;
// Casted eye -> target // Casted eye -> target
let forward = camera.target - camera.eye; let forward = camera.target - camera.eye;
@@ -130,9 +133,8 @@ impl CameraController {
// mouse movement: // mouse movement:
// target moves // target moves
// eye stays in place // eye stays in place
let decr = 200.0; camera.target.x += (self.mouse_movement.x as f32) / MOUSE_SLOWDOWN;
camera.target.x += (self.mouse_movement.x as f32) / decr; camera.target.y -= (self.mouse_movement.y as f32) / MOUSE_SLOWDOWN;
camera.target.y -= (self.mouse_movement.y as f32) / decr;
self.mouse_movement = Vector2 { x: 0.0, y: 0.0 }; self.mouse_movement = Vector2 { x: 0.0, y: 0.0 };
dbg!(&camera.eye); dbg!(&camera.eye);

View File

@@ -1,4 +1,4 @@
use winit::{dpi::PhysicalPosition, event::*, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder}; use winit::{event::*, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder};
mod state; mod state;
mod vertex; mod vertex;
@@ -15,8 +15,8 @@ fn main() {
let mut window = WindowBuilder::new() let mut window = WindowBuilder::new()
.build(&event_loop) .build(&event_loop)
.unwrap(); .unwrap();
//window.set_cursor_visible(false); window.set_cursor_visible(false);
//window.set_cursor_grab(true).unwrap(); window.set_cursor_grab(true).unwrap();
// wait until Future is ready // wait until Future is ready
let mut state = pollster::block_on(State::new(&window)); let mut state = pollster::block_on(State::new(&window));

View File

@@ -324,23 +324,6 @@ impl State {
WindowEvent::ScaleFactorChanged {new_inner_size, ..} => { WindowEvent::ScaleFactorChanged {new_inner_size, ..} => {
self.resize(**new_inner_size); self.resize(**new_inner_size);
}, },
// WindowEvent::CursorMoved { position, .. } => {
// let x = (position.x as f64) / self.size.width as f64;
// let y = (position.y as f64) / self.size.height as f64;
// self.clear_color = wgpu::Color { r: x, g: x, b: y, a: 1.0};
// true
// },
// WindowEvent::KeyboardInput {
// input: KeyboardInput {
// state: ElementState::Pressed,
// virtual_keycode: Some(VirtualKeyCode::Space),
// ..
// },
// ..
// } => {
// self.use_pentagon = !self.use_pentagon;
// true
// }
_ => self.camera_controller.input(event) _ => self.camera_controller.input(event)
} }
} }