mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 17:37:22 +02:00
fix competition between seek mouse and lasers
This commit is contained in:
parent
825fc1cfa1
commit
cb69e70781
1 changed files with 22 additions and 5 deletions
|
@ -20,6 +20,9 @@
|
||||||
// When partially squeezing over a HUD element, a laser or the reticle is shown where the active hand
|
// When partially squeezing over a HUD element, a laser or the reticle is shown where the active hand
|
||||||
// controller beam intersects the HUD.
|
// controller beam intersects the HUD.
|
||||||
|
|
||||||
|
var systemLaserOn = false;
|
||||||
|
|
||||||
|
|
||||||
Script.include("../libraries/controllers.js");
|
Script.include("../libraries/controllers.js");
|
||||||
|
|
||||||
// UTILITIES -------------
|
// UTILITIES -------------
|
||||||
|
@ -121,6 +124,12 @@ function ignoreMouseActivity() {
|
||||||
if (!Reticle.allowMouseCapture) {
|
if (!Reticle.allowMouseCapture) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the lasers are on, then reticle/mouse should be hidden and we can ignore it for seeking or depth updating
|
||||||
|
if (systemLaserOn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var pos = Reticle.position;
|
var pos = Reticle.position;
|
||||||
if (!pos || (pos.x == -1 && pos.y == -1)) {
|
if (!pos || (pos.x == -1 && pos.y == -1)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -261,6 +270,12 @@ var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
||||||
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
||||||
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
||||||
var now = Date.now(), mouse = Reticle.position, isShaking = false;
|
var now = Date.now(), mouse = Reticle.position, isShaking = false;
|
||||||
|
|
||||||
|
// if the lasers are on, then we ignore mouse shaking
|
||||||
|
if (systemLaserOn) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastIntegration && (lastIntegration !== now)) {
|
if (lastIntegration && (lastIntegration !== now)) {
|
||||||
var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration);
|
var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration);
|
||||||
averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity);
|
averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity);
|
||||||
|
@ -275,9 +290,14 @@ function isShakingMouse() { // True if the person is waving the mouse around try
|
||||||
var NON_LINEAR_DIVISOR = 2;
|
var NON_LINEAR_DIVISOR = 2;
|
||||||
var MINIMUM_SEEK_DISTANCE = 0.1;
|
var MINIMUM_SEEK_DISTANCE = 0.1;
|
||||||
function updateSeeking(doNotStartSeeking) {
|
function updateSeeking(doNotStartSeeking) {
|
||||||
|
// if the lasers are on, then we never do seeking
|
||||||
|
if (systemLaserOn) {
|
||||||
|
isSeeking = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) {
|
if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) {
|
||||||
if (!isSeeking) {
|
if (!isSeeking) {
|
||||||
print('Start seeking mouse.');
|
|
||||||
isSeeking = true;
|
isSeeking = true;
|
||||||
}
|
}
|
||||||
} // e.g., if we're about to turn it on with first movement.
|
} // e.g., if we're about to turn it on with first movement.
|
||||||
|
@ -287,7 +307,6 @@ function updateSeeking(doNotStartSeeking) {
|
||||||
averageMouseVelocity = lastIntegration = 0;
|
averageMouseVelocity = lastIntegration = 0;
|
||||||
var lookAt2D = HMD.getHUDLookAtPosition2D();
|
var lookAt2D = HMD.getHUDLookAtPosition2D();
|
||||||
if (!lookAt2D) { // If this happens, something has gone terribly wrong.
|
if (!lookAt2D) { // If this happens, something has gone terribly wrong.
|
||||||
print('Cannot seek without lookAt position');
|
|
||||||
isSeeking = false;
|
isSeeking = false;
|
||||||
return; // E.g., if parallel to location in HUD
|
return; // E.g., if parallel to location in HUD
|
||||||
}
|
}
|
||||||
|
@ -303,7 +322,6 @@ function updateSeeking(doNotStartSeeking) {
|
||||||
}
|
}
|
||||||
var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit.
|
var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit.
|
||||||
if (okX && okY) {
|
if (okX && okY) {
|
||||||
print('Finished seeking mouse');
|
|
||||||
isSeeking = false;
|
isSeeking = false;
|
||||||
} else {
|
} else {
|
||||||
Reticle.setPosition(copy); // Not setReticlePosition
|
Reticle.setPosition(copy); // Not setReticlePosition
|
||||||
|
@ -322,7 +340,7 @@ function updateMouseActivity(isClick) {
|
||||||
return;
|
return;
|
||||||
} // Bug: mouse clicks should keep going. Just not hand controller clicks
|
} // Bug: mouse clicks should keep going. Just not hand controller clicks
|
||||||
handControllerLockOut.update(now);
|
handControllerLockOut.update(now);
|
||||||
Reticle.visible = true;
|
Reticle.visible = !systemLaserOn;
|
||||||
}
|
}
|
||||||
function expireMouseCursor(now) {
|
function expireMouseCursor(now) {
|
||||||
if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) {
|
if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) {
|
||||||
|
@ -474,7 +492,6 @@ var LASER_ALPHA = 0.5;
|
||||||
var LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ALPHA};
|
var LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ALPHA};
|
||||||
var LASER_TRIGGER_COLOR_XYZW = {x: 250 / 255, y: 10 / 255, z: 10 / 255, w: LASER_ALPHA};
|
var LASER_TRIGGER_COLOR_XYZW = {x: 250 / 255, y: 10 / 255, z: 10 / 255, w: LASER_ALPHA};
|
||||||
var SYSTEM_LASER_DIRECTION = {x: 0, y: 0, z: -1};
|
var SYSTEM_LASER_DIRECTION = {x: 0, y: 0, z: -1};
|
||||||
var systemLaserOn = false;
|
|
||||||
function clearSystemLaser() {
|
function clearSystemLaser() {
|
||||||
if (!systemLaserOn) {
|
if (!systemLaserOn) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue