diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 04:58:15 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 04:58:15 +0300 |
| commit | 4e4a0795fccbcc4a2dd2f4b51c8f8f7802812791 (patch) | |
| tree | 3cd67b59d94feb1fd1515be4f0c69134a86a6cde /apps/fparkan-game/src/main.rs | |
| parent | 531753ef5fbfa846b4291864458f511d5c7e1b59 (diff) | |
| download | fparkan-4e4a0795fccbcc4a2dd2f4b51c8f8f7802812791.tar.xz fparkan-4e4a0795fccbcc4a2dd2f4b51c8f8f7802812791.zip | |
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.
Diffstat (limited to 'apps/fparkan-game/src/main.rs')
| -rw-r--r-- | apps/fparkan-game/src/main.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs index 088cc0f3..b8b81c19 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -5,6 +5,7 @@ use fparkan_runtime::initial_component_node_times as static_preview_node_times; mod camera_capture; +mod chassis_animation; #[cfg(windows)] mod control_effects; use control_effects::{advance_control_effect_instances, owner_control_capacity}; @@ -279,7 +280,7 @@ fn run(args: &[String]) -> Result<String, String> { .and_then(|c| c.celestial_births.clone()); let hold_schedule_phase = camera.is_some() && atmosphere_seconds.is_some(); let terrain_materials_duration_started = Instant::now(); - let preview = static_preview_mesh_and_materials( + let mut preview = static_preview_mesh_and_materials( mission_assets, terrain, roots, @@ -292,6 +293,9 @@ fn run(args: &[String]) -> Result<String, String> { !args.viewer, (!args.viewer).then(|| starting_cockpit(&engine)).flatten(), )?; + if !args.viewer { + chassis_animation::connect_walkers(&engine, &mut preview); + } let terrain_materials_duration = terrain_materials_duration_started.elapsed(); // Atmosphere files are mission-local assets. Resolving them from the // entire install tree would silently attach the first unrelated mission's @@ -4766,6 +4770,7 @@ struct ControlAnimationInstance { reported_unsupported_fallback: bool, door_blends: Vec<f32>, wheels: Option<fparkan_runtime::WheelAnimation>, + walk: Option<fparkan_runtime::WalkAnimation>, } #[derive(Clone)] @@ -7378,13 +7383,14 @@ fn update_gameplay_animation_pose_buffers( } } } - if let (Some(wheels), Some((roots, snapshot))) = (&mut instance.wheels, motion) { - if let Some(root) = roots.get(object_index).and_then(Option::as_ref) { - if let Some(pose) = live_root_pose(root.handle, snapshot) { - wheels.sample(root.handle, pose, &mut node_times); - } - } - } + let walking = motion.is_some_and(|(roots, snapshot)| { + roots + .get(object_index) + .and_then(Option::as_ref) + .is_some_and(|root| { + chassis_animation::sample(instance, root, snapshot, &mut node_times) + }) + }); instance.last_sampled_node_times.clone_from(&node_times); let times = node_times .into_iter() @@ -7392,7 +7398,10 @@ fn update_gameplay_animation_pose_buffers( .collect::<Vec<_>>(); let hierarchy = node38_sampled_hierarchy_at_times(&instance.model, ×) .or_else(|| node38_fallback_hierarchy(&instance.model)); - if let Some(hierarchy) = hierarchy { + if let Some(mut hierarchy) = hierarchy { + if let Some(walk) = instance.walk.as_ref().filter(|_| walking) { + walk.remove_root_progress(&mut hierarchy); + } if let Some(pose_buffer) = object_pose_buffers.get_mut(component_index) { *pose_buffer = Some(hierarchy); } @@ -8377,6 +8386,7 @@ fn static_preview_mesh_and_materials( last_sampled_node_times: Vec::new(), reported_unsupported_fallback: false, door_blends: Vec::new(), + walk: None, wheels: if component_index == 0 && mission_root .unit_dat_header_flags @@ -13832,6 +13842,7 @@ mod tests { reported_unsupported_fallback: false, door_blends: Vec::new(), wheels: None, + walk: None, }); let first = FrameClockSample { @@ -13937,6 +13948,7 @@ mod tests { reported_unsupported_fallback: false, door_blends: Vec::new(), wheels: None, + walk: None, })]]; let hierarchy = static_preview_component_pose_buffer(&model, &controls.bindings, None).unwrap(); @@ -14518,6 +14530,7 @@ mod tests { reported_unsupported_fallback: false, door_blends: Vec::new(), wheels: None, + walk: None, }), None, ]]; @@ -14861,6 +14874,7 @@ mod tests { reported_unsupported_fallback: false, door_blends: Vec::new(), wheels: None, + walk: None, }), None, ]]; @@ -15826,6 +15840,7 @@ mod tests { reported_unsupported_fallback: false, door_blends: Vec::new(), wheels: None, + walk: None, }); let turret_pose = |app: &StaticVulkanApp, node| { let hierarchy = app.component_pose_buffers[cockpit.object_index] |
