From 4a722a62f7a106c7603a1cb8d4e6f5ad739729f8 Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 31 Jul 2018 11:51:16 -0700 Subject: [PATCH] use click handler only, remove triggerClicked --- .../controllerModules/inEditMode.js | 25 ++--- .../system/libraries/entitySelectionTool.js | 91 ++++++------------- 2 files changed, 37 insertions(+), 79 deletions(-) diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index e6a5efc6a2..3e53d5af12 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -66,44 +66,33 @@ Script.include("/~/system/libraries/utils.js"); this.sendPickData = function(controllerData) { if (controllerData.triggerClicks[this.hand]) { + var hand = this.hand === RIGHT_HAND ? Controller.Standard.RightHand : Controller.Standard.LeftHand; if (!this.triggerClicked) { this.selectedTarget = controllerData.rayPicks[this.hand]; if (!this.selectedTarget.intersects) { Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "clearSelection" + method: "clearSelection", + hand: hand })); } - Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "triggerClicked", - clicked: true, - rightHand: this.hand === RIGHT_HAND - })); } if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) { if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) { Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ method: "selectEntity", - entityID: this.selectedTarget.objectID + entityID: this.selectedTarget.objectID, + hand: hand })); } } else if (this.selectedTarget.type === Picks.INTERSECTED_OVERLAY) { Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ method: "selectOverlay", - overlayID: this.selectedTarget.objectID + overlayID: this.selectedTarget.objectID, + hand: hand })); } this.triggerClicked = true; - } else { - if (this.triggerClicked) { - Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "triggerClicked", - clicked: false, - rightHand: this.hand === RIGHT_HAND - })); - } - - this.triggerClicked = false; } this.sendPointingAtData(controllerData); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 96dc9d676b..dedc1c4811 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -53,26 +53,24 @@ SelectionManager = (function() { } if (messageParsed.method === "selectEntity") { - if (wantDebug) { - print("setting selection to " + messageParsed.entityID); + if (!SelectionDisplay.triggered() || SelectionDisplay.triggeredHand === messageParsed.hand) { + if (wantDebug) { + print("setting selection to " + messageParsed.entityID); + } + that.setSelections([messageParsed.entityID]); } - that.setSelections([messageParsed.entityID]); } else if (messageParsed.method === "clearSelection") { - that.clearSelections(); + if (!SelectionDisplay.triggered() || SelectionDisplay.triggeredHand === messageParsed.hand) { + that.clearSelections(); + } } else if (messageParsed.method === "pointingAt") { - if (messageParsed.rightHand) { + if (messageParsed.hand === Controller.Standard.RightHand) { that.pointingAtDesktopWindowRight = messageParsed.desktopWindow; that.pointingAtTabletRight = messageParsed.tablet; } else { that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; that.pointingAtTabletLeft = messageParsed.tablet; } - } else if (messageParsed.method === "triggerClicked") { - if (messageParsed.rightHand) { - that.triggerClickedRight = messageParsed.clicked; - } else { - that.triggerClickedLeft = messageParsed.clicked; - } } } @@ -115,9 +113,6 @@ SelectionManager = (function() { that.pointingAtDesktopWindowRight = false; that.pointingAtTabletLeft = false; that.pointingAtTabletRight = false; - - that.triggerClickedRight = false; - that.triggerClickedLeft = false; that.saveProperties = function() { that.savedProperties = {}; @@ -761,62 +756,36 @@ SelectionDisplay = (function() { // We get mouseMoveEvents from the handControllers, via handControllerPointer. // But we dont' get mousePressEvents. that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); - that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press'); Script.scriptEnding.connect(that.triggerMapping.disable); that.triggeredHand = NO_TRIGGER_HAND; that.triggered = function() { return that.triggeredHand !== NO_TRIGGER_HAND; } - function triggerPress(hand) { - var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand && - SelectionManager.pointingAtDesktopWindowRight) || - (hand === Controller.Standard.LeftHand && - SelectionManager.pointingAtDesktopWindowLeft); - var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) || - (hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft); - if (pointingAtDesktopWindow || pointingAtTablet) { - return; - } - that.triggeredHand = hand; - that.mousePressEvent({}); - } - function triggerRelease(hand) { - that.triggeredHand = NO_TRIGGER_HAND; - that.mouseReleaseEvent({}); - var otherTriggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedLeft : - SelectionManager.triggerClickedRight; - // When one hand is released check if the other hand is clicked and should then trigger a press - if (otherTriggerClicked) { - var otherHand = hand == Controller.Standard.RightHand ? Controller.Standard.LeftHand : - Controller.Standard.RightHand; - triggerPress(otherHand); - } - } - function handleTriggerPress(hand, triggerClicked) { - // Don't allow both hands to trigger at the same time - if (that.triggered() && hand !== that.triggeredHand) { - return; - } - if (!that.triggered() && triggerClicked) { - triggerPress(hand); - } else if (that.triggered() && !triggerClicked) { - triggerRelease(hand); - } - } - function makePressHandler(hand) { - return function (value) { - var triggerClicked = hand == Controller.Standard.RightHand ? SelectionManager.triggerClickedRight : - SelectionManager.triggerClickedLeft; - handleTriggerPress(hand, triggerClicked); - }; - } function makeClickHandler(hand) { return function (clicked) { - handleTriggerPress(hand, clicked); + print("DBACK TEST makeClickHandler " + hand + " " + clicked); + // Don't allow both hands to trigger at the same time + if (that.triggered() && hand !== that.triggeredHand) { + return; + } + if (!that.triggered() && clicked) { + var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand && + SelectionManager.pointingAtDesktopWindowRight) || + (hand === Controller.Standard.LeftHand && + SelectionManager.pointingAtDesktopWindowLeft); + var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) || + (hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft); + if (pointingAtDesktopWindow || pointingAtTablet) { + return; + } + that.triggeredHand = hand; + that.mousePressEvent({}); + } else if (that.triggered() && !clicked) { + that.triggeredHand = NO_TRIGGER_HAND; + that.mouseReleaseEvent({}); + } }; } - that.triggerPressMapping.from(Controller.Standard.RT).peek().to(makePressHandler(Controller.Standard.RightHand)); - that.triggerPressMapping.from(Controller.Standard.LT).peek().to(makePressHandler(Controller.Standard.LeftHand)); that.triggerMapping.from(Controller.Standard.RTClick).peek().to(makeClickHandler(Controller.Standard.RightHand)); that.triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Controller.Standard.LeftHand));