mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 02:18:28 +00:00
Simplify API of window
This commit is contained in:
parent
fc5940c55e
commit
27ffb7d696
@ -155,9 +155,7 @@ impl ApplicationHandler for DisplayState {
|
||||
|
||||
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
|
||||
while let Ok(tri_mesh) = self.next_tri_mesh.try_recv() {
|
||||
let mut window = block_on(Window::new(event_loop)).unwrap();
|
||||
window.handle_model_update(tri_mesh);
|
||||
|
||||
let window = block_on(Window::new(tri_mesh, event_loop)).unwrap();
|
||||
self.windows.insert(window.winit_window().id(), window);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ pub struct Window {
|
||||
|
||||
impl Window {
|
||||
pub async fn new(
|
||||
tri_mesh: TriMesh,
|
||||
event_loop: &ActiveEventLoop,
|
||||
) -> Result<Self, WindowError> {
|
||||
let window = Arc::new(
|
||||
@ -41,8 +42,12 @@ impl Window {
|
||||
.with_transparent(false),
|
||||
)?,
|
||||
);
|
||||
let renderer = Renderer::new(window.clone()).await?;
|
||||
let camera = Camera::default();
|
||||
let mut renderer = Renderer::new(window.clone()).await?;
|
||||
let mut camera = Camera::default();
|
||||
|
||||
renderer.update_geometry(Vertices::from_tri_mesh(&tri_mesh));
|
||||
let aabb = tri_mesh.aabb();
|
||||
camera.init_planes(&aabb);
|
||||
|
||||
Ok(Self {
|
||||
new_screen_size: None,
|
||||
@ -54,7 +59,7 @@ impl Window {
|
||||
focus_point: None,
|
||||
window,
|
||||
renderer,
|
||||
model: None,
|
||||
model: Some((tri_mesh, aabb)),
|
||||
})
|
||||
}
|
||||
|
||||
@ -72,17 +77,6 @@ impl Window {
|
||||
self.draw_config.draw_mesh = !self.draw_config.draw_mesh;
|
||||
}
|
||||
|
||||
/// Handle the model being updated
|
||||
pub fn handle_model_update(&mut self, tri_mesh: TriMesh) {
|
||||
self.renderer
|
||||
.update_geometry(Vertices::from_tri_mesh(&tri_mesh));
|
||||
|
||||
let aabb = tri_mesh.aabb();
|
||||
if self.model.replace((tri_mesh, aabb)).is_none() {
|
||||
self.camera.init_planes(&aabb);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle an input event
|
||||
pub fn handle_input_event(&mut self, event: InputEvent) {
|
||||
let Some(focus_point) = self.focus_point else {
|
||||
|
Loading…
Reference in New Issue
Block a user