From 8120700787b354ed4bfba0993c6d4ca988a8d9e6 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:03:11 +0200 Subject: [PATCH 01/30] Added urlGoTo --- interface/src/Application.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1fabca3711..a7a00bf7c7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -356,6 +356,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } + //When -url in command line, teleport to location + urlGoTo(argc, constArgv); } Application::~Application() { @@ -3548,3 +3550,40 @@ void Application::takeSnapshot() { Snapshot::saveSnapshot(_glWidget, _myAvatar); } + +void Application::urlGoTo(int argc, const char * constArgv[]) { + //Gets the url (hifi://domain/destination/orientation) + QString customUrl = getCmdOption(argc, constArgv, "-url"); + + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; + + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; + + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); + + Menu::goToDomain(domain); + + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); + + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); + } + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + Menu::goTo(destination); + } + + } +} From d55fb60862a1fdc237a20db3d2a942fba50e6be4 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:03:33 +0200 Subject: [PATCH 02/30] Added urlGoTo --- interface/src/Application.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/Application.h b/interface/src/Application.h index 6a14788caa..de5f1fe113 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -509,6 +509,7 @@ private: void displayUpdateDialog(); bool shouldSkipVersion(QString latestVersion); void takeSnapshot(); + void urlGoTo(int argc, const char * constArgv[]); TouchEvent _lastTouchEvent; From b3ce36f1309140f9cf4e84c113bff670d0455b39 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:04:27 +0200 Subject: [PATCH 03/30] Changed goTo's to statics --- interface/src/Menu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 40ed8efdc7..c2aac5672b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -135,10 +135,10 @@ public: void removeAction(QMenu* menu, const QString& actionName); - bool goToDestination(QString destination); - void goToOrientation(QString orientation); - void goToDomain(const QString newDomain); - void goTo(QString destination); + bool static goToDestination(QString destination); + void static goToOrientation(QString orientation); + void static goToDomain(const QString newDomain); + void static goTo(QString destination); public slots: From fca4e2abba27f4676fe7bdacbb6c1531763444c8 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:09:58 +0200 Subject: [PATCH 04/30] Update Application.h --- interface/src/Application.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index de5f1fe113..a09483a1ba 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -128,6 +128,7 @@ public: void initializeGL(); void paintGL(); void resizeGL(int width, int height); + void urlGoTo(int argc, const char * constArgv[]); void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); @@ -509,7 +510,6 @@ private: void displayUpdateDialog(); bool shouldSkipVersion(QString latestVersion); void takeSnapshot(); - void urlGoTo(int argc, const char * constArgv[]); TouchEvent _lastTouchEvent; From 1c89d8f3edc33502bcb043b748ede938be41801c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 16 Apr 2014 17:33:15 -0700 Subject: [PATCH 05/30] editVoxels reformat --- examples/editVoxels.js | 510 ++++++++++++++++++++--------------------- 1 file changed, 255 insertions(+), 255 deletions(-) diff --git a/examples/editVoxels.js b/examples/editVoxels.js index 059b4186a3..030436cbc3 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -8,10 +8,10 @@ // Captures mouse clicks and edits voxels accordingly. // // click = create a new voxel on this face, same color as old (default color picker state) -// right click or control + click = delete this voxel +// right click or control + click = delete this voxel // shift + click = recolor this voxel // 1 - 8 = pick new color from palette -// 9 = create a new voxel in front of the camera +// 9 = create a new voxel in front of the camera // // Click and drag to create more new voxels in the same direction // @@ -36,7 +36,7 @@ var zFightingSizeAdjust = 0.002; // used to adjust preview voxels to prevent z f var previewLineWidth = 1.5; var inspectJsIsRunning = false; -var isAdding = false; +var isAdding = false; var isExtruding = false; var extrudeDirection = { x: 0, y: 0, z: 0 }; var extrudeScale = 0.0; @@ -48,7 +48,7 @@ var wheelPixelsMoved = 0; var mouseX = 0; -var mouseY = 0; +var mouseY = 0; // Create a table of the different colors you can choose var colors = new Array(); @@ -154,53 +154,53 @@ var editToolsOn = true; // starts out off // previewAsVoxel - by default, we will preview adds/deletes/recolors as just 4 lines on the intersecting face. But if you // the preview to show a full voxel then set this to true and the voxel will be displayed for voxel editing -var previewAsVoxel = false; +var previewAsVoxel = false; var voxelPreview = Overlays.addOverlay("cube", { - position: { x: 0, y: 0, z: 0}, - size: 1, - color: { red: 255, green: 0, blue: 0}, - alpha: 1, - solid: false, - visible: false, - lineWidth: 4 - }); - + position: { x: 0, y: 0, z: 0}, + size: 1, + color: { red: 255, green: 0, blue: 0}, + alpha: 1, + solid: false, + visible: false, + lineWidth: 4 + }); + var linePreviewTop = Overlays.addOverlay("line3d", { - position: { x: 0, y: 0, z: 0}, - end: { x: 0, y: 0, z: 0}, - color: { red: 255, green: 255, blue: 255}, - alpha: 1, - visible: false, - lineWidth: previewLineWidth - }); + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 255, green: 255, blue: 255}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); var linePreviewBottom = Overlays.addOverlay("line3d", { - position: { x: 0, y: 0, z: 0}, - end: { x: 0, y: 0, z: 0}, - color: { red: 255, green: 255, blue: 255}, - alpha: 1, - visible: false, - lineWidth: previewLineWidth - }); + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 255, green: 255, blue: 255}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); var linePreviewLeft = Overlays.addOverlay("line3d", { - position: { x: 0, y: 0, z: 0}, - end: { x: 0, y: 0, z: 0}, - color: { red: 255, green: 255, blue: 255}, - alpha: 1, - visible: false, - lineWidth: previewLineWidth - }); + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 255, green: 255, blue: 255}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); var linePreviewRight = Overlays.addOverlay("line3d", { - position: { x: 0, y: 0, z: 0}, - end: { x: 0, y: 0, z: 0}, - color: { red: 255, green: 255, blue: 255}, - alpha: 1, - visible: false, - lineWidth: previewLineWidth - }); + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 255, green: 255, blue: 255}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); // these will be used below @@ -221,33 +221,33 @@ var toolIconUrl = "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/ // create the overlays, position them in a row, set their colors, and for the selected one, use a different source image // location so that it displays the "selected" marker for (s = 0; s < numColors; s++) { - + var extraWidth = 0; - + if (s == 0) { extraWidth = swatchExtraPadding; } - + var imageFromX = swatchExtraPadding - extraWidth + s * swatchWidth; var imageFromY = swatchHeight + 1; - + var swatchX = swatchExtraPadding - extraWidth + swatchesX + ((swatchWidth - 1) * s); - + if (s == (numColors - 1)) { extraWidth = swatchExtraPadding; } - + swatches[s] = Overlays.addOverlay("image", { - x: swatchX, - y: swatchesY, - width: swatchWidth + extraWidth, - height: swatchHeight, - subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight }, - imageURL: toolIconUrl + "swatches.svg", - color: colors[s], - alpha: 1, - visible: editToolsOn - }); + x: swatchX, + y: swatchesY, + width: swatchWidth + extraWidth, + height: swatchHeight, + subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight }, + imageURL: toolIconUrl + "swatches.svg", + color: colors[s], + alpha: 1, + visible: editToolsOn + }); } @@ -267,29 +267,29 @@ var eyedropperToolAt = 2; var pasteModeColor = { red: 132, green: 61, blue: 255 }; var voxelTool = Overlays.addOverlay("image", { - x: 0, y: 0, width: toolWidth, height: toolHeight, - subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, - imageURL: toolIconUrl + "voxel-tool.svg", - visible: false, - alpha: 0.9 - }); + x: 0, y: 0, width: toolWidth, height: toolHeight, + subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, + imageURL: toolIconUrl + "voxel-tool.svg", + visible: false, + alpha: 0.9 + }); var recolorTool = Overlays.addOverlay("image", { - x: 0, y: 0, width: toolWidth, height: toolHeight, - subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, - imageURL: toolIconUrl + "paint-tool.svg", - visible: false, - alpha: 0.9 - }); + x: 0, y: 0, width: toolWidth, height: toolHeight, + subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, + imageURL: toolIconUrl + "paint-tool.svg", + visible: false, + alpha: 0.9 + }); var eyedropperTool = Overlays.addOverlay("image", { - x: 0, y: 0, width: toolWidth, height: toolHeight, - subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, - imageURL: toolIconUrl + "eyedropper-tool.svg", - visible: false, - alpha: 0.9 - }); - + x: 0, y: 0, width: toolWidth, height: toolHeight, + subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, + imageURL: toolIconUrl + "eyedropper-tool.svg", + visible: false, + alpha: 0.9 + }); + // This will create a couple of image overlays that make a "slider", we will demonstrate how to trap mouse messages to // move the slider @@ -301,12 +301,12 @@ var sliderOffsetX = 17; var sliderX = swatchesX - swatchWidth - sliderOffsetX; var sliderY = windowDimensions.y - sliderHeight + 1; var slider = Overlays.addOverlay("image", { - // alternate form of expressing bounds - bounds: { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight}, - imageURL: toolIconUrl + "voxel-size-slider-bg.svg", - alpha: 1, - visible: false - }); + // alternate form of expressing bounds + bounds: { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight}, + imageURL: toolIconUrl + "voxel-size-slider-bg.svg", + alpha: 1, + visible: false + }); // The slider is handled in the mouse event callbacks. var isMovingSlider = false; @@ -320,14 +320,14 @@ var thumbX = (minThumbX + maxThumbX) / 2; var thumbOffsetY = 11; var thumbY = sliderY + thumbOffsetY; var thumb = Overlays.addOverlay("image", { - x: sliderX + thumbX, - y: thumbY, - width: 17, - height: 17, - imageURL: toolIconUrl + "voxel-size-slider-handle.svg", - alpha: 1, - visible: false - }); + x: sliderX + thumbX, + y: thumbY, + width: 17, + height: 17, + imageURL: toolIconUrl + "voxel-size-slider-handle.svg", + alpha: 1, + visible: false + }); var pointerVoxelScale = Math.floor(MAX_VOXEL_SCALE + MIN_VOXEL_SCALE) / 2; // this is the voxel scale used for click to add or delete var pointerVoxelScaleSet = false; // if voxel scale has not yet been set, we use the intersection size @@ -377,7 +377,7 @@ function importVoxels() { } else { isImporting = false; } - + return isImporting; } @@ -471,13 +471,13 @@ function calcScaleFromThumb(newThumbX) { thumbAt = newThumbX - minThumbX; thumbStep = Math.floor((thumbAt/ thumbExtents) * (pointerVoxelScaleSteps-1)) + 1; pointerVoxelScale = Math.pow(2, (thumbStep-pointerVoxelScaleOriginStep)); - + // if importing, rescale import ... if (isImporting) { var importScale = (pointerVoxelScale / MAX_VOXEL_SCALE) * MAX_PASTE_VOXEL_SCALE; rescaleImport(importScale); } - + // now reset the display accordingly... calcThumbFromScale(pointerVoxelScale); @@ -492,18 +492,18 @@ function setAudioPosition() { } function getNewPasteVoxel(pickRay) { - + var voxelSize = MIN_PASTE_VOXEL_SCALE + (MAX_PASTE_VOXEL_SCALE - MIN_PASTE_VOXEL_SCALE) * pointerVoxelScale - 1; var origin = { x: pickRay.direction.x, y: pickRay.direction.y, z: pickRay.direction.z }; - + origin.x += pickRay.origin.x; origin.y += pickRay.origin.y; origin.z += pickRay.origin.z; - + origin.x -= voxelSize / 2; origin.y -= voxelSize / 2; origin.z += voxelSize / 2; - + return {origin: origin, voxelSize: voxelSize}; } @@ -529,26 +529,26 @@ var pasteMode = false; function calculateVoxelFromIntersection(intersection, operation) { //print("calculateVoxelFromIntersection() operation="+operation); var resultVoxel; - + var wantDebug = false; if (wantDebug) { - print(">>>>> calculateVoxelFromIntersection().... intersection voxel.red/green/blue=" + intersection.voxel.red + ", " - + intersection.voxel.green + ", " + intersection.voxel.blue); - print(" intersection voxel.x/y/z/s=" + intersection.voxel.x + ", " - + intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s); + print(">>>>> calculateVoxelFromIntersection().... intersection voxel.red/green/blue=" + intersection.voxel.red + ", " + + intersection.voxel.green + ", " + intersection.voxel.blue); + print(" intersection voxel.x/y/z/s=" + intersection.voxel.x + ", " + + intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s); print(" intersection face=" + intersection.face); print(" intersection distance=" + intersection.distance); - print(" intersection intersection.x/y/z=" + intersection.intersection.x + ", " - + intersection.intersection.y + ", " + intersection.intersection.z); + print(" intersection intersection.x/y/z=" + intersection.intersection.x + ", " + + intersection.intersection.y + ", " + intersection.intersection.z); } var voxelSize; if (pointerVoxelScaleSet) { - voxelSize = pointerVoxelScale; + voxelSize = pointerVoxelScale; } else { - voxelSize = intersection.voxel.s; + voxelSize = intersection.voxel.s; } - + var x; var y; var z; @@ -578,17 +578,17 @@ function calculateVoxelFromIntersection(intersection, operation) { } resultVoxel = { x: x, y: y, z: z, s: voxelSize }; highlightAt = { x: x, y: y, z: z, s: voxelSize }; - + // we only do the "add to the face we're pointing at" adjustment, if the operation is an add // operation, and the target voxel size is equal to or smaller than the intersecting voxel. var wantAddAdjust = (operation == "add" && (voxelSize <= intersection.voxel.s)); if (wantDebug) { print("wantAddAdjust="+wantAddAdjust); } - + // now we also want to calculate the "edge square" for the face for this voxel if (intersection.face == "MIN_X_FACE") { - + highlightAt.x = x - zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.x -= voxelSize; @@ -598,21 +598,21 @@ function calculateVoxelFromIntersection(intersection, operation) { resultVoxel.bottomRight = {x: highlightAt.x, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; resultVoxel.topLeft = {x: highlightAt.x, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z + zFightingSizeAdjust }; resultVoxel.topRight = {x: highlightAt.x, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; - + } else if (intersection.face == "MAX_X_FACE") { - + highlightAt.x = x + voxelSize + zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.x += resultVoxel.s; } - + resultVoxel.bottomRight = {x: highlightAt.x, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z + zFightingSizeAdjust }; resultVoxel.bottomLeft = {x: highlightAt.x, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; resultVoxel.topRight = {x: highlightAt.x, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z + zFightingSizeAdjust }; resultVoxel.topLeft = {x: highlightAt.x, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; - + } else if (intersection.face == "MIN_Y_FACE") { - + highlightAt.y = y - zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.y -= voxelSize; @@ -622,9 +622,9 @@ function calculateVoxelFromIntersection(intersection, operation) { resultVoxel.topLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y, z: highlightAt.z + zFightingSizeAdjust }; resultVoxel.bottomRight = {x: highlightAt.x + zFightingSizeAdjust , y: highlightAt.y, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; resultVoxel.bottomLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust , y: highlightAt.y, z: highlightAt.z + voxelSize - zFightingSizeAdjust }; - + } else if (intersection.face == "MAX_Y_FACE") { - + highlightAt.y = y + voxelSize + zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.y += voxelSize; @@ -634,9 +634,9 @@ function calculateVoxelFromIntersection(intersection, operation) { resultVoxel.bottomLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y, z: highlightAt.z + zFightingSizeAdjust}; resultVoxel.topRight = {x: highlightAt.x + zFightingSizeAdjust, y: highlightAt.y, z: highlightAt.z + voxelSize - zFightingSizeAdjust}; resultVoxel.topLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y, z: highlightAt.z + voxelSize - zFightingSizeAdjust}; - + } else if (intersection.face == "MIN_Z_FACE") { - + highlightAt.z = z - zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.z -= voxelSize; @@ -646,19 +646,19 @@ function calculateVoxelFromIntersection(intersection, operation) { resultVoxel.bottomLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z}; resultVoxel.topRight = {x: highlightAt.x + zFightingSizeAdjust, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z }; resultVoxel.topLeft = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z}; - + } else if (intersection.face == "MAX_Z_FACE") { - + highlightAt.z = z + voxelSize + zFightingSizeAdjust; if (wantAddAdjust) { resultVoxel.z += voxelSize; } - + resultVoxel.bottomLeft = {x: highlightAt.x + zFightingSizeAdjust, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z }; resultVoxel.bottomRight = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y + zFightingSizeAdjust, z: highlightAt.z}; resultVoxel.topLeft = {x: highlightAt.x + zFightingSizeAdjust, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z }; resultVoxel.topRight = {x: highlightAt.x + voxelSize - zFightingSizeAdjust, y: highlightAt.y + voxelSize - zFightingSizeAdjust, z: highlightAt.z}; - + } return resultVoxel; @@ -666,26 +666,26 @@ function calculateVoxelFromIntersection(intersection, operation) { function showPreviewVoxel() { var voxelColor; - + var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY); var intersection = Voxels.findRayIntersection(pickRay); - - // if the user hasn't updated the + + // if the user hasn't updated the if (!pointerVoxelScaleSet) { calcThumbFromScale(intersection.voxel.s); } - + if (whichColor == -1) { // Copy mode - use clicked voxel color voxelColor = { red: intersection.voxel.red, - green: intersection.voxel.green, - blue: intersection.voxel.blue }; + green: intersection.voxel.green, + blue: intersection.voxel.blue }; } else { voxelColor = { red: colors[whichColor].red, - green: colors[whichColor].green, - blue: colors[whichColor].blue }; + green: colors[whichColor].green, + blue: colors[whichColor].blue }; } - + var guidePosition; if (trackAsRecolor || recolorToolSelected || trackAsEyedropper || eyedropperToolSelected) { Overlays.editOverlay(voxelPreview, { visible: true }); @@ -697,49 +697,49 @@ function showPreviewVoxel() { } function showPreviewLines() { - + var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY); - + if (pasteMode) { // free voxel pasting - + Overlays.editOverlay(voxelPreview, { visible: false }); Overlays.editOverlay(linePreviewLeft, { visible: false }); - + var pasteVoxel = getNewPasteVoxel(pickRay); - + // X axis Overlays.editOverlay(linePreviewBottom, { - position: pasteVoxel.origin, - end: {x: pasteVoxel.origin.x + pasteVoxel.voxelSize, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z }, - visible: true - }); - + position: pasteVoxel.origin, + end: {x: pasteVoxel.origin.x + pasteVoxel.voxelSize, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z }, + visible: true + }); + // Y axis Overlays.editOverlay(linePreviewRight, { - position: pasteVoxel.origin, - end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y + pasteVoxel.voxelSize, z: pasteVoxel.origin.z }, - visible: true - }); - + position: pasteVoxel.origin, + end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y + pasteVoxel.voxelSize, z: pasteVoxel.origin.z }, + visible: true + }); + // Z axis Overlays.editOverlay(linePreviewTop, { - position: pasteVoxel.origin, - end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z - pasteVoxel.voxelSize }, - visible: true - }); - + position: pasteVoxel.origin, + end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z - pasteVoxel.voxelSize }, + visible: true + }); + return; } - + var intersection = Voxels.findRayIntersection(pickRay); if (intersection.intersects) { - - // if the user hasn't updated the + + // if the user hasn't updated the if (!pointerVoxelScaleSet) { calcThumbFromScale(intersection.voxel.s); } - + resultVoxel = calculateVoxelFromIntersection(intersection,""); Overlays.editOverlay(voxelPreview, { visible: false }); Overlays.editOverlay(linePreviewTop, { position: resultVoxel.topLeft, end: resultVoxel.topRight, visible: true }); @@ -759,7 +759,7 @@ function showPreviewGuides() { if (editToolsOn) { if (previewAsVoxel) { showPreviewVoxel(); - + // make sure alternative is hidden Overlays.editOverlay(linePreviewTop, { visible: false }); Overlays.editOverlay(linePreviewBottom, { visible: false }); @@ -791,7 +791,7 @@ function trackKeyPressEvent(event) { if (!editToolsOn) { return; } - + if (event.text == "CONTROL") { trackAsDelete = true; moveTools(); @@ -819,11 +819,11 @@ function trackKeyReleaseEvent(event) { showPreviewGuides(); scriptInitSound.playRandom(); } - + if (event.text == "ALT") { inspectJsIsRunning = false; } - + if (editToolsOn) { if (event.text == "ESC") { pointerVoxelScaleSet = false; @@ -855,15 +855,15 @@ function trackKeyReleaseEvent(event) { if (event.text == "F1") { previewAsVoxel = !previewAsVoxel; } - + showPreviewGuides(); - } + } } function mousePressEvent(event) { // if our tools are off, then don't do anything if (!editToolsOn) { - return; + return; } if (inspectJsIsRunning) { return; @@ -878,7 +878,7 @@ function mousePressEvent(event) { thumbClickOffsetX = event.x - (sliderX + thumbX); // this should be the position of the mouse relative to the thumb clickedOnSomething = true; - Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", }); + //Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", }); } else if (clickedOverlay == voxelTool) { modeSwitchSound.play(0); @@ -930,7 +930,7 @@ function mousePressEvent(event) { if (clickedOnSomething) { return; // no further processing } - + // TODO: does any of this stuff need to execute if we're panning or orbiting? trackMouseEvent(event); // used by preview support mouseX = event.x; @@ -938,7 +938,7 @@ function mousePressEvent(event) { var pickRay = Camera.computePickRay(event.x, event.y); var intersection = Voxels.findRayIntersection(pickRay); audioOptions.position = Vec3.sum(pickRay.origin, pickRay.direction); - + if (isImporting) { print("placing import..."); placeImport(); @@ -946,7 +946,7 @@ function mousePressEvent(event) { moveTools(); return; } - + if (pasteMode) { var pasteVoxel = getNewPasteVoxel(pickRay); Clipboard.pasteVoxel(pasteVoxel.origin.x, pasteVoxel.origin.y, pasteVoxel.origin.z, pasteVoxel.voxelSize); @@ -954,9 +954,9 @@ function mousePressEvent(event) { moveTools(); return; } - + if (intersection.intersects) { - // if the user hasn't updated the + // if the user hasn't updated the if (!pointerVoxelScaleSet) { calcThumbFromScale(intersection.voxel.s); } @@ -979,9 +979,9 @@ function mousePressEvent(event) { } else if (recolorToolSelected || trackAsRecolor) { // Recolor Voxel voxelDetails = calculateVoxelFromIntersection(intersection,"recolor"); - + // doing this erase then set will make sure we only recolor just the target voxel - Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s, + Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s, colors[whichColor].red, colors[whichColor].green, colors[whichColor].blue); swatchesSound.play(whichColor); Overlays.editOverlay(voxelPreview, { visible: false }); @@ -989,30 +989,30 @@ function mousePressEvent(event) { // Add voxel on face if (whichColor == -1) { // Copy mode - use clicked voxel color - newColor = { - red: intersection.voxel.red, - green: intersection.voxel.green, + newColor = { + red: intersection.voxel.red, + green: intersection.voxel.green, blue: intersection.voxel.blue }; } else { - newColor = { - red: colors[whichColor].red, - green: colors[whichColor].green, + newColor = { + red: colors[whichColor].red, + green: colors[whichColor].green, blue: colors[whichColor].blue }; } - + voxelDetails = calculateVoxelFromIntersection(intersection,"add"); Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s, - newColor.red, newColor.green, newColor.blue); + newColor.red, newColor.green, newColor.blue); lastVoxelPosition = { x: voxelDetails.x, y: voxelDetails.y, z: voxelDetails.z }; lastVoxelColor = { red: newColor.red, green: newColor.green, blue: newColor.blue }; lastVoxelScale = voxelDetails.s; - + addVoxelSound.playRandom(); Overlays.editOverlay(voxelPreview, { visible: false }); dragStart = { x: event.x, y: event.y }; isAdding = true; - } + } } } @@ -1031,18 +1031,18 @@ function keyPressEvent(event) { swatchesSound.play(whichColor); moveTools(); } else if (event.text == "0") { - // Create a brand new 1 meter voxel in front of your avatar - var color = whichColor; + // Create a brand new 1 meter voxel in front of your avatar + var color = whichColor; if (color == -1) color = 0; var newPosition = getNewVoxelPosition(); - var newVoxel = { - x: newPosition.x, - y: newPosition.y , - z: newPosition.z, - s: NEW_VOXEL_SIZE, - red: colors[color].red, - green: colors[color].green, - blue: colors[color].blue }; + var newVoxel = { + x: newPosition.x, + y: newPosition.y , + z: newPosition.z, + s: NEW_VOXEL_SIZE, + red: colors[color].red, + green: colors[color].green, + blue: colors[color].blue }; Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s); Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue); setAudioPosition(); @@ -1064,7 +1064,7 @@ function keyReleaseEvent(event) { function setupMenus() { // hook up menus Menu.menuItemEvent.connect(menuItemEvent); - + // add our menuitems Menu.addMenuItem({ menuName: "Edit", menuItemName: "Voxels", isSeparator: true, beforeItem: "Physics" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Cut", shortcutKey: "CTRL+X", afterItem: "Voxels" }); @@ -1072,7 +1072,7 @@ function setupMenus() { Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste", shortcutKey: "CTRL+V", afterItem: "Copy" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Nudge", shortcutKey: "CTRL+N", afterItem: "Paste" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Delete", shortcutKeyEvent: { text: "backspace" }, afterItem: "Nudge" }); - + Menu.addMenuItem({ menuName: "File", menuItemName: "Voxels", isSeparator: true, beforeItem: "Settings" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Export Voxels", shortcutKey: "CTRL+E", afterItem: "Voxels" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Import Voxels", shortcutKey: "CTRL+I", afterItem: "Export Voxels" }); @@ -1092,10 +1092,10 @@ function cleanupMenus() { } function menuItemEvent(menuItem) { - + // handle clipboard items if (editToolsOn) { - + var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY); var intersection = Voxels.findRayIntersection(pickRay); selectedVoxel = calculateVoxelFromIntersection(intersection,"select"); @@ -1131,7 +1131,7 @@ function menuItemEvent(menuItem) { Clipboard.deleteVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s); } } - + if (menuItem == "Export Voxels") { print("export"); Clipboard.exportVoxel(selectedVoxel.x, selectedVoxel.y, selectedVoxel.z, selectedVoxel.s); @@ -1172,9 +1172,9 @@ function mouseMoveEvent(event) { // Watch the drag direction to tell which way to 'extrude' this voxel if (!isExtruding) { var pickRay = Camera.computePickRay(event.x, event.y); - var lastVoxelDistance = { x: pickRay.origin.x - lastVoxelPosition.x, - y: pickRay.origin.y - lastVoxelPosition.y, - z: pickRay.origin.z - lastVoxelPosition.z }; + var lastVoxelDistance = { x: pickRay.origin.x - lastVoxelPosition.x, + y: pickRay.origin.y - lastVoxelPosition.y, + z: pickRay.origin.z - lastVoxelPosition.z }; var distance = Vec3.length(lastVoxelDistance); var mouseSpot = { x: pickRay.direction.x * distance, y: pickRay.direction.y * distance, z: pickRay.direction.z * distance }; mouseSpot.x += pickRay.origin.x; @@ -1192,15 +1192,15 @@ function mouseMoveEvent(event) { else if (dy < -lastVoxelScale) extrudeDirection.y = -extrudeScale; else if (dz > lastVoxelScale) extrudeDirection.z = extrudeScale; else if (dz < -lastVoxelScale) extrudeDirection.z = -extrudeScale; - else isExtruding = false; + else isExtruding = false; } else { // We have got an extrusion direction, now look for mouse move beyond threshold to add new voxel - var dx = event.x - mouseX; + var dx = event.x - mouseX; var dy = event.y - mouseY; if (Math.sqrt(dx*dx + dy*dy) > PIXELS_PER_EXTRUDE_VOXEL) { lastVoxelPosition = Vec3.sum(lastVoxelPosition, extrudeDirection); - Voxels.setVoxel(lastVoxelPosition.x, lastVoxelPosition.y, lastVoxelPosition.z, - extrudeScale, lastVoxelColor.red, lastVoxelColor.green, lastVoxelColor.blue); + Voxels.setVoxel(lastVoxelPosition.x, lastVoxelPosition.y, lastVoxelPosition.z, + extrudeScale, lastVoxelColor.red, lastVoxelColor.green, lastVoxelColor.blue); mouseX = event.x; mouseY = event.y; } @@ -1214,64 +1214,64 @@ function mouseMoveEvent(event) { function mouseReleaseEvent(event) { // if our tools are off, then don't do anything if (!editToolsOn) { - return; + return; } if (inspectJsIsRunning) { return; } - + if (isMovingSlider) { isMovingSlider = false; } isAdding = false; - isExtruding = false; + isExtruding = false; } function moveTools() { // move the swatches swatchesX = (windowDimensions.x - (swatchesWidth + sliderWidth)) / 2; swatchesY = windowDimensions.y - swatchHeight + 1; - + // create the overlays, position them in a row, set their colors, and for the selected one, use a different source image // location so that it displays the "selected" marker for (s = 0; s < numColors; s++) { var extraWidth = 0; - + if (s == 0) { extraWidth = swatchExtraPadding; } - + var imageFromX = swatchExtraPadding - extraWidth + s * swatchWidth; var imageFromY = swatchHeight + 1; if (s == whichColor) { imageFromY = 0; } - + var swatchX = swatchExtraPadding - extraWidth + swatchesX + ((swatchWidth - 1) * s); - + if (s == (numColors - 1)) { extraWidth = swatchExtraPadding; } Overlays.editOverlay(swatches[s], { - x: swatchX, - y: swatchesY, - subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight }, - color: colors[s], - alpha: 1, - visible: editToolsOn - }); + x: swatchX, + y: swatchesY, + subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight }, + color: colors[s], + alpha: 1, + visible: editToolsOn + }); } - + // move the tools toolsY = (windowDimensions.y - toolsHeight) / 2; - + var voxelToolOffset = 1, - recolorToolOffset = 1, - eyedropperToolOffset = 1; - + recolorToolOffset = 1, + eyedropperToolOffset = 1; + var voxelToolColor = WHITE_COLOR; - + if (recolorToolSelected) { recolorToolOffset = 2; } else if (eyedropperToolSelected) { @@ -1282,34 +1282,34 @@ function moveTools() { } voxelToolOffset = 2; } - + Overlays.editOverlay(voxelTool, { - subImage: { x: 0, y: toolHeight * voxelToolOffset, width: toolWidth, height: toolHeight }, - x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * voxelToolAt), width: toolWidth, height: toolHeight, - color: voxelToolColor, - visible: editToolsOn - }); - + subImage: { x: 0, y: toolHeight * voxelToolOffset, width: toolWidth, height: toolHeight }, + x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * voxelToolAt), width: toolWidth, height: toolHeight, + color: voxelToolColor, + visible: editToolsOn + }); + Overlays.editOverlay(recolorTool, { - subImage: { x: 0, y: toolHeight * recolorToolOffset, width: toolWidth, height: toolHeight }, - x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * recolorToolAt), width: toolWidth, height: toolHeight, - visible: editToolsOn - }); - + subImage: { x: 0, y: toolHeight * recolorToolOffset, width: toolWidth, height: toolHeight }, + x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * recolorToolAt), width: toolWidth, height: toolHeight, + visible: editToolsOn + }); + Overlays.editOverlay(eyedropperTool, { - subImage: { x: 0, y: toolHeight * eyedropperToolOffset, width: toolWidth, height: toolHeight }, - x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * eyedropperToolAt), width: toolWidth, height: toolHeight, - visible: editToolsOn - }); - + subImage: { x: 0, y: toolHeight * eyedropperToolOffset, width: toolWidth, height: toolHeight }, + x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * eyedropperToolAt), width: toolWidth, height: toolHeight, + visible: editToolsOn + }); + sliderX = swatchesX + swatchesWidth - sliderOffsetX; sliderY = windowDimensions.y - sliderHeight + 1; thumbY = sliderY + thumbOffsetY; Overlays.editOverlay(slider, { x: sliderX, y: sliderY, visible: editToolsOn }); - + // This is the thumb of our slider Overlays.editOverlay(thumb, { x: sliderX + thumbX, y: thumbY, visible: editToolsOn }); - + } var lastFingerAddVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area @@ -1318,8 +1318,8 @@ var lastFingerDeleteVoxel = { x: -1, y: -1, z: -1}; // off of the build-able are function checkControllers() { var controllersPerPalm = 2; // palm and finger for (var palm = 0; palm < 2; palm++) { - var palmController = palm * controllersPerPalm; - var fingerTipController = palmController + 1; + var palmController = palm * controllersPerPalm; + var fingerTipController = palmController + 1; var fingerTipPosition = Controller.getSpatialControlPosition(fingerTipController); var BUTTON_COUNT = 6; @@ -1327,7 +1327,7 @@ function checkControllers() { var BUTTON_1 = BUTTON_BASE + 1; var BUTTON_2 = BUTTON_BASE + 2; var FINGERTIP_VOXEL_SIZE = 0.05; - + if (Controller.isButtonPressed(BUTTON_1)) { if (Vec3.length(Vec3.subtract(fingerTipPosition,lastFingerAddVoxel)) > (FINGERTIP_VOXEL_SIZE / 2)) { if (whichColor == -1) { @@ -1335,10 +1335,10 @@ function checkControllers() { } else { newColor = { red: colors[whichColor].red, green: colors[whichColor].green, blue: colors[whichColor].blue }; } - + Voxels.eraseVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE); Voxels.setVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE, - newColor.red, newColor.green, newColor.blue); + newColor.red, newColor.green, newColor.blue); lastFingerAddVoxel = fingerTipPosition; } @@ -1358,18 +1358,18 @@ function update(deltaTime) { windowDimensions = newWindowDimensions; moveTools(); } - + checkControllers(); - + // Move Import Preview if (isImporting) { var position = MyAvatar.position; var forwardVector = Quat.getFront(MyAvatar.orientation); var targetPosition = Vec3.sum(position, Vec3.multiply(forwardVector, importScale)); var newPosition = { - x: Math.floor(targetPosition.x / importScale) * importScale, - y: Math.floor(targetPosition.y / importScale) * importScale, - z: Math.floor(targetPosition.z / importScale) * importScale + x: Math.floor(targetPosition.x / importScale) * importScale, + y: Math.floor(targetPosition.y / importScale) * importScale, + z: Math.floor(targetPosition.z / importScale) * importScale } moveImport(newPosition); } @@ -1398,7 +1398,7 @@ function wheelEvent(event) { calcThumbFromScale(pointerVoxelScale); trackMouseEvent(event); wheelPixelsMoved = 0; - + if (isImporting) { var importScale = (pointerVoxelScale / MAX_VOXEL_SCALE) * MAX_PASTE_VOXEL_SCALE; rescaleImport(importScale); From 6d1f4ed9420f2c238a2afb9834e189d0651be913 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 18 Apr 2014 01:13:06 +0200 Subject: [PATCH 06/30] Fix format --- interface/src/Application.cpp | 47 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a7a00bf7c7..592370705a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3555,35 +3555,34 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); - if (customUrl.startsWith("hifi://")) { - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; - if (urlParts.count() > 1) { - // if url has 2 or more parts, the first one is domain name - QString domain = urlParts[0]; + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; - // second part is either a destination coordinate or - // a place name - QString destination = urlParts[1]; + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - // any third part is an avatar orientation. - QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - - Menu::goToDomain(domain); + Menu::goToDomain(domain); - // goto either @user, #place, or x-xx,y-yy,z-zz - // style co-ordinate. - Menu::goTo(destination); + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); - if (!orientation.isEmpty()) { - // location orientation - Menu::goToOrientation(orientation); - } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - Menu::goTo(destination); + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); } - + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + Menu::goTo(destination); } + + } } From a040c997d801fb360bbcf0b15f39827a198388f7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 17 Apr 2014 16:30:23 -0700 Subject: [PATCH 07/30] ModelUploader update --- interface/src/ModelUploader.cpp | 68 ++++++++++++++++++++++++++++++--- interface/src/ModelUploader.h | 1 + 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp index edbc6c0ad9..5f219e03c8 100644 --- a/interface/src/ModelUploader.cpp +++ b/interface/src/ModelUploader.cpp @@ -34,6 +34,7 @@ static const QString TEXDIR_FIELD = "texdir"; static const QString LOD_FIELD = "lod"; static const QString S3_URL = "http://highfidelity-public.s3-us-west-1.amazonaws.com"; +static const QString DATA_SERVER_URL = "https://data-web.highfidelity.io"; static const QString MODEL_URL = "/api/v1/models"; static const QString SETTING_NAME = "LastModelUploadLocation"; @@ -201,14 +202,14 @@ void ModelUploader::send() { JSONCallbackParameters callbackParams; callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "uploadSuccess"; + callbackParams.jsonCallbackMethod = "checkJSON"; callbackParams.errorCallbackReceiver = this; callbackParams.errorCallbackMethod = "uploadFailed"; - callbackParams.updateReciever = this; - callbackParams.updateSlot = SLOT(uploadUpdate(qint64, qint64)); - AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, callbackParams, QByteArray(), _dataMultiPart); - _dataMultiPart = NULL; + AccountManager::getInstance().authenticatedRequest(MODEL_URL + "/" + QFileInfo(_url).baseName(), + QNetworkAccessManager::GetOperation, + callbackParams); + qDebug() << "Sending model..."; _progressDialog = new QDialog(); _progressBar = new QProgressBar(_progressDialog); @@ -226,6 +227,61 @@ void ModelUploader::send() { _progressBar = NULL; } +void ModelUploader::checkJSON(const QJsonObject& jsonResponse) { + if (jsonResponse.contains("status") && jsonResponse.value("status").toString() == "success") { + qDebug() << "status : success"; + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "uploadSuccess"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "uploadFailed"; + callbackParams.updateReciever = this; + callbackParams.updateSlot = SLOT(uploadUpdate(qint64, qint64)); + + if (jsonResponse.contains("exists") && jsonResponse.value("exists").toString() == "true") { + qDebug() << "exists : true"; + if (jsonResponse.contains("can_update") && jsonResponse.value("can_update").toString() == "true") { + qDebug() << "can_update : true"; + + AccountManager::getInstance().authenticatedRequest(MODEL_URL + "/" + QFileInfo(_url).baseName(), + QNetworkAccessManager::PutOperation, + callbackParams, + QByteArray(), + _dataMultiPart); + _dataMultiPart = NULL; + } else { + qDebug() << "can_update : false"; + if (_progressDialog) { + _progressDialog->reject(); + } + QMessageBox::warning(NULL, + QString("ModelUploader::checkJSON()"), + QString("This model already exist and is own by someone else."), + QMessageBox::Ok); + deleteLater(); + } + } else { + qDebug() << "exists : false"; + AccountManager::getInstance().authenticatedRequest(MODEL_URL, + QNetworkAccessManager::PostOperation, + callbackParams, + QByteArray(), + _dataMultiPart); + _dataMultiPart = NULL; + } + } else { + qDebug() << "status : failed"; + if (_progressDialog) { + _progressDialog->reject(); + } + QMessageBox::warning(NULL, + QString("ModelUploader::checkJSON()"), + QString("Something went wrong with the data-server."), + QMessageBox::Ok); + deleteLater(); + } +} + void ModelUploader::uploadUpdate(qint64 bytesSent, qint64 bytesTotal) { if (_progressDialog) { _progressBar->setRange(0, bytesTotal); @@ -249,11 +305,11 @@ void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QS if (_progressDialog) { _progressDialog->reject(); } + qDebug() << "Model upload failed (" << errorCode << "): " << errorString; QMessageBox::warning(NULL, QString("ModelUploader::uploadFailed()"), QString("There was a problem with your upload, please try again later."), QMessageBox::Ok); - qDebug() << "Model upload failed (" << errorCode << "): " << errorString; deleteLater(); } diff --git a/interface/src/ModelUploader.h b/interface/src/ModelUploader.h index ff22673cdd..54702d6420 100644 --- a/interface/src/ModelUploader.h +++ b/interface/src/ModelUploader.h @@ -30,6 +30,7 @@ public slots: void send(); private slots: + void checkJSON(const QJsonObject& jsonResponse); void uploadUpdate(qint64 bytesSent, qint64 bytesTotal); void uploadSuccess(const QJsonObject& jsonResponse); void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString); From c1e54d370c3e56adf84bcd6d2205ff229a4b35a5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Apr 2014 14:46:56 -0700 Subject: [PATCH 08/30] change Sound property to hasDownloaded --- libraries/audio/src/Sound.cpp | 5 ++++- libraries/audio/src/Sound.h | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index bcae878259..5bd63b7959 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -67,7 +67,8 @@ Sound::Sound(float volume, float frequency, float duration, float decay, QObject } Sound::Sound(const QUrl& sampleURL, QObject* parent) : - QObject(parent) + QObject(parent), + _hasDownloaded(false) { // assume we have a QApplication or QCoreApplication instance and use the // QNetworkAccess manager to grab the raw audio file at the given URL @@ -111,6 +112,8 @@ void Sound::replyFinished() { } else { qDebug() << "Network reply without 'Content-Type'."; } + + _hasDownloaded = true; } void Sound::replyError(QNetworkReply::NetworkError code) { diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index ae2fd391a1..c953ae1b33 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -23,13 +23,14 @@ public: Sound(const QUrl& sampleURL, QObject* parent = NULL); Sound(float volume, float frequency, float duration, float decay, QObject* parent = NULL); - bool isEmpty() const { return _byteArray.isEmpty(); } + bool hasDownloaded() const { return _hasDownloaded; } const QByteArray& getByteArray() { return _byteArray; } private: QByteArray _byteArray; - + bool _hasDownloaded; + void downSample(const QByteArray& rawAudioByteArray); void interpretAsWav(const QByteArray& inputAudioByteArray, QByteArray& outputAudioByteArray); From 72fe9b94b1c25f5e11086bea97346ba9ab32c75e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Apr 2014 14:48:26 -0700 Subject: [PATCH 09/30] fix property in sound --- libraries/audio/src/Sound.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index c953ae1b33..c473cdff83 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -18,7 +18,7 @@ class Sound : public QObject { Q_OBJECT - Q_PROPERTY(bool empty READ isEmpty) + Q_PROPERTY(bool downloaded READ hasDownloaded) public: Sound(const QUrl& sampleURL, QObject* parent = NULL); Sound(float volume, float frequency, float duration, float decay, QObject* parent = NULL); From d489e9dcd403114263c6d360b00e4aba75c3fca3 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 18 Apr 2014 23:55:45 +0200 Subject: [PATCH 10/30] Fix format --- interface/src/Application.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 592370705a..0abcd9d1af 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3552,11 +3552,11 @@ void Application::takeSnapshot() { } void Application::urlGoTo(int argc, const char * constArgv[]) { - //Gets the url (hifi://domain/destination/orientation) - QString customUrl = getCmdOption(argc, constArgv, "-url"); + //Gets the url (hifi://domain/destination/orientation) + QString customUrl = getCmdOption(argc, constArgv, "-url"); - if (customUrl.startsWith("hifi://")) { - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; @@ -3583,6 +3583,5 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { QString destination = urlParts[0]; Menu::goTo(destination); } - } } From 0a7ea17d43c7ad69645e496c458e21074d4235be Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Apr 2014 15:10:15 -0700 Subject: [PATCH 11/30] fix a geometry race condition crash --- interface/src/renderer/Model.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index f8de7210ea..ef0911f673 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -468,8 +468,13 @@ void Model::clearShapes() { void Model::rebuildShapes() { clearShapes(); + + if (!_geometry) { + return; + } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); - + if (geometry.joints.isEmpty()) { return; } From aa73527157921dae7fcb2be1dc0de8cf7e4c8b15 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 15:58:56 -0700 Subject: [PATCH 12/30] Some code cleaning --- interface/src/Application.cpp | 2 +- interface/src/Util.cpp | 12 ++++-- interface/src/ui/Stats.cpp | 69 ++++++++++++++++++----------------- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a46201a4d6..7a4c930bc6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2728,7 +2728,7 @@ void Application::displayOverlay() { (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) ? 80 : 20; - drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT); + drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT); } _overlays.render2D(); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 1dae3a4fd6..5238db9b13 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -186,16 +186,22 @@ const glm::vec3 randVector() { } static TextRenderer* textRenderer(int mono) { - static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY); - static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT); - static TextRenderer* inconsolataRenderer = new TextRenderer(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false); switch (mono) { case 1: + static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY); return monoRenderer; case 2: + static TextRenderer* inconsolataRenderer = new TextRenderer(INCONSOLATA_FONT_FAMILY, + -1, + QFont::Bold, false); return inconsolataRenderer; case 0: default: + static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, + -1, + -1, + false, + TextRenderer::SHADOW_EFFECT); return proportionalRenderer; } } diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 64616cbdf8..8807f3ff34 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -171,6 +171,9 @@ void Stats::display( unsigned int backgroundColor = 0x33333399; int verticalOffset = 0, lines = 0; + float scale = 0.10f; + float rotation = 0.0f; + int font = 2; QLocale locale(QLocale::English); std::stringstream voxelStats; @@ -198,11 +201,11 @@ void Stats::display( sprintf(framesPerSecond, "Framerate: %3.0f FPS", fps); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, serverNodes, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, serverNodes, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarNodes, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, framesPerSecond, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond, color); if (_expanded) { char packetsPerSecondString[30]; @@ -211,9 +214,9 @@ void Stats::display( sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)bytesPerSecond * 8.f / 1000000.f); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, packetsPerSecondString, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, averageMegabitsPerSecond, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond, color); } verticalOffset = 0; @@ -258,7 +261,7 @@ void Stats::display( "Buffer msecs %.1f", (float) (audio->getNetworkBufferLengthSamplesPerChannel() + (float) audio->getJitterBufferSamples()) / (float) audio->getNetworkSampleRate() * 1000.f); - drawText(30, glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, color); + drawText(30, glWidget->height() - 22, scale, rotation, font, audioJitter, color); char audioPing[30]; @@ -271,18 +274,18 @@ void Stats::display( sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, audioPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, audioPing, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPing, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelAvgPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelAvgPing, color); if (_expanded) { char voxelMaxPing[30]; sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelMaxPing, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelMaxPing, color); } verticalOffset = 0; @@ -306,11 +309,11 @@ void Stats::display( char avatarMixerStats[200]; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPosition, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPosition, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarVelocity, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarVelocity, color); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarBodyYaw, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarBodyYaw, color); if (_expanded) { SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer); @@ -323,7 +326,7 @@ void Stats::display( } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarMixerStats, color); stringstream downloads; downloads << "Downloads: "; @@ -333,7 +336,7 @@ void Stats::display( downloads << "(" << ResourceCache::getPendingRequestCount() << " pending)"; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloads.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, downloads.str().c_str(), color); } verticalOffset = 0; @@ -354,7 +357,7 @@ void Stats::display( voxelStats.str(""); voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB"; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); voxelStats.str(""); voxelStats << @@ -364,14 +367,14 @@ void Stats::display( voxelStats << " / GPU: " << voxels->getVoxelMemoryUsageGPU() / 1000000.f << "MB"; } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); // Voxel Rendering voxelStats.str(""); voxelStats.precision(4); voxelStats << "Voxel Rendering Slots Max: " << voxels->getMaxVoxels() / 1000.f << "K"; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); } voxelStats.str(""); @@ -379,7 +382,7 @@ void Stats::display( voxelStats << "Drawn: " << voxels->getVoxelsWritten() / 1000.f << "K " << "Abandoned: " << voxels->getAbandonedVoxels() / 1000.f << "K "; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); // iterate all the current voxel stats, and list their sending modes, and total voxel counts std::stringstream sendingMode(""); @@ -424,7 +427,7 @@ void Stats::display( sendingMode << " "; } verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)sendingMode.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)sendingMode.str().c_str(), color); } // Incoming packets @@ -435,7 +438,7 @@ void Stats::display( voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString) << " [Recent Max: " << qPrintable(maxString) << "]"; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); } if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) { @@ -458,7 +461,7 @@ void Stats::display( voxelStats.str(""); voxelStats << "Server voxels: " << qPrintable(serversTotalString); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); if (_expanded) { QString serversInternalString = locale.toString((uint)totalInternal); @@ -469,7 +472,7 @@ void Stats::display( "Internal: " << qPrintable(serversInternalString) << " " << "Leaves: " << qPrintable(serversLeavesString) << ""; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); } unsigned long localTotal = VoxelTreeElement::getNodeCount(); @@ -479,7 +482,7 @@ void Stats::display( voxelStats.str(""); voxelStats << "Local voxels: " << qPrintable(localTotalString); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); if (_expanded) { unsigned long localInternal = VoxelTreeElement::getInternalNodeCount(); @@ -492,7 +495,7 @@ void Stats::display( "Internal: " << qPrintable(localInternalString) << " " << "Leaves: " << qPrintable(localLeavesString) << ""; verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); } // LOD Details @@ -501,7 +504,7 @@ void Stats::display( QString displayLODDetails = Menu::getInstance()->getLODFeedbackText(); voxelStats << "LOD: You can see " << qPrintable(displayLODDetails.trimmed()); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); } @@ -526,7 +529,7 @@ void Stats::display( ); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); float preDelay = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingPreDelay) ? audioReflector->getPreDelay() : 0.0f; @@ -539,7 +542,7 @@ void Stats::display( audioReflector->getSoundMsPerMeter()); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); sprintf(reflectionsStatus, "Attenuation: average %5.3f, max %5.3f, min %5.3f, Factor: %5.3f", audioReflector->getAverageAttenuation(), @@ -548,7 +551,7 @@ void Stats::display( audioReflector->getDistanceAttenuationScalingFactor()); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); sprintf(reflectionsStatus, "Local Audio: %s Attenuation: %5.3f", (Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingProcessLocalAudio) @@ -556,7 +559,7 @@ void Stats::display( audioReflector->getLocalAudioAttenuationFactor()); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); bool diffusionEnabled = Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingWithDiffusions); int fanout = diffusionEnabled ? audioReflector->getDiffusionFanout() : 0; @@ -565,7 +568,7 @@ void Stats::display( (diffusionEnabled ? "yes" : "no"), fanout, diffusionPaths); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); const float AS_PERCENT = 100.0f; float reflectiveRatio = audioReflector->getReflectiveRatio() * AS_PERCENT; @@ -575,7 +578,7 @@ void Stats::display( reflectiveRatio, diffusionRatio, absorptionRatio); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); sprintf(reflectionsStatus, "Comb Filter Window: %5.3f ms, Allowed: %d, Suppressed: %d", audioReflector->getCombFilterWindow(), @@ -583,7 +586,7 @@ void Stats::display( audioReflector->getEchoesSuppressed()); verticalOffset += STATS_PELS_PER_LINE; - drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, reflectionsStatus, color); + drawText(horizontalOffset, verticalOffset, scale, rotation, font, reflectionsStatus, color); } From b098a7a294c7fbc8bc2e1a243bcca1cfad21ba30 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 15:59:37 -0700 Subject: [PATCH 13/30] Fixed wire cube overlay not drawn with right line width --- interface/src/ui/overlays/Cube3DOverlay.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/overlays/Cube3DOverlay.cpp b/interface/src/ui/overlays/Cube3DOverlay.cpp index ab9418206f..e9a366c6dc 100644 --- a/interface/src/ui/overlays/Cube3DOverlay.cpp +++ b/interface/src/ui/overlays/Cube3DOverlay.cpp @@ -40,6 +40,7 @@ void Cube3DOverlay::render() { if (_isSolid) { glutSolidCube(_size); } else { + glLineWidth(_lineWidth); glutWireCube(_size); } glPopMatrix(); From 61981b9470476eed3ced3f791abb837087d7a30c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 16:00:44 -0700 Subject: [PATCH 14/30] Added getter for tree scale in js --- libraries/voxels/src/VoxelsScriptingInterface.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/voxels/src/VoxelsScriptingInterface.h b/libraries/voxels/src/VoxelsScriptingInterface.h index 71a8405be6..d5322fdc4d 100644 --- a/libraries/voxels/src/VoxelsScriptingInterface.h +++ b/libraries/voxels/src/VoxelsScriptingInterface.h @@ -36,6 +36,9 @@ public: void setUndoStack(QUndoStack* undoStack) { _undoStack = undoStack; } public slots: + + /// provide the world scale + const int getTreeScale() const { return TREE_SCALE; } /// checks the local voxel tree for a voxel at the specified location and scale /// \param x the x-coordinate of the voxel (in meter units) From d6e7caa4db3e6e058ff60c10b03ae59df67a45a0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 16:02:01 -0700 Subject: [PATCH 15/30] Removed Debug --- interface/src/scripting/ClipboardScriptingInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/scripting/ClipboardScriptingInterface.cpp b/interface/src/scripting/ClipboardScriptingInterface.cpp index b11c0fdbff..e8fb545343 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.cpp +++ b/interface/src/scripting/ClipboardScriptingInterface.cpp @@ -78,7 +78,7 @@ void ClipboardScriptingInterface::exportVoxel(float x, float y, float z, float s } bool ClipboardScriptingInterface::importVoxels() { - qDebug() << "[DEBUG] Importing ... "; + qDebug() << "Importing ... "; QEventLoop loop; connect(Application::getInstance(), SIGNAL(importDone()), &loop, SLOT(quit())); emit readyToImport(); From c4102e3af0d580dce5bbccfe4a90749120fb6369 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 16:04:20 -0700 Subject: [PATCH 16/30] Improved scale selector, changed first swatch behaviours, improved placement tool --- examples/editVoxels.js | 582 +++++++++++++++++++++-------------------- 1 file changed, 298 insertions(+), 284 deletions(-) diff --git a/examples/editVoxels.js b/examples/editVoxels.js index 752f4cbf9b..d9d1af8461 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -19,7 +19,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var editToolsOn = true; // starts out off + var windowDimensions = Controller.getViewportDimensions(); +var WORLD_SCALE = Voxels.getTreeScale(); var NEW_VOXEL_SIZE = 1.0; var NEW_VOXEL_DISTANCE_FROM_CAMERA = 3.0; @@ -62,7 +65,7 @@ colors[6] = { red: 211, green: 115, blue: 0 }; colors[7] = { red: 48, green: 116, blue: 119 }; colors[8] = { red: 31, green: 64, blue: 64 }; var numColors = 9; -var whichColor = -1; // Starting color is 'Copy' mode +var whichColor = 0; // Starting color is 'Copy' mode // Create sounds for for every script actions that require one var audioOptions = new AudioInjectionOptions(); @@ -149,9 +152,6 @@ colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/ colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Color+Inherit/Inherit+B.raw"); colorInheritSound.addSound("https://highfidelity-public.s3.amazonaws.com/sounds/Voxel+Editing/Color+Inherit/Inherit+C.raw"); - -var editToolsOn = true; // starts out off - // previewAsVoxel - by default, we will preview adds/deletes/recolors as just 4 lines on the intersecting face. But if you // the preview to show a full voxel then set this to true and the voxel will be displayed for voxel editing var previewAsVoxel = false; @@ -204,8 +204,8 @@ var linePreviewRight = Overlays.addOverlay("line3d", { // these will be used below -var sliderWidth = 154; -var sliderHeight = 37; +var scaleSelectorWidth = 144; +var scaleSelectorHeight = 37; // These will be our "overlay IDs" var swatches = new Array(); @@ -213,7 +213,7 @@ var swatchExtraPadding = 5; var swatchHeight = 37; var swatchWidth = 27; var swatchesWidth = swatchWidth * numColors + numColors + swatchExtraPadding * 2; -var swatchesX = (windowDimensions.x - (swatchesWidth + sliderWidth)) / 2; +var swatchesX = (windowDimensions.x - (swatchesWidth + scaleSelectorWidth)) / 2; var swatchesY = windowDimensions.y - swatchHeight + 1; var toolIconUrl = "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/tools/"; @@ -270,7 +270,7 @@ var voxelTool = Overlays.addOverlay("image", { x: 0, y: 0, width: toolWidth, height: toolHeight, subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, imageURL: toolIconUrl + "voxel-tool.svg", - visible: false, + visible: editToolsOn, alpha: 0.9 }); @@ -278,7 +278,7 @@ var recolorTool = Overlays.addOverlay("image", { x: 0, y: 0, width: toolWidth, height: toolHeight, subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, imageURL: toolIconUrl + "paint-tool.svg", - visible: false, + visible: editToolsOn, alpha: 0.9 }); @@ -286,58 +286,142 @@ var eyedropperTool = Overlays.addOverlay("image", { x: 0, y: 0, width: toolWidth, height: toolHeight, subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, imageURL: toolIconUrl + "eyedropper-tool.svg", - visible: false, + visible: editToolsOn, alpha: 0.9 }); -// This will create a couple of image overlays that make a "slider", we will demonstrate how to trap mouse messages to -// move the slider - -// see above... -//var sliderWidth = 158; -//var sliderHeight = 35; - -var sliderOffsetX = 17; -var sliderX = swatchesX - swatchWidth - sliderOffsetX; -var sliderY = windowDimensions.y - sliderHeight + 1; -var slider = Overlays.addOverlay("image", { - // alternate form of expressing bounds - bounds: { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight}, - imageURL: toolIconUrl + "voxel-size-slider-bg.svg", - alpha: 1, +function ScaleSelector() { + this.x = swatchesX + swatchesWidth; + this.y = swatchesY; + this.width = scaleSelectorWidth; + this.height = scaleSelectorHeight; + + this.displayPower = false; + this.scale = 1.0; + this.power = 0; + + this.FIRST_PART = this.width * 40.0 / 100.0; + this.SECOND_PART = this.width * 37.0 / 100.0; + + this.buttonsOverlay = Overlays.addOverlay("image", { + x: this.x, y: this.y, + width: this.width, height: this.height, + //subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight }, + imageURL: toolIconUrl + "voxel-size-selector.svg", + alpha: 0.9, + visible: editToolsOn + }); + this.textOverlay = Overlays.addOverlay("text", { + x: this.x + this.FIRST_PART, y: this.y, + width: this.SECOND_PART, height: this.height, + topMargin: 13, + text: this.scale.toString(), + alpha: 0.0, + visible: editToolsOn + }); + this.powerOverlay = Overlays.addOverlay("text", { + x: this.x + this.FIRST_PART, y: this.y, + width: this.SECOND_PART, height: this.height, + leftMargin: 28, + text: this.power.toString(), + alpha: 0.0, + visible: false + }); + this.show = function(doShow) { + Overlays.editOverlay(this.buttonsOverlay, {visible: doShow}); + Overlays.editOverlay(this.textOverlay, {visible: doShow}); + Overlays.editOverlay(this.powerOverlay, {visible: doShow && this.displayPower}); + } + + this.move = function() { + this.x = swatchesX + swatchesWidth; + this.y = swatchesY; + + Overlays.editOverlay(this.buttonsOverlay, { + x: this.x, y: this.y, + }); + Overlays.editOverlay(this.textOverlay, { + x: this.x + this.FIRST_PART, y: this.y, + }); + Overlays.editOverlay(this.powerOverlay, { + x: this.x + this.FIRST_PART, y: this.y, + }); + } + + + this.switchDisplay = function() { + this.displayPower = !this.displayPower; + + if (this.displayPower) { + Overlays.editOverlay(this.textOverlay, { + leftMargin: 18, + text: "2" + }); + Overlays.editOverlay(this.powerOverlay, { + text: this.power.toString(), + visible: editToolsOn + }); + } else { + Overlays.editOverlay(this.textOverlay, { + leftMargin: 13, + text: this.scale.toString() + }); + Overlays.editOverlay(this.powerOverlay, { visible: false }); - -// The slider is handled in the mouse event callbacks. -var isMovingSlider = false; -var thumbClickOffsetX = 0; - -// This is the thumb of our slider -var minThumbX = 20; // relative to the x of the slider -var maxThumbX = minThumbX + 90; -var thumbExtents = maxThumbX - minThumbX; -var thumbX = (minThumbX + maxThumbX) / 2; -var thumbOffsetY = 11; -var thumbY = sliderY + thumbOffsetY; -var thumb = Overlays.addOverlay("image", { - x: sliderX + thumbX, - y: thumbY, - width: 17, - height: 17, - imageURL: toolIconUrl + "voxel-size-slider-handle.svg", - alpha: 1, - visible: false - }); - -var pointerVoxelScale = Math.floor(MAX_VOXEL_SCALE + MIN_VOXEL_SCALE) / 2; // this is the voxel scale used for click to add or delete -var pointerVoxelScaleSet = false; // if voxel scale has not yet been set, we use the intersection size - -var pointerVoxelScaleSteps = 8; // the number of slider position steps -var pointerVoxelScaleOriginStep = 8; // the position of slider for the 1 meter size voxel -var pointerVoxelScaleMin = Math.pow(2, (1-pointerVoxelScaleOriginStep)); -var pointerVoxelScaleMax = Math.pow(2, (pointerVoxelScaleSteps-pointerVoxelScaleOriginStep)); -var thumbDeltaPerStep = thumbExtents / (pointerVoxelScaleSteps - 1); - + } + } + + this.update = function() { + if (this.displayPower) { + Overlays.editOverlay(this.powerOverlay, {text: this.power.toString()}); + } else { + Overlays.editOverlay(this.textOverlay, {text: this.scale.toString()}); + } + } + + this.incrementScale = function() { + if (this.power < 13) { + ++this.power; + this.scale *= 2.0; + this.update(); + resizeVoxelSound.play(voxelSizePlus); + } + } + + this.decrementScale = function() { + if (-4 < this.power) { + --this.power; + this.scale /= 2.0; + this.update(); + resizeVoxelSound.play(voxelSizePlus); + } + } + + this.clicked = function(x, y) { + if (this.x < x && x < this.x + this.width && + this.y < y && y < this.y + this.height) { + + if (x < this.x + this.FIRST_PART) { + this.decrementScale(); + } else if (x < this.x + this.FIRST_PART + this.SECOND_PART) { + this.switchDisplay(); + } else { + this.incrementScale(); + } + return true; + } + return false; + } + + this.cleanup = function() { + Overlays.deleteOverlay(this.buttonsOverlay); + Overlays.deleteOverlay(this.textOverlay); + Overlays.deleteOverlay(this.powerOverlay); + } + +} +var scaleSelector = new ScaleSelector(); ///////////////////////////////////// IMPORT MODULE /////////////////////////////// @@ -345,9 +429,12 @@ var thumbDeltaPerStep = thumbExtents / (pointerVoxelScaleSteps - 1); var importTree; var importPreview; var importBoundaries; +var xImportGuide; +var yImportGuide; +var zImportGuide; var isImporting; var importPosition; -var importScale; +var importDistance; function initImport() { importPreview = Overlays.addOverlay("localvoxels", { @@ -358,49 +445,90 @@ function initImport() { }); importBoundaries = Overlays.addOverlay("cube", { position: { x: 0, y: 0, z: 0 }, - scale: 1, + size: 1, color: { red: 128, blue: 128, green: 128 }, + lineWIdth: 4, solid: false, visible: false - }) + }); + + xImportGuide = Overlays.addOverlay("line3d", { + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 255, green: 0, blue: 0}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); + yImportGuide = Overlays.addOverlay("line3d", { + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 0, green: 255, blue: 0}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); + zImportGuide = Overlays.addOverlay("line3d", { + position: { x: 0, y: 0, z: 0}, + end: { x: 0, y: 0, z: 0}, + color: { red: 0, green: 0, blue: 255}, + alpha: 1, + visible: false, + lineWidth: previewLineWidth + }); + + isImporting = false; importPosition = { x: 0, y: 0, z: 0 }; - importScale = 0; } function importVoxels() { - if (Clipboard.importVoxels()) { - isImporting = true; - if (importScale <= 0) { - importScale = 1; - } - } else { - isImporting = false; - } - + isImporting = Clipboard.importVoxels(); return isImporting; } function moveImport(position) { - if (0 < position.x && 0 < position.y && 0 < position.z) { - importPosition = position; - Overlays.editOverlay(importPreview, { - position: { x: importPosition.x, y: importPosition.y, z: importPosition.z } - }); - Overlays.editOverlay(importBoundaries, { - position: { x: importPosition.x, y: importPosition.y, z: importPosition.z } - }); - } + importPosition = position; + Overlays.editOverlay(importPreview, { + position: { x: importPosition.x, y: importPosition.y, z: importPosition.z } + }); + Overlays.editOverlay(importBoundaries, { + position: { x: importPosition.x, y: importPosition.y, z: importPosition.z } + }); + + + Overlays.editOverlay(xImportGuide, { + position: { x: importPosition.x, y: 0, z: importPosition.z }, + end: { x: importPosition.x + scaleSelector.scale, y: 0, z: importPosition.z } + }); + Overlays.editOverlay(yImportGuide, { + position: { x: importPosition.x, y: importPosition.y, z: importPosition.z }, + end: { x: importPosition.x, y: 0, z: importPosition.z } + }); + Overlays.editOverlay(zImportGuide, { + position: { x: importPosition.x, y: 0, z: importPosition.z }, + end: { x: importPosition.x, y: 0, z: importPosition.z + scaleSelector.scale } + }); + rescaleImport(); } -function rescaleImport(scale) { - if (0 < scale) { - importScale = scale; +function rescaleImport() { + if (0 < scaleSelector.scale) { Overlays.editOverlay(importPreview, { - scale: importScale + scale: scaleSelector.scale }); Overlays.editOverlay(importBoundaries, { - scale: importScale + size: scaleSelector.scale + }); + + Overlays.editOverlay(xImportGuide, { + end: { x: importPosition.x + scaleSelector.scale, y: 0, z: importPosition.z } + }); + Overlays.editOverlay(yImportGuide, { + end: { x: importPosition.x, y: 0, z: importPosition.z } + }); + Overlays.editOverlay(zImportGuide, { + end: { x: importPosition.x, y: 0, z: importPosition.z + scaleSelector.scale } }); } } @@ -412,11 +540,21 @@ function showImport(doShow) { Overlays.editOverlay(importBoundaries, { visible: doShow }); + + Overlays.editOverlay(xImportGuide, { + visible: doShow + }); + Overlays.editOverlay(yImportGuide, { + visible: doShow + }); + Overlays.editOverlay(zImportGuide, { + visible: doShow + }); } function placeImport() { if (isImporting) { - Clipboard.pasteVoxel(importPosition.x, importPosition.y, importPosition.z, importScale); + Clipboard.pasteVoxel(importPosition.x, importPosition.y, importPosition.z, scaleSelector.scale); isImporting = false; } } @@ -431,9 +569,11 @@ function cancelImport() { function cleanupImport() { Overlays.deleteOverlay(importPreview); Overlays.deleteOverlay(importBoundaries); + Overlays.deleteOverlay(xImportGuide); + Overlays.deleteOverlay(yImportGuide); + Overlays.deleteOverlay(zImportGuide); isImporting = false; importPostion = { x: 0, y: 0, z: 0 }; - importScale = 0; } /////////////////////////////////// END IMPORT MODULE ///////////////////////////// initImport(); @@ -442,49 +582,6 @@ if (editToolsOn) { moveTools(); } - -function calcThumbFromScale(scale) { - var scaleLog = Math.log(scale)/Math.log(2); - var thumbStep = scaleLog + pointerVoxelScaleOriginStep; - if (thumbStep < 1) { - thumbStep = 1; - } - if (thumbStep > pointerVoxelScaleSteps) { - thumbStep = pointerVoxelScaleSteps; - } - var oldThumbX = thumbX; - thumbX = (thumbDeltaPerStep * (thumbStep - 1)) + minThumbX; - Overlays.editOverlay(thumb, { x: thumbX + sliderX } ); - - if (thumbX > oldThumbX) { - resizeVoxelSound.play(voxelSizePlus); - print("Plus"); - } else if (thumbX < oldThumbX) { - resizeVoxelSound.play(voxelSizeMinus); - print("Minus"); - } -} - -function calcScaleFromThumb(newThumbX) { - // newThumbX is the pixel location relative to start of slider, - // we need to figure out the actual offset in the allowed slider area - thumbAt = newThumbX - minThumbX; - thumbStep = Math.floor((thumbAt/ thumbExtents) * (pointerVoxelScaleSteps-1)) + 1; - pointerVoxelScale = Math.pow(2, (thumbStep-pointerVoxelScaleOriginStep)); - - // if importing, rescale import ... - if (isImporting) { - var importScale = (pointerVoxelScale / MAX_VOXEL_SCALE) * MAX_PASTE_VOXEL_SCALE; - rescaleImport(importScale); - } - - // now reset the display accordingly... - calcThumbFromScale(pointerVoxelScale); - - // if the user moved the thumb, then they are fixing the voxel scale - pointerVoxelScaleSet = true; -} - function setAudioPosition() { var position = MyAvatar.position; var forwardVector = Quat.getFront(MyAvatar.orientation); @@ -493,7 +590,7 @@ function setAudioPosition() { function getNewPasteVoxel(pickRay) { - var voxelSize = MIN_PASTE_VOXEL_SCALE + (MAX_PASTE_VOXEL_SCALE - MIN_PASTE_VOXEL_SCALE) * pointerVoxelScale - 1; + var voxelSize = scaleSelector.scale; var origin = { x: pickRay.direction.x, y: pickRay.direction.y, z: pickRay.direction.z }; origin.x += pickRay.origin.x; @@ -542,13 +639,7 @@ function calculateVoxelFromIntersection(intersection, operation) { + intersection.intersection.y + ", " + intersection.intersection.z); } - var voxelSize; - if (pointerVoxelScaleSet) { - voxelSize = pointerVoxelScale; - } else { - voxelSize = intersection.voxel.s; - } - + var voxelSize = scaleSelector.scale; var x; var y; var z; @@ -670,21 +761,9 @@ function showPreviewVoxel() { var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY); var intersection = Voxels.findRayIntersection(pickRay); - // if the user hasn't updated the - if (!pointerVoxelScaleSet) { - calcThumbFromScale(intersection.voxel.s); - } - - if (whichColor == -1) { - // Copy mode - use clicked voxel color - voxelColor = { red: intersection.voxel.red, - green: intersection.voxel.green, - blue: intersection.voxel.blue }; - } else { - voxelColor = { red: colors[whichColor].red, + voxelColor = { red: colors[whichColor].red, green: colors[whichColor].green, - blue: colors[whichColor].blue }; - } + blue: colors[whichColor].blue }; var guidePosition; if (trackAsRecolor || recolorToolSelected || trackAsEyedropper || eyedropperToolSelected) { @@ -734,18 +813,14 @@ function showPreviewLines() { var intersection = Voxels.findRayIntersection(pickRay); if (intersection.intersects) { - - // if the user hasn't updated the - if (!pointerVoxelScaleSet) { - calcThumbFromScale(intersection.voxel.s); - } - resultVoxel = calculateVoxelFromIntersection(intersection,""); Overlays.editOverlay(voxelPreview, { visible: false }); Overlays.editOverlay(linePreviewTop, { position: resultVoxel.topLeft, end: resultVoxel.topRight, visible: true }); Overlays.editOverlay(linePreviewBottom, { position: resultVoxel.bottomLeft, end: resultVoxel.bottomRight, visible: true }); Overlays.editOverlay(linePreviewLeft, { position: resultVoxel.topLeft, end: resultVoxel.bottomLeft, visible: true }); Overlays.editOverlay(linePreviewRight, { position: resultVoxel.topRight, end: resultVoxel.bottomRight, visible: true }); + colors[0] = {red: intersection.voxel.red, green: intersection.voxel.green , blue: intersection.voxel.blue }; + moveTools(); } else { Overlays.editOverlay(voxelPreview, { visible: false }); Overlays.editOverlay(linePreviewTop, { visible: false }); @@ -756,7 +831,7 @@ function showPreviewLines() { } function showPreviewGuides() { - if (editToolsOn) { + if (editToolsOn && !isImporting) { if (previewAsVoxel) { showPreviewVoxel(); @@ -817,6 +892,7 @@ function trackKeyReleaseEvent(event) { moveTools(); setAudioPosition(); // make sure we set the audio position before playing sounds showPreviewGuides(); + scaleSelector.show(editToolsOn); scriptInitSound.playRandom(); } @@ -826,17 +902,14 @@ function trackKeyReleaseEvent(event) { if (editToolsOn) { if (event.text == "ESC") { - pointerVoxelScaleSet = false; pasteMode = false; moveTools(); } if (event.text == "-") { - thumbX -= thumbDeltaPerStep; - calcScaleFromThumb(thumbX); + scaleSelector.decrementScale(); } if (event.text == "+") { - thumbX += thumbDeltaPerStep; - calcScaleFromThumb(thumbX); + scaleSelector.incrementScale(); } if (event.text == "CONTROL") { trackAsDelete = false; @@ -872,15 +945,7 @@ function mousePressEvent(event) { var clickedOnSomething = false; var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); - // If the user clicked on the thumb, handle the slider logic - if (clickedOverlay == thumb) { - isMovingSlider = true; - thumbClickOffsetX = event.x - (sliderX + thumbX); // this should be the position of the mouse relative to the thumb - clickedOnSomething = true; - - //Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", }); - - } else if (clickedOverlay == voxelTool) { + if (clickedOverlay == voxelTool) { modeSwitchSound.play(0); voxelToolSelected = true; recolorToolSelected = false; @@ -901,19 +966,10 @@ function mousePressEvent(event) { eyedropperToolSelected = true; moveTools(); clickedOnSomething = true; - } else if (clickedOverlay == slider) { - - if (event.x < sliderX + minThumbX) { - thumbX -= thumbDeltaPerStep; - calcScaleFromThumb(thumbX); + } else if (scaleSelector.clicked(event.x, event.y)) { + if (isImporting) { + rescaleImport(); } - - if (event.x > sliderX + maxThumbX) { - thumbX += thumbDeltaPerStep; - calcScaleFromThumb(thumbX); - } - - moveTools(); clickedOnSomething = true; } else { // if the user clicked on one of the color swatches, update the selectedSwatch @@ -927,7 +983,7 @@ function mousePressEvent(event) { } } } - if (clickedOnSomething) { + if (clickedOnSomething || isImporting) { return; // no further processing } @@ -939,14 +995,6 @@ function mousePressEvent(event) { var intersection = Voxels.findRayIntersection(pickRay); audioOptions.position = Vec3.sum(pickRay.origin, pickRay.direction); - if (isImporting) { - print("placing import..."); - placeImport(); - showImport(false); - moveTools(); - return; - } - if (pasteMode) { var pasteVoxel = getNewPasteVoxel(pickRay); Clipboard.pasteVoxel(pasteVoxel.origin.x, pasteVoxel.origin.y, pasteVoxel.origin.z, pasteVoxel.voxelSize); @@ -956,11 +1004,6 @@ function mousePressEvent(event) { } if (intersection.intersects) { - // if the user hasn't updated the - if (!pointerVoxelScaleSet) { - calcThumbFromScale(intersection.voxel.s); - } - if (trackAsDelete || event.isRightButton && !trackAsEyedropper) { // Delete voxel voxelDetails = calculateVoxelFromIntersection(intersection,"delete"); @@ -968,13 +1011,11 @@ function mousePressEvent(event) { delVoxelSound.playRandom(); Overlays.editOverlay(voxelPreview, { visible: false }); } else if (eyedropperToolSelected || trackAsEyedropper) { - if (whichColor != -1) { - colors[whichColor].red = intersection.voxel.red; - colors[whichColor].green = intersection.voxel.green; - colors[whichColor].blue = intersection.voxel.blue; - moveTools(); - swatchesSound.play(whichColor); - } + colors[whichColor].red = intersection.voxel.red; + colors[whichColor].green = intersection.voxel.green; + colors[whichColor].blue = intersection.voxel.blue; + moveTools(); + swatchesSound.play(whichColor); } else if (recolorToolSelected || trackAsRecolor) { // Recolor Voxel @@ -987,18 +1028,10 @@ function mousePressEvent(event) { Overlays.editOverlay(voxelPreview, { visible: false }); } else if (voxelToolSelected) { // Add voxel on face - if (whichColor == -1) { - // Copy mode - use clicked voxel color - newColor = { - red: intersection.voxel.red, - green: intersection.voxel.green, - blue: intersection.voxel.blue }; - } else { - newColor = { - red: colors[whichColor].red, - green: colors[whichColor].green, - blue: colors[whichColor].blue }; - } + newColor = { red: colors[whichColor].red, + green: colors[whichColor].green, + blue: colors[whichColor].blue + }; voxelDetails = calculateVoxelFromIntersection(intersection,"add"); Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s, @@ -1020,29 +1053,22 @@ function keyPressEvent(event) { // if our tools are off, then don't do anything if (editToolsOn) { var nVal = parseInt(event.text); - if (event.text == "`") { - print("Color = Copy"); - whichColor = -1; - colorInheritSound.playRandom(); - moveTools(); - } else if ((nVal > 0) && (nVal <= numColors)) { + if ((nVal > 0) && (nVal <= numColors)) { whichColor = nVal - 1; print("Color = " + (whichColor + 1)); swatchesSound.play(whichColor); moveTools(); } else if (event.text == "0") { // Create a brand new 1 meter voxel in front of your avatar - var color = whichColor; - if (color == -1) color = 0; var newPosition = getNewVoxelPosition(); var newVoxel = { x: newPosition.x, y: newPosition.y , z: newPosition.z, s: NEW_VOXEL_SIZE, - red: colors[color].red, - green: colors[color].green, - blue: colors[color].blue }; + red: colors[whichColor].red, + green: colors[whichColor].green, + blue: colors[whichColor].blue }; Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s); Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue); setAudioPosition(); @@ -1158,17 +1184,44 @@ function mouseMoveEvent(event) { return; } - if (isMovingSlider) { - thumbX = (event.x - thumbClickOffsetX) - sliderX; - if (thumbX < minThumbX) { - thumbX = minThumbX; - } - if (thumbX > maxThumbX) { - thumbX = maxThumbX; - } - calcScaleFromThumb(thumbX); + // Move Import Preview + if (isImporting) { + var pickRay = Camera.computePickRay(event.x, event.y); + var intersection = Voxels.findRayIntersection(pickRay); - } else if (isAdding) { + var distance = 2 * scaleSelector.scale; + + if (intersection.intersects) { + var intersectionDistance = Vec3.length(Vec3.subtract(pickRay.origin, intersection.intersection)); + if (intersectionDistance < distance) { + distance = intersectionDistance * 0.99; + } + + } + + var targetPosition = { x: pickRay.direction.x * distance, + y: pickRay.direction.y * distance, + z: pickRay.direction.z * distance + }; + targetPosition.x += pickRay.origin.x; + targetPosition.y += pickRay.origin.y; + targetPosition.z += pickRay.origin.z; + + if (targetPosition.x < 0) targetPosition.x = 0; + if (targetPosition.y < 0) targetPosition.y = 0; + if (targetPosition.z < 0) targetPosition.z = 0; + + var nudgeFactor = scaleSelector.scale; + var newPosition = { + x: Math.floor(targetPosition.x / nudgeFactor) * nudgeFactor, + y: Math.floor(targetPosition.y / nudgeFactor) * nudgeFactor, + z: Math.floor(targetPosition.z / nudgeFactor) * nudgeFactor + } + + moveImport(newPosition); + } + + if (isAdding) { // Watch the drag direction to tell which way to 'extrude' this voxel if (!isExtruding) { var pickRay = Camera.computePickRay(event.x, event.y); @@ -1220,16 +1273,13 @@ function mouseReleaseEvent(event) { return; } - if (isMovingSlider) { - isMovingSlider = false; - } isAdding = false; isExtruding = false; } function moveTools() { // move the swatches - swatchesX = (windowDimensions.x - (swatchesWidth + sliderWidth)) / 2; + swatchesX = (windowDimensions.x - (swatchesWidth + scaleSelectorWidth)) / 2; swatchesY = windowDimensions.y - swatchHeight + 1; // create the overlays, position them in a row, set their colors, and for the selected one, use a different source image @@ -1302,14 +1352,7 @@ function moveTools() { visible: editToolsOn }); - sliderX = swatchesX + swatchesWidth - sliderOffsetX; - sliderY = windowDimensions.y - sliderHeight + 1; - thumbY = sliderY + thumbOffsetY; - Overlays.editOverlay(slider, { x: sliderX, y: sliderY, visible: editToolsOn }); - - // This is the thumb of our slider - Overlays.editOverlay(thumb, { x: sliderX + thumbX, y: thumbY, visible: editToolsOn }); - + scaleSelector.move(); } var lastFingerAddVoxel = { x: -1, y: -1, z: -1}; // off of the build-able area @@ -1330,11 +1373,7 @@ function checkControllers() { if (Controller.isButtonPressed(BUTTON_1)) { if (Vec3.length(Vec3.subtract(fingerTipPosition,lastFingerAddVoxel)) > (FINGERTIP_VOXEL_SIZE / 2)) { - if (whichColor == -1) { - newColor = { red: colors[0].red, green: colors[0].green, blue: colors[0].blue }; - } else { - newColor = { red: colors[whichColor].red, green: colors[whichColor].green, blue: colors[whichColor].blue }; - } + newColor = { red: colors[whichColor].red, green: colors[whichColor].green, blue: colors[whichColor].blue }; Voxels.eraseVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE); Voxels.setVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE, @@ -1360,19 +1399,6 @@ function update(deltaTime) { } checkControllers(); - - // Move Import Preview - if (isImporting) { - var position = MyAvatar.position; - var forwardVector = Quat.getFront(MyAvatar.orientation); - var targetPosition = Vec3.sum(position, Vec3.multiply(forwardVector, importScale)); - var newPosition = { - x: Math.floor(targetPosition.x / importScale) * importScale, - y: Math.floor(targetPosition.y / importScale) * importScale, - z: Math.floor(targetPosition.z / importScale) * importScale - } - moveImport(newPosition); - } } } @@ -1380,28 +1406,17 @@ function wheelEvent(event) { wheelPixelsMoved += event.delta; if (Math.abs(wheelPixelsMoved) > WHEEL_PIXELS_PER_SCALE_CHANGE) { - if (!pointerVoxelScaleSet) { - pointerVoxelScale = 1.0; - pointerVoxelScaleSet = true; - } + if (wheelPixelsMoved > 0) { - pointerVoxelScale /= 2.0; - if (pointerVoxelScale < MIN_VOXEL_SCALE) { - pointerVoxelScale = MIN_VOXEL_SCALE; - } + scaleSelector.decrementScale(); } else { - pointerVoxelScale *= 2.0; - if (pointerVoxelScale > MAX_VOXEL_SCALE) { - pointerVoxelScale = MAX_VOXEL_SCALE; - } + scaleSelector.incrementScale(); } - calcThumbFromScale(pointerVoxelScale); trackMouseEvent(event); wheelPixelsMoved = 0; if (isImporting) { - var importScale = (pointerVoxelScale / MAX_VOXEL_SCALE) * MAX_PASTE_VOXEL_SCALE; - rescaleImport(importScale); + rescaleImport(); } } } @@ -1428,11 +1443,10 @@ function scriptEnding() { Overlays.deleteOverlay(voxelTool); Overlays.deleteOverlay(recolorTool); Overlays.deleteOverlay(eyedropperTool); - Overlays.deleteOverlay(slider); - Overlays.deleteOverlay(thumb); Controller.releaseKeyEvents({ text: "+" }); Controller.releaseKeyEvents({ text: "-" }); cleanupImport(); + scaleSelector.cleanup(); cleanupMenus(); } Script.scriptEnding.connect(scriptEnding); From 7782e53363cbccec15fd5d2931e13d35b19ab6c7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 16:26:10 -0700 Subject: [PATCH 17/30] Restored scale copy --- examples/editVoxels.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/editVoxels.js b/examples/editVoxels.js index d9d1af8461..d9284a940d 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -290,6 +290,8 @@ var eyedropperTool = Overlays.addOverlay("image", { alpha: 0.9 }); + +var copyScale = true; function ScaleSelector() { this.x = swatchesX + swatchesWidth; this.y = swatchesY; @@ -327,6 +329,11 @@ function ScaleSelector() { alpha: 0.0, visible: false }); + this.setScale = function(scale) { + this.scale = scale; + this.power = Math.floor(Math.log(scale)); + } + this.show = function(doShow) { Overlays.editOverlay(this.buttonsOverlay, {visible: doShow}); Overlays.editOverlay(this.textOverlay, {visible: doShow}); @@ -381,6 +388,7 @@ function ScaleSelector() { } this.incrementScale = function() { + copyScale = false; if (this.power < 13) { ++this.power; this.scale *= 2.0; @@ -390,6 +398,7 @@ function ScaleSelector() { } this.decrementScale = function() { + copyScale = false; if (-4 < this.power) { --this.power; this.scale /= 2.0; @@ -820,6 +829,11 @@ function showPreviewLines() { Overlays.editOverlay(linePreviewLeft, { position: resultVoxel.topLeft, end: resultVoxel.bottomLeft, visible: true }); Overlays.editOverlay(linePreviewRight, { position: resultVoxel.topRight, end: resultVoxel.bottomRight, visible: true }); colors[0] = {red: intersection.voxel.red, green: intersection.voxel.green , blue: intersection.voxel.blue }; + + if (copyScale) { + scaleSelector.setScale(intersection.voxel.s); + scaleSelector.update(); + } moveTools(); } else { Overlays.editOverlay(voxelPreview, { visible: false }); @@ -1053,7 +1067,9 @@ function keyPressEvent(event) { // if our tools are off, then don't do anything if (editToolsOn) { var nVal = parseInt(event.text); - if ((nVal > 0) && (nVal <= numColors)) { + if (event.text == "`") { + copyScale = true; + } else if ((nVal > 0) && (nVal <= numColors)) { whichColor = nVal - 1; print("Color = " + (whichColor + 1)); swatchesSound.play(whichColor); From 178f845ad02ceaf0e2a36a068dc1e323e4ecda9d Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 16:40:13 -0700 Subject: [PATCH 18/30] Rescale import when using keys +/- --- examples/editVoxels.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/editVoxels.js b/examples/editVoxels.js index d9284a940d..12c571b09c 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -332,6 +332,7 @@ function ScaleSelector() { this.setScale = function(scale) { this.scale = scale; this.power = Math.floor(Math.log(scale)); + rescaleImport(); } this.show = function(doShow) { @@ -393,6 +394,7 @@ function ScaleSelector() { ++this.power; this.scale *= 2.0; this.update(); + rescaleImport(); resizeVoxelSound.play(voxelSizePlus); } } @@ -403,6 +405,7 @@ function ScaleSelector() { --this.power; this.scale /= 2.0; this.update(); + rescaleImport(); resizeVoxelSound.play(voxelSizePlus); } } From c664b4a087c7d0489890d0d2eedc24e472ec4be0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 17:04:38 -0700 Subject: [PATCH 19/30] Fixed JSON parsing --- interface/src/ModelUploader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp index c6376430db..048e13bdf2 100644 --- a/interface/src/ModelUploader.cpp +++ b/interface/src/ModelUploader.cpp @@ -238,9 +238,9 @@ void ModelUploader::checkJSON(const QJsonObject& jsonResponse) { callbackParams.updateReciever = this; callbackParams.updateSlot = SLOT(uploadUpdate(qint64, qint64)); - if (jsonResponse.contains("exists") && jsonResponse.value("exists").toString() == "true") { + if (jsonResponse.contains("exists") && jsonResponse.value("exists").toBool()) { qDebug() << "exists : true"; - if (jsonResponse.contains("can_update") && jsonResponse.value("can_update").toString() == "true") { + if (jsonResponse.contains("can_update") && jsonResponse.value("can_update").toBool()) { qDebug() << "can_update : true"; AccountManager::getInstance().authenticatedRequest(MODEL_URL + "/" + QFileInfo(_url).baseName(), From 05545b684d02ebb589007e8b62d1905400fa2738 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 17:47:21 -0700 Subject: [PATCH 20/30] Made glowing when speaking an option --- interface/src/Menu.cpp | 3 ++- interface/src/Menu.h | 1 + interface/src/avatar/Avatar.cpp | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index b05e5c91bc..7cdd72afd5 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -315,7 +315,8 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Visage, 0, true, appInstance->getVisage(), SLOT(updateEnabled())); #endif - + + addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::GlowWhenSpeaking, 0, true); addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::ChatCircling, 0, false); QMenu* handOptionsMenu = developerMenu->addMenu("Hand Options"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 10d3376be5..597ae4a74b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -304,6 +304,7 @@ namespace MenuOption { const QString Fullscreen = "Fullscreen"; const QString FullscreenMirror = "Fullscreen Mirror"; const QString GlowMode = "Cycle Glow Mode"; + const QString GlowWhenSpeaking = "Glow When Speaking"; const QString GoHome = "Go Home"; const QString GoTo = "Go To..."; const QString GoToDomain = "Go To Domain..."; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 8cfab7da03..fe685b89f8 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -211,9 +211,14 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { const float GLOW_DISTANCE = 20.0f; const float GLOW_MAX_LOUDNESS = 2500.0f; const float MAX_GLOW = 0.5f; - const float GLOW_FROM_AVERAGE_LOUDNESS = ((this == Application::getInstance()->getAvatar()) - ? 0.0f - : MAX_GLOW * getHeadData()->getAudioLoudness() / GLOW_MAX_LOUDNESS); + + float GLOW_FROM_AVERAGE_LOUDNESS = ((this == Application::getInstance()->getAvatar()) + ? 0.0f + : MAX_GLOW * getHeadData()->getAudioLoudness() / GLOW_MAX_LOUDNESS); + if (!Menu::getInstance()->isOptionChecked(MenuOption::GlowWhenSpeaking)) { + GLOW_FROM_AVERAGE_LOUDNESS = 0.0f; + } + Glower glower(_moving && distanceToTarget > GLOW_DISTANCE && renderMode == NORMAL_RENDER_MODE ? 1.0f : GLOW_FROM_AVERAGE_LOUDNESS); From 716bc58c2d5f2f2a6d326d4eee8fe511a7a9b824 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 18 Apr 2014 18:10:11 -0700 Subject: [PATCH 21/30] Fixed Jenkins failure --- interface/src/Util.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 5238db9b13..1dae3a4fd6 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -186,22 +186,16 @@ const glm::vec3 randVector() { } static TextRenderer* textRenderer(int mono) { + static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY); + static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT); + static TextRenderer* inconsolataRenderer = new TextRenderer(INCONSOLATA_FONT_FAMILY, -1, QFont::Bold, false); switch (mono) { case 1: - static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY); return monoRenderer; case 2: - static TextRenderer* inconsolataRenderer = new TextRenderer(INCONSOLATA_FONT_FAMILY, - -1, - QFont::Bold, false); return inconsolataRenderer; case 0: default: - static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, - -1, - -1, - false, - TextRenderer::SHADOW_EFFECT); return proportionalRenderer; } } From 6c376d6fa6701f981310dc1126fe1871f81ee368 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 19 Apr 2014 15:02:57 +0200 Subject: [PATCH 22/30] Add PageUp/Down to controls When you press PageUp/Down now you fly up and down. --- interface/src/Application.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0abcd9d1af..ca5bb260b6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -821,7 +821,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; - case Qt::Key_E: + case Qt::Key_E: case Qt::Key_PageUp: if (!_myAvatar->getDriveKeys(UP)) { _myAvatar->jump(); } @@ -832,7 +832,7 @@ void Application::keyPressEvent(QKeyEvent* event) { Menu::getInstance()->triggerOption(MenuOption::Stars); break; - case Qt::Key_C: + case Qt::Key_C: case Qt::Key_PageDown: _myAvatar->setDriveKeys(DOWN, 1.f); break; @@ -1018,11 +1018,11 @@ void Application::keyReleaseEvent(QKeyEvent* event) { } switch (event->key()) { - case Qt::Key_E: + case Qt::Key_E: case Qt::Key_PageUp: _myAvatar->setDriveKeys(UP, 0.f); break; - case Qt::Key_C: + case Qt::Key_C: case Qt::Key_PageDown: _myAvatar->setDriveKeys(DOWN, 0.f); break; From 615f8b8dadb703e5be7f432f842deb065a6d5764 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 19 Apr 2014 16:35:48 +0200 Subject: [PATCH 23/30] Fix spacing --- interface/src/Application.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ca5bb260b6..107d3c6482 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -821,7 +821,8 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; - case Qt::Key_E: case Qt::Key_PageUp: + case Qt::Key_E: + case Qt::Key_PageUp: if (!_myAvatar->getDriveKeys(UP)) { _myAvatar->jump(); } @@ -832,7 +833,8 @@ void Application::keyPressEvent(QKeyEvent* event) { Menu::getInstance()->triggerOption(MenuOption::Stars); break; - case Qt::Key_C: case Qt::Key_PageDown: + case Qt::Key_C: + case Qt::Key_PageDown: _myAvatar->setDriveKeys(DOWN, 1.f); break; @@ -1018,11 +1020,13 @@ void Application::keyReleaseEvent(QKeyEvent* event) { } switch (event->key()) { - case Qt::Key_E: case Qt::Key_PageUp: + case Qt::Key_E: + case Qt::Key_PageUp: _myAvatar->setDriveKeys(UP, 0.f); break; - case Qt::Key_C: case Qt::Key_PageDown: + case Qt::Key_C: + case Qt::Key_PageDown: _myAvatar->setDriveKeys(DOWN, 0.f); break; From 80dd0c33568c4977ff2ab805a2d74e7e2ea9afb9 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 20 Apr 2014 20:18:56 -0700 Subject: [PATCH 24/30] fix switching audio device bug --- interface/src/Audio.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 830e2fe69b..698a8db725 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -1068,7 +1068,6 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) delete _audioOutput; _audioOutput = NULL; - _numInputCallbackBytes = 0; _loopbackOutputDevice = NULL; delete _loopbackAudioOutput; From 36b58b178c33abc9633c9ad5c066f7e044787099 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 01:00:56 -0700 Subject: [PATCH 25/30] have scripted assignments added via config be static --- domain-server/src/DomainServer.cpp | 48 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index f32eb99733..da51009e6a 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -278,7 +278,8 @@ void DomainServer::createScriptedAssignmentsFromArray(const QJsonArray &configAr qDebug() << "Adding scripted assignment to queue -" << *scriptAssignment; qDebug() << "URL for script is" << assignmentURL; - _assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment)); + // scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies + addStaticAssignmentToAssignmentHash(scriptAssignment); } } } @@ -740,6 +741,16 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { return nodeJson; } +const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment"; + +QString pathForAssignmentScript(const QUuid& assignmentUUID) { + QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); + newPath += "/"; + // append the UUID for this script as the new filename, remove the curly braces + newPath += uuidStringWithoutCurlyBraces(assignmentUUID); + return newPath; +} + bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) { const QString JSON_MIME_TYPE = "application/json"; @@ -870,17 +881,13 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url assignmentPool = QString(assignmentPoolValue); } - const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment"; for (int i = 0; i < numInstances; i++) { // create an assignment for this saved script Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType, assignmentPool); - QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); - newPath += "/"; - // append the UUID for this script as the new filename, remove the curly braces - newPath += uuidStringWithoutCurlyBraces(scriptAssignment->getUUID()); + QString newPath = pathForAssignmentScript(scriptAssignment->getUUID()); // create a file with the GUID of the assignment in the script host location QFile scriptFile(newPath); @@ -945,6 +952,12 @@ void DomainServer::refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& qDebug() << "Reset UUID for assignment -" << *assignment.data() << "- and added to queue. Old UUID was" << uuidStringWithoutCurlyBraces(oldUUID); + if (assignment->getType() == Assignment::AgentType && assignment->getPayload().isEmpty()) { +\ + // if this was an Agent without a script URL, we need to rename the old file so it can be retrieved at the new UUID + QFile::rename(pathForAssignmentScript(oldUUID), pathForAssignmentScript(assignment->getUUID())); + } + // add the static assignment back under the right UUID, and to the queue _staticAssignmentHash.insert(assignment->getUUID(), assignment); @@ -1019,22 +1032,21 @@ SharedAssignmentPointer DomainServer::deployableAssignmentForRequest(const Assig bool assignmentPoolsMatch = assignment->getPool() == requestAssignment.getPool(); if ((requestIsAllTypes || assignmentTypesMatch) && (nietherHasPool || assignmentPoolsMatch)) { - - if (assignment->getType() == Assignment::AgentType) { - // if there is more than one instance to send out, simply decrease the number of instances - return _assignmentQueue.takeAt(sharedAssignment - _assignmentQueue.begin()); - } else { - // remove the assignment from the queue - SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment - - _assignmentQueue.begin()); - + + // remove the assignment from the queue + SharedAssignmentPointer deployableAssignment = _assignmentQueue.takeAt(sharedAssignment + - _assignmentQueue.begin()); + + if (deployableAssignment->getType() != Assignment::AgentType + || _staticAssignmentHash.contains(deployableAssignment->getUUID())) { + // this is a static assignment // until we get a check-in from that GUID // put assignment back in queue but stick it at the back so the others have a chance to go out _assignmentQueue.enqueue(deployableAssignment); - - // stop looping, we've handed out an assignment - return deployableAssignment; } + + // stop looping, we've handed out an assignment + return deployableAssignment; } else { // push forward the iterator to check the next assignment ++sharedAssignment; From c64ae353746a1a5a25e575b534632a9a5dd2f25a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 01:01:38 -0700 Subject: [PATCH 26/30] remove an extra bracket --- domain-server/src/DomainServer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index da51009e6a..d882bea1c8 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -953,7 +953,6 @@ void DomainServer::refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& << uuidStringWithoutCurlyBraces(oldUUID); if (assignment->getType() == Assignment::AgentType && assignment->getPayload().isEmpty()) { -\ // if this was an Agent without a script URL, we need to rename the old file so it can be retrieved at the new UUID QFile::rename(pathForAssignmentScript(oldUUID), pathForAssignmentScript(assignment->getUUID())); } From c9b04443105f29af8343a1864cf327db19816db3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 08:47:14 -0700 Subject: [PATCH 27/30] correct re-assignment of static assignments --- domain-server/src/DomainServer.cpp | 51 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index d882bea1c8..003a53027e 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -344,7 +344,6 @@ const NodeSet STATICALLY_ASSIGNED_NODES = NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::MetavoxelServer; - void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packet, const HifiSockAddr& senderSockAddr) { NodeType_t nodeType; @@ -353,34 +352,40 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe int numPreInterestBytes = parseNodeDataFromByteArray(nodeType, publicSockAddr, localSockAddr, packet, senderSockAddr); QUuid assignmentUUID = uuidFromPacketHeader(packet); - SharedAssignmentPointer matchingAssignment; + bool isStaticAssignment = _staticAssignmentHash.contains(assignmentUUID); + SharedAssignmentPointer matchingAssignment = SharedAssignmentPointer(); - if (!assignmentUUID.isNull() && (matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType)) - && matchingAssignment) { - // this is an assigned node, make sure the UUID sent is for an assignment we're actually trying to give out + if (isStaticAssignment) { + // this is a static assignment, make sure the UUID sent is for an assignment we're actually trying to give out + matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType); - // remove the matching assignment from the assignment queue so we don't take the next check in - // (if it exists) - removeMatchingAssignmentFromQueue(matchingAssignment); + if (matchingAssignment) { + // remove the matching assignment from the assignment queue so we don't take the next check in + // (if it exists) + removeMatchingAssignmentFromQueue(matchingAssignment); + } } else { assignmentUUID = QUuid(); } - // create a new session UUID for this node - QUuid nodeUUID = QUuid::createUuid(); - - SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, - publicSockAddr, localSockAddr); - - // when the newNode is created the linked data is also created - // if this was a static assignment set the UUID, set the sendingSockAddr - DomainServerNodeData* nodeData = reinterpret_cast(newNode->getLinkedData()); - - nodeData->setStaticAssignmentUUID(assignmentUUID); - nodeData->setSendingSockAddr(senderSockAddr); - - // reply back to the user with a PacketTypeDomainList - sendDomainListToNode(newNode, senderSockAddr, nodeInterestListFromPacket(packet, numPreInterestBytes)); + // make sure this was either not a static assignment or it was and we had a matching one in teh queue + if ((!isStaticAssignment && !STATICALLY_ASSIGNED_NODES.contains(nodeType)) || (isStaticAssignment && matchingAssignment)) { + // create a new session UUID for this node + QUuid nodeUUID = QUuid::createUuid(); + + SharedNodePointer newNode = LimitedNodeList::getInstance()->addOrUpdateNode(nodeUUID, nodeType, + publicSockAddr, localSockAddr); + + // when the newNode is created the linked data is also created + // if this was a static assignment set the UUID, set the sendingSockAddr + DomainServerNodeData* nodeData = reinterpret_cast(newNode->getLinkedData()); + + nodeData->setStaticAssignmentUUID(assignmentUUID); + nodeData->setSendingSockAddr(senderSockAddr); + + // reply back to the user with a PacketTypeDomainList + sendDomainListToNode(newNode, senderSockAddr, nodeInterestListFromPacket(packet, numPreInterestBytes)); + } } int DomainServer::parseNodeDataFromByteArray(NodeType_t& nodeType, HifiSockAddr& publicSockAddr, From 419e0928585dee5fe77bfbd5730527982cf7bd4d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 08:48:29 -0700 Subject: [PATCH 28/30] rename matching static method in DS --- domain-server/src/DomainServer.cpp | 4 ++-- domain-server/src/DomainServer.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 003a53027e..856078b8a9 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -357,7 +357,7 @@ void DomainServer::addNodeToNodeListAndConfirmConnection(const QByteArray& packe if (isStaticAssignment) { // this is a static assignment, make sure the UUID sent is for an assignment we're actually trying to give out - matchingAssignment = matchingStaticAssignmentForCheckIn(assignmentUUID, nodeType); + matchingAssignment = matchingQueuedAssignmentForCheckIn(assignmentUUID, nodeType); if (matchingAssignment) { // remove the matching assignment from the assignment queue so we don't take the next check in @@ -1009,7 +1009,7 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } -SharedAssignmentPointer DomainServer::matchingStaticAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType) { +SharedAssignmentPointer DomainServer::matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType) { QQueue::iterator i = _assignmentQueue.begin(); while (i != _assignmentQueue.end()) { diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 9bd10b8c60..1bc9b71064 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -70,7 +70,7 @@ private: void createStaticAssignmentsForType(Assignment::Type type, const QJsonArray& configArray); void populateDefaultStaticAssignmentsExcludingTypes(const QSet& excludedTypes); - SharedAssignmentPointer matchingStaticAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType); + SharedAssignmentPointer matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType); SharedAssignmentPointer deployableAssignmentForRequest(const Assignment& requestAssignment); void removeMatchingAssignmentFromQueue(const SharedAssignmentPointer& removableAssignment); void refreshStaticAssignmentAndAddToQueue(SharedAssignmentPointer& assignment); From cc7d9863989b797c1b860b24d5d0d954184d6196 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 09:29:08 -0700 Subject: [PATCH 29/30] don't make scripts statically assigned --- domain-server/src/DomainServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 856078b8a9..f42eb6c005 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -279,7 +279,7 @@ void DomainServer::createScriptedAssignmentsFromArray(const QJsonArray &configAr qDebug() << "URL for script is" << assignmentURL; // scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies - addStaticAssignmentToAssignmentHash(scriptAssignment); + _assignmentQueue.enqueue(SharedAssignmentPointer(scriptAssignment)); } } } @@ -991,6 +991,8 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } + if (node->getType() == NodeType::Agent && n + // cleanup the connection secrets that we set up for this node (on the other nodes) foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) { SharedNodePointer otherNode = LimitedNodeList::getInstance()->nodeWithUUID(otherNodeSessionUUID); From 07387a132e80a37938f3dc8c07f4967d88aa40cf Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 21 Apr 2014 09:31:21 -0700 Subject: [PATCH 30/30] fix broken DS build --- domain-server/src/DomainServer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index f42eb6c005..eb62dacf79 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -991,8 +991,6 @@ void DomainServer::nodeKilled(SharedNodePointer node) { } } - if (node->getType() == NodeType::Agent && n - // cleanup the connection secrets that we set up for this node (on the other nodes) foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) { SharedNodePointer otherNode = LimitedNodeList::getInstance()->nodeWithUUID(otherNodeSessionUUID);