From 9edd18c0178835371b2732035d514f2610130bb7 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 9 May 2016 14:05:59 -0700 Subject: [PATCH] Fix mouse seek bugs. --- scripts/system/controllers/handControllerPointer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 060af4b9d8..b5ffaf148d 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -150,7 +150,7 @@ var isSeeking = false; var averageMouseVelocity = 0, lastIntegration = 0, lastMouse; var WEIGHTING = 1 / 20; // simple moving average over last 20 samples var ONE_MINUS_WEIGHTING = 1 - WEIGHTING; -var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 5; +var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20; function isShakingMouse() { // True if the person is waving the mouse around trying to find it. var now = Date.now(), mouse = Reticle.position, isShaking = false; if (lastIntegration && (lastIntegration !== now)) { @@ -176,11 +176,12 @@ function updateSeeking() { function updateDimension(axis) { var distanceBetween = lookAt2D[axis] - Reticle.position[axis]; var move = distanceBetween / NON_LINEAR_DIVISOR; - if (move >= MINIMUM_SEEK_DISTANCE) { return false; } + if (Math.abs(move) < MINIMUM_SEEK_DISTANCE) { return false; } copy[axis] += move; return true; } - if (!updateDimension('x') && !updateDimension('y')) { + var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit. + if (okX && okY) { isSeeking = false; } else { Reticle.setPosition(copy); // Not setReticlePosition