Merge pull request #13390 from dback2/editHandleDebugWindowFix

Prevent edit press events when pointing at tablet or desktop windows
This commit is contained in:
David Back 2018-06-25 11:11:37 -07:00 committed by GitHub
commit 6fa191742c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 1 deletions

View file

@ -18,10 +18,16 @@ Script.include("/~/system/libraries/controllers.js");
Script.include("/~/system/libraries/utils.js");
(function () {
var MARGIN = 25;
function InEditMode(hand) {
this.hand = hand;
this.triggerClicked = false;
this.selectedTarget = null;
this.reticleMinX = MARGIN;
this.reticleMaxX;
this.reticleMinY = MARGIN;
this.reticleMaxY;
this.parameters = makeDispatcherModuleParameters(
160,
@ -47,6 +53,16 @@ Script.include("/~/system/libraries/utils.js");
return (HMD.tabletScreenID && objectID === HMD.tabletScreenID)
|| (HMD.homeButtonID && objectID === HMD.homeButtonID);
};
this.calculateNewReticlePosition = function(intersection) {
var dims = Controller.getViewportDimensions();
this.reticleMaxX = dims.x - MARGIN;
this.reticleMaxY = dims.y - MARGIN;
var point2d = HMD.overlayFromWorldPoint(intersection);
point2d.x = Math.max(this.reticleMinX, Math.min(point2d.x, this.reticleMaxX));
point2d.y = Math.max(this.reticleMinY, Math.min(point2d.y, this.reticleMaxY));
return point2d;
};
this.sendPickData = function(controllerData) {
if (controllerData.triggerClicks[this.hand]) {
@ -72,6 +88,23 @@ Script.include("/~/system/libraries/utils.js");
this.triggerClicked = true;
}
this.sendPointingAtData(controllerData);
};
this.sendPointingAtData = function(controllerData) {
var rayPick = controllerData.rayPicks[this.hand];
var hudRayPick = controllerData.hudRayPicks[this.hand];
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
var desktopWindow = Window.isPointOnDesktopWindow(point2d);
var tablet = this.pointingAtTablet(rayPick.objectID);
var rightHand = this.hand === RIGHT_HAND;
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
method: "pointingAt",
desktopWindow: desktopWindow,
tablet: tablet,
rightHand: rightHand
}));
};
this.exitModule = function() {
@ -104,6 +137,7 @@ Script.include("/~/system/libraries/utils.js");
if (overlayLaser) {
var overlayLaserReady = overlayLaser.isReady(controllerData);
var target = controllerData.rayPicks[this.hand].objectID;
this.sendPointingAtData(controllerData);
if (overlayLaserReady.active && this.pointingAtTablet(target)) {
return this.exitModule();
}

View file

@ -58,6 +58,14 @@ SelectionManager = (function() {
that.setSelections([messageParsed.entityID]);
} else if (messageParsed.method === "clearSelection") {
that.clearSelections();
} else if (messageParsed.method === "pointingAt") {
if (messageParsed.rightHand) {
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
that.pointingAtTabletRight = messageParsed.tablet;
} else {
that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow;
that.pointingAtTabletLeft = messageParsed.tablet;
}
}
}
@ -93,6 +101,11 @@ SelectionManager = (function() {
that.worldDimensions = Vec3.ZERO;
that.worldRegistrationPoint = Vec3.HALF;
that.centerPosition = Vec3.ZERO;
that.pointingAtDesktopWindowLeft = false;
that.pointingAtDesktopWindowRight = false;
that.pointingAtTabletLeft = false;
that.pointingAtTabletRight = false;
that.saveProperties = function() {
that.savedProperties = {};
@ -660,7 +673,13 @@ SelectionDisplay = (function() {
activeHand = (activeHand === Controller.Standard.RightHand) ?
Controller.Standard.LeftHand : Controller.Standard.RightHand;
}
if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) {
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.mousePressEvent({});