From 4e4a0795fccbcc4a2dd2f4b51c8f8f7802812791 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 05:58:15 +0400 Subject: feat(movement): play authored walking cycles from chassis travel Select a closed forward stride from the model for explicit walking profiles. Drive it from world displacement and subtract baked forward travel before updating geometry, mounts and shadows. Verified light, medium and heavy stock model cycles and watched leg poses change from the normal AutoDemo start with Vulkan validation clean. Stop transitions and terrain-adaptive feet remain open. --- crates/fparkan-runtime/src/unit_chassis.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'crates/fparkan-runtime/src/unit_chassis.rs') diff --git a/crates/fparkan-runtime/src/unit_chassis.rs b/crates/fparkan-runtime/src/unit_chassis.rs index 88b5a3c9..25020a4f 100644 --- a/crates/fparkan-runtime/src/unit_chassis.rs +++ b/crates/fparkan-runtime/src/unit_chassis.rs @@ -1,12 +1,13 @@ //! Chassis behavior flags shared by autonomous and player control. -use crate::MissionObjectDraft; +use crate::{Engine, MissionObjectDraft}; +use fparkan_assets::{decode_chassis_flags, ChassisFlags}; use fparkan_resource::{resource_name, CachedResourceRepository, ResourceRepository}; use std::collections::BTreeMap; pub(super) fn load_flags( resources: &CachedResourceRepository, drafts: &[MissionObjectDraft], -) -> BTreeMap> { +) -> BTreeMap { drafts .iter() .filter(|draft| { @@ -17,7 +18,7 @@ pub(super) fn load_flags( .filter_map(|draft| { draft .original_id - .map(|id| (id.0, can_fly(resources, draft))) + .map(|id| (id.0, load_profile(resources, draft).unwrap_or_default())) }) .collect() } @@ -26,6 +27,25 @@ pub(super) fn can_fly( resources: &CachedResourceRepository, draft: &MissionObjectDraft, ) -> Option { + load_profile(resources, draft)?.can_fly +} + +/// Returns whether a loaded draft has an explicit walking chassis profile. +pub fn loaded_walk_chassis(engine: &Engine, object_index: usize) -> bool { + engine.loaded.as_ref().is_some_and(|mission| { + mission + .object_drafts + .get(object_index) + .and_then(|draft| draft.original_id) + .and_then(|id| mission.unit_chassis_flags.get(&id.0)) + .is_some_and(|flags| flags.walk_chassis == Some(true)) + }) +} + +fn load_profile( + resources: &CachedResourceRepository, + draft: &MissionObjectDraft, +) -> Option { let chassis = draft.unit_components.first()?; let archive = crate::bounded_ascii_c_string(&chassis.archive_raw)?; let registry_path = crate::normalize_engine_path("chassis archive", &archive).ok()?; @@ -45,5 +65,5 @@ pub(super) fn can_fly( let entry = resources .find(archive, &resource_name(name.as_bytes())) .ok()??; - fparkan_assets::decode_chassis_can_fly(resources.read(entry).ok()?.as_slice()).ok()? + decode_chassis_flags(resources.read(entry).ok()?.as_slice()).ok() } -- cgit v1.2.3