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:
German Khokhlov committed 2026-10-17 11:02:52 +04:00
1 parent ea1e2f9c04
commit ed9ea7e679
3 files changed
+62 -5

No files matched your search

+22 -3
View File
@@ -38,6 +38,10 @@ export function createNavaraPicking({
now = () => performance.now(),
}) {
const drillPick = createCpuPicker({ projector, camera, movers, lines });
const isModelSet = (id) =>
movers().some(
({ options }) => options.id === id && options.kind === 'model',
);
// Clicks waiting for Navara's GPU answer, oldest first.
const waiting = [];
@@ -55,10 +59,25 @@ export function createNavaraPicking({
// frame): a set that changes its instances after it still names the
// instance that was under the pointer.
const resolveInfo = (info) => (info ? resolveBatch(info.batchId) : null);
// A GPU answer is checked against the CPU pick at the click: an instance
// the CPU sees must be drawn under the click (its pick radius, no slack)
// and be the one the CPU finds on top. A stale answer from the previous
// gesture (the followed aircraft at the centre) lay within twice its
// radius of a neighbour's click and won (10b/11b flake). Models, which
// the CPU pick does not see, are still taken as answered.
const answerFrom = (hit, at) => {
if (hit && !drillPick.near(hit.set, hit.instance, at)) {
stats.stale++;
return drillPick(at, 1)[0];
if (hit) {
// The instance the CPU sees on top (lines are not in the GPU pick).
const top = drillPick(at, 1, { includeLines: false })[0];
const stale =
!drillPick.near(hit.set, hit.instance, at, 1) ||
(top !== undefined &&
!(top.owner === hit.set && top.instance === hit.instance) &&
!isModelSet(hit.set));
if (stale) {
stats.stale++;
return drillPick(at, 1)[0];
}
}
return hit
? { id: hit.pickId, owner: hit.set, instance: hit.instance }