Skip to content

Commit

Permalink
Merge pull request #758 from jeevcat/main
Browse files Browse the repository at this point in the history
Only calculate focus point when needed
  • Loading branch information
hannobraun authored Jul 1, 2022
2 parents aff7824 + 38da839 commit fb4ae09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 8 additions & 2 deletions crates/fj-viewer/src/input/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fj_interop::mesh::Mesh;
use fj_math::{Point, Transform, Vector};

use crate::{
camera::{Camera, FocusPoint},
camera::Camera,
screen::{Position, Size},
};

Expand Down Expand Up @@ -53,8 +53,8 @@ impl Handler {
&mut self,
event: Event,
screen_size: Size,
focus_point: FocusPoint,
now: Instant,
mesh: &Mesh<Point<3>>,
camera: &mut Camera,
actions: &mut Actions,
) {
Expand Down Expand Up @@ -83,12 +83,18 @@ impl Handler {
}

Event::Key(Key::MouseLeft, KeyState::Pressed) => {
let focus_point =
camera.focus_point(screen_size, self.cursor(), mesh);

self.rotation.start(focus_point);
}
Event::Key(Key::MouseLeft, KeyState::Released) => {
self.rotation.stop();
}
Event::Key(Key::MouseRight, KeyState::Pressed) => {
let focus_point =
camera.focus_point(screen_size, self.cursor(), mesh);

self.movement.start(focus_point, self.cursor);
}
Event::Key(Key::MouseRight, KeyState::Released) => {
Expand Down
8 changes: 1 addition & 7 deletions crates/fj-window/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,11 @@ pub fn run(
if let (Some(event), Some(shape), Some(camera)) =
(event, &shape, &mut camera)
{
let focus_point = camera.focus_point(
window.size(),
input_handler.cursor(),
&shape.mesh,
);

input_handler.handle_event(
event,
window.size(),
focus_point,
now,
&shape.mesh,
camera,
&mut actions,
);
Expand Down

0 comments on commit fb4ae09

Please sign in to comment.