3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-13 03:32:31 +02:00

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
interface/resources/qml
desktop
windows
libraries/ui/src
scripts/system/controllers/controllerModules

View file

@ -304,10 +304,10 @@ FocusScope {
if (child.visible) {
if (child.hasOwnProperty("modality")) {
var mappedPoint = child.mapFromGlobal(point.x, point.y);
console.log(mappedPoint);
if (child.contains(mappedPoint)) {
var outLine = child.frame.children[2];
var framePoint = outLine.mapFromGlobal(point.x, point.y);
if (child.contains(mappedPoint) || outLine.contains(framePoint)) {
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 frameMarginTop: frame.decoration ? frame.decoration.frameMarginTop : 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
// beyond the window via negative margin sizes
@ -73,7 +74,7 @@ Item {
Rectangle {
id: sizeOutline
x: -frameMarginLeft
y: -frameMarginTop
y: -frameMarginTop - offsetCorrection
width: window ? window.width + frameMarginLeft + frameMarginRight + 2 : 0
height: window ? window.height + frameMarginTop + frameMarginBottom + 2 : 0
color: hifi.colors.baseGrayHighlight15

View file

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

View file

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

View file

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