Merge main through #1641 into the renderer seam

Takes main's per-point mesh floor readings (#1642) onto the seam's
port-based sampler: a spot refused only while the cell's DEM prior was
cold is probed again, each spot is recorded once, a cell keeps at most
sixteen readings, and grounded flights read the floor at the contact
held inside its sticky cell.
This commit is contained in:
Sameh Khamis committed 2026-11-10 02:39:59 -08:00
commit 077576ed99
79 files changed
+2721 -230

No files matched your search

+24 -5
View File
@@ -76,6 +76,22 @@ const samePoint = (a, b) => a.x === b.x && a.y === b.y && a.z === b.z;
/** Where a flights record carries its reported speed and track. */
const RECORD_FIELDS = { speed: 'velocity', track: 'true_track' };
/** Half a coarse floor cell (0.001°), less a margin so rounding keeps a
* clamped coordinate inside the cell. */
const HALF_CELL_DEG = 0.00049;
/**
* A coordinate held within half a cell of the cell's centre (the short way
* round for longitude), so a read lands in the given cell.
* @param {number} deg @param {number} centreDeg
* @returns {number}
*/
function clampToCell(deg, centreDeg) {
let d = deg - centreDeg;
d -= 360 * Math.round(d / 360);
return centreDeg + Math.max(-HALF_CELL_DEG, Math.min(HALF_CELL_DEG, d));
}
export function createMotion({
flightState,
services,
@@ -828,12 +844,15 @@ export function createMotion({
const carto = toCartographicRadians(pos);
// Boundary hysteresis: a position jittering across a cell edge would flip
// floors at fleet-tick rate (see stickyFloorCell).
const cell = stickyFloorCell(
toDegrees(carto.lat),
toDegrees(carto.lon),
state?.cell,
const latDeg = toDegrees(carto.lat);
const lonDeg = toDegrees(carto.lon);
const cell = stickyFloorCell(latDeg, lonDeg, state?.cell);
// A cell holds rendered-surface readings at the points they were taken,
// so the floor is read where the contact is, held inside its sticky cell.
const floor = cachedGroundFloor(
clampToCell(latDeg, cell.lat),
clampToCell(lonDeg, cell.lon),
);
const floor = cachedGroundFloor(cell.lat, cell.lon);
const next = state || {
cell,
in: vec(),