mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Hide street vehicles behind low walls and trees seen from above
In a dense downtown view from about 400 m up, the occlusion margin of max(3 m, 2% of the range) came to 14 to 20 m, so a wall, awning, tree or lower facade standing 10 to 20 m in front of a street was read as the road itself: the vehicle's dot was hidden by the scene, but its bracket and callout were still drawn. Checked against scene.pickPosition in one such view, 18 of 470 vehicles in frame fell in that band. The margin now depends on how steeply the camera looks down on the contact. A point on the line of sight s metres in front of a vehicle stands s * sin(elevation) above it, so a surface there hides the vehicle once that rise passes 2 m. The margin stays at least 3 m and at most 2% of the range, so grazing and street-level views are unchanged. In the same views no vehicle with the drawn surface within 3 m in front of it (its own road) is newly hidden. From the review of the first change: - A contact back in view after longer than a retest interval is held back and retested like a new one, instead of being drawn from an answer given before it left the view. It gets a fresh record, so a test still in flight from before cannot end the hold-back either. - The hold-back for a contact's first answer stretches with the retest pace when a crowded view slows it. - A batch whose control point failed no longer counts as a first answer. - An unknown log-depth flag reads as "no depth" rather than as standard depth, which would have put every surface in front of every contact. - A shader that fails to build leaves no shader behind and is not built again on the same context.
This commit is contained in:
1 parent
630e1b1998
commit
076d264982
6 files changed
+388
-31
No files matched your search
@@ -266,6 +266,11 @@ test('no depth source: nothing is tested and nothing is in flight', () => {
|
||||
scene.view.pickDepths[0].framebuffer = undefined; // not drawn yet
|
||||
return scene;
|
||||
})(),
|
||||
// Whether depth is logarithmic, unknown: decoding it the wrong way would
|
||||
// put every surface in front of every contact.
|
||||
{ ...wallScene(), frameState: {} },
|
||||
{ ...wallScene(), frameState: { useLogDepth: 1 } },
|
||||
{ ...wallScene(), frameState: undefined },
|
||||
(() => {
|
||||
const scene = wallScene();
|
||||
Object.defineProperty(scene, 'view', {
|
||||
@@ -329,6 +334,7 @@ test('a control point that does not draw voids its batch; a run of them stands t
|
||||
frame(probe, scene, now);
|
||||
assert.equal(entry.pending, false);
|
||||
assert.equal(entry.lastHiddenAt, Number.NEGATIVE_INFINITY, 'not believed');
|
||||
assert.notEqual(entry.answered, true, 'and not a first answer either');
|
||||
now += 16;
|
||||
}
|
||||
assert.equal(probe.mode, 'off');
|
||||
@@ -351,6 +357,7 @@ test('a control point that does not draw voids its batch; a run of them stands t
|
||||
gl.finishGpu();
|
||||
frame(probe, scene, retryAt + 16);
|
||||
assert.equal(entry.lastHiddenAt, retryAt);
|
||||
assert.equal(entry.answered, true);
|
||||
|
||||
// One good batch in between resets the count.
|
||||
const healthy = new SceneOcclusionProbe();
|
||||
@@ -366,16 +373,33 @@ test('a control point that does not draw voids its batch; a run of them stands t
|
||||
|
||||
test('a shader that does not compile, or a WebGL call that throws, stands the probe down cleanly', () => {
|
||||
let scene = wallScene();
|
||||
scene.context._gl.state.compiles = false;
|
||||
// Only the fragment shader fails: the vertex shader that did compile must
|
||||
// not be left behind.
|
||||
scene.context._gl.state.compiles = (type) =>
|
||||
type !== scene.context._gl.FRAGMENT_SHADER;
|
||||
let probe = new SceneOcclusionProbe();
|
||||
let entry = contact();
|
||||
assert.deepEqual(frame(probe, scene, 0, [[entry, behindWall]]), [false]);
|
||||
assert.equal(probe.mode, 'off');
|
||||
assert.equal(entry.pending, false);
|
||||
// Nothing half-made is kept, and the same context is never asked again:
|
||||
// compiling is a wait on the GPU process and would fail the same way.
|
||||
let gl = scene.context._gl;
|
||||
assert.equal(gl.liveShaders.size, 0, 'no shader left behind');
|
||||
let shaderCalls = 0;
|
||||
const createShader = gl.createShader;
|
||||
gl.createShader = (...args) => {
|
||||
shaderCalls++;
|
||||
return createShader(...args);
|
||||
};
|
||||
for (const now of [PROBE_RETRY_AFTER_MS + 16, 5 * PROBE_RETRY_AFTER_MS])
|
||||
assert.deepEqual(frame(probe, scene, now, [[entry, behindWall]]), [false]);
|
||||
assert.equal(shaderCalls, 0);
|
||||
assert.equal(probe.mode, 'off');
|
||||
|
||||
// A draw that throws part-way: bindings restored, no query left behind.
|
||||
scene = wallScene();
|
||||
let gl = scene.context._gl;
|
||||
gl = scene.context._gl;
|
||||
const found = {
|
||||
draw: { image: null },
|
||||
program: { uniforms: {} },
|
||||
|
||||
Reference in new issue
Block a user