mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 00:47:39 +02:00
Merge pull request #8081 from howard-stearns/continue-grabbing-through-overlays
Continue grabbing through overlays
This commit is contained in:
commit
faa2624ca7
2 changed files with 33 additions and 7 deletions
|
@ -309,12 +309,19 @@ function MyController(hand) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
var suppressedIn2D = [STATE_OFF, STATE_SEARCHING, STATE_HOLD_SEARCHING];
|
||||||
|
this.ignoreInput = function () {
|
||||||
|
// We've made the decision to use 'this' for new code, even though it is fragile,
|
||||||
|
// in order to keep/ the code uniform without making any no-op line changes.
|
||||||
|
return (-1 !== suppressedIn2D.indexOf(this.state)) && isIn2DMode();
|
||||||
|
};
|
||||||
|
|
||||||
this.update = function() {
|
this.update = function() {
|
||||||
|
|
||||||
this.updateSmoothedTrigger();
|
this.updateSmoothedTrigger();
|
||||||
|
|
||||||
if (isIn2DMode()) {
|
if (this.ignoreInput()) {
|
||||||
_this.turnOffVisualizations();
|
this.turnOffVisualizations();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,10 @@ function TimeLock(expiration) {
|
||||||
}
|
}
|
||||||
var handControllerLockOut = new TimeLock(2000);
|
var handControllerLockOut = new TimeLock(2000);
|
||||||
|
|
||||||
function Trigger() {
|
function Trigger(label) {
|
||||||
// This part is copied and adapted from handControllerGrab.js. Maybe we should refactor this.
|
// This part is copied and adapted from handControllerGrab.js. Maybe we should refactor this.
|
||||||
var that = this;
|
var that = this;
|
||||||
|
that.label = label;
|
||||||
that.TRIGGER_SMOOTH_RATIO = 0.1; // Time averaging of trigger - 0.0 disables smoothing
|
that.TRIGGER_SMOOTH_RATIO = 0.1; // Time averaging of trigger - 0.0 disables smoothing
|
||||||
that.TRIGGER_ON_VALUE = 0.4; // Squeezed just enough to activate search or near grab
|
that.TRIGGER_ON_VALUE = 0.4; // Squeezed just enough to activate search or near grab
|
||||||
that.TRIGGER_GRAB_VALUE = 0.85; // Squeezed far enough to complete distant grab
|
that.TRIGGER_GRAB_VALUE = 0.85; // Squeezed far enough to complete distant grab
|
||||||
|
@ -301,8 +302,8 @@ setupHandler(Controller.mouseDoublePressEvent, onMouseClick);
|
||||||
// CONTROLLER MAPPING ---------
|
// CONTROLLER MAPPING ---------
|
||||||
//
|
//
|
||||||
|
|
||||||
var leftTrigger = new Trigger();
|
var leftTrigger = new Trigger('left');
|
||||||
var rightTrigger = new Trigger();
|
var rightTrigger = new Trigger('right');
|
||||||
var activeTrigger = rightTrigger;
|
var activeTrigger = rightTrigger;
|
||||||
var activeHand = Controller.Standard.RightHand;
|
var activeHand = Controller.Standard.RightHand;
|
||||||
var LEFT_HUD_LASER = 1;
|
var LEFT_HUD_LASER = 1;
|
||||||
|
@ -336,8 +337,26 @@ Script.scriptEnding.connect(clickMapping.disable);
|
||||||
clickMapping.from(Controller.Standard.RT).peek().to(rightTrigger.triggerPress);
|
clickMapping.from(Controller.Standard.RT).peek().to(rightTrigger.triggerPress);
|
||||||
clickMapping.from(Controller.Standard.LT).peek().to(leftTrigger.triggerPress);
|
clickMapping.from(Controller.Standard.LT).peek().to(leftTrigger.triggerPress);
|
||||||
// Full smoothed trigger is a click.
|
// Full smoothed trigger is a click.
|
||||||
clickMapping.from(rightTrigger.full).when(isPointingAtOverlay).to(Controller.Actions.ReticleClick);
|
function isPointingAtOverlayStartedNonFullTrigger(trigger) {
|
||||||
clickMapping.from(leftTrigger.full).when(isPointingAtOverlay).to(Controller.Actions.ReticleClick);
|
// true if isPointingAtOverlay AND we were NOT full triggered when we became so.
|
||||||
|
// The idea is to not count clicks when we're full-triggering and reach the edge of a window.
|
||||||
|
var lockedIn = false;
|
||||||
|
return function () {
|
||||||
|
if (trigger !== activeTrigger) {
|
||||||
|
return lockedIn = false;
|
||||||
|
}
|
||||||
|
if (!isPointingAtOverlay()) {
|
||||||
|
return lockedIn = false;
|
||||||
|
}
|
||||||
|
if (lockedIn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
lockedIn = !trigger.full();
|
||||||
|
return lockedIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clickMapping.from(rightTrigger.full).when(isPointingAtOverlayStartedNonFullTrigger(rightTrigger)).to(Controller.Actions.ReticleClick);
|
||||||
|
clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigger(leftTrigger)).to(Controller.Actions.ReticleClick);
|
||||||
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||||
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||||
// Partial smoothed trigger is activation.
|
// Partial smoothed trigger is activation.
|
||||||
|
|
Loading…
Reference in a new issue