From 6d735f9c11cce9a29b9e7e8f0b2654c42d960195 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:29:26 +0200 Subject: [PATCH 1/5] Remove `DebugInfo` Debug information hasn't been generated in a while. --- crates/fj-interop/src/debug.rs | 50 ------------------------ crates/fj-interop/src/lib.rs | 1 - crates/fj-interop/src/processed_shape.rs | 5 +-- crates/fj-window/src/display.rs | 5 +-- 4 files changed, 2 insertions(+), 59 deletions(-) delete mode 100644 crates/fj-interop/src/debug.rs diff --git a/crates/fj-interop/src/debug.rs b/crates/fj-interop/src/debug.rs deleted file mode 100644 index 035d1a23a..000000000 --- a/crates/fj-interop/src/debug.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! Debug information definitions for the Fornjot ecosystem -//! -//! Defines debug information that is used by other crates within the Fornjot -//! ecosystem. The types in here aren't very useful in themselves, but they -//! define an interface that other crates use to communicate between each other. - -use fj_math::{Point, Segment}; - -/// Debug info from the CAD kernel that can be visualized -#[derive(Clone, Debug, Default)] -pub struct DebugInfo { - /// Rays being used during face triangulation - pub triangle_edge_checks: Vec, -} - -impl DebugInfo { - /// Construct an empty instance of `DebugInfo` - pub fn new() -> Self { - Self::default() - } - - /// Clear all information within this instance - /// - /// The resulting instance is the same, as if created by [`DebugInfo::new`], - /// but calling `clear` might be more efficient in regard to heap - /// allocations. - pub fn clear(&mut self) { - self.triangle_edge_checks.clear(); - } -} - -/// Record of a check to determine if a triangle edge is within a face -#[derive(Clone, Debug)] -pub struct TriangleEdgeCheck { - /// The origin of the ray used to perform the check - pub origin: Point<3>, - - /// The points where the ray hit edges of the face - pub hits: Vec>, -} - -impl TriangleEdgeCheck { - /// Construct a new instance - pub fn new(origin: Point<3>) -> Self { - Self { - origin, - hits: Vec::new(), - } - } -} diff --git a/crates/fj-interop/src/lib.rs b/crates/fj-interop/src/lib.rs index e2f455476..dc518515b 100644 --- a/crates/fj-interop/src/lib.rs +++ b/crates/fj-interop/src/lib.rs @@ -11,7 +11,6 @@ #![warn(missing_docs)] -pub mod debug; pub mod ext; pub mod mesh; pub mod processed_shape; diff --git a/crates/fj-interop/src/processed_shape.rs b/crates/fj-interop/src/processed_shape.rs index 6a112bd7d..5abe29c1f 100644 --- a/crates/fj-interop/src/processed_shape.rs +++ b/crates/fj-interop/src/processed_shape.rs @@ -2,7 +2,7 @@ use fj_math::{Aabb, Point}; -use crate::{debug::DebugInfo, mesh::Mesh}; +use crate::mesh::Mesh; /// A processed shape #[derive(Clone, Debug)] @@ -12,7 +12,4 @@ pub struct ProcessedShape { /// The triangle mesh that approximates the original shape pub mesh: Mesh>, - - /// The debug info generated while processing the shape - pub debug_info: DebugInfo, } diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index 93fd1fab0..cc06b8790 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -1,6 +1,4 @@ -use fj_interop::{ - debug::DebugInfo, mesh::Mesh, processed_shape::ProcessedShape, -}; +use fj_interop::{mesh::Mesh, processed_shape::ProcessedShape}; use fj_math::{Aabb, Point}; use fj_viewer::{ InputEvent, NormalizedScreenPosition, RendererInitError, Screen, @@ -27,7 +25,6 @@ pub fn display(mesh: Mesh>, invert_zoom: bool) -> Result<(), Error> { viewer.handle_shape_update(ProcessedShape { aabb: Aabb::<3>::from_points(mesh.vertices()), mesh, - debug_info: DebugInfo::new(), }); let mut held_mouse_button = None; From d6d657d4011ed2eade664d42d4ffef34452c08ba Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:31:50 +0200 Subject: [PATCH 2/5] Rename `ProcessedShape` to `Model` --- crates/fj-interop/src/processed_shape.rs | 2 +- crates/fj-viewer/src/camera.rs | 4 ++-- crates/fj-viewer/src/viewer.rs | 6 +++--- crates/fj-window/src/display.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/fj-interop/src/processed_shape.rs b/crates/fj-interop/src/processed_shape.rs index 5abe29c1f..f1ef7c957 100644 --- a/crates/fj-interop/src/processed_shape.rs +++ b/crates/fj-interop/src/processed_shape.rs @@ -6,7 +6,7 @@ use crate::mesh::Mesh; /// A processed shape #[derive(Clone, Debug)] -pub struct ProcessedShape { +pub struct Model { /// The axis-aligned bounding box of the shape pub aabb: Aabb<3>, diff --git a/crates/fj-viewer/src/camera.rs b/crates/fj-viewer/src/camera.rs index 5cb41ed40..39ae33dba 100644 --- a/crates/fj-viewer/src/camera.rs +++ b/crates/fj-viewer/src/camera.rs @@ -1,7 +1,7 @@ //! Viewer camera module use std::f64::consts::FRAC_PI_2; -use fj_interop::{mesh::Mesh, processed_shape::ProcessedShape}; +use fj_interop::{mesh::Mesh, processed_shape::Model}; use fj_math::{Aabb, Point, Scalar, Transform, Vector}; use crate::screen::NormalizedScreenPosition; @@ -82,7 +82,7 @@ impl Camera { pub fn focus_point( &self, cursor: Option, - shape: &ProcessedShape, + shape: &Model, ) -> FocusPoint { self.calculate_focus_point(cursor, &shape.mesh) .unwrap_or_else(|| FocusPoint(shape.aabb.center())) diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index b99936d6d..e2a6fe311 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -1,4 +1,4 @@ -use fj_interop::processed_shape::ProcessedShape; +use fj_interop::processed_shape::Model; use fj_math::Aabb; use tracing::warn; @@ -28,7 +28,7 @@ pub struct Viewer { pub renderer: Renderer, /// The shape - pub shape: Option, + pub shape: Option, } impl Viewer { @@ -60,7 +60,7 @@ impl Viewer { } /// Handle the shape being updated - pub fn handle_shape_update(&mut self, shape: ProcessedShape) { + pub fn handle_shape_update(&mut self, shape: Model) { self.renderer.update_geometry((&shape.mesh).into()); let aabb = shape.aabb; diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index cc06b8790..ce81f9cb7 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -1,4 +1,4 @@ -use fj_interop::{mesh::Mesh, processed_shape::ProcessedShape}; +use fj_interop::{mesh::Mesh, processed_shape::Model}; use fj_math::{Aabb, Point}; use fj_viewer::{ InputEvent, NormalizedScreenPosition, RendererInitError, Screen, @@ -22,7 +22,7 @@ pub fn display(mesh: Mesh>, invert_zoom: bool) -> Result<(), Error> { let window = Window::new(&event_loop)?; let mut viewer = block_on(Viewer::new(&window))?; - viewer.handle_shape_update(ProcessedShape { + viewer.handle_shape_update(Model { aabb: Aabb::<3>::from_points(mesh.vertices()), mesh, }); From 1b79f957398f2bd927c1a8df66aad2ef14deb84d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:33:50 +0200 Subject: [PATCH 3/5] Update documentation of `Model` --- crates/fj-interop/src/processed_shape.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fj-interop/src/processed_shape.rs b/crates/fj-interop/src/processed_shape.rs index f1ef7c957..0f1076d42 100644 --- a/crates/fj-interop/src/processed_shape.rs +++ b/crates/fj-interop/src/processed_shape.rs @@ -1,15 +1,15 @@ -//! A processed shape +//! An approximated model use fj_math::{Aabb, Point}; use crate::mesh::Mesh; -/// A processed shape +/// An approximated model #[derive(Clone, Debug)] pub struct Model { - /// The axis-aligned bounding box of the shape + /// The axis-aligned bounding box of the model pub aabb: Aabb<3>, - /// The triangle mesh that approximates the original shape + /// The triangle mesh that approximates the model pub mesh: Mesh>, } From b94ed8a3ef8017c4850a3c148ba665b2c8cbcedb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:34:40 +0200 Subject: [PATCH 4/5] Update module name --- crates/fj-interop/src/lib.rs | 2 +- crates/fj-interop/src/{processed_shape.rs => model.rs} | 0 crates/fj-viewer/src/camera.rs | 2 +- crates/fj-viewer/src/viewer.rs | 2 +- crates/fj-window/src/display.rs | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename crates/fj-interop/src/{processed_shape.rs => model.rs} (100%) diff --git a/crates/fj-interop/src/lib.rs b/crates/fj-interop/src/lib.rs index dc518515b..afc1b93d8 100644 --- a/crates/fj-interop/src/lib.rs +++ b/crates/fj-interop/src/lib.rs @@ -13,4 +13,4 @@ pub mod ext; pub mod mesh; -pub mod processed_shape; +pub mod model; diff --git a/crates/fj-interop/src/processed_shape.rs b/crates/fj-interop/src/model.rs similarity index 100% rename from crates/fj-interop/src/processed_shape.rs rename to crates/fj-interop/src/model.rs diff --git a/crates/fj-viewer/src/camera.rs b/crates/fj-viewer/src/camera.rs index 39ae33dba..5f328f186 100644 --- a/crates/fj-viewer/src/camera.rs +++ b/crates/fj-viewer/src/camera.rs @@ -1,7 +1,7 @@ //! Viewer camera module use std::f64::consts::FRAC_PI_2; -use fj_interop::{mesh::Mesh, processed_shape::Model}; +use fj_interop::{mesh::Mesh, model::Model}; use fj_math::{Aabb, Point, Scalar, Transform, Vector}; use crate::screen::NormalizedScreenPosition; diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index e2a6fe311..24cbc25e7 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -1,4 +1,4 @@ -use fj_interop::processed_shape::Model; +use fj_interop::model::Model; use fj_math::Aabb; use tracing::warn; diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index ce81f9cb7..fb9ca48aa 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -1,4 +1,4 @@ -use fj_interop::{mesh::Mesh, processed_shape::Model}; +use fj_interop::{mesh::Mesh, model::Model}; use fj_math::{Aabb, Point}; use fj_viewer::{ InputEvent, NormalizedScreenPosition, RendererInitError, Screen, From 5b8c3a18aea2b970559c1d138f5275e3967c99a1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 12:48:43 +0200 Subject: [PATCH 5/5] Update order of struct fields The mesh is much more integral to the model than the AABB, so it makes sense to list it first. --- crates/fj-interop/src/model.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-interop/src/model.rs b/crates/fj-interop/src/model.rs index 0f1076d42..3ea622da9 100644 --- a/crates/fj-interop/src/model.rs +++ b/crates/fj-interop/src/model.rs @@ -7,9 +7,9 @@ use crate::mesh::Mesh; /// An approximated model #[derive(Clone, Debug)] pub struct Model { - /// The axis-aligned bounding box of the model - pub aabb: Aabb<3>, - /// The triangle mesh that approximates the model pub mesh: Mesh>, + + /// The axis-aligned bounding box of the model + pub aabb: Aabb<3>, }