Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up model-related code in fj-interop #1863

Merged
merged 5 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions crates/fj-interop/src/debug.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/fj-interop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#![warn(missing_docs)]

pub mod debug;
pub mod ext;
pub mod mesh;
pub mod processed_shape;
pub mod model;
15 changes: 15 additions & 0 deletions crates/fj-interop/src/model.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! An approximated model

use fj_math::{Aabb, Point};

use crate::mesh::Mesh;

/// An approximated model
#[derive(Clone, Debug)]
pub struct Model {
/// The triangle mesh that approximates the model
pub mesh: Mesh<Point<3>>,

/// The axis-aligned bounding box of the model
pub aabb: Aabb<3>,
}
18 changes: 0 additions & 18 deletions crates/fj-interop/src/processed_shape.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/fj-viewer/src/camera.rs
Original file line number Diff line number Diff line change
@@ -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, model::Model};
use fj_math::{Aabb, Point, Scalar, Transform, Vector};

use crate::screen::NormalizedScreenPosition;
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Camera {
pub fn focus_point(
&self,
cursor: Option<NormalizedScreenPosition>,
shape: &ProcessedShape,
shape: &Model,
) -> FocusPoint {
self.calculate_focus_point(cursor, &shape.mesh)
.unwrap_or_else(|| FocusPoint(shape.aabb.center()))
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-viewer/src/viewer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fj_interop::processed_shape::ProcessedShape;
use fj_interop::model::Model;
use fj_math::Aabb;
use tracing::warn;

Expand Down Expand Up @@ -28,7 +28,7 @@ pub struct Viewer {
pub renderer: Renderer,

/// The shape
pub shape: Option<ProcessedShape>,
pub shape: Option<Model>,
}

impl Viewer {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions crates/fj-window/src/display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use fj_interop::{
debug::DebugInfo, mesh::Mesh, processed_shape::ProcessedShape,
};
use fj_interop::{mesh::Mesh, model::Model};
use fj_math::{Aabb, Point};
use fj_viewer::{
InputEvent, NormalizedScreenPosition, RendererInitError, Screen,
Expand All @@ -24,10 +22,9 @@ pub fn display(mesh: Mesh<Point<3>>, 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,
debug_info: DebugInfo::new(),
});

let mut held_mouse_button = None;
Expand Down