From fbaf44e97a413e1705b1dfb011849e19d4b21fa5 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 06:17:14 +0400 Subject: fix(movement): drive tread material cycles from chassis travel Bind animated tread batches to their individual hull displacements. Preserve the authored phase sequence and derive nominal cycle length from the Control speed, scale and MAT0 duration. Checked stock tracked models in the normal AutoDemo window with Vulkan validation clean. Signed travel, stop and respawn are covered by a unit test. Per-track turning and physical cycle length are approximate. --- crates/fparkan-assets/src/chassis_profile.rs | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'crates/fparkan-assets') diff --git a/crates/fparkan-assets/src/chassis_profile.rs b/crates/fparkan-assets/src/chassis_profile.rs index e750cff0..9eef4478 100644 --- a/crates/fparkan-assets/src/chassis_profile.rs +++ b/crates/fparkan-assets/src/chassis_profile.rs @@ -7,6 +7,8 @@ pub struct ChassisFlags { pub can_fly: Option, /// The chassis uses legs to move. pub walk_chassis: Option, + /// The movement class declared by the chassis profile. + pub chassis_type: Option, } /// Reads the bound `CanFly` boolean from a native chassis VAR profile. @@ -33,14 +35,18 @@ pub fn decode_chassis_flags(bytes: &[u8]) -> Result { let name = read_lp_bytes(&mut cursor, 64 * 1024)?; read_lp_bytes(&mut cursor, 64 * 1024)?; cursor.read_exact(size as usize)?; - if size == 4 && kind == 2 { - let value = cursor.read_u32_le()? == 1; - match name.split(|byte| *byte == 0).next().unwrap_or_default() { - b"CanFly" => { - flags.can_fly.get_or_insert(value); + if size == 4 { + let value = cursor.read_u32_le()?; + let name = name.split(|byte| *byte == 0).next().unwrap_or_default(); + match (kind, name) { + (2, b"CanFly") => { + flags.can_fly.get_or_insert(value == 1); } - b"WalkChassis" => { - flags.walk_chassis.get_or_insert(value); + (2, b"WalkChassis") => { + flags.walk_chassis.get_or_insert(value == 1); + } + (5, b"ChassisType") => { + flags.chassis_type.get_or_insert(value); } _ => {} } @@ -59,13 +65,17 @@ mod tests { #[test] fn uses_the_bound_boolean_instead_of_its_default() { - let mut profile = 2_u32.to_le_bytes().to_vec(); - for (name, value) in [("CanFly", 1), ("WalkChassis\0", 0)] { - for word in [4_u32, 2, 0, name.len() as u32] { + let mut profile = 3_u32.to_le_bytes().to_vec(); + for (name, kind, default, value) in [ + ("CanFly", 2, 0, 1), + ("WalkChassis\0", 2, 1, 0), + ("ChassisType", 5, 2, 4), + ] { + for word in [4_u32, kind, 0, name.len() as u32] { profile.extend(word.to_le_bytes()); } profile.extend(name.as_bytes()); - for word in [0_u32, 1 - value, value, 0, 1] { + for word in [0_u32, default, value, 0, 1] { profile.extend(word.to_le_bytes()); } } @@ -75,6 +85,7 @@ mod tests { Ok(ChassisFlags { can_fly: Some(true), walk_chassis: Some(false), + chassis_type: Some(4), }) ); profile.truncate(profile.len() - 1); -- cgit v1.2.3