diff options
Diffstat (limited to 'apps/fparkan-game/src')
| -rw-r--r-- | apps/fparkan-game/src/cockpit_instrument.rs | 28 | ||||
| -rw-r--r-- | apps/fparkan-game/src/mission_overlay.rs | 1 |
2 files changed, 23 insertions, 6 deletions
diff --git a/apps/fparkan-game/src/cockpit_instrument.rs b/apps/fparkan-game/src/cockpit_instrument.rs index 37023fea..400f3a7d 100644 --- a/apps/fparkan-game/src/cockpit_instrument.rs +++ b/apps/fparkan-game/src/cockpit_instrument.rs @@ -156,7 +156,6 @@ impl CockpitInstrument { renderer: &mut VulkanSmokeRenderer, live: Option<(&Engine, StartingCockpit, &WorldSnapshot)>, selected: Option<ObjectHandle>, - drawable: [f32; 2], mut live_models: LiveModels<'_>, ) -> Result<[Option<VulkanModelPreview>; 2], String> { if !self.initialized { @@ -217,7 +216,7 @@ impl CockpitInstrument { }; self.models .get(unit.object_index)? - .view(panel.side, center, radius, forward, drawable) + .view(panel.side, center, radius, forward) })(); if views[index].is_some() { active[index] = Some(unit.object_index); @@ -370,7 +369,6 @@ impl Model { center: [f32; 3], radius: f32, forward: [f32; 3], - drawable: [f32; 2], ) -> Option<VulkanModelPreview> { let near = 0.5; let far = 300.0; @@ -392,8 +390,10 @@ impl Model { right_edge / 640.0, bottom / 480.0, ]; - let aspect = super::preview_aspect((drawable[0] / 640.0) / (drawable[1] / 480.0)); - let fov = ((0.6_f32).tan() / aspect).atan() * 2.0; + // The camera applied at iron3d+0x42117 uses a 75-degree field + // of view in the instrument's square layout viewport. + let fov = 75.0_f32.to_radians(); + let aspect = (right_edge - left) / (bottom - top); let camera = VulkanStaticCamera { clip_from_world: clip_from_world_for_view( eye, forward, right, up, fov, near, far, aspect, @@ -416,3 +416,21 @@ impl Model { }) } } + +#[cfg(test)] +#[test] +fn targeter_projection_uses_the_original_focal_scale_on_both_axes() { + let model = Model { + bounds: None, + ranges: 0..1, + counts: Vec::new(), + components: Vec::new(), + }; + for side in [Side::Left, Side::Right] { + let view = model.view(side, [0.0; 3], 2.0, [0.0, 1.0, 0.0]).unwrap(); + let matrix = view.camera.clip_from_world; + let focal = 1.303_225_4; + assert!((matrix[0] - focal).abs() < 1e-6); + assert!((matrix[9] + focal).abs() < 1e-6); + } +} diff --git a/apps/fparkan-game/src/mission_overlay.rs b/apps/fparkan-game/src/mission_overlay.rs index 06db1c90..b93ece81 100644 --- a/apps/fparkan-game/src/mission_overlay.rs +++ b/apps/fparkan-game/src/mission_overlay.rs @@ -490,7 +490,6 @@ impl StaticVulkanApp { renderer, live, self.selected_contact, - frame.viewport, LiveModels { mesh: &mut self.mesh, poses: &self.component_pose_buffers, |
