From 00da80f6e5e33c9e04886d3ede4e63be101638a8 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 23 Apr 2026 21:39:43 +0300 Subject: [PATCH] fix: align ViewCube hit-test with widget bounds instead of full window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prepare() was passing viewport.logical_size() (full window) to viewcube.upload(), while hit_test/hover_id used the shader widget's bounds. With the properties panel present the widget is narrower than the full window, so the visual cube was scaled smaller but the click area stayed full-size — causing the mismatch that grew toward the bottom-left corner. Co-Authored-By: Claude Sonnet 4.6 --- src/scene/render.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/scene/render.rs b/src/scene/render.rs index e0b7bb1a4..56c6bce90 100644 --- a/src/scene/render.rs +++ b/src/scene/render.rs @@ -100,7 +100,7 @@ impl shader::Primitive for Primitive { pipeline: &mut Pipeline, device: &iced::wgpu::Device, queue: &iced::wgpu::Queue, - _bounds: &Rectangle, + bounds: &Rectangle, viewport: &Viewport, ) { let phys = viewport.physical_size(); @@ -109,8 +109,8 @@ impl shader::Primitive for Primitive { // not the full surface — so the MSAA resolve can't overwrite other widgets. let scale = viewport.scale_factor() as f32; let clip_size = Size::new( - (_bounds.width * scale).ceil() as u32, - (_bounds.height * scale).ceil() as u32, + (bounds.width * scale).ceil() as u32, + (bounds.height * scale).ceil() as u32, ); pipeline.ensure_depth_texture(device, clip_size); pipeline.viewcube.ensure_depth_texture(device, full_size); @@ -120,12 +120,11 @@ impl shader::Primitive for Primitive { pipeline.upload_images(device, queue, &self.images); pipeline.upload_meshes(device, &self.meshes); pipeline.upload_wires(device, &self.wires); - let logical = viewport.logical_size(); pipeline.viewcube.upload( queue, self.cam_rotation, - logical.width as u32, - logical.height as u32, + bounds.width as u32, + bounds.height as u32, self.hover_region, ); }