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
|
/// Toggle for displaying the wireframe model
|
||||||
pub draw_mesh: bool,
|
pub draw_mesh: bool,
|
||||||
|
|
||||||
/// Toggle for displaying model debug information
|
|
||||||
pub draw_debug: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DrawConfig {
|
impl Default for DrawConfig {
|
||||||
@ -16,7 +13,6 @@ impl Default for DrawConfig {
|
|||||||
Self {
|
Self {
|
||||||
draw_model: true,
|
draw_model: true,
|
||||||
draw_mesh: false,
|
draw_mesh: false,
|
||||||
draw_debug: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,14 @@ use super::{
|
|||||||
pub struct Drawables<'r> {
|
pub struct Drawables<'r> {
|
||||||
pub model: Drawable<'r>,
|
pub model: Drawable<'r>,
|
||||||
pub mesh: Drawable<'r>,
|
pub mesh: Drawable<'r>,
|
||||||
pub lines: Drawable<'r>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'r> Drawables<'r> {
|
impl<'r> Drawables<'r> {
|
||||||
pub fn new(geometries: &'r Geometries, pipelines: &'r Pipelines) -> Self {
|
pub fn new(geometries: &'r Geometries, pipelines: &'r Pipelines) -> Self {
|
||||||
let model = Drawable::new(&geometries.mesh, &pipelines.model);
|
let model = Drawable::new(&geometries.mesh, &pipelines.model);
|
||||||
let mesh = Drawable::new(&geometries.mesh, &pipelines.mesh);
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct Geometries {
|
pub struct Geometries {
|
||||||
pub mesh: Geometry,
|
pub mesh: Geometry,
|
||||||
pub lines: Geometry,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Geometries {
|
impl Geometries {
|
||||||
pub fn new(
|
pub fn new(device: &wgpu::Device, mesh: &Vertices) -> Self {
|
||||||
device: &wgpu::Device,
|
|
||||||
mesh: &Vertices,
|
|
||||||
debug_info: &Vertices,
|
|
||||||
) -> Self {
|
|
||||||
let mesh = Geometry::new(device, mesh.vertices(), mesh.indices());
|
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,
|
label: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let geometries =
|
let geometries = Geometries::new(&device, &Vertices::empty());
|
||||||
Geometries::new(&device, &Vertices::empty(), &Vertices::empty());
|
|
||||||
let pipelines =
|
let pipelines =
|
||||||
Pipelines::new(&device, &bind_group_layout, color_format);
|
Pipelines::new(&device, &bind_group_layout, color_format);
|
||||||
|
|
||||||
@ -213,8 +212,8 @@ impl Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the geometry of the model being rendered.
|
/// Updates the geometry of the model being rendered.
|
||||||
pub fn update_geometry(&mut self, mesh: Vertices, lines: Vertices) {
|
pub fn update_geometry(&mut self, mesh: Vertices) {
|
||||||
self.geometries = Geometries::new(&self.device, &mesh, &lines);
|
self.geometries = Geometries::new(&self.device, &mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resizes the render surface.
|
/// Resizes the render surface.
|
||||||
@ -310,14 +309,9 @@ impl Renderer {
|
|||||||
drawables.model.draw(&mut render_pass);
|
drawables.model.draw(&mut render_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_line_drawing_available() {
|
if self.is_line_drawing_available() && config.draw_mesh {
|
||||||
if config.draw_mesh {
|
|
||||||
drawables.mesh.draw(&mut render_pass);
|
drawables.mesh.draw(&mut render_pass);
|
||||||
}
|
}
|
||||||
if config.draw_debug {
|
|
||||||
drawables.lines.draw(&mut render_pass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.navigation_cube_renderer.draw(
|
self.navigation_cube_renderer.draw(
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use fj_interop::{
|
use fj_interop::mesh::{Index, Mesh};
|
||||||
debug::DebugInfo,
|
|
||||||
mesh::{Index, Mesh},
|
|
||||||
};
|
|
||||||
use fj_math::{Point, Vector};
|
use fj_math::{Point, Vector};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[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)]
|
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Vertex {
|
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
|
/// Handle the shape being updated
|
||||||
pub fn handle_shape_update(&mut self, shape: ProcessedShape) {
|
pub fn handle_shape_update(&mut self, shape: ProcessedShape) {
|
||||||
self.renderer
|
self.renderer.update_geometry((&shape.mesh).into());
|
||||||
.update_geometry((&shape.mesh).into(), (&shape.debug_info).into());
|
|
||||||
|
|
||||||
let aabb = shape.aabb;
|
let aabb = shape.aabb;
|
||||||
if self.shape.replace(shape).is_none() {
|
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 => {
|
VirtualKeyCode::Key2 => {
|
||||||
viewer.toggle_draw_mesh();
|
viewer.toggle_draw_mesh();
|
||||||
}
|
}
|
||||||
VirtualKeyCode::Key3 => {
|
|
||||||
viewer.toggle_draw_debug();
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
|
Loading…
Reference in New Issue
Block a user