From 24a12a2f8fd792d9fcaa06e052e9867304660f41 Mon Sep 17 00:00:00 2001 From: beholder Date: Sun, 24 Sep 2017 22:44:13 +0300 Subject: [PATCH 01/15] 7722 Add onHover Outline to Tablet "X" Button --- .../src/scripting/HMDScriptingInterface.h | 5 +++ scripts/system/libraries/WebTablet.js | 37 +++++++++++++++++++ scripts/system/libraries/utils.js | 9 ++++- scripts/system/tablet-ui/tabletUI.js | 5 +++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 2eefe6ea22..e5040b1f90 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -32,6 +32,7 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen Q_PROPERTY(bool showTablet READ getShouldShowTablet) Q_PROPERTY(QUuid tabletID READ getCurrentTabletFrameID WRITE setCurrentTabletFrameID) Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonID WRITE setCurrentHomeButtonID) + Q_PROPERTY(QUuid homeButtonHighlightID READ getCurrentHomeButtonHightlightID WRITE setCurrentHomeButtonHightlightID) Q_PROPERTY(QUuid tabletScreenID READ getCurrentTabletScreenID WRITE setCurrentTabletScreenID) public: @@ -97,6 +98,9 @@ public: void setCurrentHomeButtonID(QUuid homeButtonID) { _homeButtonID = homeButtonID; } QUuid getCurrentHomeButtonID() const { return _homeButtonID; } + void setCurrentHomeButtonHightlightID(QUuid homeButtonHightlightID) { _homeButtonHightlightID = homeButtonHightlightID; } + QUuid getCurrentHomeButtonHightlightID() const { return _homeButtonHightlightID; } + void setCurrentTabletScreenID(QUuid tabletID) { _tabletScreenID = tabletID; } QUuid getCurrentTabletScreenID() const { return _tabletScreenID; } @@ -105,6 +109,7 @@ private: QUuid _tabletUIID; // this is the entityID of the tablet frame QUuid _tabletScreenID; // this is the overlayID which is part of (a child of) the tablet-ui. QUuid _homeButtonID; + QUuid _homeButtonHightlightID; QUuid _tabletEntityID; // Get the position of the HMD diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index c5f8168c30..34e8dd96fd 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -150,6 +150,22 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { parentJointIndex: -1 }); + this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { + name: "homeButtonHighlight", + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.015 }, + localRotation: { x: 0, y: 1, z: 0, w: 0 }, + dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, + solid: true, + outerRadius: 25 * tabletScaleFactor, + innerRadius: 17 * tabletScaleFactor, + alpha: 1.0, + color: { red: 255, green: 255, blue: 255 }, + visible: visible, + drawInFront: false, + parentID: this.tabletEntityID, + parentJointIndex: -1 + }); + this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonID == senderID) { var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); @@ -272,6 +288,7 @@ WebTablet.prototype.destroy = function () { Overlays.deleteOverlay(this.webOverlayID); Overlays.deleteOverlay(this.tabletEntityID); Overlays.deleteOverlay(this.homeButtonID); + Overlays.deleteOverlay(this.homeButtonHighlightID); HMD.displayModeChanged.disconnect(this.myOnHmdChanged); Controller.mousePressEvent.disconnect(this.myMousePressEvent); @@ -500,6 +517,22 @@ WebTablet.prototype.scheduleMouseMoveProcessor = function() { } }; +WebTablet.prototype.handleHomeButtonHover = function(x, y) { + var pickRay = Camera.computePickRay(x, y); + var entityPickResults; + var homebuttonHovered = false; + entityPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]); + if (entityPickResults.intersects && (entityPickResults.entityID === this.tabletEntityID || + entityPickResults.overlayID === this.tabletEntityID)) { + var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID], []); + if (overlayPickResults.intersects && overlayPickResults.overlayID === this.homeButtonID) { + homebuttonHovered = true; + } + } + + Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homebuttonHovered ? 1.0 : 0.0 }); +} + WebTablet.prototype.mouseMoveEvent = function (event) { if (this.dragging) { this.currentMouse = { @@ -507,6 +540,8 @@ WebTablet.prototype.mouseMoveEvent = function (event) { y: event.y }; this.scheduleMouseMoveProcessor(); + } else { + this.handleHomeButtonHover(event.x, event.y); } }; @@ -533,6 +568,8 @@ WebTablet.prototype.mouseMoveProcessor = function () { }); } this.scheduleMouseMoveProcessor(); + } else { + this.handleHomeButtonHover(this.currentMouse.x, this.currentMouse.y); } }; diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js index 162edcaea0..3a10d5d713 100644 --- a/scripts/system/libraries/utils.js +++ b/scripts/system/libraries/utils.js @@ -370,7 +370,7 @@ getTabletWidthFromSettings = function () { resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) { - if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID) { + if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID || !HMD.homeButtonHighlightID) { return; } @@ -413,4 +413,11 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0}, dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor} }); + + Overlays.editOverlay(HMD.homeButtonHighlightID, { + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.015 }, + dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, + outerRadius: 25 * tabletScaleFactor, + innerRadius: 17 * tabletScaleFactor + }); }; diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index 9d2382b3f8..4ce155dbb0 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -103,6 +103,7 @@ UIWebTablet.register(); HMD.tabletID = UIWebTablet.tabletEntityID; HMD.homeButtonID = UIWebTablet.homeButtonID; + HMD.homeButtonHighlightID = UIWebTablet.homeButtonHighlightID; HMD.tabletScreenID = UIWebTablet.webOverlayID; HMD.displayModeChanged.connect(onHmdChanged); MyAvatar.sensorToWorldScaleChanged.connect(onSensorToWorldScaleChanged); @@ -127,6 +128,7 @@ tabletProperties.visible = true; Overlays.editOverlay(HMD.tabletID, tabletProperties); Overlays.editOverlay(HMD.homeButtonID, { visible: true }); + Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: true }); Overlays.editOverlay(HMD.tabletScreenID, { visible: true }); Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 90 }); updateTabletWidthFromSettings(true); @@ -147,6 +149,7 @@ Overlays.editOverlay(HMD.tabletID, { visible: false }); Overlays.editOverlay(HMD.homeButtonID, { visible: false }); + Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: false }); Overlays.editOverlay(HMD.tabletScreenID, { visible: false }); Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 1 }); } @@ -167,6 +170,7 @@ UIWebTablet = null; HMD.tabletID = null; HMD.homeButtonID = null; + HMD.homeButtonHighlightID = null; HMD.tabletScreenID = null; } else if (debugTablet) { print("TABLET closeTabletUI, UIWebTablet is null"); @@ -317,6 +321,7 @@ Overlays.deleteOverlay(tabletID); HMD.tabletID = null; HMD.homeButtonID = null; + HMD.homeButtonHighlightID = null; HMD.tabletScreenID = null; }); }()); // END LOCAL_SCOPE From 6409580b0302ce091097d9ece137303966562f32 Mon Sep 17 00:00:00 2001 From: beholder Date: Wed, 27 Sep 2017 01:06:22 +0300 Subject: [PATCH 02/15] ignore intersection for 'close' button highlight overlay --- scripts/system/libraries/WebTablet.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 34e8dd96fd..0632827bf6 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -158,6 +158,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { solid: true, outerRadius: 25 * tabletScaleFactor, innerRadius: 17 * tabletScaleFactor, + ignoreIntersection: true, alpha: 1.0, color: { red: 255, green: 255, blue: 255 }, visible: visible, From ef732fb5475ad3711943c6b9d45d8326578e9d7e Mon Sep 17 00:00:00 2001 From: beholder Date: Wed, 27 Sep 2017 01:07:32 +0300 Subject: [PATCH 03/15] enable 'close' button overlay on hover/leave with stylys/lasers --- scripts/system/libraries/WebTablet.js | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 0632827bf6..fbe869c602 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -187,6 +187,23 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { } }; + this.myOnHoverEnterOverlay = function (overlayID, pointerEvent) { + _this.onHoverEnterOverlay(overlayID, pointerEvent); + }; + + Overlays.hoverEnterOverlay.connect(this.myOnHoverEnterOverlay); + + this.myOnHoverLeaveOverlay = function (overlayID, pointerEvent) { + _this.onHoverLeaveOverlay(overlayID, pointerEvent); + }; + + Overlays.hoverLeaveOverlay.connect(this.myOnHoverLeaveOverlay); + + this.myOnHoverOverOverlay = function (overlayID, pointerEvent) { + _this.onHoverOverOverlay(overlayID, pointerEvent); + }; + Overlays.hoverOverOverlay.connect(this.myOnHoverOverOverlay); + this.state = "idle"; this.getRoot = function() { @@ -286,6 +303,10 @@ WebTablet.prototype.setWidth = function (width) { }; WebTablet.prototype.destroy = function () { + Overlays.hoverEnterOverlay.disconnect(this.myOnHoverEnterOverlay); + Overlays.hoverLeaveOverlay.disconnect(this.myOnHoverLeaveOverlay); + Overlays.hoverOverOverlay.disconnect(this.myOnHoverOverOverlay); + Overlays.deleteOverlay(this.webOverlayID); Overlays.deleteOverlay(this.tabletEntityID); Overlays.deleteOverlay(this.homeButtonID); @@ -381,6 +402,24 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos }; }; +WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) { + if (overlayID === this.homeButtonID) { + Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 1.0 }); + } +} + +WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) { + if (overlayID !== this.homeButtonID) { + Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); + } +} + +WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) { + if (overlayID === this.homeButtonID) { + Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); + } +} + // compute position, rotation & parentJointIndex of the tablet WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMouse, tabletProperties) { if (HMD.active) { From e77ac9fd104d16ba9bb6c4203d8f72e261a00a43 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Tue, 10 Oct 2017 13:47:33 -0700 Subject: [PATCH 04/15] include release message --- scripts/system/controllers/controllerModules/equipEntity.js | 6 ++++++ .../controllers/controllerModules/nearActionGrabEntity.js | 6 ++++++ .../controllers/controllerModules/nearParentGrabEntity.js | 5 +++++ .../controllers/controllerModules/nearParentGrabOverlay.js | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/scripts/system/controllers/controllerModules/equipEntity.js b/scripts/system/controllers/controllerModules/equipEntity.js index 4978f225ce..ef7a7ab062 100644 --- a/scripts/system/controllers/controllerModules/equipEntity.js +++ b/scripts/system/controllers/controllerModules/equipEntity.js @@ -546,6 +546,12 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(this.targetEntityID, "releaseEquip", args); + Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + action: 'release', + grabbedEntity: this.targetEntityID, + joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand" + })); + ensureDynamic(this.targetEntityID); this.targetEntityID = null; this.messageGrabEntity = false; diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index 2484067655..12d1533703 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -144,6 +144,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); Entities.deleteAction(this.targetEntityID, this.actionID); this.actionID = null; + Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + action: 'release', + grabbedEntity: this.targetEntityID, + joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand" + })); + this.targetEntityID = null; }; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 70d91bf1ec..87d4811967 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -138,6 +138,11 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; Entities.callEntityMethod(this.targetEntityID, "releaseGrab", args); + Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + action: 'release', + grabbedEntity: this.targetEntityID, + joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand" + })); this.grabbing = false; this.targetEntityID = null; }; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js index f9557f685f..471ee89926 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabOverlay.js @@ -148,6 +148,12 @@ Script.include("/~/system/libraries/utils.js"); } } + Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + action: 'release', + grabbedEntity: this.grabbedThingID, + joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand" + })); + this.grabbedThingID = null; }; From 8f3fa08b1eae683812b1dbf3bf7097493af43b3d Mon Sep 17 00:00:00 2001 From: druiz17 Date: Wed, 11 Oct 2017 11:41:10 -0700 Subject: [PATCH 05/15] hud module intersects with stats window --- interface/resources/qml/Stats.qml | 1 + interface/resources/qml/desktop/Desktop.qml | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 8737e422cb..3ac37545d9 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -8,6 +8,7 @@ Item { anchors.leftMargin: 300 objectName: "StatsItem" + property var statsObject: root Component.onCompleted: { stats.parentChanged.connect(fill); diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index bb23148ec6..a5b1b8eb7c 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -301,14 +301,18 @@ FocusScope { function isPointOnWindow(point) { for (var i = 0; i < desktop.visibleChildren.length; i++) { var child = desktop.visibleChildren[i]; - if (child.visible) { - if (child.hasOwnProperty("modality")) { - var mappedPoint = child.mapFromGlobal(point.x, point.y); - var outLine = child.frame.children[2]; - var framePoint = outLine.mapFromGlobal(point.x, point.y); - if (child.contains(mappedPoint) || outLine.contains(framePoint)) { - return true; - } + var childName = child.objectName; + if (child.hasOwnProperty("modality")) { + var mappedPoint = child.mapFromGlobal(point.x, point.y); + var outLine = child.frame.children[2]; + var framePoint = outLine.mapFromGlobal(point.x, point.y); + if (child.contains(mappedPoint) || outLine.contains(framePoint)) { + return true; + } + } else if (childName === "StatsItem") { + var mappedPoint = child.statsObject.mapFromGlobal(point.x, point.y); + if (child.statsObject.contains(mappedPoint)) { + return true; } } } From f3b2ccf5f821d57c388d350ca3696244d9bb284a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 12 Oct 2017 09:09:57 +1300 Subject: [PATCH 06/15] Preload asset files so that they're in disk cache ready for use --- .../shapes/modules/createPalette.js | 8 +- .../marketplace/shapes/modules/preload.js | 165 ++++++++++++++++++ .../marketplace/shapes/modules/toolIcon.js | 5 + .../marketplace/shapes/modules/toolsMenu.js | 9 +- .../marketplace/shapes/shapes.js | 9 +- 5 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 unpublishedScripts/marketplace/shapes/modules/preload.js diff --git a/unpublishedScripts/marketplace/shapes/modules/createPalette.js b/unpublishedScripts/marketplace/shapes/modules/createPalette.js index 0eea8379d6..38dad5b827 100644 --- a/unpublishedScripts/marketplace/shapes/modules/createPalette.js +++ b/unpublishedScripts/marketplace/shapes/modules/createPalette.js @@ -8,7 +8,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global CreatePalette: true, App, Feedback, History, UIT */ +/* global CreatePalette:true, App, Feedback, History, Preload, UIT */ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) { // Tool menu displayed on top of forearm. @@ -332,6 +332,11 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) { } + function getAssetURLs() { + return Preload.findURLs([PALETTE_HEADER_HEADING_PROPERTIES, PALETTE_HEADER_BAR_PROPERTIES, PALETTE_TITLE_PROPERTIES, + PALETTE_ITEMS]); + } + function setHand(hand) { // Assumes UI is not displaying. var NUMBER_OF_HANDS = 2; @@ -533,6 +538,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) { } return { + assetURLs: getAssetURLs, setHand: setHand, overlayIDs: getOverlayIDs, setVisible: setVisible, diff --git a/unpublishedScripts/marketplace/shapes/modules/preload.js b/unpublishedScripts/marketplace/shapes/modules/preload.js new file mode 100644 index 0000000000..8ffc8dcce3 --- /dev/null +++ b/unpublishedScripts/marketplace/shapes/modules/preload.js @@ -0,0 +1,165 @@ +// +// preload.js +// +// Created by David Rowe on 11 Oct 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +/* global Preload:true, App */ + +Preload = (function () { + // Provide facility to preload asset files so that they are in disk cache. + // Global object. + + "use strict"; + + var loadTimer = null, + urlsToLoad = [], + nextURLToLoad = 0, + LOAD_INTERVAL = 50, // ms + overlays = [], + deleteTimer = null, + DELETE_INTERVAL = LOAD_INTERVAL; // ms + + function findURLs(items) { + var urls = [], + i, + length; + + function findURLsInObject(item) { + var property; + + for (property in item) { + if (item.hasOwnProperty(property)) { + if (property === "url") { + urls.push(item.url); + } else if (typeof item[property] === "object") { + findURLsInObject(item[property]); + } + } + } + } + + for (i = 0, length = items.length; i < length; i++) { + switch (typeof items[i]) { + case "string": + urls.push(items[i]); + break; + case "object": + findURLsInObject(items[i]); + break; + default: + App.log("ERROR: Cannot find URL in item type " + (typeof items[i])); + } + } + + return urls; + } + + function deleteOverlay() { + if (overlays.length === 0) { // Just in case. + deleteTimer = null; + return; + } + + Overlays.deleteOverlay(overlays[0]); + overlays.shift(); + + if (overlays.length > 0) { + deleteTimer = Script.setTimeout(deleteOverlay, DELETE_INTERVAL); + } else { + deleteTimer = null; + } + } + + function loadNextURL() { + + function loadURL(url) { + var DOMAIN_CORNER = { x: -16382, y: -16382, z: -16382 }, // Near but not right on domain corner. + DUMMY_OVERLAY_PROPERTIES = { + fbx: { + overlay: "model", + dimensions: { x: 0.001, y: 0.001, z: 0.001 }, + position: DOMAIN_CORNER, + ignoreRayIntersection: false, + alpha: 0.0, + visible: false + }, + svg: { + overlay: "image3d", + scale: 0.001, + position: DOMAIN_CORNER, + ignoreRayIntersection: true, + alpha: 0.0, + visible: false + } + }, + fileType, + properties; + + fileType = url.slice(-3); + if (DUMMY_OVERLAY_PROPERTIES.hasOwnProperty(fileType)) { + properties = Object.clone(DUMMY_OVERLAY_PROPERTIES[fileType]); + properties.url = url; + overlays.push(Overlays.addOverlay(properties.overlay, properties)); + if (deleteTimer === null) { + // Can't delete overlay straight away otherwise asset load is abandoned. + deleteTimer = Script.setTimeout(deleteOverlay, DELETE_INTERVAL); + } + } else { + App.log("ERROR: Cannot preload asset " + url); + } + } + + // Find next URL that hasn't already been loaded; + while (nextURLToLoad < urlsToLoad.length && urlsToLoad.indexOf(urlsToLoad[nextURLToLoad]) < nextURLToLoad) { + nextURLToLoad += 1; + } + + // Load the URL if there's one to load. + if (nextURLToLoad < urlsToLoad.length) { + // Load the URL. + loadURL(urlsToLoad[nextURLToLoad]); + nextURLToLoad += 1; + + // Load the next, if any, after a short delay. + loadTimer = Script.setTimeout(loadNextURL, LOAD_INTERVAL); + } else { + loadTimer = null; + } + } + + function load(urls) { + urlsToLoad = urlsToLoad.concat(urls); + if (loadTimer === null) { + loadNextURL(); + } + } + + function tearDown() { + var i, + length; + + if (loadTimer) { + Script.clearTimeout(loadTimer); + } + + if (deleteTimer) { + Script.clearTimeout(deleteTimer); + for (i = 0, length = overlays.length; i < length; i++) { + Overlays.deleteOverlay(overlays[i]); + } + } + } + + Script.scriptEnding.connect(tearDown); + + return { + findURLs: findURLs, + load: load + }; + +}()); diff --git a/unpublishedScripts/marketplace/shapes/modules/toolIcon.js b/unpublishedScripts/marketplace/shapes/modules/toolIcon.js index 1571a6b037..143d768466 100644 --- a/unpublishedScripts/marketplace/shapes/modules/toolIcon.js +++ b/unpublishedScripts/marketplace/shapes/modules/toolIcon.js @@ -72,6 +72,10 @@ ToolIcon = function (side) { return new ToolIcon(); } + function getAssetURLs() { + return [MODEL_PROPERTIES.url]; + } + function setHand(side) { // Assumes UI is not displaying. if (side === LEFT_HAND) { @@ -154,6 +158,7 @@ ToolIcon = function (side) { } return { + assetURLs: getAssetURLs, setHand: setHand, display: display, clear: clear, diff --git a/unpublishedScripts/marketplace/shapes/modules/toolsMenu.js b/unpublishedScripts/marketplace/shapes/modules/toolsMenu.js index 19c114c8e9..04bb88d040 100644 --- a/unpublishedScripts/marketplace/shapes/modules/toolsMenu.js +++ b/unpublishedScripts/marketplace/shapes/modules/toolsMenu.js @@ -8,7 +8,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global ToolsMenu: true, App, Feedback, UIT */ +/* global ToolsMenu:true, App, Feedback, Preload, UIT */ ToolsMenu = function (side, leftInputs, rightInputs, uiCommandCallback) { // Tool menu displayed on top of forearm. @@ -2042,6 +2042,12 @@ ToolsMenu = function (side, leftInputs, rightInputs, uiCommandCallback) { return new ToolsMenu(); } + function getAssetURLs() { + return Preload.findURLs([MENU_HEADER_HEADING_PROPERTIES, MENU_HEADER_BAR_PROPERTIES, MENU_HEADER_BACK_PROPERTIES, + MENU_HEADER_TITLE_PROPERTIES, MENU_HEADER_TITLE_BACK_URL, MENU_HEADER_ICON_PROPERTIES, UI_ELEMENTS, + PICKLIST_UP_ARROW, PICKLIST_DOWN_ARROW, OPTONS_PANELS, MENU_ITEMS, FOOTER_ITEMS]); + } + controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand(); function setHand(hand) { @@ -3672,6 +3678,7 @@ ToolsMenu = function (side, leftInputs, rightInputs, uiCommandCallback) { } return { + assetURLs: getAssetURLs, COLOR_TOOL: COLOR_TOOL, SCALE_TOOL: SCALE_TOOL, CLONE_TOOL: CLONE_TOOL, diff --git a/unpublishedScripts/marketplace/shapes/shapes.js b/unpublishedScripts/marketplace/shapes/shapes.js index 290424f55e..cd5f119588 100644 --- a/unpublishedScripts/marketplace/shapes/shapes.js +++ b/unpublishedScripts/marketplace/shapes/shapes.js @@ -8,7 +8,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global Feedback, History */ +/* global Feedback, History, Preload */ (function () { @@ -87,6 +87,7 @@ Script.include("./modules/highlights.js"); Script.include("./modules/history.js"); Script.include("./modules/laser.js"); + Script.include("./modules/preload.js"); Script.include("./modules/selection.js"); Script.include("./modules/toolIcon.js"); Script.include("./modules/toolsMenu.js"); @@ -235,8 +236,12 @@ } toolIcon = new ToolIcon(otherHand(side)); - toolsMenu = new ToolsMenu(side, leftInputs, rightInputs, uiCommandCallback); createPalette = new CreatePalette(side, leftInputs, rightInputs, uiCommandCallback); + toolsMenu = new ToolsMenu(side, leftInputs, rightInputs, uiCommandCallback); + + Preload.load(toolIcon.assetURLs()); + Preload.load(createPalette.assetURLs()); + Preload.load(toolsMenu.assetURLs()); getIntersection = side === LEFT_HAND ? rightInputs.intersection : leftInputs.intersection; From c6672fc4aceb84cdae6500f3aa08759a2fdeb928 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 11 Oct 2017 09:44:01 -0700 Subject: [PATCH 07/15] Fix KTX requests thrashing if a mip level can't be assigned When downloading a mip level and assigning it to the underlying resource, we weren't checking to see if the assignment was successful. If it was unsuccessful, we would queue up a request for the next mip which would end up being a request for the same mip that was just attempted. This change fixes this problem by checking to see if the texture's available mip level is at least <= the assigned mip level. --- .../model-networking/src/model-networking/TextureCache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 5d8f840c85..4184351c2d 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -620,6 +620,12 @@ void NetworkTexture::ktxMipRequestFinished() { texture->assignStoredMip(mipLevel, data.size(), reinterpret_cast(data.data())); + // If mip level assigned above is still unavailable, then we assume future requests will also fail. + auto minMipLevel = texture->minAvailableMipLevel(); + if (minMipLevel > mipLevel) { + return; + } + QMetaObject::invokeMethod(resource.data(), "setImage", Q_ARG(gpu::TexturePointer, texture), Q_ARG(int, texture->getWidth()), From 42cab19ab2b14feaef66bbf41ebe1eaf1916deac Mon Sep 17 00:00:00 2001 From: druiz17 Date: Wed, 11 Oct 2017 16:04:35 -0700 Subject: [PATCH 08/15] generialze window search --- interface/resources/qml/AvatarInputs.qml | 1 + interface/resources/qml/Stats.qml | 9 ++++++--- interface/resources/qml/desktop/Desktop.qml | 16 ++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/interface/resources/qml/AvatarInputs.qml b/interface/resources/qml/AvatarInputs.qml index d86d4fd022..be4bf03465 100644 --- a/interface/resources/qml/AvatarInputs.qml +++ b/interface/resources/qml/AvatarInputs.qml @@ -17,6 +17,7 @@ import "./hifi/audio" as HifiAudio Hifi.AvatarInputs { id: root; objectName: "AvatarInputs" + property int modality: Qt.NonModal width: audio.width; height: audio.height; x: 10; y: 5; diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 3ac37545d9..4626d9bcda 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -8,7 +8,9 @@ Item { anchors.leftMargin: 300 objectName: "StatsItem" - property var statsObject: root + property int modality: Qt.NonModal + implicitHeight: row.height + implicitWidth: row.width Component.onCompleted: { stats.parentChanged.connect(fill); @@ -19,8 +21,9 @@ Item { } function fill() { - // Explicitly fill in order to avoid warnings at shutdown - anchors.fill = parent; + // This will cause a warning at shutdown, need to find another way to remove + // the warning other than filling the anchors to the parent + anchors.horizontalCenter = parent.horizontalCenter } Hifi.Stats { diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index a5b1b8eb7c..a93dd3cdd7 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -301,17 +301,17 @@ FocusScope { function isPointOnWindow(point) { for (var i = 0; i < desktop.visibleChildren.length; i++) { var child = desktop.visibleChildren[i]; - var childName = child.objectName; if (child.hasOwnProperty("modality")) { var mappedPoint = child.mapFromGlobal(point.x, point.y); - var outLine = child.frame.children[2]; - var framePoint = outLine.mapFromGlobal(point.x, point.y); - if (child.contains(mappedPoint) || outLine.contains(framePoint)) { - return true; + if (child.hasOwnProperty("frame")) { + var outLine = child.frame.children[2]; + var framePoint = outLine.mapFromGlobal(point.x, point.y); + if (child.contains(mappedPoint) || outLine.contains(framePoint)) { + return true; + } } - } else if (childName === "StatsItem") { - var mappedPoint = child.statsObject.mapFromGlobal(point.x, point.y); - if (child.statsObject.contains(mappedPoint)) { + + if (child.contains(mappedPoint)) { return true; } } From 0a943fbe7b2c569f892fc4c569d000799bbd0a50 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 11 Oct 2017 17:32:34 -0700 Subject: [PATCH 09/15] Crash/Deadlock fix: Web3DOverlay could be destroyed on wrong thread. When script calls Entities.getChildrenIDs*() it is possible to deadlock the main thread, and also invoke the destructor of Entities and Overlays, which is very NOT thread safe. The fix is to use a pattern already in use in several places in our codebase. Use the custom deleter parameter of std::shared_ptr to call deleteLater() instead of destroying the object in place. This allows any thread to use shared_ptrs of SpatiallyNestables without fear. --- interface/src/avatar/AvatarManager.cpp | 4 +-- interface/src/ui/overlays/Overlays.cpp | 30 +++++++++---------- .../src/RenderableModelEntityItem.cpp | 3 +- .../src/RenderablePolyVoxEntityItem.cpp | 2 +- libraries/entities/src/LightEntityItem.cpp | 2 +- libraries/entities/src/LineEntityItem.cpp | 4 +-- libraries/entities/src/ModelEntityItem.cpp | 2 +- .../entities/src/ParticleEffectEntityItem.cpp | 2 +- libraries/entities/src/PolyLineEntityItem.cpp | 2 +- libraries/entities/src/PolyVoxEntityItem.cpp | 2 +- libraries/entities/src/ShapeEntityItem.cpp | 2 +- libraries/entities/src/TextEntityItem.cpp | 2 +- libraries/entities/src/WebEntityItem.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 2 +- 14 files changed, 31 insertions(+), 30 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 5d8393ba7a..e8b800db69 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -53,7 +53,7 @@ const QUuid MY_AVATAR_KEY; // NULL key AvatarManager::AvatarManager(QObject* parent) : _avatarsToFade(), - _myAvatar(std::make_shared(qApp->thread())) + _myAvatar(new MyAvatar(qApp->thread()), [](MyAvatar* ptr) { ptr->deleteLater(); }) { // register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar qRegisterMetaType >("NodeWeakPointer"); @@ -297,7 +297,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { } AvatarSharedPointer AvatarManager::newSharedAvatar() { - return std::make_shared(qApp->thread()); + return AvatarSharedPointer(new OtherAvatar(qApp->thread()), [](OtherAvatar* ptr) { ptr->deleteLater(); }); } void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) { diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 0280cf2038..f268e71bbb 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -161,33 +161,33 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties) Overlay::Pointer thisOverlay = nullptr; if (type == ImageOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new ImageOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Image3DOverlay::TYPE || type == "billboard") { // "billboard" for backwards compatibility - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Image3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == TextOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new TextOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Text3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Text3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Shape3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Shape3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Cube3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Cube3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Sphere3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Sphere3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Circle3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Circle3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Rectangle3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Rectangle3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Line3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Line3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Grid3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Grid3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == ModelOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new ModelOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == Web3DOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new Web3DOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } else if (type == RectangleOverlay::TYPE) { - thisOverlay = std::make_shared(); + thisOverlay = Overlay::Pointer(new RectangleOverlay(), [](Overlay* ptr) { ptr->deleteLater(); }); } if (thisOverlay) { @@ -230,7 +230,7 @@ OverlayID Overlays::cloneOverlay(OverlayID id) { Overlay::Pointer thisOverlay = getOverlay(id); if (thisOverlay) { - OverlayID cloneId = addOverlay(Overlay::Pointer(thisOverlay->createClone())); + OverlayID cloneId = addOverlay(Overlay::Pointer(thisOverlay->createClone(), [](Overlay* ptr) { ptr->deleteLater(); })); #if OVERLAY_PANELS auto attachable = std::dynamic_pointer_cast(thisOverlay); if (attachable && attachable->getParentPanel()) { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 9120cd1788..e9d395a857 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -60,7 +60,8 @@ bool ModelEntityWrapper::isModelLoaded() const { } EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity{ new RenderableModelEntityItem(entityID, properties.getDimensionsInitialized()) }; + EntityItemPointer entity(new RenderableModelEntityItem(entityID, properties.getDimensionsInitialized()), + [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 4c254980c4..b11ab76c2f 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -138,7 +138,7 @@ void loop3(const T& start, const T& end, F f) { } EntityItemPointer RenderablePolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - std::shared_ptr entity{ new RenderablePolyVoxEntityItem(entityID) }; + std::shared_ptr entity(new RenderablePolyVoxEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); entity->initializePolyVox(); return entity; diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index ce530400ef..e1ccf8556b 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -30,7 +30,7 @@ const float LightEntityItem::DEFAULT_CUTOFF = PI / 2.0f; bool LightEntityItem::_lightsArePickable = false; EntityItemPointer LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new LightEntityItem(entityID) }; + EntityItemPointer entity(new LightEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/LineEntityItem.cpp b/libraries/entities/src/LineEntityItem.cpp index 8d133126ab..119236e32d 100644 --- a/libraries/entities/src/LineEntityItem.cpp +++ b/libraries/entities/src/LineEntityItem.cpp @@ -26,7 +26,7 @@ const int LineEntityItem::MAX_POINTS_PER_LINE = 70; EntityItemPointer LineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new LineEntityItem(entityID) }; + EntityItemPointer entity(new LineEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } @@ -214,4 +214,4 @@ void LineEntityItem::resetPointsChanged() { withWriteLock([&] { _pointsChanged = false; }); -} \ No newline at end of file +} diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 9c3ce47886..6af4db154a 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -26,7 +26,7 @@ const QString ModelEntityItem::DEFAULT_MODEL_URL = QString(""); const QString ModelEntityItem::DEFAULT_COMPOUND_SHAPE_URL = QString(""); EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new ModelEntityItem(entityID) }; + EntityItemPointer entity(new ModelEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index c6616f8cd3..1a815de632 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -147,7 +147,7 @@ uint64_t Properties::emitIntervalUsecs() const { EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new ParticleEffectEntityItem(entityID) }; + EntityItemPointer entity(new ParticleEffectEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/PolyLineEntityItem.cpp b/libraries/entities/src/PolyLineEntityItem.cpp index ad9686bdf2..a308a17c66 100644 --- a/libraries/entities/src/PolyLineEntityItem.cpp +++ b/libraries/entities/src/PolyLineEntityItem.cpp @@ -26,7 +26,7 @@ const int PolyLineEntityItem::MAX_POINTS_PER_LINE = 70; EntityItemPointer PolyLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity{ new PolyLineEntityItem(entityID) }; + EntityItemPointer entity(new PolyLineEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index daf7ca3f79..e577a6c1a7 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -47,7 +47,7 @@ const QString PolyVoxEntityItem::DEFAULT_Y_TEXTURE_URL = QString(""); const QString PolyVoxEntityItem::DEFAULT_Z_TEXTURE_URL = QString(""); EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new PolyVoxEntityItem(entityID) }; + EntityItemPointer entity(new PolyVoxEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 586344ee81..6e3bdc27a4 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -52,7 +52,7 @@ namespace entity { } ShapeEntityItem::Pointer ShapeEntityItem::baseFactory(const EntityItemID& entityID, const EntityItemProperties& properties) { - Pointer entity { new ShapeEntityItem(entityID) }; + Pointer entity(new ShapeEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 3ade5879c5..074691e1d4 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -30,7 +30,7 @@ const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0}; const bool TextEntityItem::DEFAULT_FACE_CAMERA = false; EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new TextEntityItem(entityID) }; + EntityItemPointer entity(new TextEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 9595f2959c..dd4bf518e0 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -24,7 +24,7 @@ const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com"); EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new WebEntityItem(entityID) }; + EntityItemPointer entity(new WebEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 88e4f3c9e6..13a1bbac43 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -32,7 +32,7 @@ const bool ZoneEntityItem::DEFAULT_GHOSTING_ALLOWED = true; const QString ZoneEntityItem::DEFAULT_FILTER_URL = ""; EntityItemPointer ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - EntityItemPointer entity { new ZoneEntityItem(entityID) }; + EntityItemPointer entity(new ZoneEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); entity->setProperties(properties); return entity; } From 74899e4798536886f5877387db57a1740c2d64a6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 12 Oct 2017 13:58:18 +1300 Subject: [PATCH 10/15] Preload PNG files also --- .../marketplace/shapes/modules/preload.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/unpublishedScripts/marketplace/shapes/modules/preload.js b/unpublishedScripts/marketplace/shapes/modules/preload.js index 8ffc8dcce3..e93ef9ac71 100644 --- a/unpublishedScripts/marketplace/shapes/modules/preload.js +++ b/unpublishedScripts/marketplace/shapes/modules/preload.js @@ -34,8 +34,10 @@ Preload = (function () { for (property in item) { if (item.hasOwnProperty(property)) { - if (property === "url") { - urls.push(item.url); + if (property === "url" || property === "imageURL" || property === "imageOverlayURL") { + if (item[property]) { + urls.push(item[property]); + } } else if (typeof item[property] === "object") { findURLsInObject(item[property]); } @@ -95,6 +97,14 @@ Preload = (function () { ignoreRayIntersection: true, alpha: 0.0, visible: false + }, + png: { + overlay: "image3d", + scale: 0.001, + position: DOMAIN_CORNER, + ignoreRayIntersection: true, + alpha: 0.0, + visible: false } }, fileType, From 9c15af9fbebe8d8fac43f84b4bbe4e9ecf2ac030 Mon Sep 17 00:00:00 2001 From: beholder Date: Thu, 12 Oct 2017 14:46:01 +0300 Subject: [PATCH 11/15] raise highlight above button overlay to reduce flickering --- scripts/system/libraries/WebTablet.js | 2 +- scripts/system/libraries/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index fbe869c602..0bfdf91afe 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -152,7 +152,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { name: "homeButtonHighlight", - localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.015 }, + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.019 }, localRotation: { x: 0, y: 1, z: 0, w: 0 }, dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, solid: true, diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js index 3a10d5d713..23c6d5f222 100644 --- a/scripts/system/libraries/utils.js +++ b/scripts/system/libraries/utils.js @@ -415,7 +415,7 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) }); Overlays.editOverlay(HMD.homeButtonHighlightID, { - localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.015 }, + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.019 }, dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, outerRadius: 25 * tabletScaleFactor, innerRadius: 17 * tabletScaleFactor From 8c7462f01250b069ef14bed3e6ffa8a580390861 Mon Sep 17 00:00:00 2001 From: beholder Date: Thu, 12 Oct 2017 22:21:40 +0300 Subject: [PATCH 12/15] fine-tuning based on discussion with Anshuman --- scripts/system/libraries/WebTablet.js | 4 ++-- scripts/system/libraries/utils.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 0bfdf91afe..29eb27890a 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -152,12 +152,12 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { name: "homeButtonHighlight", - localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.019 }, + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.0158 }, localRotation: { x: 0, y: 1, z: 0, w: 0 }, dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, solid: true, outerRadius: 25 * tabletScaleFactor, - innerRadius: 17 * tabletScaleFactor, + innerRadius: 20 * tabletScaleFactor, ignoreIntersection: true, alpha: 1.0, color: { red: 255, green: 255, blue: 255 }, diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js index 23c6d5f222..61ef5ac653 100644 --- a/scripts/system/libraries/utils.js +++ b/scripts/system/libraries/utils.js @@ -415,9 +415,9 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) }); Overlays.editOverlay(HMD.homeButtonHighlightID, { - localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.019 }, + localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.0158 }, dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor }, outerRadius: 25 * tabletScaleFactor, - innerRadius: 17 * tabletScaleFactor + innerRadius: 20 * tabletScaleFactor }); }; From 83d2a54b0fa132949b4eb3dd8b08a8fcac87e28c Mon Sep 17 00:00:00 2001 From: druiz17 Date: Thu, 12 Oct 2017 13:48:21 -0700 Subject: [PATCH 13/15] fixed some bugs --- interface/resources/qml/desktop/Desktop.qml | 3 ++- interface/src/ui/Stats.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index a93dd3cdd7..329e71a305 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -302,11 +302,12 @@ FocusScope { for (var i = 0; i < desktop.visibleChildren.length; i++) { var child = desktop.visibleChildren[i]; if (child.hasOwnProperty("modality")) { - var mappedPoint = child.mapFromGlobal(point.x, point.y); + var mappedPoint = mapToItem(child, point.x, point.y); if (child.hasOwnProperty("frame")) { var outLine = child.frame.children[2]; var framePoint = outLine.mapFromGlobal(point.x, point.y); if (child.contains(mappedPoint) || outLine.contains(framePoint)) { + console.log("it should not be here"); return true; } } diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 8140dfb8ae..d4a300c337 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -106,14 +106,15 @@ extern std::atomic DECIMATED_TEXTURE_COUNT; extern std::atomic RECTIFIED_TEXTURE_COUNT; void Stats::updateStats(bool force) { + QQuickItem* parent = parentItem(); if (!force) { if (!Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { - if (isVisible()) { - setVisible(false); + if (parent->isVisible()) { + parent->setVisible(false); } return; - } else if (!isVisible()) { - setVisible(true); + } else if (!parent->isVisible()) { + parent->setVisible(true); } } From 6799b9ca13996ceed554206f8bcc386f535d6981 Mon Sep 17 00:00:00 2001 From: druiz17 Date: Fri, 13 Oct 2017 09:34:08 -0700 Subject: [PATCH 14/15] fix stylus --- .../system/controllers/controllerModules/tabletStylusInput.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/system/controllers/controllerModules/tabletStylusInput.js b/scripts/system/controllers/controllerModules/tabletStylusInput.js index 29fa878cb1..b633c6e058 100644 --- a/scripts/system/controllers/controllerModules/tabletStylusInput.js +++ b/scripts/system/controllers/controllerModules/tabletStylusInput.js @@ -264,6 +264,8 @@ Script.include("/~/system/libraries/controllers.js"); if (!this.stylusTip.valid || this.overlayLaserActive(controllerData) || this.otherModuleNeedsToRun(controllerData)) { this.pointFinger(false); this.hideStylus(); + this.stylusTouchingTarget = false; + this.relinquishTouchFocus(); return false; } From 2422c9d9f3efb5bd88ecbc7c391a84b506ef017f Mon Sep 17 00:00:00 2001 From: druiz17 Date: Fri, 13 Oct 2017 10:45:24 -0700 Subject: [PATCH 15/15] made requested changes --- interface/resources/qml/desktop/Desktop.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 329e71a305..847111b8a0 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -306,8 +306,7 @@ FocusScope { if (child.hasOwnProperty("frame")) { var outLine = child.frame.children[2]; var framePoint = outLine.mapFromGlobal(point.x, point.y); - if (child.contains(mappedPoint) || outLine.contains(framePoint)) { - console.log("it should not be here"); + if (outLine.contains(framePoint)) { return true; } }