mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-28 01:55:52 +00:00
Prepare main loop for not having camera available
This will help with a fix I'm working on.
This commit is contained in:
parent
3a35b4b803
commit
1227f69d06
@ -144,7 +144,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
processed_shape.update_geometry(&mut renderer);
|
processed_shape.update_geometry(&mut renderer);
|
||||||
|
|
||||||
let mut draw_config = DrawConfig::default();
|
let mut draw_config = DrawConfig::default();
|
||||||
let mut camera = Camera::new(&processed_shape.aabb);
|
let mut camera = Some(Camera::new(&processed_shape.aabb));
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
trace!("Handling event: {:?}", event);
|
trace!("Handling event: {:?}", event);
|
||||||
@ -181,23 +181,28 @@ fn main() -> anyhow::Result<()> {
|
|||||||
event: WindowEvent::CursorMoved { position, .. },
|
event: WindowEvent::CursorMoved { position, .. },
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
input_handler.handle_cursor_moved(
|
if let Some(camera) = &mut camera {
|
||||||
position,
|
input_handler
|
||||||
&mut camera,
|
.handle_cursor_moved(position, camera, &window);
|
||||||
&window,
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::MouseInput { state, button, .. },
|
event: WindowEvent::MouseInput { state, button, .. },
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let focus_point = camera.focus_point(
|
if let Some(camera) = &camera {
|
||||||
&window,
|
let focus_point = camera.focus_point(
|
||||||
input_handler.cursor(),
|
&window,
|
||||||
&processed_shape.triangles,
|
input_handler.cursor(),
|
||||||
);
|
&processed_shape.triangles,
|
||||||
|
);
|
||||||
|
|
||||||
input_handler.handle_mouse_input(button, state, focus_point);
|
input_handler.handle_mouse_input(
|
||||||
|
button,
|
||||||
|
state,
|
||||||
|
focus_point,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::MouseWheel { delta, .. },
|
event: WindowEvent::MouseWheel { delta, .. },
|
||||||
@ -209,23 +214,27 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let delta_t = now.duration_since(previous_time);
|
let delta_t = now.duration_since(previous_time);
|
||||||
previous_time = now;
|
previous_time = now;
|
||||||
|
|
||||||
input_handler.update(
|
if let Some(camera) = &mut camera {
|
||||||
delta_t.as_secs_f64(),
|
input_handler.update(
|
||||||
now,
|
delta_t.as_secs_f64(),
|
||||||
&mut camera,
|
now,
|
||||||
&window,
|
camera,
|
||||||
&processed_shape.triangles,
|
&window,
|
||||||
);
|
&processed_shape.triangles,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
window.inner().request_redraw();
|
window.inner().request_redraw();
|
||||||
}
|
}
|
||||||
Event::RedrawRequested(_) => {
|
Event::RedrawRequested(_) => {
|
||||||
camera.update_planes(&processed_shape.aabb);
|
if let Some(camera) = &mut camera {
|
||||||
|
camera.update_planes(&processed_shape.aabb);
|
||||||
|
|
||||||
match renderer.draw(&camera, &draw_config) {
|
match renderer.draw(camera, &draw_config) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
panic!("Draw error: {}", err);
|
panic!("Draw error: {}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user