aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 20:26:06 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 20:26:06 +0300
commit87801add32ad300f1c7b1fc6fb449ceaf6685731 (patch)
treefeda359ba27889e32e9a9903aa9b130b5711313c /apps
parent5fcaba2e62a60ac88d007ecc84987c5523c93ff7 (diff)
downloadfparkan-87801add32ad300f1c7b1fc6fb449ceaf6685731.tar.xz
fparkan-87801add32ad300f1c7b1fc6fb449ceaf6685731.zip
fix(ui): frame cockpit miniatures using the unit node bounds
Diffstat (limited to 'apps')
-rw-r--r--apps/fparkan-game/src/cockpit_instrument.rs24
-rw-r--r--apps/fparkan-game/src/mission_overlay.rs2
2 files changed, 18 insertions, 8 deletions
diff --git a/apps/fparkan-game/src/cockpit_instrument.rs b/apps/fparkan-game/src/cockpit_instrument.rs
index 76533778..37023fea 100644
--- a/apps/fparkan-game/src/cockpit_instrument.rs
+++ b/apps/fparkan-game/src/cockpit_instrument.rs
@@ -17,8 +17,8 @@ use fparkan_render_vulkan::{
};
use fparkan_runtime::{
cockpit_instruments::{
- instrument_distance, instrument_readout, instrument_sphere, InstrumentReadout,
- InstrumentStatus,
+ instrument_bounds, instrument_distance, instrument_readout, instrument_sphere,
+ InstrumentReadout, InstrumentStatus,
},
Engine, StartingCockpit,
};
@@ -47,6 +47,7 @@ struct PanelReadout {
}
struct Model {
+ bounds: Option<([f32; 3], f32)>,
ranges: Range<usize>,
counts: Vec<u32>,
components: Vec<ModelComponent>,
@@ -65,7 +66,11 @@ pub(super) struct LiveModels<'a> {
}
impl CockpitInstrument {
- pub(super) fn load(root: &Path, scene: &mut StaticPreviewScene) -> Result<Self, String> {
+ pub(super) fn load(
+ root: &Path,
+ engine: &Engine,
+ scene: &mut StaticPreviewScene,
+ ) -> Result<Self, String> {
let images = Images::load(&DirectoryVfs::new(root))?;
let strings = StringResources::open(&root.join("iron3d.dll"))?;
let panels = [
@@ -123,6 +128,7 @@ impl CockpitInstrument {
}
let ranges = start..scene.mesh.draw_ranges.len();
models.push(Model {
+ bounds: instrument_bounds(engine, object),
ranges,
counts,
components: projected,
@@ -161,6 +167,10 @@ impl CockpitInstrument {
}
let mut views = [None, None];
let mut active = [None; 2];
+ let sphere = |engine, subject, object_index| {
+ let model: &Model = self.models.get(object_index)?;
+ instrument_sphere(engine, subject, object_index, model.bounds)
+ };
for (index, panel) in self.panels.iter_mut().enumerate() {
let mut model_pose = None;
let reading = live.and_then(|(engine, cockpit, snapshot)| {
@@ -171,13 +181,13 @@ impl CockpitInstrument {
cockpit.handle
};
let unit = instrument_readout(engine, cockpit, subject)?;
- let sphere = instrument_sphere(engine, subject, unit.object_index);
+ let subject_sphere = sphere(engine, subject, unit.object_index);
let observer = if observing {
- instrument_sphere(engine, cockpit.handle, cockpit.object_index)
+ sphere(engine, cockpit.handle, cockpit.object_index)
} else {
None
};
- let centers = sphere.zip(observer);
+ let centers = subject_sphere.zip(observer);
let distance = if observing {
centers
.and_then(|((center, _), (origin, _))| instrument_distance(origin, center))
@@ -185,7 +195,7 @@ impl CockpitInstrument {
None
};
views[index] = (|| {
- let (center, radius) = sphere?;
+ let (center, radius) = subject_sphere?;
let pose = live_root_pose(subject, snapshot)?;
model_pose = Some(pose);
let forward = if observing {
diff --git a/apps/fparkan-game/src/mission_overlay.rs b/apps/fparkan-game/src/mission_overlay.rs
index 717bbd17..06db1c90 100644
--- a/apps/fparkan-game/src/mission_overlay.rs
+++ b/apps/fparkan-game/src/mission_overlay.rs
@@ -100,7 +100,7 @@ impl MissionOverlay {
});
#[cfg(windows)]
let instrument = cockpit.and_then(|_| {
- CockpitInstrument::load(root, preview)
+ CockpitInstrument::load(root, engine, preview)
.inspect_err(|error| eprintln!("cockpit_instrument_unavailable reason={error}"))
.ok()
});