mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(globe): a Navara click never takes a stale GPU pick of a neighbour
Navara 0.2.1 can answer a click with the previous gesture's pick. The check let that answer through when its instance was drawn within twice its pick radius of the click — the followed aircraft at the centre beside the clicked one (the 20/24 flights checklist run: a click selected the previously followed aircraft). A GPU answer for a sprite or point set now has to be drawn under the click (no slack) and be the instance the CPU pick finds on top there (lines left out: they are not in the GPU pick); otherwise the CPU pick answers. Models, which the CPU pick does not see, are still taken as answered. The CPU drill takes `includeLines`. Test: 20 gestures alternating a click on A and a click on its neighbour B answered with A's stale pick — B every time. In the app, 40 scripted click/follow/release gestures on Navara selected the clicked aircraft every time with and without the fix (the stale answer is rare).
This commit is contained in:
1 parent
ea1e2f9c04
commit
ed9ea7e679
3 files changed
+62
-5
No files matched your search
@@ -296,3 +296,37 @@ test('the pick id is the one the instance had when Navara answered', async () =>
|
||||
time += 1;
|
||||
assert.equal((await picking.clickPick({ x: 10, y: 10 })).id, 'before');
|
||||
});
|
||||
|
||||
test('a stale GPU answer for a neighbour of the click never wins over the instance under it (20 gestures)', async () => {
|
||||
// The followed aircraft A sits at the centre; B is drawn 15 px from it.
|
||||
// Navara answers B's click with the previous gesture's pick (A): within
|
||||
// twice A's pick radius, but the instance under the click is B.
|
||||
const view = fakeView();
|
||||
const sets = [
|
||||
moverSet('flights', [
|
||||
[100, 100, 5, 'a'],
|
||||
[115, 100, 5, 'b'],
|
||||
]),
|
||||
];
|
||||
const picking = createNavaraPicking({
|
||||
view,
|
||||
projector,
|
||||
camera,
|
||||
movers: () => sets,
|
||||
lines: () => [],
|
||||
resolveBatch: (batchId) =>
|
||||
batchId === 1
|
||||
? { set: 'flights', instance: 0, pickId: 'a' }
|
||||
: { set: 'flights', instance: 1, pickId: 'b' },
|
||||
...timers(),
|
||||
});
|
||||
for (let gesture = 0; gesture < 20; gesture++) {
|
||||
const onA = picking.clickPick({ x: 100, y: 100 });
|
||||
view.emit('featureClick', { batchId: 1 });
|
||||
assert.equal((await onA).id, 'a', `gesture ${gesture}: a`);
|
||||
const onB = picking.clickPick({ x: 115, y: 100 });
|
||||
view.emit('featureClick', { batchId: 1 }); // stale: A again
|
||||
assert.equal((await onB).id, 'b', `gesture ${gesture}: b, not the stale a`);
|
||||
}
|
||||
assert.equal(picking.clickStats().stale, 20);
|
||||
});
|
||||
Reference in new issue
Block a user