Disable parallel feature by default, recalc camera matrix

This commit is contained in:
griffi-gh 2023-03-09 00:31:19 +01:00
parent 2189d114c7
commit 0cb066b02b
3 changed files with 17 additions and 9 deletions

View file

@ -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"] }

View file

@ -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"]

View file

@ -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<Camera>,
resize: View<WindowResizedEvent>,
size: UniqueView<WindowSize>,
) {
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<Camera>,
resize_event: View<WindowResizedEvent>,
) -> 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()
}