hud-10 (rev3): cursor on the guide line; a press is attributed to the acting hand
ADDENDUM 11b, both reported against ADDENDUM 11. 1. The cursor drifted off the guide line, worse near the panel edge. panelHit() clamps an off-panel intersection to the border and flags it via inBounds, but updatePointer() published that clamped nx,ny as pointer.hit, so the ring was drawn on the border while the beam ended at the true (off-panel) intersection. pointer.hit is now published only when inBounds; distance is still published so an edge-aimed beam reaches the plane (beamLength no longer requires p.hit). Near-misses still summon the bar, but no longer press. 2. A right-hand press could still act at the left hand's position, for three separate reasons: the activate cooldown was global (a gamepad edge from one hand swallowed the other hand's select - now per input source); a missing ray fell back to another hand (with a preferKey the acting source now owns the shot and a missing candidate MISSes); and a null frame skipped re-attribution entirely (now falls back to S.lastFrame and MISSes if the acting source yields no pointer). New diagnostics: stats.pressSrc, stats.pressPtr. Verified with injected synthetic input sources: both on panel, right press pressSrc hand:right pressAt 0.78,0.50 seek 79.5% left press then right 100ms pressSrc hand:right pressAt 0.78,0.50 (not swallowed) both off panel state.pointer.hit = null (no clamped cursor) off panel, right press pressPtr "hand:right nohit" MISS (no hit on the panel)
This commit is contained in:
Vendored
+41
-6
@@ -3271,8 +3271,11 @@
|
||||
return d > 0 ? d : null;
|
||||
}
|
||||
|
||||
// ADDENDUM 11b: the beam reaches the panel plane whenever the ray meets it,
|
||||
// even when the intersection is off the panel (there is simply no cursor then).
|
||||
// Previously it fell back to a fixed length without a hit, so an edge-aimed
|
||||
// beam stopped short of the plane while the cursor was clamped to the border.
|
||||
function beamLength(p) {
|
||||
if (!p.hit) return BEAM_L_DEFAULT;
|
||||
var d = num(p.distance);
|
||||
if (d == null) d = panelDistance(p);
|
||||
if (d == null || !(d > BEAM_L_MIN)) return BEAM_L_DEFAULT;
|
||||
@@ -5247,6 +5250,7 @@
|
||||
panelPose = null;
|
||||
pointer = { visible: false, beam: false, source: 'none', origin: { x: 0, y: 0, z: 0 }, dir: { x: 0, y: 0, z: -1 }, hit: null };
|
||||
activeSrcKey = null; // ADDENDUM 11: fresh hand choice every session
|
||||
lastActivateByKey = {};
|
||||
S.pointer = null;
|
||||
S.session = null;
|
||||
S.refSpace = null;
|
||||
@@ -5448,11 +5452,14 @@
|
||||
// cands [{ key, onPanel, ... }] in runtime order
|
||||
// preferKey the source that is acting right now (select / gamepad press)
|
||||
// activeKey the source that acted last
|
||||
// Order: acting -> last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
// When `preferKey` is given the acting source OWNS the shot: if it is not among
|
||||
// the candidates (no resolvable ray) we return null so the press MISSES rather
|
||||
// than silently reusing another hand's pointer. Otherwise:
|
||||
// last-active-while-on-panel -> any-on-panel -> last-active -> first.
|
||||
function pickPointerCand(cands, preferKey, activeKey) {
|
||||
if (preferKey) return candByKey(cands, preferKey);
|
||||
if (!cands || !cands.length) return null;
|
||||
var i, c;
|
||||
if (preferKey) { c = candByKey(cands, preferKey); if (c) return c; }
|
||||
if (activeKey) {
|
||||
c = candByKey(cands, activeKey);
|
||||
if (c && c.onPanel) return c;
|
||||
@@ -5516,7 +5523,13 @@
|
||||
source: (pick.src.hand ? 'hand' : 'controller') + ':' + pick.src.handedness,
|
||||
origin: pick.ray.origin,
|
||||
dir: pick.ray.dir,
|
||||
hit: pick.hit ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
// ADDENDUM 11b: only a hit that is really ON the panel becomes the
|
||||
// cursor. panelHit() clamps an off-panel intersection to the border, and
|
||||
// drawing the cursor at that clamped point while the beam ended at the
|
||||
// true intersection made the two drift apart - the further off the panel
|
||||
// the ray pointed, the worse the gap. `distance` is still published so the
|
||||
// beam still reaches the panel plane.
|
||||
hit: (pick.hit && pick.hit.inBounds) ? { nx: pick.hit.nx, ny: pick.hit.ny } : null,
|
||||
distance: pick.hit ? pick.hit.distance : null,
|
||||
pressed: performance.now() < pressUntil
|
||||
};
|
||||
@@ -5876,6 +5889,10 @@
|
||||
* ------------------------------------------------------------------ */
|
||||
var ACTIVATE_COOLDOWN_MS = 250;
|
||||
var lastActivate = 0;
|
||||
// ADDENDUM 11b: the cooldown is per INPUT SOURCE, not global. With hands, a
|
||||
// stray gamepad edge from one hand used to swallow the other hand's `select`
|
||||
// within 250 ms, so the click silently used the first hand's position.
|
||||
var lastActivateByKey = {};
|
||||
var padPrev = new WeakMap();
|
||||
|
||||
/* ---------------- grab & drag the subtitle strip ---------------- *
|
||||
@@ -6020,15 +6037,33 @@
|
||||
function pointerDown(src, frame, via) {
|
||||
if (!S.session) return;
|
||||
var now = performance.now();
|
||||
if (now - lastActivate < ACTIVATE_COOLDOWN_MS) return; // dedupe select+gamepad
|
||||
var actKey = srcKey(src) || (via || '?');
|
||||
if (now - (lastActivateByKey[actKey] || 0) < ACTIVATE_COOLDOWN_MS) return;
|
||||
lastActivateByKey[actKey] = now;
|
||||
lastActivate = now;
|
||||
S.stats.lastActivate = (via || '?') + (src && src.handedness ? ':' + src.handedness : '');
|
||||
S.stats.pressSrc = actKey;
|
||||
|
||||
// Captured BEFORE show(): when the control bar is already up, a pinch belongs
|
||||
// to the bar, so it must not also yank the subtitles.
|
||||
var barWasShown = NS.Controls && NS.Controls.isVisible ? !!NS.Controls.isVisible() : false;
|
||||
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
// ADDENDUM 11b: attribute the shot to the acting source. If its ray cannot be
|
||||
// resolved, MISS - never fall back to whatever hand the per-frame pointer was
|
||||
// on, which is exactly how a right-hand pinch ended up landing on the left
|
||||
// hand's position.
|
||||
frame = frame || S.lastFrame;
|
||||
if (src) {
|
||||
if (frame) { try { updatePointer(frame, src); } catch (e) {} }
|
||||
if (!pointer || !pointer.visible) {
|
||||
S.stats.pressAt = 'MISS (acting source has no ray)';
|
||||
S.stats.pressPtr = '(no ray)';
|
||||
return;
|
||||
}
|
||||
S.stats.pressPtr = pointer.source + (pointer.hit ? ' HIT' : ' nohit');
|
||||
} else if (frame) {
|
||||
try { updatePointer(frame); } catch (e) {}
|
||||
}
|
||||
|
||||
// 1) grabbing the subtitle strip wins, but only while the bar is down
|
||||
if (frame && !barWasShown) {
|
||||
|
||||
Reference in New Issue
Block a user