From 72f272b5d3ba908f202c4878dacbee96a7643b77 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 27 Apr 2016 09:48:16 -0700 Subject: [PATCH 01/15] lampfix --- .../DomainContent/Home/kineticObjects/deskLamp.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpublishedScripts/DomainContent/Home/kineticObjects/deskLamp.json b/unpublishedScripts/DomainContent/Home/kineticObjects/deskLamp.json index 9b15f6c260..762a43658f 100644 --- a/unpublishedScripts/DomainContent/Home/kineticObjects/deskLamp.json +++ b/unpublishedScripts/DomainContent/Home/kineticObjects/deskLamp.json @@ -20,7 +20,7 @@ "parentID": "{f59b50d8-13fb-4ceb-b80a-62cd03428a7c}", "position": { "x": 0, - "y": -0.075, + "y": 0.11, "z": 0 }, "queryAACube": { From c686418be0f434139c09e950dab74a2f156e9d12 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 27 Apr 2016 10:34:29 -0700 Subject: [PATCH 02/15] optimize use of EntityItem::getDimensions() --- libraries/entities/src/EntityItem.cpp | 73 +++++++++++++++------------ libraries/entities/src/EntityItem.h | 2 +- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 938fbe12ac..2d1bbf2f88 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -781,7 +781,8 @@ void EntityItem::adjustEditPacketForClockSkew(QByteArray& buffer, qint64 clockSk } float EntityItem::computeMass() const { - return _density * _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + return _density * _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; } void EntityItem::setDensity(float density) { @@ -801,7 +802,8 @@ void EntityItem::setMass(float mass) { // we must protect the density range to help maintain stability of physics simulation // therefore this method might not accept the mass that is supplied. - float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + float volume = _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; // compute new density const float MIN_VOLUME = 1.0e-6f; // 0.001mm^3 @@ -1222,11 +1224,13 @@ AACube EntityItem::getMaximumAACube(bool& success) const { // * we know that the position is the center of rotation glm::vec3 centerOfRotation = getPosition(success); // also where _registration point is if (success) { + _recalcMaxAACube = false; // * we know that the registration point is the center of rotation // * we can calculate the length of the furthest extent from the registration point // as the dimensions * max (registrationPoint, (1.0,1.0,1.0) - registrationPoint) - glm::vec3 registrationPoint = (getDimensions() * getRegistrationPoint()); - glm::vec3 registrationRemainder = (getDimensions() * (glm::vec3(1.0f, 1.0f, 1.0f) - getRegistrationPoint())); + glm::vec3 dimensions = getDimensions(); + glm::vec3 registrationPoint = (dimensions * _registrationPoint); + glm::vec3 registrationRemainder = (dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint)); glm::vec3 furthestExtentFromRegistration = glm::max(registrationPoint, registrationRemainder); // * we know that if you rotate in any direction you would create a sphere @@ -1238,7 +1242,6 @@ AACube EntityItem::getMaximumAACube(bool& success) const { glm::vec3 minimumCorner = centerOfRotation - glm::vec3(radius, radius, radius); _maxAACube = AACube(minimumCorner, radius * 2.0f); - _recalcMaxAACube = false; } } else { success = true; @@ -1251,28 +1254,27 @@ AACube EntityItem::getMaximumAACube(bool& success) const { /// AACube EntityItem::getMinimumAACube(bool& success) const { if (_recalcMinAACube) { - // _position represents the position of the registration point. - glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; - - glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * getRegistrationPoint()); - glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder; - Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; - Extents rotatedExtentsRelativeToRegistrationPoint = - unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation()); - - // shift the extents to be relative to the position/registration point - rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition(success)); - + // position represents the position of the registration point. + glm::vec3 position = getPosition(success); if (success) { + _recalcMinAACube = false; + glm::vec3 dimensions = getDimensions(); + glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint); + glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint); + Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; + extents.rotate(getRotation()); + + // shift the extents to be relative to the position/registration point + extents.shiftBy(position); + // the cube that best encompasses extents is... - AABox box(rotatedExtentsRelativeToRegistrationPoint); + AABox box(extents); glm::vec3 centerOfBox = box.calcCenter(); float longestSide = box.getLargestDimension(); float halfLongestSide = longestSide / 2.0f; glm::vec3 cornerOfCube = centerOfBox - glm::vec3(halfLongestSide, halfLongestSide, halfLongestSide); _minAACube = AACube(cornerOfCube, longestSide); - _recalcMinAACube = false; } } else { success = true; @@ -1282,21 +1284,20 @@ AACube EntityItem::getMinimumAACube(bool& success) const { AABox EntityItem::getAABox(bool& success) const { if (_recalcAABox) { - // _position represents the position of the registration point. - glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; - - glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * _registrationPoint); - glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder; - Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; - Extents rotatedExtentsRelativeToRegistrationPoint = - unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation()); - - // shift the extents to be relative to the position/registration point - rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition(success)); - + // position represents the position of the registration point. + glm::vec3 position = getPosition(success); if (success) { - _cachedAABox = AABox(rotatedExtentsRelativeToRegistrationPoint); _recalcAABox = false; + glm::vec3 dimensions = getDimensions(); + glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint); + glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint); + Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; + extents.rotate(getRotation()); + + // shift the extents to be relative to the position/registration point + extents.shiftBy(position); + + _cachedAABox = AABox(extents); } } else { success = true; @@ -1373,6 +1374,11 @@ void EntityItem::computeShapeInfo(ShapeInfo& info) { adjustShapeInfoByRegistration(info); } +float EntityItem::getVolumeEstimate() const { + glm::vec3 dimensions = getDimensions(); + return dimensions.x * dimensions.y * dimensions.z; +} + void EntityItem::updateRegistrationPoint(const glm::vec3& value) { if (value != _registrationPoint) { setRegistrationPoint(value); @@ -1433,7 +1439,8 @@ void EntityItem::updateMass(float mass) { // we must protect the density range to help maintain stability of physics simulation // therefore this method might not accept the mass that is supplied. - float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + float volume = _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; // compute new density float newDensity = _density; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 5e34d942f6..b3689b9b56 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -314,7 +314,7 @@ public: virtual bool isReadyToComputeShape() { return !isDead(); } virtual void computeShapeInfo(ShapeInfo& info); - virtual float getVolumeEstimate() const { return getDimensions().x * getDimensions().y * getDimensions().z; } + virtual float getVolumeEstimate() const; /// return preferred shape type (actual physical shape may differ) virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; } From b5ad98981128a586e2adedc05acc184e7da9e358 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 27 Apr 2016 11:04:22 -0700 Subject: [PATCH 03/15] more optimized uses of EntityItem::getDimensions() --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 5 +++-- .../entities-renderer/src/RenderablePolyVoxEntityItem.cpp | 8 +++++--- .../entities-renderer/src/RenderableWebEntityItem.cpp | 5 +++-- libraries/entities/src/LightEntityItem.cpp | 5 +++-- libraries/entities/src/LineEntityItem.cpp | 4 +--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index f3a8d3110c..c4ac9b09e5 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -339,15 +339,16 @@ void RenderableModelEntityItem::updateModelBounds() { return; } bool movingOrAnimating = isMovingRelativeToParent() || isAnimatingSomething(); + glm::vec3 dimensions = getDimensions(); if ((movingOrAnimating || _needsInitialSimulation || _needsJointSimulation || _model->getTranslation() != getPosition() || - _model->getScaleToFitDimensions() != getDimensions() || + _model->getScaleToFitDimensions() != dimensions || _model->getRotation() != getRotation() || _model->getRegistrationPoint() != getRegistrationPoint()) && _model->isActive() && _dimensionsInitialized) { - _model->setScaleToFit(true, getDimensions()); + _model->setScaleToFit(true, dimensions); _model->setSnapModelToRegistrationPoint(true, getRegistrationPoint()); _model->setRotation(getRotation()); _model->setTranslation(getPosition()); diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index c9c4c8503a..6c4e3994c6 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -206,13 +206,14 @@ glm::mat4 RenderablePolyVoxEntityItem::voxelToLocalMatrix() const { voxelVolumeSize = _voxelVolumeSize; }); - glm::vec3 scale = getDimensions() / voxelVolumeSize; // meters / voxel-units + glm::vec3 dimensions = getDimensions(); + glm::vec3 scale = dimensions / voxelVolumeSize; // meters / voxel-units bool success; // TODO -- Does this actually have to happen in world space? glm::vec3 center = getCenterPosition(success); // this handles registrationPoint changes glm::vec3 position = getPosition(success); glm::vec3 positionToCenter = center - position; - positionToCenter -= getDimensions() * Vectors::HALF - getSurfacePositionAdjustment(); + positionToCenter -= dimensions * Vectors::HALF - getSurfacePositionAdjustment(); glm::mat4 centerToCorner = glm::translate(glm::mat4(), positionToCenter); glm::mat4 scaled = glm::scale(centerToCorner, scale); return scaled; @@ -445,7 +446,8 @@ bool RenderablePolyVoxEntityItem::findDetailedRayIntersection(const glm::vec3& o // the PolyVox ray intersection code requires a near and far point. // set ray cast length to long enough to cover all of the voxel space float distanceToEntity = glm::distance(origin, getPosition()); - float largestDimension = glm::max(getDimensions().x, getDimensions().y, getDimensions().z) * 2.0f; + glm::vec3 dimensions = getDimensions(); + float largestDimension = glm::max(dimensions.x, dimensions.y, dimensions.z) * 2.0f; glm::vec3 farPoint = origin + normDirection * (distanceToEntity + largestDimension); glm::vec4 originInVoxel = wtvMatrix * glm::vec4(origin, 1.0f); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 855fd16408..26aecf6050 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -119,12 +119,13 @@ bool RenderableWebEntityItem::buildWebSurface(EntityTreeRenderer* renderer) { // Map the intersection point to an actual offscreen pixel glm::vec3 point = intersection.intersection; + glm::vec3 dimensions = getDimensions(); point -= getPosition(); point = glm::inverse(getRotation()) * point; - point /= getDimensions(); + point /= dimensions; point += 0.5f; point.y = 1.0f - point.y; - point *= getDimensions() * METERS_TO_INCHES * DPI; + point *= dimensions * (METERS_TO_INCHES * DPI); if (event->button() == Qt::MouseButton::LeftButton) { if (event->type() == QEvent::MouseButtonPress) { diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index 852b37a751..1be133463c 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -76,12 +76,13 @@ void LightEntityItem::setIsSpotlight(bool value) { if (value != _isSpotlight) { _isSpotlight = value; + glm::vec3 dimensions = getDimensions(); if (_isSpotlight) { - const float length = getDimensions().z; + const float length = dimensions.z; const float width = length * glm::sin(glm::radians(_cutoff)); setDimensions(glm::vec3(width, width, length)); } else { - float maxDimension = glm::max(getDimensions().x, getDimensions().y, getDimensions().z); + float maxDimension = glm::max(dimensions.x, dimensions.y, dimensions.z); setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension)); } } diff --git a/libraries/entities/src/LineEntityItem.cpp b/libraries/entities/src/LineEntityItem.cpp index d48780845f..78b6107d88 100644 --- a/libraries/entities/src/LineEntityItem.cpp +++ b/libraries/entities/src/LineEntityItem.cpp @@ -101,15 +101,13 @@ bool LineEntityItem::setLinePoints(const QVector& points) { if (points.size() > MAX_POINTS_PER_LINE) { return false; } + glm::vec3 halfBox = getDimensions() * 0.5f; for (int i = 0; i < points.size(); i++) { glm::vec3 point = points.at(i); - // glm::vec3 pos = getPosition(); - glm::vec3 halfBox = getDimensions() * 0.5f; if ( (point.x < - halfBox.x || point.x > halfBox.x) || (point.y < -halfBox.y || point.y > halfBox.y) || (point.z < - halfBox.z || point.z > halfBox.z) ) { qDebug() << "Point is outside entity's bounding box"; return false; } - } _points = points; _pointsChanged = true; From 26e8e22b8bbfe3e21d49c0ce3eab93b25b8fe7ae Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 28 Apr 2016 12:23:47 +1200 Subject: [PATCH 04/15] Move directory, examples, and edit toolbar buttons down Moved down as far as they can go within the getRecommendedOverlayRect(), i.e., there's a 50px margin. --- scripts/system/directory.js | 2 +- scripts/system/edit.js | 2 +- scripts/system/examples.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/directory.js b/scripts/system/directory.js index cf9aa6aba7..881b25b771 100644 --- a/scripts/system/directory.js +++ b/scripts/system/directory.js @@ -26,7 +26,7 @@ var directoryWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 25; +var TOOLBAR_MARGIN_Y = 0; function showDirectory() { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 2796297e40..b82554aae0 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -53,7 +53,7 @@ selectionManager.addEventListener(function() { var toolIconUrl = Script.resolvePath("assets/images/tools/"); var toolHeight = 50; var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 25; +var TOOLBAR_MARGIN_Y = 0; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; diff --git a/scripts/system/examples.js b/scripts/system/examples.js index 9caedec70f..9438aef613 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -26,7 +26,7 @@ var examplesWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 25; +var TOOLBAR_MARGIN_Y = 0; function showExamples(marketplaceID) { From eee3cedd951fa1bc82d83cec04aeb82340a9aaec Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 28 Apr 2016 12:55:41 +1200 Subject: [PATCH 05/15] Fix typo --- scripts/system/examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/examples.js b/scripts/system/examples.js index 9438aef613..9d33e473af 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -58,7 +58,7 @@ var toolBar = (function() { browseExamplesButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { x: windowDimensions.x / 2, y: windowDimensions.y From 90c59c5af079274826db3ee5b71cdeb2a9cc3f1a Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 10:39:53 -0700 Subject: [PATCH 06/15] remove directory from default --- scripts/defaultScripts.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 3772fd51e9..ceccf20647 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -17,7 +17,5 @@ Script.load("system/notifications.js"); Script.load("system/controllers/handControllerGrab.js"); Script.load("system/controllers/squeezeHands.js"); Script.load("system/controllers/grab.js"); -Script.load("system/directory.js"); Script.load("system/dialTone.js"); -// Script.load("attachedEntitiesManager.js"); Script.load("system/depthReticle.js"); \ No newline at end of file From b7188bad30510298f4810f22b2009444cf5bc553 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 29 Apr 2016 07:13:56 +1200 Subject: [PATCH 07/15] Automatically upgrade toolbar position to bottom center of window --- scripts/system/libraries/toolBars.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/system/libraries/toolBars.js b/scripts/system/libraries/toolBars.js index 1f83a4ffa6..110e3d1ea9 100644 --- a/scripts/system/libraries/toolBars.js +++ b/scripts/system/libraries/toolBars.js @@ -452,7 +452,11 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit return id; } if (this.fractionKey || optionalInitialPositionFunction) { - var savedFraction = JSON.parse(Settings.getValue(this.fractionKey) || '0'); // getValue can answer empty string + var NEW_TOOLBAR_POSITION = "newToolbarPosition"; // New default position is bottom center of screen instead of right. + var isNewPosition = Settings.getValue(NEW_TOOLBAR_POSITION); + var savedFraction = isNewPosition ? JSON.parse(Settings.getValue(this.fractionKey) || "0") : 0; + Settings.setValue(NEW_TOOLBAR_POSITION, true); + var recommendedRect = Controller.getRecommendedOverlayRect(); var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; if (savedFraction) { From 1cf53829d3adab9875ec28962e75ece01c60cbc7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 29 Apr 2016 08:20:20 +1200 Subject: [PATCH 08/15] Fix upgrading for all toolbar buttons --- scripts/system/libraries/toolBars.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/system/libraries/toolBars.js b/scripts/system/libraries/toolBars.js index 110e3d1ea9..d97575d349 100644 --- a/scripts/system/libraries/toolBars.js +++ b/scripts/system/libraries/toolBars.js @@ -383,6 +383,9 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit }; if (optionalPersistenceKey) { this.fractionKey = optionalPersistenceKey + '.fraction'; + // FIXME: New default position in RC8 is bottom center of screen instead of right. Can remove this key and associated + // code once the new toolbar position is well established with users. + this.isNewPositionKey = optionalPersistenceKey + '.isNewPosition'; this.save = function () { var recommendedRect = Controller.getRecommendedOverlayRect(); var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; @@ -452,10 +455,9 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit return id; } if (this.fractionKey || optionalInitialPositionFunction) { - var NEW_TOOLBAR_POSITION = "newToolbarPosition"; // New default position is bottom center of screen instead of right. - var isNewPosition = Settings.getValue(NEW_TOOLBAR_POSITION); + var isNewPosition = Settings.getValue(this.isNewPositionKey); var savedFraction = isNewPosition ? JSON.parse(Settings.getValue(this.fractionKey) || "0") : 0; - Settings.setValue(NEW_TOOLBAR_POSITION, true); + Settings.setValue(this.isNewPositionKey, true); var recommendedRect = Controller.getRecommendedOverlayRect(); var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; From 795d866da9555f8151b07705e85c5874de07860c Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:29:54 -0700 Subject: [PATCH 09/15] re add locking/visibility tools to edit.js --- scripts/system/edit.js | 22 +++++++++------------- scripts/system/html/entityList.html | 2 +- scripts/system/libraries/entityList.js | 8 +++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 2796297e40..163ac867b4 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -50,10 +50,9 @@ selectionManager.addEventListener(function() { lightOverlayManager.updatePositions(); }); -var toolIconUrl = Script.resolvePath("assets/images/tools/"); +var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; var toolHeight = 50; var toolWidth = 50; -var TOOLBAR_MARGIN_Y = 25; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -106,7 +105,7 @@ IMPORTING_SVO_OVERLAY_HEIGHT = 30; IMPORTING_SVO_OVERLAY_MARGIN = 5; IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34; var importingSVOImageOverlay = Overlays.addOverlay("image", { - imageURL: Script.resolvePath("assets") + "/images/hourglass.svg", + imageURL: HIFI_PUBLIC_BUCKET + "images/hourglass.svg", width: 20, height: 20, alpha: 1.0, @@ -180,18 +179,15 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x / 2, - y: windowDimensions.y + x: windowDimensions.x - 8 - toolbar.width, + y: (windowDimensions.y - toolbar.height) / 2 }; - }, { - x: toolWidth, - y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ - imageURL: toolIconUrl + "edit-01.svg", + imageURL: toolIconUrl + "edit-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -205,7 +201,7 @@ var toolBar = (function() { }, true, false); newModelButton = toolBar.addTool({ - imageURL:toolIconUrl + "model-01.svg", + imageURL: toolIconUrl + "model-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -220,7 +216,7 @@ var toolBar = (function() { }); newCubeButton = toolBar.addTool({ - imageURL:toolIconUrl + "cube-01.svg", + imageURL: toolIconUrl + "cube-01.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, @@ -1864,4 +1860,4 @@ entityListTool.webView.webEventReceived.connect(function(data) { } } } -}); +}); \ No newline at end of file diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index e5fa2ce839..dbc224e9fb 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -378,4 +378,4 @@ - + \ No newline at end of file diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 00120ab4c2..e9baeac86c 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -59,6 +59,8 @@ EntityListTool = function(opts) { name: properties.name, type: properties.type, url: properties.type == "Model" ? properties.modelURL : "", + locked: properties.locked, + visible: properties.visible }); } @@ -99,6 +101,10 @@ EntityListTool = function(opts) { } } else if (data.type == "delete") { deleteSelectedEntities(); + } else if (data.type == "toggleLocked") { + toggleSelectedEntitiesLocked(); + } else if (data.type == "toggleVisible") { + toggleSelectedEntitiesVisible(); } else if (data.type === "radius") { searchRadius = data.radius; that.sendUpdate(); @@ -112,4 +118,4 @@ EntityListTool = function(opts) { }); return that; -}; +}; \ No newline at end of file From b52406e127504c3264d9986143733a5bf630d715 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:40:58 -0700 Subject: [PATCH 10/15] horizontal --- scripts/system/edit.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 163ac867b4..30e1996bae 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -53,6 +53,7 @@ selectionManager.addEventListener(function() { var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 25; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -179,11 +180,14 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: (windowDimensions.y - toolbar.height) / 2 + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ From aafed4e1b8470889ac9284bb52547aef83bfeb20 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:42:10 -0700 Subject: [PATCH 11/15] fix horizontal typo in examples --- scripts/system/examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/examples.js b/scripts/system/examples.js index 9caedec70f..eeadfc21a0 100644 --- a/scripts/system/examples.js +++ b/scripts/system/examples.js @@ -58,7 +58,7 @@ var toolBar = (function() { browseExamplesButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { x: windowDimensions.x / 2, y: windowDimensions.y From e68909ce3e65288c27790403693d23a1a6180e5a Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 13:48:09 -0700 Subject: [PATCH 12/15] re add local paths --- scripts/system/edit.js | 47 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 30e1996bae..568ee28bc6 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -48,9 +48,9 @@ var entityListTool = EntityListTool(); selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); lightOverlayManager.updatePositions(); -}); +}); -var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; +var toolIconUrl = Script.resolvePath("assets/images/tools/"); var toolHeight = 50; var toolWidth = 50; var TOOLBAR_MARGIN_Y = 25; @@ -106,7 +106,7 @@ IMPORTING_SVO_OVERLAY_HEIGHT = 30; IMPORTING_SVO_OVERLAY_MARGIN = 5; IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34; var importingSVOImageOverlay = Overlays.addOverlay("image", { - imageURL: HIFI_PUBLIC_BUCKET + "images/hourglass.svg", + imageURL: Script.resolvePath("assets") + "/images/hourglass.svg", width: 20, height: 20, alpha: 1.0, @@ -336,7 +336,9 @@ var toolBar = (function() { if (active && !Entities.canAdjustLocks()) { Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG); } else { - Messages.sendLocalMessage("edit-events", JSON.stringify({enabled: active})); + Messages.sendLocalMessage("edit-events", JSON.stringify({ + enabled: active + })); isActive = active; if (!isActive) { entityListTool.setVisible(false); @@ -549,8 +551,16 @@ var toolBar = (function() { type: "ParticleEffect", isEmitting: true, particleRadius: 0.1, - emitAcceleration: {x: 0, y: -1, z: 0}, - accelerationSpread: {x: 5, y: 0, z: 5}, + emitAcceleration: { + x: 0, + y: -1, + z: 0 + }, + accelerationSpread: { + x: 5, + y: 0, + z: 5 + }, emitSpeed: 1, lifespan: 1, particleRadius: 0.025, @@ -563,7 +573,7 @@ var toolBar = (function() { return false; }; - that.mouseReleaseEvent = function (event) { + that.mouseReleaseEvent = function(event) { return false; } @@ -604,7 +614,7 @@ var intersection; var SCALE_FACTOR = 200.0; -function rayPlaneIntersection(pickRay, point, normal) { // +function rayPlaneIntersection(pickRay, point, normal) { // // // This version of the test returns the intersection of a line with a plane // @@ -1207,7 +1217,9 @@ function toggleSelectedEntitiesLocked() { var locked = !Entities.getEntityProperties(SelectionManager.selections[0], ["locked"]).locked; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { locked: locked }); + Entities.editEntity(entityID, { + locked: locked + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1219,7 +1231,9 @@ function toggleSelectedEntitiesVisible() { var visible = !Entities.getEntityProperties(SelectionManager.selections[0], ["visible"]).visible; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { visible: visible }); + Entities.editEntity(entityID, { + visible: visible + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1554,8 +1568,7 @@ PropertiesTool = function(opts) { data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS); } Entities.editEntity(selectionManager.selections[0], data.properties); - if (data.properties.name !== undefined || data.properties.modelURL !== undefined - || data.properties.visible !== undefined || data.properties.locked !== undefined) { + if (data.properties.name !== undefined || data.properties.modelURL !== undefined || data.properties.visible !== undefined || data.properties.locked !== undefined) { entityListTool.sendUpdate(); } } @@ -1835,15 +1848,15 @@ entityListTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.type == "selectionUpdate") { var ids = data.entityIds; - if(ids.length === 1) { - if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) { + if (ids.length === 1) { + if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { // This particle entity is already selected, so return return; } // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); + particleExplorerTool.destroyWebView(); + particleExplorerTool.createWebView(); var properties = Entities.getEntityProperties(ids[0]); var particleData = { messageType: "particle_settings", @@ -1855,7 +1868,7 @@ entityListTool.webView.webEventReceived.connect(function(data) { particleExplorerTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.messageType === "page_loaded") { - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); } }); } else { From 851f9b09148e16aae52722c1f663b0eca45f0cfc Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 28 Apr 2016 16:23:32 -0700 Subject: [PATCH 13/15] move dev templates into a dif location --- .../templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js | 0 .../utilities}/templates/entityScripts/exampleTimeoutNoCleanup.js | 0 .../utilities}/templates/entityScripts/exampleUpdate.js | 0 .../templates/entityScripts/exampleUpdateNoDisconnect.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename scripts/{ => developer/utilities}/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js (100%) rename scripts/{ => developer/utilities}/templates/entityScripts/exampleTimeoutNoCleanup.js (100%) rename scripts/{ => developer/utilities}/templates/entityScripts/exampleUpdate.js (100%) rename scripts/{ => developer/utilities}/templates/entityScripts/exampleUpdateNoDisconnect.js (100%) diff --git a/scripts/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js b/scripts/developer/utilities/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js similarity index 100% rename from scripts/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js rename to scripts/developer/utilities/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js diff --git a/scripts/templates/entityScripts/exampleTimeoutNoCleanup.js b/scripts/developer/utilities/templates/entityScripts/exampleTimeoutNoCleanup.js similarity index 100% rename from scripts/templates/entityScripts/exampleTimeoutNoCleanup.js rename to scripts/developer/utilities/templates/entityScripts/exampleTimeoutNoCleanup.js diff --git a/scripts/templates/entityScripts/exampleUpdate.js b/scripts/developer/utilities/templates/entityScripts/exampleUpdate.js similarity index 100% rename from scripts/templates/entityScripts/exampleUpdate.js rename to scripts/developer/utilities/templates/entityScripts/exampleUpdate.js diff --git a/scripts/templates/entityScripts/exampleUpdateNoDisconnect.js b/scripts/developer/utilities/templates/entityScripts/exampleUpdateNoDisconnect.js similarity index 100% rename from scripts/templates/entityScripts/exampleUpdateNoDisconnect.js rename to scripts/developer/utilities/templates/entityScripts/exampleUpdateNoDisconnect.js From 688389174841ead7b11ce901382dd8a1b990234f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 Apr 2016 17:08:40 -0700 Subject: [PATCH 14/15] don't require authentication to send user activity --- libraries/networking/src/UserActivityLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 8eefaac9b0..09cfc298bc 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -63,7 +63,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall } accountManager.sendRequest(USER_ACTIVITY_URL, - AccountManagerAuth::Required, + AccountManagerAuth::Optional, QNetworkAccessManager::PostOperation, params, NULL, multipart); } From 09981db83461bbadc3f56a78c03af743d3d13a4e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 Apr 2016 18:05:06 -0700 Subject: [PATCH 15/15] use a setting handle for UAL disabled to fix startup race --- libraries/networking/src/UserActivityLogger.cpp | 7 ++----- libraries/networking/src/UserActivityLogger.h | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 09cfc298bc..0d7690840d 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -25,15 +25,12 @@ UserActivityLogger& UserActivityLogger::getInstance() { return sharedInstance; } -UserActivityLogger::UserActivityLogger() : _disabled(false) { -} - void UserActivityLogger::disable(bool disable) { - _disabled = disable; + _disabled.set(disable); } void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCallbackParameters params) { - if (_disabled) { + if (_disabled.get()) { return; } diff --git a/libraries/networking/src/UserActivityLogger.h b/libraries/networking/src/UserActivityLogger.h index c48169d207..5c1cb03e3a 100644 --- a/libraries/networking/src/UserActivityLogger.h +++ b/libraries/networking/src/UserActivityLogger.h @@ -19,6 +19,8 @@ #include #include +#include + class UserActivityLogger : public QObject { Q_OBJECT @@ -44,8 +46,8 @@ private slots: void requestError(QNetworkReply& errorReply); private: - UserActivityLogger(); - bool _disabled; + UserActivityLogger() {}; + Setting::Handle _disabled { "UserActivityLoggerDisabled", false }; }; #endif // hifi_UserActivityLogger_h