Keep vehicles off rooftops: probe the mesh where the vehicle is and keep a cell's lowest reading

The rendered-mesh floor took one probe at each coarse cell's centre and kept it
for the session. A centre on a roof passed the +80 m DEM window and lifted every
vehicle in the cell to roof height (a Haymarket bus drew 23.5 m above the
street); a centre in the river put Red Line trains on the Longfellow Bridge
6-9 m under the deck. The sampler now probes at the caller's point, reads a
latched cell again at up to four points apart from each other, and the gate
keeps the lowest reading that passes.
This commit is contained in:
Sameh Khamis committed 2026-11-08 22:45:51 -08:00
1 parent 347427f83d
commit 18a9e0470d
4 files changed
+119 -13

No files matched your search

+13 -6
View File
@@ -418,7 +418,8 @@ export function createGroundFloor({ terrain, signal }) {
// is the photogrammetric MESH, which sits above it (measured ~17 m at the
// Austin airport apron). DEM-flooring therefore still buried sprites/trails
// inside the mesh. These cells hold the RENDERED surface height, sampled
// one-shot per coarse cell near the viewer (scene.sampleHeight — the same
// a few probes per coarse cell near the viewer, lowest passing reading kept
// (a probe can land on a roof) (scene.sampleHeight — the same
// source groundSnap uses, which is why 3D models always looked right) and
// reported here by meshFloorSampler.js. Design principle (owner): NEVER
// below the visible surface; slightly above is always fine. The DEM stays
@@ -444,7 +445,8 @@ export function createGroundFloor({ terrain, signal }) {
/**
* Records a sampled rendered-surface height for the cell containing the
* coordinate (one-shot latch — first accepted sample wins).
* coordinate, unchecked; the first record wins. The sampler goes through
* `reportValidatedMeshFloorCell`, which keeps the lowest passing reading.
* @param {number} lat @param {number} lon @param {number} heightM
*/
function reportMeshFloorCell(lat, lon, heightM) {
@@ -471,9 +473,10 @@ export function createGroundFloor({ terrain, signal }) {
/**
* Validate and record a rendered-mesh floor through the single shared gate.
* Callers must not bypass this with raw `reportMeshFloorCell`: a coarse-LOD,
* rooftop, or aircraft hit would otherwise win the session-long first-write
* latch and poison every floor consumer in the cell.
* Callers must not bypass this with raw `reportMeshFloorCell`: a coarse-LOD
* or aircraft hit would otherwise poison every floor consumer in the cell.
* The lowest passing reading is kept, so a rooftop hit within the window
* gives way to a later probe that reached the street.
* @returns {boolean} Whether the sample passed and was reported.
*/
function reportValidatedMeshFloorCell(lat, lon, heightM) {
@@ -481,7 +484,11 @@ export function createGroundFloor({ terrain, signal }) {
const cell = coarseFloorCoord(lat, lon);
const prior = cachedRealEllipsoidalGround(cell.lat, cell.lon);
if (!meshFloorSampleWithinPrior(heightM, prior)) return false;
reportMeshFloorCell(cell.lat, cell.lon, heightM);
// The lowest passing reading wins: a probe that hit a roof is replaced
// by a later one that reached the street.
const key = `${cell.lat},${cell.lon}`;
const held = _meshCells.get(key);
if (held == null || heightM < held) _meshCells.set(key, heightM);
return true;
}