From dab650bbff13fe5fee6a4a14b0ad627f11c5b94b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 17:54:01 +0400 Subject: perf(render): prepare live factory scene geometry in background --- apps/fparkan-game/src/projectile_render.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'apps/fparkan-game/src/projectile_render.rs') diff --git a/apps/fparkan-game/src/projectile_render.rs b/apps/fparkan-game/src/projectile_render.rs index 343f0e63..c57c63a1 100644 --- a/apps/fparkan-game/src/projectile_render.rs +++ b/apps/fparkan-game/src/projectile_render.rs @@ -42,10 +42,12 @@ pub(super) struct ProjectileDrawSlot { pub(super) trail_segment: Option<[[f32; 3]; 2]>, } +pub(super) type ProjectileLoader<'a> = dyn Fn(&str, &str) -> Result + 'a; + #[allow(clippy::too_many_arguments)] pub(super) fn prepare_player_draws( root: &Path, - engine: &Engine, + load_projectile: &ProjectileLoader<'_>, weapons_by_object: impl IntoIterator, first_pool: usize, mesh: &mut VulkanStaticMesh, @@ -96,7 +98,7 @@ pub(super) fn prepare_player_draws( }; let draw = match prepare_projectile_draw_into( root, - engine, + load_projectile, &archive, &name, capacity, @@ -133,7 +135,7 @@ pub(super) fn prepare_projectile_draw( ) -> Result, String> { prepare_projectile_draw_into( root, - engine, + &|archive, name| load_player_projectile(engine, archive, name), archive, name, capacity, @@ -147,7 +149,7 @@ pub(super) fn prepare_projectile_draw( #[allow(clippy::too_many_arguments)] pub(super) fn prepare_projectile_draw_into( root: &Path, - engine: &Engine, + load_projectile: &ProjectileLoader<'_>, archive: &str, name: &str, capacity: impl FnOnce(u32) -> u32, @@ -156,7 +158,7 @@ pub(super) fn prepare_projectile_draw_into( material_animations: &mut Vec, trail_materials: &mut EffectMaterials, ) -> Result, String> { - let projectile = load_player_projectile(engine, archive, name)?; + let projectile = load_projectile(archive, name)?; let assets = &projectile.assets; let [id] = assets.visuals_for_object(0) else { return Err("projectile has no single visual".into()); -- cgit v1.2.3