mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 01:48:28 +00:00
Move function to more appropriate location
This commit is contained in:
parent
7eeeb1ef7f
commit
4805298357
@ -266,6 +266,18 @@ impl Camera {
|
||||
Scalar::ZERO,
|
||||
]));
|
||||
}
|
||||
|
||||
/// # Apply a zoom
|
||||
pub fn apply_zoom(
|
||||
zoom_delta: f64,
|
||||
focus_point: FocusPoint,
|
||||
camera: &mut Camera,
|
||||
) {
|
||||
let distance = (focus_point.0 - camera.position()).magnitude();
|
||||
let displacement = zoom_delta * distance.into_f64();
|
||||
camera.translation = camera.translation
|
||||
* Transform::translation(Vector::from([0.0, 0.0, displacement]));
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Camera {
|
||||
|
@ -1,14 +0,0 @@
|
||||
use fj_math::{Transform, Vector};
|
||||
|
||||
use crate::camera::{Camera, FocusPoint};
|
||||
|
||||
pub fn apply_zoom(
|
||||
zoom_delta: f64,
|
||||
focus_point: FocusPoint,
|
||||
camera: &mut Camera,
|
||||
) {
|
||||
let distance = (focus_point.0 - camera.position()).magnitude();
|
||||
let displacement = zoom_delta * distance.into_f64();
|
||||
camera.translation = camera.translation
|
||||
* Transform::translation(Vector::from([0.0, 0.0, displacement]));
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
//! User input parsing and propagation.
|
||||
|
||||
mod event;
|
||||
pub mod handler;
|
||||
|
||||
pub use self::event::InputEvent;
|
||||
|
@ -4,7 +4,6 @@ use tracing::warn;
|
||||
use crate::{
|
||||
camera::{Camera, FocusPoint},
|
||||
graphics::{DrawConfig, Renderer},
|
||||
input::handler::apply_zoom,
|
||||
InputEvent, NormalizedScreenPosition, RendererInitError, Screen,
|
||||
ScreenSize,
|
||||
};
|
||||
@ -74,7 +73,11 @@ impl Viewer {
|
||||
self.camera.apply_rotation(angle_x, angle_y, focus_point);
|
||||
}
|
||||
InputEvent::Zoom(zoom_delta) => {
|
||||
apply_zoom(zoom_delta, focus_point, &mut self.camera);
|
||||
Camera::apply_zoom(
|
||||
zoom_delta,
|
||||
focus_point,
|
||||
&mut self.camera,
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user