From b74be92fd8965ae297ad442ede65c4cd933b5fb8 Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 6 Mar 2018 11:29:43 -0800 Subject: [PATCH 01/11] redo scale handles to fix scaling into avatar collision causing chaos --- .../system/libraries/entitySelectionTool.js | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 8a07ff0d20..3c794f14fb 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -458,12 +458,12 @@ SelectionDisplay = (function() { borderSize: 1.4 }; var handleScaleLBNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, -y, -z) - var handleScaleRBNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, -y, z) - var handleScaleLBFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, -y, -z) + var handleScaleRBNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, -y, -z) + var handleScaleLBFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, -y, z) var handleScaleRBFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, -y, z) var handleScaleLTNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, y, -z) - var handleScaleRTNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, y, z) - var handleScaleLTFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, y, -z) + var handleScaleRTNCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, y, -z) + var handleScaleLTFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // (-x, y, z) var handleScaleRTFCube = Overlays.addOverlay("cube", handlePropertiesScaleCubes); // ( x, y, z) var handlePropertiesScaleEdge = { @@ -1021,7 +1021,6 @@ SelectionDisplay = (function() { return; } - if (SelectionManager.hasSelection()) { var position = SelectionManager.worldPosition; var rotation = spaceMode === SPACE_LOCAL ? SelectionManager.localRotation : SelectionManager.worldRotation; @@ -1147,14 +1146,14 @@ SelectionDisplay = (function() { rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRBNCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleRBNCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; scaleRBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBNCubePosition)); Overlays.editOverlay(handleScaleRBNCube, { position: scaleRBNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleLBFCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleLBFCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; scaleLBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBFCubePosition)); Overlays.editOverlay(handleScaleLBFCube, { position: scaleLBFCubePosition, @@ -1175,14 +1174,14 @@ SelectionDisplay = (function() { rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRTNCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleRTNCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; scaleRTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTNCubePosition)); Overlays.editOverlay(handleScaleRTNCube, { position: scaleRTNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleLTFCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleLTFCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; scaleLTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTFCubePosition)); Overlays.editOverlay(handleScaleLTFCube, { position: scaleLTFCubePosition, @@ -1236,9 +1235,11 @@ SelectionDisplay = (function() { }); // UPDATE STRETCH HIGHLIGHT PANELS - var scaleLTFCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleLTFCubePosition); var scaleRBFCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRBFCubePosition); - var stretchPanelXDimensions = Vec3.subtract(scaleLTFCubePositionRotated, scaleRBFCubePositionRotated); + var scaleRTFCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRTFCubePosition); + var scaleLTNCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleLTNCubePosition); + var scaleRTNCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRTNCubePosition); + var stretchPanelXDimensions = Vec3.subtract(scaleRTNCubePositionRotated, scaleRBFCubePositionRotated); var tempY = Math.abs(stretchPanelXDimensions.y); stretchPanelXDimensions.x = STRETCH_PANEL_WIDTH; stretchPanelXDimensions.y = Math.abs(stretchPanelXDimensions.z); @@ -1249,8 +1250,6 @@ SelectionDisplay = (function() { rotation: rotationZ, dimensions: stretchPanelXDimensions }); - var scaleLTNCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleLTNCubePosition); - var scaleRTFCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRTFCubePosition); var stretchPanelYDimensions = Vec3.subtract(scaleLTNCubePositionRotated, scaleRTFCubePositionRotated); var tempX = Math.abs(stretchPanelYDimensions.x); stretchPanelYDimensions.x = Math.abs(stretchPanelYDimensions.z); @@ -1262,9 +1261,7 @@ SelectionDisplay = (function() { rotation: rotationY, dimensions: stretchPanelYDimensions }); - var scaleRTFCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRTFCubePosition); - var scaleRBNCubePositionRotated = Vec3.multiplyQbyV(rotationInverse, scaleRBNCubePosition); - var stretchPanelZDimensions = Vec3.subtract(scaleRTFCubePositionRotated, scaleRBNCubePositionRotated); + var stretchPanelZDimensions = Vec3.subtract(scaleLTNCubePositionRotated, scaleRBFCubePositionRotated); var tempX = Math.abs(stretchPanelZDimensions.x); stretchPanelZDimensions.x = Math.abs(stretchPanelZDimensions.y); stretchPanelZDimensions.y = tempX; @@ -1957,7 +1954,11 @@ SelectionDisplay = (function() { }; var onMove = function(event) { - var proportional = (spaceMode === SPACE_WORLD) || event.isShifted || directionEnum === STRETCH_DIRECTION.ALL; + if (event.x === undefined || event.y === undefined) { + return; + } + + var proportional = (spaceMode === SPACE_WORLD) || directionEnum === STRETCH_DIRECTION.ALL; var position, dimensions, rotation; if (spaceMode === SPACE_LOCAL) { @@ -1998,12 +1999,6 @@ SelectionDisplay = (function() { vector = grid.snapToSpacing(vector); var changeInDimensions = Vec3.multiply(NEGATE_VECTOR, vec3Mult(localSigns, vector)); - if (directionEnum === STRETCH_DIRECTION.ALL) { - var toCameraDistance = getDistanceToCamera(position); - var dimensionsMultiple = toCameraDistance * STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE; - changeInDimensions = Vec3.multiply(changeInDimensions, dimensionsMultiple); - } - var newDimensions; if (proportional) { var absoluteX = Math.abs(changeInDimensions.x); @@ -2085,31 +2080,38 @@ SelectionDisplay = (function() { function addHandleScaleTool(overlay, mode, directionEnum) { var directionVector, offset, selectedHandle; if (directionEnum === SCALE_DIRECTION.LBN) { - directionVector = { x:1, y:1, z:1 }; + directionVector = { x:1, y:0, z:1 }; + offset = { x:-1, y:-1, z:-1 }; selectedHandle = handleScaleLBNCube; } else if (directionEnum === SCALE_DIRECTION.RBN) { - directionVector = { x:1, y:1, z:-1 }; + directionVector = { x:-1, y:0, z:1 }; + offset = { x:1, y:-1, z:-1 }; selectedHandle = handleScaleRBNCube; } else if (directionEnum === SCALE_DIRECTION.LBF) { - directionVector = { x:-1, y:1, z:1 }; + directionVector = { x:1, y:0, z:-1 }; + offset = { x:-1, y:-1, z:1 }; selectedHandle = handleScaleLBFCube; } else if (directionEnum === SCALE_DIRECTION.RBF) { - directionVector = { x:-1, y:1, z:-1 }; + directionVector = { x:-1, y:0, z:-1 }; + offset = { x:1, y:-1, z:1 }; selectedHandle = handleScaleRBFCube; } else if (directionEnum === SCALE_DIRECTION.LTN) { - directionVector = { x:1, y:-1, z:1 }; + directionVector = { x:1, y:0, z:1 }; + offset = { x:-1, y:1, z:-1 }; selectedHandle = handleScaleLTNCube; } else if (directionEnum === SCALE_DIRECTION.RTN) { - directionVector = { x:1, y:-1, z:-1 }; + directionVector = { x:-1, y:0, z:1 }; + offset = { x:1, y:1, z:-1 }; selectedHandle = handleScaleRTNCube; } else if (directionEnum === SCALE_DIRECTION.LTF) { - directionVector = { x:-1, y:-1, z:1 }; + directionVector = { x:1, y:0, z:-1 }; + offset = { x:-1, y:1, z:1 }; selectedHandle = handleScaleLTFCube; } else if (directionEnum === SCALE_DIRECTION.RTF) { - directionVector = { x:-1, y:-1, z:-1 }; + directionVector = { x:-1, y:0, z:-1 }; + offset = { x:1, y:1, z:1 }; selectedHandle = handleScaleRTFCube; } - offset = Vec3.multiply(directionVector, NEGATE_VECTOR); var tool = makeStretchTool(mode, STRETCH_DIRECTION.ALL, directionVector, directionVector, offset, null, selectedHandle); return addHandleTool(overlay, tool); From 47e8e26255d267f450d7143f0c35ea2d8eece588 Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 6 Mar 2018 14:04:15 -0800 Subject: [PATCH 02/11] CR indent fixes --- .../system/libraries/entitySelectionTool.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 3c794f14fb..a4acbbf67c 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1954,10 +1954,10 @@ SelectionDisplay = (function() { }; var onMove = function(event) { - if (event.x === undefined || event.y === undefined) { - return; - } - + if (event.x === undefined || event.y === undefined) { + return; + } + var proportional = (spaceMode === SPACE_WORLD) || directionEnum === STRETCH_DIRECTION.ALL; var position, dimensions, rotation; @@ -2081,35 +2081,35 @@ SelectionDisplay = (function() { var directionVector, offset, selectedHandle; if (directionEnum === SCALE_DIRECTION.LBN) { directionVector = { x:1, y:0, z:1 }; - offset = { x:-1, y:-1, z:-1 }; + offset = { x:-1, y:-1, z:-1 }; selectedHandle = handleScaleLBNCube; } else if (directionEnum === SCALE_DIRECTION.RBN) { directionVector = { x:-1, y:0, z:1 }; - offset = { x:1, y:-1, z:-1 }; + offset = { x:1, y:-1, z:-1 }; selectedHandle = handleScaleRBNCube; } else if (directionEnum === SCALE_DIRECTION.LBF) { directionVector = { x:1, y:0, z:-1 }; - offset = { x:-1, y:-1, z:1 }; + offset = { x:-1, y:-1, z:1 }; selectedHandle = handleScaleLBFCube; } else if (directionEnum === SCALE_DIRECTION.RBF) { directionVector = { x:-1, y:0, z:-1 }; - offset = { x:1, y:-1, z:1 }; + offset = { x:1, y:-1, z:1 }; selectedHandle = handleScaleRBFCube; } else if (directionEnum === SCALE_DIRECTION.LTN) { directionVector = { x:1, y:0, z:1 }; - offset = { x:-1, y:1, z:-1 }; + offset = { x:-1, y:1, z:-1 }; selectedHandle = handleScaleLTNCube; } else if (directionEnum === SCALE_DIRECTION.RTN) { directionVector = { x:-1, y:0, z:1 }; - offset = { x:1, y:1, z:-1 }; + offset = { x:1, y:1, z:-1 }; selectedHandle = handleScaleRTNCube; } else if (directionEnum === SCALE_DIRECTION.LTF) { directionVector = { x:1, y:0, z:-1 }; - offset = { x:-1, y:1, z:1 }; + offset = { x:-1, y:1, z:1 }; selectedHandle = handleScaleLTFCube; } else if (directionEnum === SCALE_DIRECTION.RTF) { directionVector = { x:-1, y:0, z:-1 }; - offset = { x:1, y:1, z:1 }; + offset = { x:1, y:1, z:1 }; selectedHandle = handleScaleRTFCube; } var tool = makeStretchTool(mode, STRETCH_DIRECTION.ALL, directionVector, From 251e4a312736cba17c7e4a51e0f38cd7029dc561 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Tue, 6 Mar 2018 16:35:49 -0800 Subject: [PATCH 03/11] Fixed blocks importer textures being interpreted as image entities --- interface/src/Application.cpp | 18 +++++++++--------- interface/src/Application.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index af159263ed..189b4c02bc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6607,17 +6607,17 @@ void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, boo addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server."); - addAssetToWorldWithNewMapping(path, mapping, 0); + addAssetToWorldWithNewMapping(path, mapping, 0, isBlocks); } -void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy) { +void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks) { auto request = DependencyManager::get()->createGetMappingRequest(mapping); QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard. auto result = request->getError(); if (result == GetMappingRequest::NotFound) { - addAssetToWorldUpload(filePath, mapping); + addAssetToWorldUpload(filePath, mapping, isBlocks); } else if (result != GetMappingRequest::NoError) { QString errorInfo = "Could not map asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6629,7 +6629,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin } copy++; mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy)); - addAssetToWorldWithNewMapping(filePath, mapping, copy); + addAssetToWorldWithNewMapping(filePath, mapping, copy, isBlocks); } else { QString errorInfo = "Too many copies of asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6642,7 +6642,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin request->start(); } -void Application::addAssetToWorldUpload(QString filePath, QString mapping) { +void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks) { qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping; auto upload = DependencyManager::get()->createUpload(filePath); QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { @@ -6651,7 +6651,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping) { qWarning(interfaceapp) << "Error downloading model: " + errorInfo; addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { - addAssetToWorldSetMapping(filePath, mapping, hash); + addAssetToWorldSetMapping(filePath, mapping, hash, isBlocks); } // Remove temporary directory created by Clara.io market place download. @@ -6668,7 +6668,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping) { upload->start(); } -void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash) { +void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks) { auto request = DependencyManager::get()->createSetMappingRequest(mapping, hash); connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable { if (request->getError() != SetMappingRequest::NoError) { @@ -6677,8 +6677,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { // to prevent files that aren't models from being loaded into world automatically - if (filePath.endsWith(OBJ_EXTENSION) || filePath.endsWith(FBX_EXTENSION) || - filePath.endsWith(JPG_EXTENSION) || filePath.endsWith(PNG_EXTENSION)) { + if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || + filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && (!isBlocks)) { addAssetToWorldAddEntity(filePath, mapping); } else { qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; diff --git a/interface/src/Application.h b/interface/src/Application.h index ad12a4dc67..8b8e76d584 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -322,9 +322,9 @@ public slots: void addAssetToWorldFromURLRequestFinished(); void addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks); void addAssetToWorldUnzipFailure(QString filePath); - void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy); - void addAssetToWorldUpload(QString filePath, QString mapping); - void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash); + void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks); + void addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks); + void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks); void addAssetToWorldAddEntity(QString filePath, QString mapping); void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks); From c6e5f4c9c83774d323f7408f1d7b7a8f4e452765 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Tue, 6 Mar 2018 19:24:09 -0800 Subject: [PATCH 04/11] zip file drags don't auto add model textures --- interface/src/Application.cpp | 17 +++++++++-------- interface/src/Application.h | 8 ++++---- .../src/FileScriptingInterface.cpp | 13 +++++++++++++ .../script-engine/src/FileScriptingInterface.h | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 189b4c02bc..9a04a9509e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6607,17 +6607,17 @@ void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, boo addAssetToWorldInfo(filename, "Adding " + mapping.mid(1) + " to the Asset Server."); - addAssetToWorldWithNewMapping(path, mapping, 0, isBlocks); + addAssetToWorldWithNewMapping(path, mapping, 0, isZip, isBlocks); } -void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks) { +void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isZip, bool isBlocks) { auto request = DependencyManager::get()->createGetMappingRequest(mapping); QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable { const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard. auto result = request->getError(); if (result == GetMappingRequest::NotFound) { - addAssetToWorldUpload(filePath, mapping, isBlocks); + addAssetToWorldUpload(filePath, mapping, isZip, isBlocks); } else if (result != GetMappingRequest::NoError) { QString errorInfo = "Could not map asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6629,7 +6629,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin } copy++; mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy)); - addAssetToWorldWithNewMapping(filePath, mapping, copy, isBlocks); + addAssetToWorldWithNewMapping(filePath, mapping, copy, isZip, isBlocks); } else { QString errorInfo = "Too many copies of asset name: " + mapping.left(mapping.length() - QString::number(copy).length() - 1); @@ -6642,7 +6642,7 @@ void Application::addAssetToWorldWithNewMapping(QString filePath, QString mappin request->start(); } -void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks) { +void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool isZip, bool isBlocks) { qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping; auto upload = DependencyManager::get()->createUpload(filePath); QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { @@ -6651,7 +6651,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool qWarning(interfaceapp) << "Error downloading model: " + errorInfo; addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { - addAssetToWorldSetMapping(filePath, mapping, hash, isBlocks); + addAssetToWorldSetMapping(filePath, mapping, hash, isZip, isBlocks); } // Remove temporary directory created by Clara.io market place download. @@ -6668,7 +6668,7 @@ void Application::addAssetToWorldUpload(QString filePath, QString mapping, bool upload->start(); } -void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks) { +void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isZip, bool isBlocks) { auto request = DependencyManager::get()->createSetMappingRequest(mapping, hash); connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable { if (request->getError() != SetMappingRequest::NoError) { @@ -6678,7 +6678,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q } else { // to prevent files that aren't models from being loaded into world automatically if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || - filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && (!isBlocks)) { + filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && + (!isBlocks) && (!isZip)) { addAssetToWorldAddEntity(filePath, mapping); } else { qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; diff --git a/interface/src/Application.h b/interface/src/Application.h index 8b8e76d584..e4d784f2d5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -320,11 +320,11 @@ public slots: // FIXME: Move addAssetToWorld* methods to own class? void addAssetToWorldFromURL(QString url); void addAssetToWorldFromURLRequestFinished(); - void addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks); + void addAssetToWorld(QString filePath, QString zipFile, bool isZip = false, bool isBlocks = false); void addAssetToWorldUnzipFailure(QString filePath); - void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isBlocks); - void addAssetToWorldUpload(QString filePath, QString mapping, bool isBlocks); - void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isBlocks); + void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy, bool isZip = false, bool isBlocks = false); + void addAssetToWorldUpload(QString filePath, QString mapping, bool isZip = false, bool isBlocks = false); + void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash, bool isZip = false, bool isBlocks = false); void addAssetToWorldAddEntity(QString filePath, QString mapping); void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks); diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 1472e53045..3bf044fd8b 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -68,6 +68,10 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool if (path.contains("vr.google.com/downloads")) { isZip = true; } + if (!hasModel(fileList)) { + isZip = false; + } + emit unzipResult(path, fileList, autoAdd, isZip, isBlocks); } @@ -107,6 +111,15 @@ bool FileScriptingInterface::isTempDir(QString tempDir) { return (testContainer == tempContainer); } +bool FileScriptingInterface::hasModel(QStringList fileList) { + for (int i = 0; i < fileList.size(); i++) { + if (fileList.at(i).toLower().contains(".fbx") || fileList.at(i).toLower().contains(".obj")) { + return true; + } + } + return false; +} + QString FileScriptingInterface::getTempDir() { QTemporaryDir dir; dir.setAutoRemove(false); diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index e4c27dbf7f..5cbe417130 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -32,6 +32,7 @@ signals: private: bool isTempDir(QString tempDir); + bool hasModel(QStringList fileList); QStringList unzipFile(QString path, QString tempDir); void recursiveFileScan(QFileInfo file, QString* dirName); void downloadZip(QString path, const QString link); From 28589094c2b6f4b7b569ed40a3efd152f2b5cc46 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Wed, 7 Mar 2018 10:18:40 -0800 Subject: [PATCH 05/11] hopefully fixed mac/ubuntu builds --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9a04a9509e..7a9ce6f649 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6677,8 +6677,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { // to prevent files that aren't models from being loaded into world automatically - if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || - filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && + if ((filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || + filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) && (!isBlocks) && (!isZip)) { addAssetToWorldAddEntity(filePath, mapping); } else { From 9ae2da7e4b3a3b9f2560b39602d955874a5bf934 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Wed, 7 Mar 2018 13:18:36 -0800 Subject: [PATCH 06/11] fixed logic for texture files/non-models --- 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 7a9ce6f649..7fff296323 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6676,10 +6676,10 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q qWarning(interfaceapp) << "Error downloading model: " + errorInfo; addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { - // to prevent files that aren't models from being loaded into world automatically - if ((filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || - filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) && - (!isBlocks) && (!isZip)) { + // to prevent files that aren't models or texture files from being loaded into world automatically + if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || + (filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && + ((!isBlocks) && (!isZip)))) { addAssetToWorldAddEntity(filePath, mapping); } else { qCDebug(interfaceapp) << "Zipped contents are not supported entity files"; From 2987c90f965ff2f92eb7d847097d4c716be85731 Mon Sep 17 00:00:00 2001 From: Elisa Lupin-Jimenez Date: Wed, 7 Mar 2018 13:48:35 -0800 Subject: [PATCH 07/11] fixed syntax for ubuntu --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7fff296323..429348c593 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6677,8 +6677,8 @@ void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, Q addAssetToWorldError(filenameFromPath(filePath), errorInfo); } else { // to prevent files that aren't models or texture files from being loaded into world automatically - if (filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION) || - (filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION) && + if ((filePath.toLower().endsWith(OBJ_EXTENSION) || filePath.toLower().endsWith(FBX_EXTENSION)) || + ((filePath.toLower().endsWith(JPG_EXTENSION) || filePath.toLower().endsWith(PNG_EXTENSION)) && ((!isBlocks) && (!isZip)))) { addAssetToWorldAddEntity(filePath, mapping); } else { From a0eb7e0712373cdd87901e85f283ee56db9ad23c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 7 Mar 2018 15:01:12 -0800 Subject: [PATCH 08/11] Don't default unknown Marketplace item types to 'Entity' --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 372fb3c774..96ffa390bf 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -147,8 +147,7 @@ Rectangle { } else if (root.itemHref.indexOf('.json') > -1) { root.itemType = "entity"; // "wearable" type handled later } else { - console.log("WARNING - Item type is UNKNOWN!"); - root.itemType = "entity"; + root.itemType = "unknown"; } } From 9681f0eb779278c7170ccbb6647cef940cbdff56 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 7 Mar 2018 18:20:26 -0800 Subject: [PATCH 09/11] restore old scale math, disable avatar collisions while scaling --- .../system/libraries/entitySelectionTool.js | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 54254f6548..53769650e2 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -272,17 +272,19 @@ SelectionDisplay = (function() { var STRETCH_SPHERE_OFFSET = 0.06; var STRETCH_SPHERE_CAMERA_DISTANCE_MULTIPLE = 0.01; var STRETCH_MINIMUM_DIMENSION = 0.001; - var STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE = 2; + var STRETCH_ALL_MINIMUM_DIMENSION = 0.01; + var STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE = 6; var STRETCH_PANEL_WIDTH = 0.01; var SCALE_CUBE_OFFSET = 0.5; var SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.015; - var SCALE_MINIMUM_DIMENSION = 0.02; var CLONER_OFFSET = { x:0.9, y:-0.9, z:0.9 }; var CTRL_KEY_CODE = 16777249; + var AVATAR_COLLISIONS_OPTION = "Enable Avatar Collisions"; + var TRANSLATE_DIRECTION = { X : 0, Y : 1, @@ -336,6 +338,8 @@ SelectionDisplay = (function() { var ctrlPressed = false; + var handleStretchCollisionOverride = false; + var handlePropertiesTranslateArrowCones = { shape: "Cone", solid: true, @@ -597,6 +601,11 @@ SelectionDisplay = (function() { var activeTool = null; var handleTools = {}; + that.shutdown = function() { + that.restoreAvatarCollisionsFromStretch(); + } + Script.scriptEnding.connect(that.shutdown); + // We get mouseMoveEvents from the handControllers, via handControllerPointer. // But we dont' get mousePressEvents. that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); @@ -1740,6 +1749,13 @@ SelectionDisplay = (function() { }; }; + that.restoreAvatarCollisionsFromStretch = function() { + if (handleStretchCollisionOverride) { + Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, true); + handleStretchCollisionOverride = false; + } + } + // TOOL DEFINITION: HANDLE STRETCH TOOL function makeStretchTool(stretchMode, directionEnum, directionVec, pivot, offset, stretchPanel, scaleHandle) { var directionFor3DStretch = directionVec; @@ -1942,6 +1958,10 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } + if (Menu.isOptionChecked(AVATAR_COLLISIONS_OPTION)) { + Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, false); + handleStretchCollisionOverride = true; + } }; var onEnd = function(event, reason) { @@ -1951,6 +1971,7 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE }); } + that.restoreAvatarCollisionsFromStretch(); pushCommandForSelections(); }; @@ -2000,6 +2021,12 @@ SelectionDisplay = (function() { vector = grid.snapToSpacing(vector); var changeInDimensions = Vec3.multiply(NEGATE_VECTOR, vec3Mult(localSigns, vector)); + if (directionEnum === STRETCH_DIRECTION.ALL) { + var toCameraDistance = getDistanceToCamera(position); + var dimensionsMultiple = toCameraDistance * STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE; + changeInDimensions = Vec3.multiply(changeInDimensions, dimensionsMultiple); + } + var newDimensions; if (proportional) { var absoluteX = Math.abs(changeInDimensions.x); @@ -2022,9 +2049,11 @@ SelectionDisplay = (function() { newDimensions = Vec3.sum(initialDimensions, changeInDimensions); } - newDimensions.x = Math.max(newDimensions.x, STRETCH_MINIMUM_DIMENSION); - newDimensions.y = Math.max(newDimensions.y, STRETCH_MINIMUM_DIMENSION); - newDimensions.z = Math.max(newDimensions.z, STRETCH_MINIMUM_DIMENSION); + var minimumDimension = directionEnum === STRETCH_DIRECTION.ALL ? STRETCH_ALL_MINIMUM_DIMENSION : + STRETCH_MINIMUM_DIMENSION; + newDimensions.x = Math.max(newDimensions.x, minimumDimension); + newDimensions.y = Math.max(newDimensions.y, minimumDimension); + newDimensions.z = Math.max(newDimensions.z, minimumDimension); var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions)); if (directionEnum === STRETCH_DIRECTION.ALL) { @@ -2081,38 +2110,31 @@ SelectionDisplay = (function() { function addHandleScaleTool(overlay, mode, directionEnum) { var directionVector, offset, selectedHandle; if (directionEnum === SCALE_DIRECTION.LBN) { - directionVector = { x:1, y:0, z:1 }; - offset = { x:-1, y:-1, z:-1 }; + directionVector = { x:1, y:1, z:1 }; selectedHandle = handleScaleLBNCube; } else if (directionEnum === SCALE_DIRECTION.RBN) { - directionVector = { x:-1, y:0, z:1 }; - offset = { x:1, y:-1, z:-1 }; + directionVector = { x:-1, y:1, z:1 }; selectedHandle = handleScaleRBNCube; } else if (directionEnum === SCALE_DIRECTION.LBF) { - directionVector = { x:1, y:0, z:-1 }; - offset = { x:-1, y:-1, z:1 }; + directionVector = { x:1, y:1, z:-1 }; selectedHandle = handleScaleLBFCube; } else if (directionEnum === SCALE_DIRECTION.RBF) { - directionVector = { x:-1, y:0, z:-1 }; - offset = { x:1, y:-1, z:1 }; + directionVector = { x:-1, y:1, z:-1 }; selectedHandle = handleScaleRBFCube; } else if (directionEnum === SCALE_DIRECTION.LTN) { - directionVector = { x:1, y:0, z:1 }; - offset = { x:-1, y:1, z:-1 }; + directionVector = { x:1, y:-1, z:1 }; selectedHandle = handleScaleLTNCube; } else if (directionEnum === SCALE_DIRECTION.RTN) { - directionVector = { x:-1, y:0, z:1 }; - offset = { x:1, y:1, z:-1 }; + directionVector = { x:-1, y:-1, z:1 }; selectedHandle = handleScaleRTNCube; } else if (directionEnum === SCALE_DIRECTION.LTF) { - directionVector = { x:1, y:0, z:-1 }; - offset = { x:-1, y:1, z:1 }; + directionVector = { x:1, y:-1, z:-1 }; selectedHandle = handleScaleLTFCube; } else if (directionEnum === SCALE_DIRECTION.RTF) { - directionVector = { x:-1, y:0, z:-1 }; - offset = { x:1, y:1, z:1 }; + directionVector = { x:-1, y:-1, z:-1 }; selectedHandle = handleScaleRTFCube; } + offset = Vec3.multiply(directionVector, NEGATE_VECTOR); var tool = makeStretchTool(mode, STRETCH_DIRECTION.ALL, directionVector, directionVector, offset, null, selectedHandle); return addHandleTool(overlay, tool); From 554c37d14b5c1b25669eff2c9e9568d0e554b39f Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 7 Mar 2018 19:34:08 -0800 Subject: [PATCH 10/11] removed undefined event checks in scaling --- scripts/system/libraries/entitySelectionTool.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 53769650e2..fced5fc4e9 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1976,10 +1976,6 @@ SelectionDisplay = (function() { }; var onMove = function(event) { - if (event.x === undefined || event.y === undefined) { - return; - } - var proportional = (spaceMode === SPACE_WORLD) || directionEnum === STRETCH_DIRECTION.ALL; var position, dimensions, rotation; From 22f18dbf56598b3644cddd9739e8e54c59856217 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 8 Mar 2018 13:12:13 -0800 Subject: [PATCH 11/11] Don't hit certain Commerce backend endpoints when wallet isn't yet auth'd --- interface/src/commerce/Ledger.cpp | 41 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index 712c505e8a..858af9b13d 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -80,9 +80,13 @@ void Ledger::signedSend(const QString& propertyName, const QByteArray& text, con void Ledger::keysQuery(const QString& endpoint, const QString& success, const QString& fail, QJsonObject& requestParams) { auto wallet = DependencyManager::get(); - requestParams["public_keys"] = QJsonArray::fromStringList(wallet->listPublicKeys()); - - send(endpoint, success, fail, QNetworkAccessManager::PostOperation, AccountManagerAuth::Required, requestParams); + QStringList cachedPublicKeys = wallet->listPublicKeys(); + if (!cachedPublicKeys.isEmpty()) { + requestParams["public_keys"] = QJsonArray::fromStringList(cachedPublicKeys); + send(endpoint, success, fail, QNetworkAccessManager::PostOperation, AccountManagerAuth::Required, requestParams); + } else { + qDebug(commerce) << "User attempted to call keysQuery, but cachedPublicKeys was empty!"; + } } void Ledger::keysQuery(const QString& endpoint, const QString& success, const QString& fail) { @@ -296,14 +300,18 @@ void Ledger::updateLocation(const QString& asset_id, const QString location, con emit walletScriptingInterface->walletNotSetup(); qDebug(commerce) << "User attempted to update the location of a certificate, but their wallet wasn't ready. Status:" << walletStatus; } else { - QStringList keys = wallet->listPublicKeys(); - QString key = keys[0]; - QJsonObject transaction; - transaction["certificate_id"] = asset_id; - transaction["place_name"] = location; - QJsonDocument transactionDoc{ transaction }; - auto transactionString = transactionDoc.toJson(QJsonDocument::Compact); - signedSend("transaction", transactionString, key, "location", "updateLocationSuccess", "updateLocationFailure", controlledFailure); + QStringList cachedPublicKeys = wallet->listPublicKeys(); + if (!cachedPublicKeys.isEmpty()) { + QString key = cachedPublicKeys[0]; + QJsonObject transaction; + transaction["certificate_id"] = asset_id; + transaction["place_name"] = location; + QJsonDocument transactionDoc{ transaction }; + auto transactionString = transactionDoc.toJson(QJsonDocument::Compact); + signedSend("transaction", transactionString, key, "location", "updateLocationSuccess", "updateLocationFailure", controlledFailure); + } else { + qDebug(commerce) << "User attempted to update the location of a certificate, but cachedPublicKeys was empty!"; + } } } @@ -359,7 +367,12 @@ void Ledger::alreadyOwned(const QString& marketplaceId) { auto wallet = DependencyManager::get(); QString endpoint = "already_owned"; QJsonObject request; - request["public_keys"] = QJsonArray::fromStringList(wallet->listPublicKeys()); - request["marketplace_item_id"] = marketplaceId; - send(endpoint, "alreadyOwnedSuccess", "alreadyOwnedFailure", QNetworkAccessManager::PutOperation, AccountManagerAuth::Required, request); + QStringList cachedPublicKeys = wallet->listPublicKeys(); + if (!cachedPublicKeys.isEmpty()) { + request["public_keys"] = QJsonArray::fromStringList(wallet->listPublicKeys()); + request["marketplace_item_id"] = marketplaceId; + send(endpoint, "alreadyOwnedSuccess", "alreadyOwnedFailure", QNetworkAccessManager::PutOperation, AccountManagerAuth::Required, request); + } else { + qDebug(commerce) << "User attempted to use the alreadyOwned endpoint, but cachedPublicKeys was empty!"; + } }