diff --git a/crates/fj-viewer/src/camera.rs b/crates/fj-viewer/src/camera.rs index 5f328f186..45066fb84 100644 --- a/crates/fj-viewer/src/camera.rs +++ b/crates/fj-viewer/src/camera.rs @@ -82,10 +82,10 @@ impl Camera { pub fn focus_point( &self, cursor: Option, - shape: &Model, + model: &Model, ) -> FocusPoint { - self.calculate_focus_point(cursor, &shape.mesh) - .unwrap_or_else(|| FocusPoint(shape.aabb.center())) + self.calculate_focus_point(cursor, &model.mesh) + .unwrap_or_else(|| FocusPoint(model.aabb.center())) } fn calculate_focus_point( diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 24cbc25e7..7abf32eb1 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -27,8 +27,8 @@ pub struct Viewer { /// The renderer pub renderer: Renderer, - /// The shape - pub shape: Option, + /// The model + pub model: Option, } impl Viewer { @@ -43,7 +43,7 @@ impl Viewer { focus_point: None, input_handler: InputHandler::default(), renderer, - shape: None, + model: None, }) } @@ -59,12 +59,12 @@ impl Viewer { } } - /// Handle the shape being updated - pub fn handle_shape_update(&mut self, shape: Model) { - self.renderer.update_geometry((&shape.mesh).into()); + /// Handle the model being updated + pub fn handle_model_update(&mut self, model: Model) { + self.renderer.update_geometry((&model.mesh).into()); - let aabb = shape.aabb; - if self.shape.replace(shape).is_none() { + let aabb = model.aabb; + if self.model.replace(model).is_none() { self.camera.init_planes(&aabb); } } @@ -83,11 +83,10 @@ impl Viewer { /// Compute and store a focus point, unless one is already stored pub fn add_focus_point(&mut self) { - // Don't recompute the focus point unnecessarily. - if let Some(shape) = &self.shape { + if let Some(model) = &self.model { if self.focus_point.is_none() { self.focus_point = - Some(self.camera.focus_point(self.cursor, shape)); + Some(self.camera.focus_point(self.cursor, model)); } } } @@ -100,7 +99,7 @@ impl Viewer { /// Draw the graphics pub fn draw(&mut self) { let aabb = self - .shape + .model .as_ref() .map(|shape| shape.aabb) .unwrap_or_else(Aabb::default); diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index fb9ca48aa..209a9bca9 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -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(Model { + viewer.handle_model_update(Model { aabb: Aabb::<3>::from_points(mesh.vertices()), mesh, });