Compare commits

..

No commits in common. "5e8716acf05525660a676ee22bac71c8f6c6abf8" and "1a8097be9b2bdf2e565e00e42e81536d448f527c" have entirely different histories.

5 changed files with 15 additions and 19 deletions

View File

@ -25,8 +25,15 @@ anyhow = "1.0"
pollster = "0.4"
cgmath = "0.18"
[profile.dev]
codegen-backend = "cranelift"
opt-level = 0
lto = false
incremental = true
[profile.release]
opt-level = 3
strip = true
lto = true
codegen-units = 1

View File

@ -59,9 +59,9 @@ impl<'a> ApplicationHandler for App<'a> {
event_loop.exit();
}
WindowEvent::RedrawRequested => {
state.window.request_redraw();
state.update();
state.render().unwrap();
state.window.request_redraw();
}
WindowEvent::Resized(new_size) => {
state.resize(new_size);

View File

@ -65,16 +65,15 @@ impl CameraController {
(x, y)
}
false => {
let movement_speed = self.movement_speed / 3.0;
let x = match position.x {
x if x < 100.0 => -movement_speed,
x if x > window_size.0 - 100.0 => movement_speed,
x if x < 100.0 => -0.0005,
x if x > window_size.0 - 100.0 => 0.0005,
_ => 0.0,
};
let y = match position.y {
y if y < 100.0 => movement_speed,
y if y > window_size.1 - 100.0 => -movement_speed,
y if y < 100.0 => 0.0005,
y if y > window_size.1 - 100.0 => -0.0005,
_ => 0.0,
};

View File

@ -11,7 +11,7 @@ pub mod vertex;
pub fn capture() -> anyhow::Result<()> {
let event_loop = EventLoop::new()?;
event_loop.set_control_flow(ControlFlow::Poll);
event_loop.set_control_flow(ControlFlow::Wait);
let mut app = App::default();

View File

@ -8,14 +8,11 @@ use winit::{
use crate::controller::CameraController;
const REFRESH_RATE: f32 = 1.0 / 60.0;
pub struct Spotlight {
window: Arc<winit::window::Window>,
cursor_position: (f32, f32),
size: f32,
delta_size: f32,
is_ctrl_pressed: bool,
}
@ -34,7 +31,6 @@ impl Spotlight {
cursor_position: (960.0, 540.0),
size: 50.0,
delta_size: 0.0,
is_ctrl_pressed: false,
};
@ -112,7 +108,7 @@ impl Spotlight {
WindowEvent::MouseWheel { delta, .. } => {
if let MouseScrollDelta::LineDelta(_, y) = delta {
if self.is_ctrl_pressed {
self.delta_size += *y;
self.size += y * 5.0;
}
}
}
@ -120,13 +116,7 @@ impl Spotlight {
}
}
pub fn update(&mut self) {
if self.is_ctrl_pressed && self.delta_size.abs() > 0.01 {
self.size = (self.size + self.delta_size * REFRESH_RATE).max(0.01);
self.size = self.size.clamp(5.0, 250.0);
self.delta_size -= self.delta_size * REFRESH_RATE * 0.1;
}
}
pub fn update(&mut self) {}
}
#[repr(C)]