propertly determine is laser intersects with HUD UI

This commit is contained in:
druiz17 2017-10-02 16:46:43 -07:00
parent 68780f56b7
commit 8a0ecf4e6f
5 changed files with 28 additions and 8 deletions

View file

@ -304,10 +304,10 @@ FocusScope {
if (child.visible) { if (child.visible) {
if (child.hasOwnProperty("modality")) { if (child.hasOwnProperty("modality")) {
var mappedPoint = child.mapFromGlobal(point.x, point.y); var mappedPoint = child.mapFromGlobal(point.x, point.y);
console.log(mappedPoint); var outLine = child.frame.children[2];
if (child.contains(mappedPoint)) { var framePoint = outLine.mapFromGlobal(point.x, point.y);
if (child.contains(mappedPoint) || outLine.contains(framePoint)) {
return true; return true;
console.log(child);
} }
} }
} }

View file

@ -26,6 +26,7 @@ Item {
readonly property int frameMarginRight: frame.decoration ? frame.decoration.frameMarginRight : 0 readonly property int frameMarginRight: frame.decoration ? frame.decoration.frameMarginRight : 0
readonly property int frameMarginTop: frame.decoration ? frame.decoration.frameMarginTop : 0 readonly property int frameMarginTop: frame.decoration ? frame.decoration.frameMarginTop : 0
readonly property int frameMarginBottom: frame.decoration ? frame.decoration.frameMarginBottom : 0 readonly property int frameMarginBottom: frame.decoration ? frame.decoration.frameMarginBottom : 0
readonly property int offsetCorrection: 20
// Frames always fill their parents, but their decorations may extend // Frames always fill their parents, but their decorations may extend
// beyond the window via negative margin sizes // beyond the window via negative margin sizes
@ -73,7 +74,7 @@ Item {
Rectangle { Rectangle {
id: sizeOutline id: sizeOutline
x: -frameMarginLeft x: -frameMarginLeft
y: -frameMarginTop y: -frameMarginTop - offsetCorrection
width: window ? window.width + frameMarginLeft + frameMarginRight + 2 : 0 width: window ? window.width + frameMarginLeft + frameMarginRight + 2 : 0
height: window ? window.height + frameMarginTop + frameMarginBottom + 2 : 0 height: window ? window.height + frameMarginTop + frameMarginBottom + 2 : 0
color: hifi.colors.baseGrayHighlight15 color: hifi.colors.baseGrayHighlight15

View file

@ -141,7 +141,6 @@ bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow", BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
Q_RETURN_ARG(QVariant, result), Q_RETURN_ARG(QVariant, result),
Q_ARG(QVariant, point)); Q_ARG(QVariant, point));
qDebug() << "------> invoke method isPointOnWindow <------";
return result.toBool(); return result.toBool();
} }

View file

@ -108,13 +108,17 @@ Script.include("/~/system/libraries/controllers.js");
"userData" "userData"
]; ];
var MARGIN = 25;
function FarActionGrabEntity(hand) { function FarActionGrabEntity(hand) {
this.hand = hand; this.hand = hand;
this.grabbedThingID = null; this.grabbedThingID = null;
this.actionID = null; // action this script created... this.actionID = null; // action this script created...
this.entityWithContextOverlay = false; this.entityWithContextOverlay = false;
this.contextOverlayTimer = false; this.contextOverlayTimer = false;
this.reticleMinX = MARGIN;
this.reticleMaxX;
this.reticleMinY = MARGIN;
this.reticleMaxY;
var ACTION_TTL = 15; // seconds var ACTION_TTL = 15; // seconds
@ -344,12 +348,28 @@ Script.include("/~/system/libraries/controllers.js");
this.grabbedThingID = null; this.grabbedThingID = null;
}; };
this.updateRecommendedArea = function() {
var dims = Controller.getViewportDimensions();
this.reticleMaxX = dims.x - MARGIN;
this.reticleMaxY = dims.y - MARGIN;
};
this.calculateNewReticlePosition = function(intersection) {
this.updateRecommendedArea();
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.notPointingAtEntity = function(controllerData) { this.notPointingAtEntity = function(controllerData) {
var intersection = controllerData.rayPicks[this.hand]; var intersection = controllerData.rayPicks[this.hand];
var entityProperty = Entities.getEntityProperties(intersection.objectID); var entityProperty = Entities.getEntityProperties(intersection.objectID);
var entityType = entityProperty.type; var entityType = entityProperty.type;
var hudRayPick = controllerData.hudRayPicks[this.hand];
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") || if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") ||
intersection.type === RayPick.INTERSECTED_OVERLAY) { intersection.type === RayPick.INTERSECTED_OVERLAY || Window.isPointOnDesktopWindow(point2d)) {
return true; return true;
} }
return false; return false;

View file

@ -178,7 +178,7 @@
} }
var hudRayPick = controllerData.hudRayPicks[this.hand]; var hudRayPick = controllerData.hudRayPicks[this.hand];
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection); var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
if (!Window.isPointOnDesktopWindow(point2d)) { if (!Window.isPointOnDesktopWindow(point2d) && !controllerData.triggerClicks[this.hand]) {
this.exitModule(); this.exitModule();
return false; return false;
} }