diff --git a/kubi-shared/Cargo.toml b/kubi-shared/Cargo.toml index 90617c0..a63255d 100644 --- a/kubi-shared/Cargo.toml +++ b/kubi-shared/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] glam = { version = "0.23", features = ["debug-glam-assert", "fast-math", "serde"] } -shipyard = { git = "https://github.com/leudz/shipyard", rev = "eb189f66" } +shipyard = { git = "https://github.com/leudz/shipyard", rev = "eb189f66", default-features = false, features = ["std"] } strum = { version = "0.24", features = ["derive"] } postcard = { version = "1.0", features = ["alloc"] } serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } diff --git a/kubi/Cargo.toml b/kubi/Cargo.toml index 743daf8..f2ca9d0 100644 --- a/kubi/Cargo.toml +++ b/kubi/Cargo.toml @@ -14,7 +14,7 @@ image = { version = "0.24", default_features = false, features = ["png"] } strum = { version = "0.24", features = ["derive"] } hashbrown = "0.13" rayon = "1.6" -shipyard = { git = "https://github.com/leudz/shipyard", rev = "eb189f66", features = ["thread_local"] } +shipyard = { git = "https://github.com/leudz/shipyard", rev = "eb189f66", default-features = false, features = ["std", "proc", "thread_local"] } nohash-hasher = "0.2.0" anyhow = "1.0" flume = "0.10" @@ -27,4 +27,5 @@ winapi = { version = "0.3" } [features] default = [] +parallel = ["shipyard/parallel"] nightly = ["glam/core-simd", "kubi-shared/nightly"] diff --git a/kubi/src/camera/matrices.rs b/kubi/src/camera/matrices.rs index 109c3de..b6ded27 100644 --- a/kubi/src/camera/matrices.rs +++ b/kubi/src/camera/matrices.rs @@ -1,6 +1,6 @@ use glam::{Vec3, Mat4}; -use shipyard::{ViewMut, View, IntoIter, Workload, IntoWorkload, track}; -use crate::{transform::Transform, events::WindowResizedEvent}; +use shipyard::{ViewMut, View, IntoIter, Workload, IntoWorkload, track, UniqueView, SystemModificator}; +use crate::{transform::Transform, rendering::WindowSize, events::WindowResizedEvent}; use super::Camera; //maybe parallelize these two? @@ -18,11 +18,8 @@ fn update_view_matrix( fn update_perspective_matrix( mut vm_camera: ViewMut, - resize: View, + size: UniqueView, ) { - let Some(&size) = resize.iter().next() else { - return - }; for mut camera in (&mut vm_camera).iter() { camera.perspective_matrix = Mat4::perspective_rh_gl( camera.fov, @@ -33,9 +30,19 @@ fn update_perspective_matrix( } } +fn need_perspective_calc( + v_camera: View, + resize_event: View, +) -> bool { + (resize_event.len() > 0) || + (v_camera.iter().any(|camera| { + camera.perspective_matrix == Mat4::default() + })) +} + pub fn update_matrices() -> Workload { ( update_view_matrix, - update_perspective_matrix, + update_perspective_matrix.run_if(need_perspective_calc), ).into_workload() }