From 1950ce5a4b9d1d9d023205300a8a51e3a820d497 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 25 Nov 2014 14:09:32 -0800 Subject: [PATCH 01/10] Add option for white grid color --- examples/html/gridControls.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/html/gridControls.html b/examples/html/gridControls.html index 241fa2406c..d95c9545e4 100644 --- a/examples/html/gridControls.html +++ b/examples/html/gridControls.html @@ -6,7 +6,7 @@ var gridColor = { red: 0, green: 0, blue: 0 }; var gridColors = [ { red: 0, green: 0, blue: 0 }, - { red: 128, green: 128, blue: 128 }, + { red: 255, green: 255, blue: 255 }, { red: 255, green: 0, blue: 0 }, { red: 0, green: 255, blue: 0}, { red: 0, green: 0, blue: 255 }, From 2c524cd70ce3835982092e9b4a40d7563d70b77d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 25 Nov 2014 14:10:39 -0800 Subject: [PATCH 02/10] Darken colors of selection/highlight boxes --- examples/libraries/entitySelectionTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 813bf015d1..f1e311246e 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -306,7 +306,7 @@ SelectionDisplay = (function () { var highlightBox = Overlays.addOverlay("cube", { position: { x:0, y: 0, z: 0}, size: 1, - color: { red: 180, green: 180, blue: 180}, + color: { red: 90, green: 90, blue: 90}, alpha: 1, solid: false, visible: false, @@ -318,7 +318,7 @@ SelectionDisplay = (function () { var selectionBox = Overlays.addOverlay("cube", { position: { x:0, y: 0, z: 0}, size: 1, - color: { red: 180, green: 180, blue: 180}, + color: { red: 60, green: 60, blue: 60}, alpha: 1, solid: false, visible: false, From fc5adef501a326300fb3ef42cf29a14188ea3a08 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 25 Nov 2014 14:11:04 -0800 Subject: [PATCH 03/10] Update the tool window to use tabbed windows --- interface/src/ui/ToolWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/ToolWindow.cpp b/interface/src/ui/ToolWindow.cpp index de88d75b3d..799402a486 100644 --- a/interface/src/ui/ToolWindow.cpp +++ b/interface/src/ui/ToolWindow.cpp @@ -21,6 +21,7 @@ ToolWindow::ToolWindow(QWidget* parent) : _hasShown(false), _lastGeometry() { + setDockOptions(QMainWindow::ForceTabbedDocks); Application::getInstance()->installEventFilter(this); } From da568c96cea7d7a5bacb43b5f0f1de63f5c70b30 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 12:04:00 -0800 Subject: [PATCH 04/10] Add rotation degrees overlay --- examples/libraries/entitySelectionTool.js | 131 +++++++++++++++++++--- 1 file changed, 113 insertions(+), 18 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index f1e311246e..2b3819aff1 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -200,6 +200,12 @@ SelectionManager = (function() { return that; })(); +function normalizeDegrees(degrees) { + while (degrees > 180) degrees -= 360; + while (degrees < -180) degrees += 360; + return degrees; +} + SelectionDisplay = (function () { var that = {}; @@ -207,6 +213,8 @@ SelectionDisplay = (function () { var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.0075; + var ROTATION_DISPLAY_DISTANCE_MULTIPLIER = 1.2; + var showExtendedStretchHandles = false; var spaceMode = SPACE_LOCAL; @@ -223,6 +231,9 @@ SelectionDisplay = (function () { var innerSnapAngle = 22.5; // the angle which we snap to on the inner rotation tool var innerRadius; var outerRadius; + var yawOffset = 0; + var pitchOffset = 0; + var rollOffset = 0; var yawHandleRotation; var pitchHandleRotation; var rollHandleRotation; @@ -326,6 +337,23 @@ SelectionDisplay = (function () { lineWidth: 1.0, }); + var rotationDegreesDisplay = Overlays.addOverlay("text3d", { + position: { x:0, y: 0, z: 0}, + text: "", + color: { red: 0, green: 0, blue: 0}, + backgroundColor: { red: 255, green: 255, blue: 255 }, + alpha: 0.7, + visible: false, + isFacingAvatar: true, + drawInFront: true, + dimensions: { x: 0, y: 0 }, + lineHeight: 0.0, + topMargin: 0, + rightMargin: 0, + bottomMargin: 0, + leftMargin: 0, + }); + var grabberMoveUp = Overlays.addOverlay("billboard", { url: HIFI_PUBLIC_BUCKET + "images/up-arrow.png", position: { x:0, y: 0, z: 0}, @@ -585,6 +613,7 @@ SelectionDisplay = (function () { rotateOverlayCurrent, rotateZeroOverlay, rotateCurrentOverlay, + rotationDegreesDisplay, xRailOverlay, yRailOverlay, zRailOverlay, @@ -757,6 +786,10 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 90, z: 0 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 0 }); + yawOffset = 90; + pitchOffset = 0; + rollOffset = 0; + yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -788,6 +821,10 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 90 }); + yawOffset = 0; + pitchOffset = 180; + rollOffset = 90; + yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -822,6 +859,10 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 90, y: 0, z: 90 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 }); + yawOffset = 180; + pitchOffset = 90; + rollOffset = 180; + yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -848,8 +889,12 @@ SelectionDisplay = (function () { } else { yawHandleRotation = Quat.fromVec3Degrees({ x: 270, y: 270, z: 0 }); - rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 }); pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 }); + rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 }); + + yawOffset = 270; + pitchOffset = 180; + rollOffset = 180; yawNormal = { x: 0, y: 1, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -1570,11 +1615,17 @@ SelectionDisplay = (function () { endAt: 0, innerRadius: 0.9, }); + + Overlays.editOverlay(rotationDegreesDisplay, { + visible: true, + ignoreRayIntersection: true, + }); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); Overlays.editOverlay(rotateOverlayOuter, { visible: false }); Overlays.editOverlay(rotateOverlayCurrent, { visible: false }); + Overlays.editOverlay(rotationDegreesDisplay, { visible: false }); pushCommandForSelections(); }, @@ -1605,12 +1656,9 @@ SelectionDisplay = (function () { var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); - var snapToInner = false; - // var innerRadius = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1; - if (distanceFromCenter < innerRadius) { - angleFromZero = Math.floor(angleFromZero/innerSnapAngle) * innerSnapAngle; - snapToInner = true; - } + var snapToInner = distanceFromCenter < innerRadius; + var snapAngle = snapToInner ? innerSnapAngle : 1.0; + angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle; // for debugging if (debug) { @@ -1632,7 +1680,20 @@ SelectionDisplay = (function () { rotation: Quat.multiply(yawChange, initialProperties.rotation), }); } - + + var angle = (yawOffset + angleFromZero + 180) * (Math.PI / 180); + var position = Vec3.sum( selectionManager.worldPosition, { + x: -Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + y: -selectionManager.worldDimensions.y / 2, + z: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + }); + Overlays.editOverlay(rotationDegreesDisplay, { + position: position, + dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, + lineHeight: innerRadius / 6, + text: normalizeDegrees(angleFromZero), + }); + // update the rotation display accordingly... var startAtCurrent = 0; var endAtCurrent = angleFromZero; @@ -1701,11 +1762,17 @@ SelectionDisplay = (function () { endAt: 0, innerRadius: 0.9, }); + + Overlays.editOverlay(rotationDegreesDisplay, { + visible: true, + ignoreRayIntersection: true, + }); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); Overlays.editOverlay(rotateOverlayOuter, { visible: false }); Overlays.editOverlay(rotateOverlayCurrent, { visible: false }); + Overlays.editOverlay(rotationDegreesDisplay, { visible: false }); pushCommandForSelections(); }, @@ -1736,11 +1803,9 @@ SelectionDisplay = (function () { var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); - var snapToInner = false; - if (distanceFromCenter < innerRadius) { - angleFromZero = Math.floor(angleFromZero/innerSnapAngle) * innerSnapAngle; - snapToInner = true; - } + var snapToInner = distanceFromCenter < innerRadius; + var snapAngle = snapToInner ? innerSnapAngle : 1.0; + angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle; // for debugging if (debug) { @@ -1764,6 +1829,19 @@ SelectionDisplay = (function () { }); } + var angle = (rollOffset + angleFromZero - 90) * (Math.PI / 180); + var position = Vec3.sum( selectionManager.worldPosition, { + x: selectionManager.worldDimensions.x / 2, + y: Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + z: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + }); + Overlays.editOverlay(rotationDegreesDisplay, { + position: position, + dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, + lineHeight: innerRadius / 6, + text: normalizeDegrees(angleFromZero), + }); + // update the rotation display accordingly... var startAtCurrent = 0; var endAtCurrent = angleFromZero; @@ -1831,11 +1909,17 @@ SelectionDisplay = (function () { endAt: 0, innerRadius: 0.9, }); + + Overlays.editOverlay(rotationDegreesDisplay, { + visible: true, + ignoreRayIntersection: true, + }); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); Overlays.editOverlay(rotateOverlayOuter, { visible: false }); Overlays.editOverlay(rotateOverlayCurrent, { visible: false }); + Overlays.editOverlay(rotationDegreesDisplay, { visible: false }); pushCommandForSelections(); }, @@ -1866,11 +1950,9 @@ SelectionDisplay = (function () { var angleFromZero = Vec3.orientedAngle(centerToZero, centerToIntersect, rotationNormal); var distanceFromCenter = Vec3.distance(center, result.intersection); - var snapToInner = false; - if (distanceFromCenter < innerRadius) { - angleFromZero = Math.floor(angleFromZero/innerSnapAngle) * innerSnapAngle; - snapToInner = true; - } + var snapToInner = distanceFromCenter < innerRadius; + var snapAngle = snapToInner ? innerSnapAngle : 1.0; + angleFromZero = Math.floor(angleFromZero / snapAngle) * snapAngle; // for debugging if (debug) { @@ -1893,6 +1975,19 @@ SelectionDisplay = (function () { }); } + var angle = (rollOffset + angleFromZero + 90) * (Math.PI / 180); + var position = Vec3.sum( selectionManager.worldPosition, { + x: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + y: -Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + z: -selectionManager.worldDimensions.z / 2, + }); + Overlays.editOverlay(rotationDegreesDisplay, { + position: position, + dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, + lineHeight: innerRadius / 6, + text: normalizeDegrees(angleFromZero), + }); + // update the rotation display accordingly... var startAtCurrent = 0; var endAtCurrent = angleFromZero; From 4f0683dc5ee9f45d02275e52c0540b19462e511c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 15:07:03 -0800 Subject: [PATCH 05/10] Fix stretch tools not following mouse correctly --- examples/libraries/entitySelectionTool.js | 76 ++++++++++++++--------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 2b3819aff1..ead424522a 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -1337,7 +1337,11 @@ SelectionDisplay = (function () { var vec3Mult = function(v1, v2) { return { x: v1.x * v2.x, y: v1.y * v2.y, z: v1.z * v2.z }; } - var makeStretchTool = function(stretchMode, direction, pivot) { + // stretchMode - name of mode + // direction - direction to stretch in + // pivot - point to use as a pivot + // offset - the position of the overlay tool relative to the selections center position + var makeStretchTool = function(stretchMode, direction, pivot, offset) { var signs = { x: direction.x < 0 ? -1 : (direction.x > 0 ? 1 : 0), y: direction.y < 0 ? -1 : (direction.y > 0 ? 1 : 0), @@ -1358,6 +1362,7 @@ SelectionDisplay = (function () { var initialDimensions = null; var initialIntersection = null; var initialProperties = null; + var pickRayPosition = null; var rotation = null; var onBegin = function(event) { @@ -1366,13 +1371,22 @@ SelectionDisplay = (function () { rotation = spaceMode == SPACE_LOCAL ? properties.rotation : Quat.fromPitchYawRollDegrees(0, 0, 0); if (spaceMode == SPACE_LOCAL) { + rotation = SelectionManager.localRotation; initialPosition = SelectionManager.localPosition; initialDimensions = SelectionManager.localDimensions; } else { + rotation = SelectionManager.worldRotation; initialPosition = SelectionManager.worldPosition; initialDimensions = SelectionManager.worldDimensions; } + var scaledOffset = { + x: initialDimensions.x * offset.x * 0.5, + y: initialDimensions.y * offset.y * 0.5, + z: initialDimensions.z * offset.z * 0.5, + }; + pickRayPosition = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffset)); + if (numDimensions == 1 && mask.x) { var start = Vec3.multiplyQbyV(rotation, { x: -10000, y: 0, z: 0 }); start = Vec3.sum(start, properties.position); @@ -1426,7 +1440,7 @@ SelectionDisplay = (function () { planeNormal = Vec3.multiplyQbyV(rotation, planeNormal); var pickRay = Camera.computePickRay(event.x, event.y); lastPick = rayPlaneIntersection(pickRay, - initialPosition, + pickRayPosition, planeNormal); // Overlays.editOverlay(normalLine, { @@ -1461,7 +1475,7 @@ SelectionDisplay = (function () { var pickRay = Camera.computePickRay(event.x, event.y); newPick = rayPlaneIntersection(pickRay, - initialPosition, + pickRayPosition, planeNormal); var vector = Vec3.subtract(newPick, lastPick); @@ -1536,44 +1550,44 @@ SelectionDisplay = (function () { }; }; - function addStretchTool(overlay, mode, pivot, direction) { + function addStretchTool(overlay, mode, pivot, direction, offset) { if (!pivot) { pivot = Vec3.multiply(-1, direction); pivot.y = direction.y; } - var tool = makeStretchTool(mode, direction, pivot); + var tool = makeStretchTool(mode, direction, pivot, offset); addGrabberTool(overlay, tool); } - addStretchTool(grabberNEAR, "STRETCH_NEAR", { x: 0, y: 0, z: -1 }, { x: 0, y: 0, z: 1 }); - addStretchTool(grabberFAR, "STRETCH_FAR", { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }); - addStretchTool(grabberTOP, "STRETCH_TOP", { x: 0, y: 1, z: 0 }, { x: 0, y: -1, z: 0 }); - addStretchTool(grabberBOTTOM, "STRETCH_BOTTOM", { x: 0, y: -1, z: 0 }, { x: 0, y: 1, z: 0 }); - addStretchTool(grabberRIGHT, "STRETCH_RIGHT", { x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }); - addStretchTool(grabberLEFT, "STRETCH_LEFT", { x: -1, y: 0, z: 0 }, { x: 1, y: 0, z: 0 }); + addStretchTool(grabberNEAR, "STRETCH_NEAR", { x: 0, y: 0, z: -1 }, { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }); + addStretchTool(grabberFAR, "STRETCH_FAR", { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }, { x: 0, y: 0, z: 1 }); + addStretchTool(grabberTOP, "STRETCH_TOP", { x: 0, y: 1, z: 0 }, { x: 0, y: -1, z: 0 }, { x: 0, y: 1, z: 0 }); + addStretchTool(grabberBOTTOM, "STRETCH_BOTTOM", { x: 0, y: -1, z: 0 }, { x: 0, y: 1, z: 0 }, { x: 0, y: -1, z: 0 }); + addStretchTool(grabberRIGHT, "STRETCH_RIGHT", { x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }, { x: 1, y: 0, z: 0 }); + addStretchTool(grabberLEFT, "STRETCH_LEFT", { x: -1, y: 0, z: 0 }, { x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }); - addStretchTool(grabberLBN, "STRETCH_LBN", null, {x: 1, y: 0, z: 1}); - addStretchTool(grabberRBN, "STRETCH_RBN", null, {x: -1, y: 0, z: 1}); - addStretchTool(grabberLBF, "STRETCH_LBF", null, {x: 1, y: 0, z: -1}); - addStretchTool(grabberRBF, "STRETCH_RBF", null, {x: -1, y: 0, z: -1}); - addStretchTool(grabberLTN, "STRETCH_LTN", null, {x: 1, y: 0, z: 1}); - addStretchTool(grabberRTN, "STRETCH_RTN", null, {x: -1, y: 0, z: 1}); - addStretchTool(grabberLTF, "STRETCH_LTF", null, {x: 1, y: 0, z: -1}); - addStretchTool(grabberRTF, "STRETCH_RTF", null, {x: -1, y: 0, z: -1}); + addStretchTool(grabberLBN, "STRETCH_LBN", null, {x: 1, y: 0, z: 1}, { x: -1, y: -1, z: -1 }); + addStretchTool(grabberRBN, "STRETCH_RBN", null, {x: -1, y: 0, z: 1}, { x: 1, y: -1, z: -1 }); + addStretchTool(grabberLBF, "STRETCH_LBF", null, {x: 1, y: 0, z: -1}, { x: -1, y: -1, z: 1 }); + addStretchTool(grabberRBF, "STRETCH_RBF", null, {x: -1, y: 0, z: -1}, { x: 1, y: -1, z: 1 }); + addStretchTool(grabberLTN, "STRETCH_LTN", null, {x: 1, y: 0, z: 1}, { x: -1, y: 1, z: -1 }); + addStretchTool(grabberRTN, "STRETCH_RTN", null, {x: -1, y: 0, z: 1}, { x: 1, y: 1, z: -1 }); + addStretchTool(grabberLTF, "STRETCH_LTF", null, {x: 1, y: 0, z: -1}, { x: -1, y: 1, z: 1 }); + addStretchTool(grabberRTF, "STRETCH_RTF", null, {x: -1, y: 0, z: -1}, { x: 1, y: 1, z: 1 }); - addStretchTool(grabberEdgeTR, "STRETCH_EdgeTR", null, {x: 1, y: 1, z: 0}); - addStretchTool(grabberEdgeTL, "STRETCH_EdgeTL", null, {x: -1, y: 1, z: 0}); - addStretchTool(grabberEdgeTF, "STRETCH_EdgeTF", null, {x: 0, y: 1, z: -1}); - addStretchTool(grabberEdgeTN, "STRETCH_EdgeTN", null, {x: 0, y: 1, z: 1}); - addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: -1, y: 0, z: 0}); - addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: 1, y: 0, z: 0}); - addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: 0, z: -1}); - addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: 0, z: 1}); - addStretchTool(grabberEdgeNR, "STRETCH_EdgeNR", null, {x: -1, y: 0, z: 1}); - addStretchTool(grabberEdgeNL, "STRETCH_EdgeNL", null, {x: 1, y: 0, z: 1}); - addStretchTool(grabberEdgeFR, "STRETCH_EdgeFR", null, {x: -1, y: 0, z: -1}); - addStretchTool(grabberEdgeFL, "STRETCH_EdgeFL", null, {x: 1, y: 0, z: -1}); + addStretchTool(grabberEdgeTR, "STRETCH_EdgeTR", null, {x: 1, y: 1, z: 0}, { x: 1, y: 1, z: 0 }); + addStretchTool(grabberEdgeTL, "STRETCH_EdgeTL", null, {x: -1, y: 1, z: 0}, { x: -1, y: 1, z: 0 }); + addStretchTool(grabberEdgeTF, "STRETCH_EdgeTF", null, {x: 0, y: 1, z: -1}, { x: 0, y: 1, z: -1 }); + addStretchTool(grabberEdgeTN, "STRETCH_EdgeTN", null, {x: 0, y: 1, z: 1}, { x: 0, y: 1, z: 1 }); + addStretchTool(grabberEdgeBR, "STRETCH_EdgeBR", null, {x: -1, y: 0, z: 0}, { x: 1, y: -1, z: 0 }); + addStretchTool(grabberEdgeBL, "STRETCH_EdgeBL", null, {x: 1, y: 0, z: 0}, { x: -1, y: -1, z: 0 }); + addStretchTool(grabberEdgeBF, "STRETCH_EdgeBF", null, {x: 0, y: 0, z: -1}, { x: 0, y: -1, z: -1 }); + addStretchTool(grabberEdgeBN, "STRETCH_EdgeBN", null, {x: 0, y: 0, z: 1}, { x: 0, y: -1, z: 1 }); + addStretchTool(grabberEdgeNR, "STRETCH_EdgeNR", null, {x: -1, y: 0, z: 1}, { x: 1, y: 0, z: -1 }); + addStretchTool(grabberEdgeNL, "STRETCH_EdgeNL", null, {x: 1, y: 0, z: 1}, { x: -1, y: 0, z: -1 }); + addStretchTool(grabberEdgeFR, "STRETCH_EdgeFR", null, {x: -1, y: 0, z: -1}, { x: 1, y: 0, z: 1 }); + addStretchTool(grabberEdgeFL, "STRETCH_EdgeFL", null, {x: 1, y: 0, z: -1}, { x: -1, y: 0, z: 1 }); var initialPosition = SelectionManager.worldPosition; addGrabberTool(yawHandle, { From 06ab17987bbd12e58c8457a8a5e4aedd8a12d33f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 16:08:50 -0800 Subject: [PATCH 06/10] Fix position of rotation degrees display The position of the display was not always correct depending on the camera orientation relative to the selection. --- examples/libraries/entitySelectionTool.js | 69 +++++++++++------------ 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index ead424522a..e37171c92a 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -213,7 +213,11 @@ SelectionDisplay = (function () { var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.0075; + // These are multipliers for sizing the rotation degrees display while rotating an entity var ROTATION_DISPLAY_DISTANCE_MULTIPLIER = 1.2; + var ROTATION_DISPLAY_SIZE_X_MULTIPLIER = 0.5; + var ROTATION_DISPLAY_SIZE_Y_MULTIPLIER = 0.18; + var ROTATION_DISPLAY_LINE_HEIGHT_MULTIPLIER = 0.17; var showExtendedStretchHandles = false; @@ -1589,6 +1593,26 @@ SelectionDisplay = (function () { addStretchTool(grabberEdgeFR, "STRETCH_EdgeFR", null, {x: -1, y: 0, z: -1}, { x: 1, y: 0, z: 1 }); addStretchTool(grabberEdgeFL, "STRETCH_EdgeFL", null, {x: 1, y: 0, z: -1}, { x: -1, y: 0, z: 1 }); + function updateRotationDegreesOverlay(angleFromZero, handleRotation, centerPosition) { + var angle = angleFromZero * (Math.PI / 180); + var position = { + x: Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + y: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, + z: 0, + }; + position = Vec3.multiplyQbyV(handleRotation, position); + position = Vec3.sum(centerPosition, position); + Overlays.editOverlay(rotationDegreesDisplay, { + position: position, + dimensions: { + x: innerRadius * ROTATION_DISPLAY_SIZE_X_MULTIPLIER, + y: innerRadius * ROTATION_DISPLAY_SIZE_Y_MULTIPLIER + }, + lineHeight: innerRadius * ROTATION_DISPLAY_LINE_HEIGHT_MULTIPLIER, + text: normalizeDegrees(angleFromZero), + }); + } + var initialPosition = SelectionManager.worldPosition; addGrabberTool(yawHandle, { mode: "ROTATE_YAW", @@ -1634,6 +1658,8 @@ SelectionDisplay = (function () { visible: true, ignoreRayIntersection: true, }); + + updateRotationDegreesOverlay(0, yawHandleRotation, yawCenter); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); @@ -1695,18 +1721,7 @@ SelectionDisplay = (function () { }); } - var angle = (yawOffset + angleFromZero + 180) * (Math.PI / 180); - var position = Vec3.sum( selectionManager.worldPosition, { - x: -Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - y: -selectionManager.worldDimensions.y / 2, - z: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - }); - Overlays.editOverlay(rotationDegreesDisplay, { - position: position, - dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, - lineHeight: innerRadius / 6, - text: normalizeDegrees(angleFromZero), - }); + updateRotationDegreesOverlay(angleFromZero, yawHandleRotation, yawCenter); // update the rotation display accordingly... var startAtCurrent = 0; @@ -1781,6 +1796,8 @@ SelectionDisplay = (function () { visible: true, ignoreRayIntersection: true, }); + + updateRotationDegreesOverlay(0, pitchHandleRotation, pitchCenter); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); @@ -1843,18 +1860,7 @@ SelectionDisplay = (function () { }); } - var angle = (rollOffset + angleFromZero - 90) * (Math.PI / 180); - var position = Vec3.sum( selectionManager.worldPosition, { - x: selectionManager.worldDimensions.x / 2, - y: Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - z: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - }); - Overlays.editOverlay(rotationDegreesDisplay, { - position: position, - dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, - lineHeight: innerRadius / 6, - text: normalizeDegrees(angleFromZero), - }); + updateRotationDegreesOverlay(angleFromZero, pitchHandleRotation, pitchCenter); // update the rotation display accordingly... var startAtCurrent = 0; @@ -1928,6 +1934,8 @@ SelectionDisplay = (function () { visible: true, ignoreRayIntersection: true, }); + + updateRotationDegreesOverlay(0, rollHandleRotation, rollCenter); }, onEnd: function(event, reason) { Overlays.editOverlay(rotateOverlayInner, { visible: false }); @@ -1989,18 +1997,7 @@ SelectionDisplay = (function () { }); } - var angle = (rollOffset + angleFromZero + 90) * (Math.PI / 180); - var position = Vec3.sum( selectionManager.worldPosition, { - x: Math.sin(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - y: -Math.cos(angle) * outerRadius * ROTATION_DISPLAY_DISTANCE_MULTIPLIER, - z: -selectionManager.worldDimensions.z / 2, - }); - Overlays.editOverlay(rotationDegreesDisplay, { - position: position, - dimensions: { x: innerRadius / 2, y: innerRadius / 5.6 }, - lineHeight: innerRadius / 6, - text: normalizeDegrees(angleFromZero), - }); + updateRotationDegreesOverlay(angleFromZero, rollHandleRotation, rollCenter); // update the rotation display accordingly... var startAtCurrent = 0; From ce4d4073789da913e19eefe32f4e1d3ea2b2e027 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 16:12:18 -0800 Subject: [PATCH 07/10] Update normalizeDegrees to be exclusive on the -180 end --- examples/libraries/entitySelectionTool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index e37171c92a..478782c6ec 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -200,9 +200,10 @@ SelectionManager = (function() { return that; })(); +// Normalize degrees to be in the range (-180, 180] function normalizeDegrees(degrees) { while (degrees > 180) degrees -= 360; - while (degrees < -180) degrees += 360; + while (degrees <= -180) degrees += 360; return degrees; } From 0b7ddb009dca37a3433def60898fbb9347cbc73a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 16:33:51 -0800 Subject: [PATCH 08/10] Fix tabification of tool windows --- interface/src/ui/ToolWindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interface/src/ui/ToolWindow.cpp b/interface/src/ui/ToolWindow.cpp index 799402a486..da1d2c68f4 100644 --- a/interface/src/ui/ToolWindow.cpp +++ b/interface/src/ui/ToolWindow.cpp @@ -100,8 +100,17 @@ void ToolWindow::onChildVisibilityUpdated(bool visible) { } void ToolWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget* dockWidget) { + QList dockWidgets = findChildren(); + QMainWindow::addDockWidget(area, dockWidget); + // We want to force tabbing, so retabify all of our widgets. + QDockWidget* lastDockWidget = dockWidget; + foreach (QDockWidget* nextDockWidget, dockWidgets) { + tabifyDockWidget(lastDockWidget, nextDockWidget); + lastDockWidget = nextDockWidget; + } + connect(dockWidget, &QDockWidget::visibilityChanged, this, &ToolWindow::onChildVisibilityUpdated); } From a8eb49a8226c5ae6a4acf550a5fe37818620369d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 16:38:40 -0800 Subject: [PATCH 09/10] Remove now-unused *Offset variables --- examples/libraries/entitySelectionTool.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 478782c6ec..5544fec84d 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -236,9 +236,6 @@ SelectionDisplay = (function () { var innerSnapAngle = 22.5; // the angle which we snap to on the inner rotation tool var innerRadius; var outerRadius; - var yawOffset = 0; - var pitchOffset = 0; - var rollOffset = 0; var yawHandleRotation; var pitchHandleRotation; var rollHandleRotation; @@ -791,10 +788,6 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 90, z: 0 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 0 }); - yawOffset = 90; - pitchOffset = 0; - rollOffset = 0; - yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -826,10 +819,6 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 90 }); - yawOffset = 0; - pitchOffset = 180; - rollOffset = 90; - yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -864,10 +853,6 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 90, y: 0, z: 90 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 }); - yawOffset = 180; - pitchOffset = 90; - rollOffset = 180; - yawNormal = { x: 0, y: 1, z: 0 }; pitchNormal = { x: 1, y: 0, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; @@ -897,10 +882,6 @@ SelectionDisplay = (function () { pitchHandleRotation = Quat.fromVec3Degrees({ x: 180, y: 270, z: 0 }); rollHandleRotation = Quat.fromVec3Degrees({ x: 0, y: 0, z: 180 }); - yawOffset = 270; - pitchOffset = 180; - rollOffset = 180; - yawNormal = { x: 0, y: 1, z: 0 }; rollNormal = { x: 0, y: 0, z: 1 }; pitchNormal = { x: 1, y: 0, z: 0 }; From 9d9a7ead5b8f73dcfe6e306aac220bbb7bfb2a6a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 1 Dec 2014 16:39:36 -0800 Subject: [PATCH 10/10] Remove unnecessary overlay property updates --- examples/libraries/entitySelectionTool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 5544fec84d..1a43231f6f 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -348,6 +348,7 @@ SelectionDisplay = (function () { visible: false, isFacingAvatar: true, drawInFront: true, + ignoreRayIntersection: true, dimensions: { x: 0, y: 0 }, lineHeight: 0.0, topMargin: 0, @@ -1638,7 +1639,6 @@ SelectionDisplay = (function () { Overlays.editOverlay(rotationDegreesDisplay, { visible: true, - ignoreRayIntersection: true, }); updateRotationDegreesOverlay(0, yawHandleRotation, yawCenter); @@ -1776,7 +1776,6 @@ SelectionDisplay = (function () { Overlays.editOverlay(rotationDegreesDisplay, { visible: true, - ignoreRayIntersection: true, }); updateRotationDegreesOverlay(0, pitchHandleRotation, pitchCenter); @@ -1914,7 +1913,6 @@ SelectionDisplay = (function () { Overlays.editOverlay(rotationDegreesDisplay, { visible: true, - ignoreRayIntersection: true, }); updateRotationDegreesOverlay(0, rollHandleRotation, rollCenter);