diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-27 02:37:54 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-27 02:37:54 +0300 |
| commit | 16befe409021bc98222ca5fd926e1f63e16d04da (patch) | |
| tree | 8beba0454760a7b69b6a72439917f5b98310438c /crates/fparkan-runtime/src | |
| parent | 414d7d871ea3ccf9872fcf8b098416ddeb94cc2d (diff) | |
| download | fparkan-16befe409021bc98222ca5fd926e1f63e16d04da.tar.xz fparkan-16befe409021bc98222ca5fd926e1f63e16d04da.zip | |
fix(gameplay): fire hero projectiles along the posed muzzle
Use the CPT direction after the current node, component mount, and body transforms. Validate the raised barrel axis with the original Constructor resources.
Diffstat (limited to 'crates/fparkan-runtime/src')
| -rw-r--r-- | crates/fparkan-runtime/src/player_weapon.rs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs index 31681670..a4d51c51 100644 --- a/crates/fparkan-runtime/src/player_weapon.rs +++ b/crates/fparkan-runtime/src/player_weapon.rs @@ -304,6 +304,11 @@ impl PlayerWeapon { self.rounds_remaining } + /// Whether the device uses the prepared mount tracks of the hero's weapons. + pub fn has_deployment_tracks(&self) -> bool { + self.deployment.is_some() + } + /// Conservative lower bound used to size the projectile draw pool. pub fn interval_ms(&self) -> u32 { let fastest = self @@ -633,15 +638,24 @@ mod tests { assert_eq!(fired_slot, slot); weapons.apply_firing_pose(hero.component_index, &mut times); assert_eq!(times[11], Some(48.0)); - let sampled: Vec<_> = times.iter().map(|time| time.map(AnimationTime)).collect(); - let hierarchy = node38_sampled_hierarchy_at_times(model, &sampled).unwrap(); - let barrel = hierarchy.poses[muzzle.raw_signed_field_04 as usize]; - let origin = barrel.transform_point(muzzle.position); - let forward = barrel.transform_point(std::array::from_fn(|axis| { - muzzle.position[axis] + muzzle.direction[axis] - })); + let muzzle_points = |times: &[Option<f32>]| { + let sampled: Vec<_> = + times.iter().map(|time| time.map(AnimationTime)).collect(); + let hierarchy = node38_sampled_hierarchy_at_times(model, &sampled).unwrap(); + let barrel = hierarchy.poses[muzzle.raw_signed_field_04 as usize]; + let origin = barrel.transform_point(muzzle.position); + let forward = barrel.transform_point(std::array::from_fn(|axis| { + muzzle.position[axis] + muzzle.direction[axis] + })); + (origin, forward) + }; + let (origin, forward) = muzzle_points(×); assert!(origin[1] > 1.0 && origin[2] > 0.1, "{origin:?}"); assert!(forward[1] - origin[1] > 0.99, "{origin:?} -> {forward:?}"); + fparkan_assets::apply_manual_turret_elevation(control, 0.5, &mut times); + let (origin, forward) = muzzle_points(×); + let elevation = (forward[2] - origin[2]).atan2(forward[1] - origin[1]); + assert!((elevation - 0.5).abs() < 0.003, "{elevation}"); } let phase = weapons .firing_effect_phases(hero.object_index) |
