mirror of
https://github.com/hannobraun/Fornjot
synced 2025-03-01 10:35:54 +00:00
Merge pull request #1862 from hannobraun/viewer
Remove vestigial debug rendering code
This commit is contained in:
commit
d478f9c5db
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<fj_math::Point<3>>> 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 {
|
||||
|
@ -59,17 +59,9 @@ 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(), (&shape.debug_info).into());
|
||||
self.renderer.update_geometry((&shape.mesh).into());
|
||||
|
||||
let aabb = shape.aabb;
|
||||
if self.shape.replace(shape).is_none() {
|
||||
|
@ -73,9 +73,6 @@ pub fn display(mesh: Mesh<Point<3>>, invert_zoom: bool) -> Result<(), Error> {
|
||||
VirtualKeyCode::Key2 => {
|
||||
viewer.toggle_draw_mesh();
|
||||
}
|
||||
VirtualKeyCode::Key3 => {
|
||||
viewer.toggle_draw_debug();
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Event::WindowEvent {
|
||||
|
Loading…
Reference in New Issue
Block a user