From bb9109d50a5b6f5835235857036ee86dadb7742b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:25:40 +0200 Subject: [PATCH 1/3] Remove vestigial debug rendering code Debug info hasn't been generated in a while, so this hasn't been used. --- crates/fj-viewer/src/graphics/drawables.rs | 4 +--- crates/fj-viewer/src/graphics/geometries.rs | 11 ++--------- crates/fj-viewer/src/graphics/renderer.rs | 16 +++++----------- crates/fj-viewer/src/viewer.rs | 3 +-- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/crates/fj-viewer/src/graphics/drawables.rs b/crates/fj-viewer/src/graphics/drawables.rs index b553dea62..4c46f955d 100644 --- a/crates/fj-viewer/src/graphics/drawables.rs +++ b/crates/fj-viewer/src/graphics/drawables.rs @@ -6,16 +6,14 @@ use super::{ pub struct Drawables<'r> { pub model: Drawable<'r>, pub mesh: Drawable<'r>, - pub lines: Drawable<'r>, } impl<'r> Drawables<'r> { pub fn new(geometries: &'r Geometries, pipelines: &'r Pipelines) -> Self { let model = Drawable::new(&geometries.mesh, &pipelines.model); let mesh = Drawable::new(&geometries.mesh, &pipelines.mesh); - let lines = Drawable::new(&geometries.lines, &pipelines.lines); - Self { model, mesh, lines } + Self { model, mesh } } } diff --git a/crates/fj-viewer/src/graphics/geometries.rs b/crates/fj-viewer/src/graphics/geometries.rs index 1fb3b4578..e7d040fd1 100644 --- a/crates/fj-viewer/src/graphics/geometries.rs +++ b/crates/fj-viewer/src/graphics/geometries.rs @@ -7,20 +7,13 @@ use super::vertices::{Vertex, Vertices}; #[derive(Debug)] pub struct Geometries { pub mesh: Geometry, - pub lines: Geometry, } impl Geometries { - pub fn new( - device: &wgpu::Device, - mesh: &Vertices, - debug_info: &Vertices, - ) -> Self { + pub fn new(device: &wgpu::Device, mesh: &Vertices) -> Self { let mesh = Geometry::new(device, mesh.vertices(), mesh.indices()); - let lines = - Geometry::new(device, debug_info.vertices(), debug_info.indices()); - Self { mesh, lines } + Self { mesh } } } diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index f9c5c8fb7..20f32a670 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -184,8 +184,7 @@ impl Renderer { label: None, }); - let geometries = - Geometries::new(&device, &Vertices::empty(), &Vertices::empty()); + let geometries = Geometries::new(&device, &Vertices::empty()); let pipelines = Pipelines::new(&device, &bind_group_layout, color_format); @@ -213,8 +212,8 @@ impl Renderer { } /// Updates the geometry of the model being rendered. - pub fn update_geometry(&mut self, mesh: Vertices, lines: Vertices) { - self.geometries = Geometries::new(&self.device, &mesh, &lines); + pub fn update_geometry(&mut self, mesh: Vertices) { + self.geometries = Geometries::new(&self.device, &mesh); } /// Resizes the render surface. @@ -310,13 +309,8 @@ impl Renderer { drawables.model.draw(&mut render_pass); } - if self.is_line_drawing_available() { - if config.draw_mesh { - drawables.mesh.draw(&mut render_pass); - } - if config.draw_debug { - drawables.lines.draw(&mut render_pass); - } + if self.is_line_drawing_available() && config.draw_mesh { + drawables.mesh.draw(&mut render_pass); } } diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 92bbe9fa7..79a0444eb 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -68,8 +68,7 @@ impl Viewer { /// Handle the shape being updated pub fn handle_shape_update(&mut self, shape: ProcessedShape) { - self.renderer - .update_geometry((&shape.mesh).into(), (&shape.debug_info).into()); + self.renderer.update_geometry((&shape.mesh).into()); let aabb = shape.aabb; if self.shape.replace(shape).is_none() { From 07f3ab21a1289d032dd0fa84109fc03fd9f6eddc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:27:08 +0200 Subject: [PATCH 2/3] Remove vestigial draw setting for debug rendering --- crates/fj-viewer/src/graphics/draw_config.rs | 4 ---- crates/fj-viewer/src/viewer.rs | 7 ------- crates/fj-window/src/display.rs | 3 --- 3 files changed, 14 deletions(-) diff --git a/crates/fj-viewer/src/graphics/draw_config.rs b/crates/fj-viewer/src/graphics/draw_config.rs index ef54108f7..bed33832d 100644 --- a/crates/fj-viewer/src/graphics/draw_config.rs +++ b/crates/fj-viewer/src/graphics/draw_config.rs @@ -6,9 +6,6 @@ pub struct DrawConfig { /// Toggle for displaying the wireframe model pub draw_mesh: bool, - - /// Toggle for displaying model debug information - pub draw_debug: bool, } impl Default for DrawConfig { @@ -16,7 +13,6 @@ impl Default for DrawConfig { Self { draw_model: true, draw_mesh: false, - draw_debug: false, } } } diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 79a0444eb..b99936d6d 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -59,13 +59,6 @@ impl Viewer { } } - /// Toggle the "draw debug" setting - pub fn toggle_draw_debug(&mut self) { - if self.renderer.is_line_drawing_available() { - self.draw_config.draw_debug = !self.draw_config.draw_debug; - } - } - /// Handle the shape being updated pub fn handle_shape_update(&mut self, shape: ProcessedShape) { self.renderer.update_geometry((&shape.mesh).into()); diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index f02f731f9..93fd1fab0 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -73,9 +73,6 @@ pub fn display(mesh: Mesh>, invert_zoom: bool) -> Result<(), Error> { VirtualKeyCode::Key2 => { viewer.toggle_draw_mesh(); } - VirtualKeyCode::Key3 => { - viewer.toggle_draw_debug(); - } _ => {} }, Event::WindowEvent { From 5b748ea1e3263ccf891c0b94e41248c6f7d2246a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:28:32 +0200 Subject: [PATCH 3/3] Remove unused conversion --- crates/fj-viewer/src/graphics/vertices.rs | 35 +---------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/crates/fj-viewer/src/graphics/vertices.rs b/crates/fj-viewer/src/graphics/vertices.rs index db641c4b1..d7f76c4a4 100644 --- a/crates/fj-viewer/src/graphics/vertices.rs +++ b/crates/fj-viewer/src/graphics/vertices.rs @@ -1,8 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use fj_interop::{ - debug::DebugInfo, - mesh::{Index, Mesh}, -}; +use fj_interop::mesh::{Index, Mesh}; use fj_math::{Point, Vector}; #[derive(Debug)] @@ -102,36 +99,6 @@ impl From<&Mesh>> for Vertices { } } -impl From<&DebugInfo> for Vertices { - fn from(debug_info: &DebugInfo) -> Self { - let mut self_ = Self::empty(); - - for triangle_edge_check in &debug_info.triangle_edge_checks { - let normal = [0.; 3]; - - let red = [1., 0., 0., 1.]; - let green = [0., 1., 0., 1.]; - - let color = if triangle_edge_check.hits.len() % 2 == 0 { - red - } else { - green - }; - - self_.push_cross(triangle_edge_check.origin, normal, color); - - for &hit in &triangle_edge_check.hits { - let line = hit.points(); - let color = [0., 0., 0., 1.]; - - self_.push_line(line, normal, color); - } - } - - self_ - } -} - #[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)] #[repr(C)] pub struct Vertex {