aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-26 20:21:49 +0300
committerValentin Popov <valentin@popov.link>2026-11-26 20:21:49 +0300
commit78a63745f471c028c0ed67f133de9034e901c905 (patch)
tree4f9f382e15dfe642505699e73d2526ce864680ae /crates/fparkan-runtime/src/lib.rs
parent75dcc70912d4e6feb14d9370452914ff826849f7 (diff)
downloadfparkan-78a63745f471c028c0ed67f133de9034e901c905.tar.xz
fparkan-78a63745f471c028c0ed67f133de9034e901c905.zip
feat(camera): free look with left Shift from the cockpit
Route shifted mouse samples to the independent Control camera phases, apply yaw then pitch at the existing cockpit point, and recenter on Shift release or right click. Original World3D dispatch and Control camera calls verified wrapping, clamping, recentering, and the transform. A stock Firing Range window showed the view move and return with hull yaw and turret pitch unchanged.
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
-rw-r--r--crates/fparkan-runtime/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index f62c0784..3aa78bbe 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -1408,6 +1408,8 @@ pub struct FrameResult {
pub clan_notices: Vec<MissionNotice>,
/// Vertical aim of the controlled hero as an IEEE-754 radian value.
pub player_pitch_bits: u32,
+ /// View-only yaw and pitch relative to the sights, encoded as radians.
+ pub player_view_offset_bits: [u32; 2],
/// Footstep from the accepted player motion, if this tick reached a footfall.
pub player_footstep: Option<PlayerFootstep>,
/// Autonomous combat events during the step.
@@ -2990,6 +2992,9 @@ pub fn step_headless(
.loaded
.as_ref()
.map_or(0, |mission| mission.player_pitch_bits),
+ player_view_offset_bits: engine.loaded.as_ref().map_or([0; 2], |mission| {
+ mission.hero_look.camera_offset().map(f32::to_bits)
+ }),
})
}
@@ -3045,6 +3050,7 @@ pub fn frame_with_player_motion(
motion,
blocked || drowned || landing.is_some(),
);
+ frame.player_view_offset_bits = mission.hero_look.camera_offset().map(f32::to_bits);
if !blocked
&& !drowned
&& landing.is_none()
@@ -17987,6 +17993,7 @@ mod tests {
mouse_x: 100.0,
mouse_y: -500.0,
delta_seconds: 0.1,
+ ..Default::default()
};
let proposed = plan_player_motion(&engine, cockpit, input)
.unwrap()