From 48e327815dd7ba973cd6f9bf3e62c7746076b490 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper <1p-cusack@1stplayable.com> Date: Tue, 1 Aug 2017 16:26:45 -0400 Subject: [PATCH 1/6] [Case 6491] Resolves arg order to centerToZero and centerToIntersection vectors. Changes Committed: modified: scripts/system/libraries/entitySelectionTool.js --- .../system/libraries/entitySelectionTool.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 77b62913bf..30d54e3530 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -3549,6 +3549,8 @@ SelectionDisplay = (function() { }); } + //----------------------------------------- + // YAW GRABBER TOOL DEFINITION var initialPosition = SelectionManager.worldPosition; addGrabberTool(yawHandle, { mode: "ROTATE_YAW", @@ -3625,10 +3627,10 @@ SelectionDisplay = (function() { if (result.intersects) { var center = yawCenter; var zero = yawZero; - // TODO: these vectors are backwards to their names, doesn't matter for this use case (inverted vectors still give same angle) - var centerToZero = Vec3.subtract(center, zero); - var centerToIntersect = Vec3.subtract(center, result.intersection); - // TODO: orientedAngle wants normalized centerToZero and centerToIntersect + var centerToZero = Vec3.subtract(zero, center); + var centerToIntersect = Vec3.subtract(result.intersection, center); + // Note: orientedAngle which wants normalized centerToZero and centerToIntersect + // handles that internally, so it's to pass unnormalized vectors here. var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); var snapToInner = distanceFromCenter < innerRadius; @@ -3717,6 +3719,8 @@ SelectionDisplay = (function() { } }); + //----------------------------------------- + // PITCH GRABBER TOOL DEFINITION addGrabberTool(pitchHandle, { mode: "ROTATE_PITCH", onBegin: function(event) { @@ -3792,8 +3796,10 @@ SelectionDisplay = (function() { var properties = Entities.getEntityProperties(selectionManager.selections[0]); var center = pitchCenter; var zero = pitchZero; - var centerToZero = Vec3.subtract(center, zero); - var centerToIntersect = Vec3.subtract(center, result.intersection); + var centerToZero = Vec3.subtract(zero, center); + var centerToIntersect = Vec3.subtract(result.intersection, center); + // Note: orientedAngle which wants normalized centerToZero & centerToIntersect, handles + // this internally, so it's fine to pass non-normalized versions here. var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); @@ -3874,6 +3880,8 @@ SelectionDisplay = (function() { } }); + //----------------------------------------- + // ROLL GRABBER TOOL DEFINITION addGrabberTool(rollHandle, { mode: "ROTATE_ROLL", onBegin: function(event) { @@ -3949,8 +3957,10 @@ SelectionDisplay = (function() { var properties = Entities.getEntityProperties(selectionManager.selections[0]); var center = rollCenter; var zero = rollZero; - var centerToZero = Vec3.subtract(center, zero); - var centerToIntersect = Vec3.subtract(center, result.intersection); + var centerToZero = Vec3.subtract(zero, center); + var centerToIntersect = Vec3.subtract(result.intersection, center); + // Note: orientedAngle which wants normalized centerToZero & centerToIntersect, handles + // this internally, so it's fine to pass non-normalized versions here. var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); From 1c273351933424bcae61f277b8bbcedfc31d1753 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 14 Aug 2017 17:34:32 -0700 Subject: [PATCH 2/6] a couple logging fixes --- interface/resources/qml/Web3DOverlay.qml | 5 +++++ interface/resources/qml/desktop/Desktop.qml | 5 +++++ interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml | 5 +++++ scripts/system/edit.js | 2 +- scripts/system/help.js | 1 + scripts/system/snapshot.js | 4 ++-- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/Web3DOverlay.qml b/interface/resources/qml/Web3DOverlay.qml index e0689e614d..a1fa2d2641 100644 --- a/interface/resources/qml/Web3DOverlay.qml +++ b/interface/resources/qml/Web3DOverlay.qml @@ -15,6 +15,11 @@ import "controls" as Controls Controls.WebView { + // This is for JS/QML communication, which is unused in a Web3DOverlay, + // but not having this here results in spurious warnings about a + // missing signal + signal sendToScript(var message); + function onWebEventReceived(event) { if (event.slice(0, 17) === "CLARA.IO DOWNLOAD") { ApplicationInterface.addAssetToWorldFromURL(event.slice(18)); diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 3dcf747113..ca7226a6ab 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -41,6 +41,11 @@ FocusScope { // when they're opened. signal showDesktop(); + // This is for JS/QML communication, which is unused in the Desktop, + // but not having this here results in spurious warnings about a + // missing signal + signal sendToScript(var message); + // Allows QML/JS to find the desktop through the parent chain property bool desktopRoot: true diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml index 12e8de3bfc..76484cf8c7 100644 --- a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml +++ b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml @@ -28,6 +28,11 @@ ScrollingWindow { HifiConstants { id: hifi } + // This is for JS/QML communication, which is unused in the AttachmentsDialog, + // but not having this here results in spurious warnings about a + // missing signal + signal sendToScript(var message); + property var settings: Settings { category: "AttachmentsDialog" property alias x: root.x diff --git a/scripts/system/edit.js b/scripts/system/edit.js index c141c7cd52..7ee6c64858 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1228,7 +1228,7 @@ Script.scriptEnding.connect(function () { Controller.mouseMoveEvent.disconnect(mouseMoveEventBuffered); Controller.mouseReleaseEvent.disconnect(mouseReleaseEvent); - Messages.messageReceived.disconnect(handleOverlaySelectionToolUpdates); + Messages.messageReceived.disconnect(handleMessagesReceived); Messages.unsubscribe("entityToolUpdates"); Messages.unsubscribe("Toolbar-DomainChanged"); createButton = null; diff --git a/scripts/system/help.js b/scripts/system/help.js index 1265a5597b..9ab7fa3fb3 100644 --- a/scripts/system/help.js +++ b/scripts/system/help.js @@ -61,6 +61,7 @@ tablet.gotoHomeScreen(); } button.clicked.disconnect(onClicked); + tablet.screenChanged.disconnect(onScreenChanged); Script.clearInterval(interval); if (tablet) { tablet.removeButton(button); diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 37618253ee..df5ed45fed 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -764,8 +764,8 @@ Script.scriptEnding.connect(function () { } Window.snapshotShared.disconnect(snapshotUploaded); Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet); - Entities.canRezChanged.disconnect(processRezPermissionChange); - Entities.canRezTmpChanged.disconnect(processRezPermissionChange); + Entities.canRezChanged.disconnect(updatePrintPermissions); + Entities.canRezTmpChanged.disconnect(updatePrintPermissions); }); }()); // END LOCAL_SCOPE From 3a8856fae6590cc7d38334eaf37451c79aa7bf25 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 14 Aug 2017 15:58:28 -0700 Subject: [PATCH 3/6] fix selection issue for TreeView.qml --- interface/resources/qml/controls-uit/Tree.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/resources/qml/controls-uit/Tree.qml b/interface/resources/qml/controls-uit/Tree.qml index 8bce092947..6c9533a40c 100644 --- a/interface/resources/qml/controls-uit/Tree.qml +++ b/interface/resources/qml/controls-uit/Tree.qml @@ -27,6 +27,7 @@ TreeView { model: treeModel selection: ItemSelectionModel { + id: selectionModel model: treeModel } @@ -215,6 +216,10 @@ TreeView { onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index) + onClicked: { + selectionModel.setCurrentIndex(index, ItemSelectionModel.ClearAndSelect); + } + onActivated: { var path = scriptsModel.data(index, 0x100) if (path) { From 84738f51c27d24decf5c8e1ebd78c0aa036485d6 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 14 Aug 2017 16:03:12 -0700 Subject: [PATCH 4/6] fixed tab issue --- interface/resources/qml/controls-uit/Tree.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/controls-uit/Tree.qml b/interface/resources/qml/controls-uit/Tree.qml index 6c9533a40c..53f66fa67c 100644 --- a/interface/resources/qml/controls-uit/Tree.qml +++ b/interface/resources/qml/controls-uit/Tree.qml @@ -27,7 +27,7 @@ TreeView { model: treeModel selection: ItemSelectionModel { - id: selectionModel + id: selectionModel model: treeModel } @@ -217,7 +217,7 @@ TreeView { onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index) onClicked: { - selectionModel.setCurrentIndex(index, ItemSelectionModel.ClearAndSelect); + selectionModel.setCurrentIndex(index, ItemSelectionModel.ClearAndSelect); } onActivated: { From cc2ff565ac549de78a7fe43b5ac07b46e267b023 Mon Sep 17 00:00:00 2001 From: LaShonda Hopper <1p-cusack@1stplayable.com> Date: Wed, 2 Aug 2017 14:55:10 -0400 Subject: [PATCH 5/6] [Case 6491] Ran lint on entitySelectionTool.js (details below). Prior Issue Count: 35 Current Issue Count: 3 Resolved: * 17 used out of scope issues. * 11 already defined issues. * 2 missing semicolon issues. * 1 implicit comparison against null issue. * 1 readability warning. Remaining Issues as of this commit: * scripts/system/libraries/entitySelectionTool.js: line 17, col 1, Read only. ** HIFI_PUBLIC_BUCKET assignment * scripts/system/libraries/entitySelectionTool.js: line 19, col 1, Read only. ** SPACE_WORLD assignment * scripts/system/libraries/entitySelectionTool.js: line 30, col 1, Read only. ** SelectionManager assignment One notable item was a chunk of code from makeStretchTool's onMove function which wasn't in scope of the vars being utilized. Changes Committed: modified: scripts/system/libraries/entitySelectionTool.js --- .../system/libraries/entitySelectionTool.js | 148 ++++++++++-------- 1 file changed, 81 insertions(+), 67 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 30d54e3530..44f3c9e041 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -30,11 +30,13 @@ function objectTranslationPlanePoint(position, dimensions) { SelectionManager = (function() { var that = {}; + // FUNCTION: SUBSCRIBE TO UPDATE MESSAGES function subscribeToUpdateMessages() { Messages.subscribe("entityToolUpdates"); Messages.messageReceived.connect(handleEntitySelectionToolUpdates); } + // FUNCTION: HANDLE ENTITY SELECTION TOOL UDPATES function handleEntitySelectionToolUpdates(channel, message, sender) { if (channel !== 'entityToolUpdates') { return; @@ -238,6 +240,7 @@ function normalizeDegrees(degrees) { return degrees; } +// FUNCTION: getRelativeCenterPosition // Return the enter position of an entity relative to it's registrationPoint // A registration point of (0.5, 0.5, 0.5) will have an offset of (0, 0, 0) // A registration point of (1.0, 1.0, 1.0) will have an offset of (-dimensions.x / 2, -dimensions.y / 2, -dimensions.z / 2) @@ -249,6 +252,7 @@ function getRelativeCenterPosition(dimensions, registrationPoint) { }; } +// SELECTION DISPLAY DEFINITION SelectionDisplay = (function() { var that = {}; @@ -1152,6 +1156,7 @@ SelectionDisplay = (function() { that.updateHandles(); }; + // FUNCTION: UPDATE ROTATION HANDLES that.updateRotationHandles = function() { var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1; var halfDimensions = Vec3.multiply(selectionManager.worldDimensions, 0.5); @@ -1545,11 +1550,6 @@ SelectionDisplay = (function() { translateHandlesVisible = false; } - var rotation = selectionManager.worldRotation; - var dimensions = selectionManager.worldDimensions; - var position = selectionManager.worldPosition; - - Overlays.editOverlay(rotateOverlayTarget, { visible: rotationOverlaysVisible }); @@ -1577,6 +1577,7 @@ SelectionDisplay = (function() { }); }; + // FUNCTION: SET SPACE MODE that.setSpaceMode = function(newSpaceMode) { if (spaceMode != newSpaceMode) { spaceMode = newSpaceMode; @@ -1584,6 +1585,7 @@ SelectionDisplay = (function() { } }; + // FUNCTION: TOGGLE SPACE MODE that.toggleSpaceMode = function() { if (spaceMode == SPACE_WORLD && SelectionManager.selections.length > 1) { print("Local space editing is not available with multiple selections"); @@ -1593,8 +1595,11 @@ SelectionDisplay = (function() { that.updateHandles(); }; + // FUNCTION: UNSELECT ALL + // TODO?: Needs implementation that.unselectAll = function() {}; + // FUNCTION: UPDATE HANDLES that.updateHandles = function() { if (SelectionManager.selections.length === 0) { that.setOverlaysVisible(false); @@ -2168,10 +2173,10 @@ SelectionDisplay = (function() { position: EdgeTR }); - var boxPosition = Vec3.multiplyQbyV(rotation, center); - boxPosition = Vec3.sum(position, boxPosition); + var selectionBoxPosition = Vec3.multiplyQbyV(rotation, center); + selectionBoxPosition = Vec3.sum(position, selectionBoxPosition); Overlays.editOverlay(selectionBox, { - position: boxPosition, + position: selectionBoxPosition, dimensions: dimensions, rotation: rotation, visible: !(mode == "ROTATE_YAW" || mode == "ROTATE_PITCH" || mode == "ROTATE_ROLL"), @@ -2218,13 +2223,13 @@ SelectionDisplay = (function() { var offset = vec3Mult(props.dimensions, centeredRP); offset = Vec3.multiply(-1, offset); offset = Vec3.multiplyQbyV(props.rotation, offset); - var boxPosition = Vec3.sum(props.position, offset); + var curBoxPosition = Vec3.sum(props.position, offset); var color = {red: 255, green: 128, blue: 0}; if (i >= selectionManager.selections.length - 1) color = {red: 255, green: 255, blue: 64}; Overlays.editOverlay(selectionBoxes[i], { - position: boxPosition, + position: curBoxPosition, color: color, rotation: props.rotation, dimensions: props.dimensions, @@ -2305,9 +2310,9 @@ SelectionDisplay = (function() { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z - } + }; Overlays.editOverlay(grabberMoveUp, { - visible: activeTool == null || mode == "TRANSLATE_UP_DOWN" + visible: (activeTool === null) || (mode == "TRANSLATE_UP_DOWN") }); Overlays.editOverlay(baseOfEntityProjectionOverlay, { @@ -2327,21 +2332,24 @@ SelectionDisplay = (function() { }; + // FUNCTION: SET OVERLAYS VISIBLE that.setOverlaysVisible = function(isVisible) { var length = allOverlays.length; - for (var i = 0; i < length; i++) { - Overlays.editOverlay(allOverlays[i], { + for (var overlayIndex = 0; overlayIndex < length; overlayIndex++) { + Overlays.editOverlay(allOverlays[overlayIndex], { visible: isVisible }); } length = selectionBoxes.length; - for (var i = 0; i < length; i++) { - Overlays.editOverlay(selectionBoxes[i], { + for (var boxIndex = 0; boxIndex < length; boxIndex++) { + Overlays.editOverlay(selectionBoxes[boxIndex], { visible: isVisible }); } }; + // FUNCTION: UNSELECT + // TODO?: Needs implementation that.unselect = function(entityID) {}; var initialXZPick = null; @@ -2350,6 +2358,7 @@ SelectionDisplay = (function() { var startPosition = null; var duplicatedEntityIDs = null; + // TOOL DEFINITION: TRANSLATE XZ TOOL var translateXZTool = { mode: 'TRANSLATE_XZ', pickPlanePosition: { x: 0, y: 0, z: 0 }, @@ -2538,7 +2547,8 @@ SelectionDisplay = (function() { } }; - var lastXYPick = null + // GRABBER TOOL: GRABBER MOVE UP + var lastXYPick = null; var upDownPickNormal = null; addGrabberTool(grabberMoveUp, { mode: "TRANSLATE_UP_DOWN", @@ -2594,7 +2604,7 @@ SelectionDisplay = (function() { print(" event.y:" + event.y); Vec3.print(" newIntersection:", newIntersection); Vec3.print(" vector:", vector); - Vec3.print(" newPosition:", newPosition); + //Vec3.print(" newPosition:", newPosition); } for (var i = 0; i < SelectionManager.selections.length; i++) { var id = SelectionManager.selections[i]; @@ -2612,6 +2622,7 @@ SelectionDisplay = (function() { }, }); + // GRABBER TOOL: GRABBER CLONER addGrabberTool(grabberCloner, { mode: "CLONE", onBegin: function(event) { @@ -2639,7 +2650,7 @@ SelectionDisplay = (function() { - + // FUNCTION: VEC 3 MULT var vec3Mult = function(v1, v2) { return { x: v1.x * v2.x, @@ -2647,6 +2658,8 @@ SelectionDisplay = (function() { z: v1.z * v2.z }; }; + + // FUNCTION: MAKE STRETCH TOOL // stretchMode - name of mode // direction - direction to stretch in // pivot - point to use as a pivot @@ -2898,13 +2911,14 @@ SelectionDisplay = (function() { // Are we using handControllers or Mouse - only relevant for 3D tools var controllerPose = getControllerWorldLocation(activeHand, true); - if (HMD.isHMDAvailable() - && HMD.isHandControllerAvailable() && controllerPose.valid && that.triggered && directionFor3DStretch) { + var vector = null; + if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() && + controllerPose.valid && that.triggered && directionFor3DStretch) { localDeltaPivot = deltaPivot3D; newPick = pickRay.origin; - var vector = Vec3.subtract(newPick, lastPick3D); + vector = Vec3.subtract(newPick, lastPick3D); vector = Vec3.multiplyQbyV(Quat.inverse(rotation), vector); @@ -2919,7 +2933,7 @@ SelectionDisplay = (function() { newPick = rayPlaneIntersection(pickRay, pickRayPosition, planeNormal); - var vector = Vec3.subtract(newPick, lastPick); + vector = Vec3.subtract(newPick, lastPick); vector = Vec3.multiplyQbyV(Quat.inverse(rotation), vector); @@ -2955,41 +2969,39 @@ SelectionDisplay = (function() { } else { newDimensions = Vec3.sum(initialDimensions, changeInDimensions); } - } - - - newDimensions.x = Math.max(newDimensions.x, MINIMUM_DIMENSION); - newDimensions.y = Math.max(newDimensions.y, MINIMUM_DIMENSION); - newDimensions.z = Math.max(newDimensions.z, MINIMUM_DIMENSION); - var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions)); - var newPosition = Vec3.sum(initialPosition, changeInPosition); + newDimensions.x = Math.max(newDimensions.x, MINIMUM_DIMENSION); + newDimensions.y = Math.max(newDimensions.y, MINIMUM_DIMENSION); + newDimensions.z = Math.max(newDimensions.z, MINIMUM_DIMENSION); - for (var i = 0; i < SelectionManager.selections.length; i++) { - Entities.editEntity(SelectionManager.selections[i], { - position: newPosition, - dimensions: newDimensions, - }); - } - + var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions)); + var newPosition = Vec3.sum(initialPosition, changeInPosition); - var wantDebug = false; - if (wantDebug) { - print(stretchMode); - //Vec3.print(" newIntersection:", newIntersection); - Vec3.print(" vector:", vector); - //Vec3.print(" oldPOS:", oldPOS); - //Vec3.print(" newPOS:", newPOS); - Vec3.print(" changeInDimensions:", changeInDimensions); - Vec3.print(" newDimensions:", newDimensions); + for (var i = 0; i < SelectionManager.selections.length; i++) { + Entities.editEntity(SelectionManager.selections[i], { + position: newPosition, + dimensions: newDimensions, + }); + } + - Vec3.print(" changeInPosition:", changeInPosition); - Vec3.print(" newPosition:", newPosition); + var wantDebug = false; + if (wantDebug) { + print(stretchMode); + //Vec3.print(" newIntersection:", newIntersection); + Vec3.print(" vector:", vector); + //Vec3.print(" oldPOS:", oldPOS); + //Vec3.print(" newPOS:", newPOS); + Vec3.print(" changeInDimensions:", changeInDimensions); + Vec3.print(" newDimensions:", newDimensions); + + Vec3.print(" changeInPosition:", changeInPosition); + Vec3.print(" newPosition:", newPosition); + } } SelectionManager._update(); - - }; + };//--End of onMove def return { mode: stretchMode, @@ -3042,7 +3054,8 @@ SelectionDisplay = (function() { z: -1 } }; - + + // FUNCTION: GET DIRECTION FOR 3D STRETCH // Returns a vector with directions for the stretch tool in 3D using hand controllers function getDirectionsFor3DStretch(mode) { if (mode === "STRETCH_LBN") { @@ -3067,7 +3080,7 @@ SelectionDisplay = (function() { } - + // FUNCTION: ADD STRETCH TOOL function addStretchTool(overlay, mode, pivot, direction, offset, handleMove) { if (!pivot) { pivot = direction; @@ -3077,6 +3090,7 @@ SelectionDisplay = (function() { addGrabberTool(overlay, tool); } + // FUNCTION: CUTOFF STRETCH FUNC function cutoffStretchFunc(vector, change) { vector = change; Vec3.print("Radius stretch: ", vector); @@ -3097,6 +3111,7 @@ SelectionDisplay = (function() { SelectionManager._update(); } + // FUNCTION: RADIUS STRETCH FUNC function radiusStretchFunc(vector, change) { var props = selectionManager.savedProperties[selectionManager.selections[0]]; @@ -3123,6 +3138,7 @@ SelectionDisplay = (function() { SelectionManager._update(); } + // STRETCH TOOL DEF SECTION addStretchTool(grabberNEAR, "STRETCH_NEAR", { x: 0, y: 0, @@ -3529,6 +3545,7 @@ SelectionDisplay = (function() { z: 1 }); + // FUNCTION: UPDATE ROTATION DEGREES OVERLAY function updateRotationDegreesOverlay(angleFromZero, handleRotation, centerPosition) { var angle = angleFromZero * (Math.PI / 180); var position = { @@ -3549,7 +3566,6 @@ SelectionDisplay = (function() { }); } - //----------------------------------------- // YAW GRABBER TOOL DEFINITION var initialPosition = SelectionManager.worldPosition; addGrabberTool(yawHandle, { @@ -3719,7 +3735,6 @@ SelectionDisplay = (function() { } }); - //----------------------------------------- // PITCH GRABBER TOOL DEFINITION addGrabberTool(pitchHandle, { mode: "ROTATE_PITCH", @@ -3793,7 +3808,6 @@ SelectionDisplay = (function() { var result = Overlays.findRayIntersection(pickRay, true, [rotateOverlayTarget]); if (result.intersects) { - var properties = Entities.getEntityProperties(selectionManager.selections[0]); var center = pitchCenter; var zero = pitchZero; var centerToZero = Vec3.subtract(zero, center); @@ -3815,7 +3829,6 @@ SelectionDisplay = (function() { for (var i = 0; i < SelectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - var properties = Entities.getEntityProperties(entityID); var initialProperties = SelectionManager.savedProperties[entityID]; var dPos = Vec3.subtract(initialProperties.position, initialPosition); dPos = Vec3.multiplyQbyV(pitchChange, dPos); @@ -3880,7 +3893,6 @@ SelectionDisplay = (function() { } }); - //----------------------------------------- // ROLL GRABBER TOOL DEFINITION addGrabberTool(rollHandle, { mode: "ROTATE_ROLL", @@ -3954,7 +3966,6 @@ SelectionDisplay = (function() { var result = Overlays.findRayIntersection(pickRay, true, [rotateOverlayTarget]); if (result.intersects) { - var properties = Entities.getEntityProperties(selectionManager.selections[0]); var center = rollCenter; var zero = rollZero; var centerToZero = Vec3.subtract(zero, center); @@ -3975,7 +3986,6 @@ SelectionDisplay = (function() { }); for (var i = 0; i < SelectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - var properties = Entities.getEntityProperties(entityID); var initialProperties = SelectionManager.savedProperties[entityID]; var dPos = Vec3.subtract(initialProperties.position, initialPosition); dPos = Vec3.multiplyQbyV(rollChange, dPos); @@ -4040,6 +4050,7 @@ SelectionDisplay = (function() { } }); + // FUNCTION: CHECK MOVE that.checkMove = function() { if (SelectionManager.hasSelection()) { @@ -4054,6 +4065,7 @@ SelectionDisplay = (function() { } }; + // FUNCTION: MOUSE PRESS EVENT that.mousePressEvent = function(event) { var wantDebug = false; if (!event.isLeftButton && !that.triggered) { @@ -4177,7 +4189,7 @@ SelectionDisplay = (function() { // Only intersect versus yaw/pitch/roll. - var result = Overlays.findRayIntersection(pickRay, true, [ yawHandle, pitchHandle, rollHandle ] ); + result = Overlays.findRayIntersection(pickRay, true, [ yawHandle, pitchHandle, rollHandle ] ); var overlayOrientation; var overlayCenter; @@ -4194,10 +4206,10 @@ SelectionDisplay = (function() { originalRoll = roll; if (result.intersects) { - var tool = grabberTools[result.overlayID]; - if (tool) { - activeTool = tool; - mode = tool.mode; + var resultTool = grabberTools[result.overlayID]; + if (resultTool) { + activeTool = resultTool; + mode = resultTool.mode; somethingClicked = 'tool'; if (activeTool && activeTool.onBegin) { activeTool.onBegin(event); @@ -4380,7 +4392,7 @@ SelectionDisplay = (function() { if (!somethingClicked) { // Only intersect versus selectionBox. - var result = Overlays.findRayIntersection(pickRay, true, [selectionBox]); + result = Overlays.findRayIntersection(pickRay, true, [selectionBox]); if (result.intersects) { switch (result.overlayID) { case selectionBox: @@ -4435,6 +4447,7 @@ SelectionDisplay = (function() { return somethingClicked; }; + // FUNCTION: MOUSE MOVE EVENT that.mouseMoveEvent = function(event) { if (activeTool) { activeTool.onMove(event); @@ -4564,7 +4577,7 @@ SelectionDisplay = (function() { return false; }; - + // FUNCTION: UPDATE HANDLE SIZES that.updateHandleSizes = function() { if (selectionManager.hasSelection()) { var diff = Vec3.subtract(selectionManager.worldPosition, Camera.getPosition()); @@ -4603,6 +4616,7 @@ SelectionDisplay = (function() { }; Script.update.connect(that.updateHandleSizes); + // FUNCTION: MOUSE RELEASE EVENT that.mouseReleaseEvent = function(event) { var showHandles = false; if (activeTool && activeTool.onEnd) { From ecd1f1319715c6ea1f88df151c29ef08210ddaca Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 16 Aug 2017 15:34:06 -0700 Subject: [PATCH 6/6] Allow users to take a snapshot from the secondary camera --- interface/src/Application.cpp | 6 ++++++ interface/src/Application.h | 1 + .../src/scripting/WindowScriptingInterface.cpp | 4 ++++ interface/src/scripting/WindowScriptingInterface.h | 1 + .../src/display-plugins/NullDisplayPlugin.cpp | 4 ++++ .../src/display-plugins/NullDisplayPlugin.h | 1 + .../src/display-plugins/OpenGLDisplayPlugin.cpp | 13 +++++++++++++ .../src/display-plugins/OpenGLDisplayPlugin.h | 1 + libraries/plugins/src/plugins/DisplayPlugin.h | 1 + 9 files changed, 32 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f954a1e2c4..616b6914e9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6911,6 +6911,12 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa }); } +void Application::takeSecondaryCameraSnapshot() { + postLambdaEvent([this] { + Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot()); + }); +} + void Application::shareSnapshot(const QString& path, const QUrl& href) { postLambdaEvent([path, href] { // not much to do here, everything is done in snapshot code... diff --git a/interface/src/Application.h b/interface/src/Application.h index dddc373c91..752d6657fb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -274,6 +274,7 @@ public: float getAverageSimsPerSecond() const { return _simCounter.rate(); } void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f); + void takeSecondaryCameraSnapshot(); void shareSnapshot(const QString& filename, const QUrl& href = QUrl("")); model::SkyboxPointer getDefaultSkybox() const { return _defaultSkybox; } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 84f4cbbbd8..277989439c 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -294,6 +294,10 @@ void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, f qApp->takeSnapshot(notify, includeAnimated, aspectRatio); } +void WindowScriptingInterface::takeSecondaryCameraSnapshot() { + qApp->takeSecondaryCameraSnapshot(); +} + void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) { qApp->shareSnapshot(path, href); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index f8ed20f42f..28f1bafa5d 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -60,6 +60,7 @@ public slots: void showAssetServer(const QString& upload = ""); void copyToClipboard(const QString& text); void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f); + void takeSecondaryCameraSnapshot(); void makeConnection(bool success, const QString& userNameOrError); void displayAnnouncement(const QString& message); void shareSnapshot(const QString& path, const QUrl& href = QUrl("")); diff --git a/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.cpp index a4777b087b..6a19a34727 100644 --- a/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.cpp @@ -34,3 +34,7 @@ void NullDisplayPlugin::submitFrame(const gpu::FramePointer& frame) { QImage NullDisplayPlugin::getScreenshot(float aspectRatio) const { return QImage(); } + +QImage NullDisplayPlugin::getSecondaryCameraScreenshot() const { + return QImage(); +} diff --git a/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.h index 8d01539e8a..97b71b5780 100644 --- a/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/NullDisplayPlugin.h @@ -19,6 +19,7 @@ public: bool hasFocus() const override; void submitFrame(const gpu::FramePointer& newFrame) override; QImage getScreenshot(float aspectRatio = 0.0f) const override; + QImage getSecondaryCameraScreenshot() const override; void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override {}; private: static const QString NAME; diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index e1259fc5fc..7144e401e4 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -775,6 +775,19 @@ QImage OpenGLDisplayPlugin::getScreenshot(float aspectRatio) const { return screenshot.mirrored(false, true); } +QImage OpenGLDisplayPlugin::getSecondaryCameraScreenshot() const { + auto textureCache = DependencyManager::get(); + auto secondaryCameraFramebuffer = textureCache->getSpectatorCameraFramebuffer(); + gpu::Vec4i region(0, 0, secondaryCameraFramebuffer->getWidth(), secondaryCameraFramebuffer->getHeight()); + + auto glBackend = const_cast(*this).getGLBackend(); + QImage screenshot(region.z, region.w, QImage::Format_ARGB32); + withMainThreadContext([&] { + glBackend->downloadFramebuffer(secondaryCameraFramebuffer, region, screenshot); + }); + return screenshot.mirrored(false, true); +} + glm::uvec2 OpenGLDisplayPlugin::getSurfacePixels() const { uvec2 result; auto window = _container->getPrimaryWidget(); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 2f93fa630d..2080fa5ea6 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -60,6 +60,7 @@ public: virtual bool setDisplayTexture(const QString& name) override; virtual bool onDisplayTextureReset() { return false; }; QImage getScreenshot(float aspectRatio = 0.0f) const override; + QImage getSecondaryCameraScreenshot() const override; float presentRate() const override; diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index 9e18ee534d..d7531e66a7 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -183,6 +183,7 @@ public: // Fetch the most recently displayed image as a QImage virtual QImage getScreenshot(float aspectRatio = 0.0f) const = 0; + virtual QImage getSecondaryCameraScreenshot() const = 0; // will query the underlying hmd api to compute the most recent head pose virtual bool beginFrameRender(uint32_t frameIndex) { return true; }