Mod models: draw far models as scaled impostors past the far plane, cull at 4096

This commit is contained in:
2026-10-28 22:09:30 +03:00
committed by airdef
parent 77aa482f6a
commit 6604b09ded
+16 -4
View File
@@ -120,14 +120,26 @@ impl Game<'_> {
return;
}
let t = alpha.clamp(0.0, 1.0);
// Missiles are seen from far off: past the far plane a model is drawn nearer and
// smaller, the same size on screen.
let depth_far = f64::from(horizon_client::camera::depth_far(
self.terrain_distance(),
self.settings.cloud_range,
));
let reach = depth_far * 0.85;
for p in self.mods.models.poses.values() {
let at = p.previous.lerp(p.position, t);
// Far models are culled by distance; the view frustum does the rest.
if at.distance_squared(camera) > 512.0 * 512.0 {
let mut at = p.previous.lerp(p.position, t);
let d = at.distance(camera);
if d > 4096.0 {
continue;
}
let mut shrink = 1.0f32;
if d > reach {
shrink = (reach / d) as f32;
at = camera + (at - camera) * (reach / d);
}
let rotation = p.old_rotation.slerp(p.rotation, t as f32);
let scale = p.old_scale + (p.scale - p.old_scale) * t as f32;
let scale = (p.old_scale + (p.scale - p.old_scale) * t as f32) * shrink;
if scale <= 0.0 {
continue;
}