Working alg

This commit is contained in:
2025-12-30 01:15:13 +01:00
parent 68c73a111b
commit e0b5b1135c
5 changed files with 1502 additions and 29 deletions

View File

@ -1,14 +1,17 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
pub mod egui_renderer;
pub mod state;
pub mod voxel;
use std::sync::Arc;
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{self, EventLoop},
window::Window,
};
use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::EventLoop;
use winit::event_loop::{self};
use winit::window::Window;
use crate::state::State;
@ -45,6 +48,10 @@ impl ApplicationHandler for App {
self.state = Some(state);
window.request_redraw();
window.set_cursor_visible(false);
window
.set_cursor_grab(winit::window::CursorGrabMode::Locked)
.unwrap();
}
fn window_event(
@ -68,6 +75,29 @@ impl ApplicationHandler for App {
WindowEvent::Resized(size) => {
state.resize(size);
}
WindowEvent::MouseWheel { delta, .. } => {
state.mouse_wheel(delta);
}
_ => {}
}
}
fn device_event(
&mut self,
_event_loop: &event_loop::ActiveEventLoop,
_device_id: winit::event::DeviceId,
event: winit::event::DeviceEvent,
) {
let state = self.state.as_mut().unwrap();
#[allow(clippy::single_match)]
match event {
winit::event::DeviceEvent::MouseMotion { delta } => {
state.cursor_moved(delta.0 as f32, delta.1 as f32);
}
_ => {}
}
}