Replays: smoke rebuilt from the recording, recorded objects and searchlights, film cut in true order, export sessions guarded, gun camera above water; export keeps its last frames; hd_bench no longer excuses strong flicker (#76-#84, fork patch 35)
build / mod (push) Successful in 3m49s
build / mod (push) Successful in 3m49s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,17 @@ use crate::sim::{Class, DroneKind, Out, Sim};
|
||||
use glam::DVec3;
|
||||
use horizon_mod_sdk::render::{CameraView, FillShape, Point, QuadShape, Rect, Shape, TextShape};
|
||||
|
||||
/// Metres the camera keeps above the surface (land or water) it stands over.
|
||||
const SURFACE_CLEAR: f64 = 2.5;
|
||||
|
||||
/// `eye` lifted above the surface under it (`Ground::land_state`: unanswered or no land: unchanged).
|
||||
fn above_surface(eye: DVec3, land: Option<Option<f64>>) -> DVec3 {
|
||||
match land {
|
||||
Some(Some(h)) if eye.y < h + SURFACE_CLEAR => DVec3::new(eye.x, h + SURFACE_CLEAR, eye.z),
|
||||
_ => eye,
|
||||
}
|
||||
}
|
||||
|
||||
/// Ghost models' ids, clear of the live ones.
|
||||
const GHOSTS: u32 = 0x5000_0000;
|
||||
/// The camera view's id (a new one each cut, so the game doesn't sweep between shots).
|
||||
@@ -419,7 +430,7 @@ impl Player {
|
||||
return;
|
||||
}
|
||||
sim.draw_ghosts(rec, self.t, GHOSTS, out);
|
||||
self.direct(rec);
|
||||
self.direct(rec, ground);
|
||||
self.sounds(rec, listener, out);
|
||||
}
|
||||
|
||||
@@ -565,7 +576,7 @@ impl Player {
|
||||
}
|
||||
|
||||
/// The event the camera films now: (eye, look, fov, shot).
|
||||
fn shoot(&mut self, rec: &Recording, i: usize) -> (DVec3, DVec3, f32, u8) {
|
||||
fn shoot(&mut self, rec: &Recording, i: usize, ground: &mut Ground) -> (DVec3, DVec3, f32, u8) {
|
||||
let e = rec.events[i];
|
||||
let t = self.t;
|
||||
let te = e.at as f64;
|
||||
@@ -602,6 +613,10 @@ impl Player {
|
||||
None => {
|
||||
// A gun kill, from the gun.
|
||||
let at = rec.sam(sam).map_or(e.pos + DVec3::Y * 20.0, |s| s.1 + DVec3::Y * 4.0);
|
||||
// A system on the sea floor (or a lake's) must not film from under the water:
|
||||
// the game's ground height is the top of the highest block that blocks motion
|
||||
// or holds a fluid, i.e. the water's surface there.
|
||||
let at = above_surface(at, ground.land_state(at));
|
||||
let dist = target.distance(at).max(1.0);
|
||||
let fov = (2.0 * (10.0 / dist).atan()).to_degrees().clamp(6.0, 60.0) as f32;
|
||||
(at, target, fov, 1)
|
||||
@@ -630,7 +645,7 @@ impl Player {
|
||||
}
|
||||
|
||||
/// Chooses the shot and moves the camera; a new shot is a cut.
|
||||
fn direct(&mut self, rec: &Recording) {
|
||||
fn direct(&mut self, rec: &Recording, ground: &mut Ground) {
|
||||
let focus = match &self.mode {
|
||||
Mode::Clips { list, at, .. } => Some(list[*at].event),
|
||||
// The full replay follows what comes next: the next event within 6 s, else the drone
|
||||
@@ -644,7 +659,7 @@ impl Player {
|
||||
};
|
||||
let (eye, look, fov, shot) = match focus {
|
||||
Some(i) => {
|
||||
let s = self.shoot(rec, i);
|
||||
let s = self.shoot(rec, i, ground);
|
||||
(s.0, s.1, s.2, (i, s.3))
|
||||
}
|
||||
None => {
|
||||
@@ -957,3 +972,21 @@ impl Player {
|
||||
Mode::Clips { list: vec![clip(rec, i)], at: 0, reel: false }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod surface_tests {
|
||||
use super::*;
|
||||
|
||||
/// A gun standing on the sea floor films from above the water, not from under it.
|
||||
#[test]
|
||||
fn the_gun_camera_is_lifted_above_the_water() {
|
||||
let eye = DVec3::new(10.0, 44.0, 5.0); // 4 above a Gepard on the floor at 40
|
||||
let lifted = above_surface(eye, Some(Some(62.0))); // the surface
|
||||
assert!(lifted.y >= 62.0 + SURFACE_CLEAR - 1e-9);
|
||||
assert_eq!((lifted.x, lifted.z), (10.0, 5.0));
|
||||
// On dry land, or with no answer yet, the camera stays where it was.
|
||||
assert_eq!(above_surface(DVec3::new(0.0, 74.0, 0.0), Some(Some(70.0))), DVec3::new(0.0, 74.0, 0.0));
|
||||
assert_eq!(above_surface(eye, None), eye);
|
||||
assert_eq!(above_surface(eye, Some(None)), eye);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user