diff --git a/crates/fj-viewer/src/graphics/config_ui.rs b/crates/fj-viewer/src/graphics/config_ui.rs deleted file mode 100644 index 9e420c174..000000000 --- a/crates/fj-viewer/src/graphics/config_ui.rs +++ /dev/null @@ -1,147 +0,0 @@ -use std::collections::HashMap; - -use fj_math::Aabb; -use wgpu::util::StagingBelt; -use wgpu_glyph::{ - ab_glyph::{FontArc, InvalidFont}, - GlyphBrush, GlyphBrushBuilder, Section, Text, -}; - -use super::draw_config::DrawConfig; - -pub struct ConfigUi { - glyph_brush: GlyphBrush<()>, - texts: HashMap<(Element, bool), String>, - staging_belt: StagingBelt, -} - -impl std::fmt::Debug for ConfigUi { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ConfigUi") - .field("glyph_brush", &self.glyph_brush) - .field("texts", &self.texts) - .finish() - } -} - -impl ConfigUi { - pub fn new( - device: &wgpu::Device, - color_format: wgpu::TextureFormat, - ) -> Result { - let font = - FontArc::try_from_slice(include_bytes!("fonts/B612-Bold.ttf"))?; - let glyph_brush = GlyphBrushBuilder::using_font(font) - .initial_cache_size((512, 512)) - .build(device, color_format); - - let mut texts = HashMap::new(); - for element in Element::elements() { - let (name, key) = element.name_key(); - - for (enabled, word) in [(false, "disabled"), (true, "enabled")] { - texts.insert( - (element, enabled), - format!( - "{} rendering is {} (toggle with {})\n", - name, word, key - ), - ); - } - } - - // I haven't put any thought into the staging belt's buffer size. - // 1024 just seemed like a good number, and so far it hasn't caused - // any problems. - // - // - @hannobraun - let staging_belt = StagingBelt::new(1024); - - Ok(Self { - glyph_brush, - texts, - staging_belt, - }) - } - - pub fn draw( - &mut self, - device: &wgpu::Device, - encoder: &mut wgpu::CommandEncoder, - view: &wgpu::TextureView, - surface_config: &wgpu::SurfaceConfiguration, - aabb: &Aabb<3>, - draw_config: &DrawConfig, - ) -> Result<(), String> { - let mut section = Section::new().with_screen_position((50.0, 50.0)); - - for element in Element::elements() { - let enabled = element.is_enabled(draw_config); - let text = &self.texts[&(element, enabled)]; - - let alpha = if enabled { 1.0 } else { 0.75 }; - - let text = Text::new(text) - .with_color([0.0, 0.0, 0.0, alpha]) - .with_scale(50.0); - - section = section.add_text(text); - } - - /* Render size of model bounding box */ - let bbsize = aabb.size().components; - let info = format!( - "Model bounding box size: {:0.1} {:0.1} {:0.1}", - bbsize[0].into_f32(), - bbsize[1].into_f32(), - bbsize[2].into_f32() - ); - let text = Text::new(&info) - .with_color([0.0, 0.0, 0.0, 1.0]) - .with_scale(50.0); - section = section.add_text(text); - - self.glyph_brush.queue(section); - self.glyph_brush.draw_queued( - device, - &mut self.staging_belt, - encoder, - view, - surface_config.width, - surface_config.height, - )?; - - self.staging_belt.finish(); - - Ok(()) - } -} - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -enum Element { - Model, - Mesh, - Debug, -} - -impl Element { - fn elements() -> [Self; 3] { - [Self::Model, Self::Mesh, Self::Debug] - } - - fn name_key(&self) -> (&'static str, &'static str) { - match self { - Self::Model => ("model", "1"), - Self::Mesh => ("mesh", "2"), - Self::Debug => ("debug info", "3"), - } - } - - fn is_enabled(&self, config: &DrawConfig) -> bool { - match self { - Self::Model => config.draw_model, - Self::Mesh => config.draw_mesh, - Self::Debug => config.draw_debug, - } - } -} diff --git a/crates/fj-viewer/src/graphics/mod.rs b/crates/fj-viewer/src/graphics/mod.rs index ea0632c8d..b93c3c554 100644 --- a/crates/fj-viewer/src/graphics/mod.rs +++ b/crates/fj-viewer/src/graphics/mod.rs @@ -1,6 +1,5 @@ //! Rendering primitives, routines, and structures. -mod config_ui; mod draw_config; mod drawables; mod geometries; diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 092e110a3..c896005d4 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -14,9 +14,9 @@ use crate::{ }; use super::{ - config_ui::ConfigUi, draw_config::DrawConfig, drawables::Drawables, - geometries::Geometries, pipelines::Pipelines, transform::Transform, - uniforms::Uniforms, vertices::Vertices, DEPTH_FORMAT, + draw_config::DrawConfig, drawables::Drawables, geometries::Geometries, + pipelines::Pipelines, transform::Transform, uniforms::Uniforms, + vertices::Vertices, DEPTH_FORMAT, }; #[derive(Default)] @@ -24,7 +24,6 @@ struct EguiOptionsState { show_trace: bool, show_layout_debug_on_hover: bool, show_debug_text_example: bool, - show_original_ui: bool, show_settings_ui: bool, show_inspection_ui: bool, } @@ -59,8 +58,6 @@ pub struct Renderer { geometries: Geometries, pipelines: Pipelines, - config_ui: ConfigUi, - /// State required for integration with `egui`. pub egui: EguiState, } @@ -232,8 +229,6 @@ impl Renderer { let pipelines = Pipelines::new(&device, &bind_group_layout, color_format); - let config_ui = ConfigUi::new(&device, color_format)?; - // // Note: We need to hold on to this otherwise (from my memory) // it causes the egui font texture to get dropped after @@ -267,8 +262,6 @@ impl Renderer { geometries, pipelines, - config_ui, - egui: EguiState { context: egui_context, winit_state: egui_winit_state, @@ -380,19 +373,6 @@ impl Renderer { } } - if self.egui.options.show_original_ui { - self.config_ui - .draw( - &self.device, - &mut encoder, - &color_view, - &self.surface_config, - &self.geometries.aabb, - config, - ) - .map_err(DrawError::Text)?; - } - // // NOTE: The following comment was written for the original // proof-of-concept which targeted older versions of @@ -461,10 +441,6 @@ impl Renderer { .on_disabled_hover_text( "Rendering device does not have line rendering feature support" ); - ui.checkbox( - &mut self.egui.options.show_original_ui, - "Render original UI", - ); ui.add_space(16.0); ui.strong(get_bbox_size_text(&self.geometries.aabb)); });