aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/projectile_render.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 16:54:01 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 16:54:01 +0300
commitdab650bbff13fe5fee6a4a14b0ad627f11c5b94b (patch)
tree8a92b1377a09f14499cbe6896b2e557ebbd29dee /apps/fparkan-game/src/projectile_render.rs
parent1d241fe9ed96355a003e2ae43a8ab49ee047d9b6 (diff)
downloadfparkan-dab650bbff13fe5fee6a4a14b0ad627f11c5b94b.tar.xz
fparkan-dab650bbff13fe5fee6a4a14b0ad627f11c5b94b.zip
perf(render): prepare live factory scene geometry in background
Diffstat (limited to 'apps/fparkan-game/src/projectile_render.rs')
-rw-r--r--apps/fparkan-game/src/projectile_render.rs12
1 files changed, 7 insertions, 5 deletions
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<ProjectileAssets, String> + 'a;
+
#[allow(clippy::too_many_arguments)]
pub(super) fn prepare_player_draws(
root: &Path,
- engine: &Engine,
+ load_projectile: &ProjectileLoader<'_>,
weapons_by_object: impl IntoIterator<Item = (usize, fparkan_runtime::PlayerWeapons)>,
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<Option<ProjectileDraw>, 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<MaterialAnimationBinding>,
trail_materials: &mut EffectMaterials,
) -> Result<Option<ProjectileDraw>, 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());