diff --git a/crates/vent-math/src/scalar/mat4.rs b/crates/vent-math/src/scalar/mat4.rs index 97c371d..8f7f8e0 100644 --- a/crates/vent-math/src/scalar/mat4.rs +++ b/crates/vent-math/src/scalar/mat4.rs @@ -125,6 +125,32 @@ impl Mat4 { ) } + #[inline] + #[must_use] + pub fn orthographic_rh( + left: f32, + right: f32, + bottom: f32, + top: f32, + near: f32, + far: f32, + ) -> Self { + let rcp_width = 1.0 / (right - left); + let rcp_height = 1.0 / (top - bottom); + let r = 1.0 / (near - far); + Self::from_cols( + Vec4::new(rcp_width + rcp_width, 0.0, 0.0, 0.0), + Vec4::new(0.0, rcp_height + rcp_height, 0.0, 0.0), + Vec4::new(0.0, 0.0, r, 0.0), + Vec4::new( + -(left + right) * rcp_width, + -(top + bottom) * rcp_height, + r * near, + 1.0, + ), + ) + } + #[inline] #[must_use] pub fn mul_mat4(&self, rhs: &Self) -> Self { diff --git a/crates/vent-rendering/src/pipeline.rs b/crates/vent-rendering/src/pipeline.rs index c0dff0b..3ad69b2 100644 --- a/crates/vent-rendering/src/pipeline.rs +++ b/crates/vent-rendering/src/pipeline.rs @@ -89,7 +89,7 @@ impl VulkanPipeline { front_face: vk::FrontFace::COUNTER_CLOCKWISE, line_width: 1.0, polygon_mode: vk::PolygonMode::FILL, - cull_mode: vk::CullModeFlags::BACK, + cull_mode: vk::CullModeFlags::NONE, // TODO ..Default::default() }; let multisample_state_info = vk::PipelineMultisampleStateCreateInfo { @@ -97,11 +97,11 @@ impl VulkanPipeline { ..Default::default() }; - let depth_state_info = vk::PipelineDepthStencilStateCreateInfo::default() - .depth_test_enable(true) - .depth_write_enable(true) - .depth_compare_op(vk::CompareOp::LESS) - .max_depth_bounds(1.0); + let depth_state_info = vk::PipelineDepthStencilStateCreateInfo::default(); + // .depth_test_enable(true) + // .depth_write_enable(true) + // .depth_compare_op(vk::CompareOp::LESS) + // .max_depth_bounds(1.0); let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState { color_write_mask: vk::ColorComponentFlags::RGBA, ..Default::default() diff --git a/crates/vent-runtime/src/lib.rs b/crates/vent-runtime/src/lib.rs index abcf09a..acaa8a4 100644 --- a/crates/vent-runtime/src/lib.rs +++ b/crates/vent-runtime/src/lib.rs @@ -44,7 +44,7 @@ impl VentApplication { // TODO let mut renderer = DefaultRuntimeRenderer::new(&project, &app_window); - let mut controller = CameraController3D::new(20.0, 10.0); + let mut controller = CameraController3D::new(20.0, 1.0); let mut delta_time = 0.0; // TODO, Handle scale factor change @@ -60,7 +60,7 @@ impl VentApplication { delta_time, ); } - WindowEvent::Mouse { button, state } => { + WindowEvent::MouseButton { button, state } => { controller.process_mouse_input(&button, &state); } WindowEvent::Resize { @@ -69,7 +69,8 @@ impl VentApplication { } => { renderer.resize((new_width, new_height)); } - WindowEvent::Draw => delta_time = renderer.render(), // Default, + WindowEvent::Draw => delta_time = renderer.render(), + WindowEvent::MouseMotion { x, y } => controller.process_mouse_movement(renderer.camera.downcast_mut().expect("TODO"), x, y, delta_time), // Default, } }); } diff --git a/crates/vent-runtime/src/render/camera/camera_controller3d.rs b/crates/vent-runtime/src/render/camera/camera_controller3d.rs index 06f077e..ec33ceb 100644 --- a/crates/vent-runtime/src/render/camera/camera_controller3d.rs +++ b/crates/vent-runtime/src/render/camera/camera_controller3d.rs @@ -8,6 +8,8 @@ pub struct CameraController3D { sensitivity_x: f32, sensitivity_y: f32, + old_x: f64, + old_y: f64, mouse_left_down: bool, } @@ -20,6 +22,8 @@ impl CameraController3D { sensitivity_x: sensitivity, sensitivity_y: sensitivity, mouse_left_down: false, + old_x: 0.0, + old_y: 0.0, } } @@ -80,14 +84,16 @@ impl CameraController3D { } pub fn process_mouse_movement( - &self, + &mut self, camera: &mut Camera3D, - mouse_dx: f64, - mouse_dy: f64, + mouse_x: f64, + mouse_y: f64, delta_time: f32, ) { if self.mouse_left_down { - let deltaposition = Vec2::new(mouse_dx as f32, mouse_dy as f32); + let deltaposition = Vec2::new((mouse_x - self.old_x) as f32, (mouse_y - self.old_y) as f32); + self.old_x = mouse_x; + self.old_y = mouse_y; let moveposition = deltaposition * Vec2::new(self.sensitivity_x, self.sensitivity_y) * delta_time; diff --git a/crates/vent-window/src/lib.rs b/crates/vent-window/src/lib.rs index 9cf0c3b..a9b98d8 100644 --- a/crates/vent-window/src/lib.rs +++ b/crates/vent-window/src/lib.rs @@ -13,10 +13,14 @@ pub enum WindowEvent { key: keyboard::Key, state: keyboard::KeyState, }, - Mouse { + MouseButton { button: mouse::Button, state: mouse::ButtonState, }, + MouseMotion { + x: f64, + y: f64, + }, Resize { new_width: u32, new_height: u32, diff --git a/crates/vent-window/src/platform/wayland/mod.rs b/crates/vent-window/src/platform/wayland/mod.rs index 77e483e..be3d654 100644 --- a/crates/vent-window/src/platform/wayland/mod.rs +++ b/crates/vent-window/src/platform/wayland/mod.rs @@ -397,6 +397,7 @@ impl PointerHandler for WaylandWindow { self.set_cursor = true; self.decorations_cursor = Some(new_cursor); } + self.event_sender.send(WindowEvent::MouseMotion { x, y, }).unwrap(); } PointerEventKind::Press { button, @@ -439,49 +440,49 @@ fn press_mouse(button: u32, state: &WaylandWindow, mouse_state: mouse::ButtonSta match button { BTN_LEFT => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::LEFT, state: mouse_state, }) .unwrap(), BTN_RIGHT => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::RIGHT, state: mouse_state, }) .unwrap(), BTN_MIDDLE => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::MIDDLE, state: mouse_state, }) .unwrap(), BTN_SIDE => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::SIDE, state: mouse_state, }) .unwrap(), BTN_EXTRA => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::EXTRA, state: mouse_state, }) .unwrap(), BTN_FORWARD => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::FORWARD, state: mouse_state, }) .unwrap(), BTN_BACK => state .event_sender - .send(WindowEvent::Mouse { + .send(WindowEvent::MouseButton { button: crate::mouse::Button::BACK, state: mouse_state, }) diff --git a/docs/icon.png b/docs/icon.png deleted file mode 100644 index 0256e39..0000000 Binary files a/docs/icon.png and /dev/null differ diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index 0000000..e43178b Binary files /dev/null and b/docs/logo.png differ