Keep radar target blips above the player arrow
Draw the player marker before network tracks so a close blip is not hidden. Add a shape-order regression and verify a live raid with truth disabled. Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
+21
-5
@@ -143,6 +143,11 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
|
||||
s.push(square(x, y, 1.5, 0xFFFFFFA0));
|
||||
}
|
||||
}
|
||||
// The player is below target blips: a close target must not disappear under the white arrow.
|
||||
// Minecraft's yaw 0 looks south (+z, down the scope).
|
||||
let face = yaw.to_radians();
|
||||
let tip = |a: f32, l: f32| pt(cx - (face + a).sin() * l, cy + (face + a).cos() * l);
|
||||
s.push(quad(tip(0.0, 6.0), tip(2.5, 4.0), pt(cx, cy), tip(-2.5, 4.0), 0xFFFFFFFF));
|
||||
let mut far = 0;
|
||||
// The air picture is what the systems' radars hold, as they last measured it (a track older than a second
|
||||
// is a forecast, dimmer); with no system deployed, the sky as it is. Nothing else is read (#93).
|
||||
@@ -176,11 +181,6 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The player: a white arrow the way they look.
|
||||
// Minecraft's yaw 0 looks south (+z, down the scope).
|
||||
let face = yaw.to_radians();
|
||||
let tip = |a: f32, l: f32| pt(cx - (face + a).sin() * l, cy + (face + a).cos() * l);
|
||||
s.push(quad(tip(0.0, 6.0), tip(2.5, 4.0), pt(cx, cy), tip(-2.5, 4.0), 0xFFFFFFFF));
|
||||
// Labels.
|
||||
s.push(text(format!("РЛС · {}", distance(RANGE)), cx, SIZE + 2.0, 0xFF80FF90, true));
|
||||
s.push(text("С".into(), cx, 3.0, 0xFF80FF90, true));
|
||||
@@ -189,3 +189,19 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::sim::{DroneKind, Out};
|
||||
|
||||
#[test]
|
||||
fn target_blips_are_drawn_over_the_player_arrow() {
|
||||
let mut sim = Sim::new(1);
|
||||
sim.launch(DroneKind::Shahed, DVec3::new(0.0, 64.0, -10.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
|
||||
let shapes = draw(&sim, DVec3::ZERO, 0.0);
|
||||
let arrow = shapes.iter().rposition(|s| matches!(s, Shape::Quad(q) if q.color == 0xFFFFFFFF)).unwrap();
|
||||
let target = shapes.iter().rposition(|s| matches!(s, Shape::Fill(f) if f.color == 0xFFFF4040)).unwrap();
|
||||
assert!(target > arrow, "the player arrow covers the target blip");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user