From da4f2b8c2f1810528cac4001aa9f97b3a2c30326 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Fri, 30 Mar 2018 15:34:00 -0300 Subject: [PATCH 001/192] Fix zoom in unresponsive in radar mode --- scripts/system/+android/radar.js | 47 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 455299dd5f..2b87f8955d 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -21,7 +21,7 @@ function printd(str) { } var radar = false; -var radarHeight = 10; // camera position meters above the avatar +var radarHeight = MyAvatar.position.y + 10; // camera position (absolute y) var tablet; var RADAR_CAMERA_OFFSET = -1; // 1 meter below the avatar @@ -46,11 +46,11 @@ var uniqueColor; function moveTo(position) { if (radar) { MyAvatar.position = position; - Camera.position = Vec3.sum(MyAvatar.position, { - x : 0, + Camera.position = { + x : MyAvatar.position.x, y : radarHeight, - z : 0 - }); + z : MyAvatar.position.z + }; } } @@ -386,12 +386,12 @@ function pinchUpdate(event) { radarHeight -= pinchIncrement; } } - var deltaHeight = avatarY + radarHeight - Camera.position.y; - Camera.position = Vec3.sum(Camera.position, { - x : 0, - y : deltaHeight, - z : 0 - }); + Camera.position = { + x: Camera.position.x, + y:radarHeight, + z:Camera.position.z + }; + if (!draggingCamera) { startedDraggingCamera = true; draggingCamera = true; @@ -401,7 +401,8 @@ function pinchUpdate(event) { } function isInsideSquare(coords0, coords1, halfside) { - return Math.abs(coords0.x - coords1.x) <= halfside + return coords0 != undefined && coords1!= undefined && + Math.abs(coords0.x - coords1.x) <= halfside && Math.abs(coords0.y - coords1.y) <= halfside; } @@ -412,7 +413,7 @@ function dragScrollUpdate(event) { // drag management var pickRay = Camera.computePickRay(event.x, event.y); var dragAt = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, - radarHeight)); + radarHeight-MyAvatar.position.y)); if (lastDragAt === undefined || lastDragAt === null) { lastDragAt = dragAt; @@ -722,7 +723,7 @@ function Teleporter() { return { dragTeleportBegin : function(event) { printd("[newTeleport] TELEPORT began"); - var overlayDimensions = entityIconModelDimensions(); + var overlayDimensions = entityIconModelDimensions(MyAvatar.position.y); // var destination = computeDestination(event, MyAvatar.position, // Camera.position, radarHeight); // Dimension teleport and cancel overlays (not show them yet) @@ -843,7 +844,7 @@ var avatarIconDimensionsVal = { }; function avatarIconPlaneDimensions() { // given the current height, give a size - var xy = -0.003531 * radarHeight + 0.1; + var xy = -0.003531 * (radarHeight - MyAvatar.position.y) + 0.1; avatarIconDimensionsVal.x = Math.abs(xy); avatarIconDimensionsVal.y = Math.abs(xy); // reuse object @@ -1165,9 +1166,10 @@ var entityIconModelDimensionsVal = { y : 0.00001, z : 0 }; -function entityIconModelDimensions() { +function entityIconModelDimensions(y) { // given the current height, give a size - var xz = -0.002831 * radarHeight + 0.1; + // TODO: receive entity.position.y and substract to radarHeight + var xz = -0.002831 * (radarHeight - y) + 0.1; entityIconModelDimensionsVal.x = xz; entityIconModelDimensionsVal.z = xz; // reuse object @@ -1177,8 +1179,8 @@ function entityIconModelDimensions() { * entityIconPlaneDimensions: similar to entityIconModelDimensions but using xy * plane */ -function entityIconPlaneDimensions() { - var dim = entityIconModelDimensions(); +function entityIconPlaneDimensions(y) { + var dim = entityIconModelDimensions(y); var z = dim.z; dim.z = dim.y; dim.y = z; @@ -1255,15 +1257,15 @@ function hideAllEntitiesIcons() { function renderAllEntitiesIcons() { var entityPos; var entityProps; - var iconDimensions = entityIconModelDimensions(); - var planeDimensions = entityIconPlaneDimensions(); // plane overlays uses - // xy instead of xz + for ( var QUuid in entitiesData) { if (entitiesData.hasOwnProperty(QUuid)) { entityProps = Entities.getEntityProperties(QUuid, [ "position", "visible" ]); if (entityProps != null) { entityPos = entityProps.position; + var planeDimensions = entityIconPlaneDimensions(entityPos.y); // plane overlays uses + // xy instead of xz if (entitiesData[QUuid].icon != undefined && entityPos) { var iconPos = findLineToHeightIntersectionCoords( entityPos.x, @@ -1276,6 +1278,7 @@ function renderAllEntitiesIcons() { printd("entity icon pos bad for " + QUuid); continue; } + var iconDimensions = entityIconModelDimensions(entityPos.y); var dimensions = entitiesData[QUuid].planar ? planeDimensions : iconDimensions; Overlays.editOverlay(entitiesData[QUuid].icon, { From fc86525863df9eb5a2a01c948fa08f30e6cf616d Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Wed, 4 Apr 2018 12:00:06 +0200 Subject: [PATCH 002/192] Cleaned up a bit shadow map clear --- libraries/render-utils/src/RenderShadowTask.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index 69c5b3c689..faa5889307 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -149,9 +149,7 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con batch.setStateScissorRect(viewport); batch.setFramebuffer(fbo); - batch.clearFramebuffer( - gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, - vec4(vec3(1.0, 1.0, 1.0), 0.0), 1.0, 0, true); + batch.clearDepthFramebuffer(1.0, false); glm::mat4 projMat; Transform viewMat; From 36bc5f841627e170cb0d15c35586106d5c176eb5 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Thu, 5 Apr 2018 15:35:08 -0300 Subject: [PATCH 003/192] Fix the view snap when user starts zooming --- scripts/system/+android/radar.js | 37 ++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 2b87f8955d..120bec33c3 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -21,7 +21,8 @@ function printd(str) { } var radar = false; -var radarHeight = MyAvatar.position.y + 10; // camera position (absolute y) +var RADAR_HEIGHT_INIT_DELTA = 10; +var radarHeight = MyAvatar.position.y + RADAR_HEIGHT_INIT_DELTA; // camera position (absolute y) var tablet; var RADAR_CAMERA_OFFSET = -1; // 1 meter below the avatar @@ -386,6 +387,7 @@ function pinchUpdate(event) { radarHeight -= pinchIncrement; } } + Camera.position = { x: Camera.position.x, y:radarHeight, @@ -655,6 +657,7 @@ function Teleporter() { return; } + Camera.position = Vec3.sum(Camera.position, { x : xDelta, y : 0, @@ -1301,11 +1304,12 @@ function startRadar() { saveAllOthersAvatarsData(); Camera.mode = "independent"; - Camera.position = Vec3.sum(MyAvatar.position, { - x : 0, - y : radarHeight, - z : 0 - }); + Camera.position = { + x : MyAvatar.position.x, + y : radarHeight, + z : MyAvatar.position.z + }; + Camera.orientation = Quat.fromPitchYawRollDegrees(-90, 0, 0); radar = true; @@ -1394,15 +1398,25 @@ function connectRadarModeEvents() { Controller.keyPressEvent.connect(keyPressEvent); Controller.mousePressEvent.connect(mousePress); // single click/touch Controller.touchUpdateEvent.connect(touchUpdate); + Window.domainChanged.connect(domainChanged); MyAvatar.positionGoneTo.connect(positionGoneTo); } -function positionGoneTo() { - Camera.position = Vec3.sum(MyAvatar.position, { - x : 0, +function domainChanged() { + radarHeight = MyAvatar.position.y + RADAR_HEIGHT_INIT_DELTA; + Camera.position = { + x : MyAvatar.position.x, y : radarHeight, - z : 0 - }); + z : MyAvatar.position.z + }; +} + +function positionGoneTo() { + Camera.position = { + x : MyAvatar.position.x, + y : radarHeight, + z : MyAvatar.position.z + }; } function disconnectRadarModeEvents() { @@ -1411,6 +1425,7 @@ function disconnectRadarModeEvents() { Controller.mousePressEvent.disconnect(mousePress); Controller.touchUpdateEvent.disconnect(touchUpdate); MyAvatar.positionGoneTo.disconnect(positionGoneTo); + Window.domainChanged.disconnect(domainChanged); } function init() { From 573f399023eafd625212284f827ea3207f006f76 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Fri, 6 Apr 2018 14:45:16 +0200 Subject: [PATCH 004/192] Fixed incorrect shadow frustum far clip computation due to not taking into account shadow receivers --- .../render-utils/src/RenderShadowTask.cpp | 27 ++++++++++-------- libraries/render-utils/src/RenderShadowTask.h | 2 +- libraries/render/src/render/CullTask.cpp | 28 +++++++++++++------ libraries/render/src/render/CullTask.h | 2 +- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index faa5889307..fbb4bba263 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -230,12 +230,11 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende const auto queryResolution = setupOutput.getN(2); // Fetch and cull the items from the scene - // Enable models to not cast shadows (otherwise, models will always cast shadows) - static const auto shadowCasterFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask).withShadowCaster(); + static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask); - const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterFilter, queryResolution).asVarying(); + const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterReceiverFilter, queryResolution).asVarying(); const auto shadowSelection = task.addJob("FetchShadowTree", fetchInput); - const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterFilter).asVarying(); + const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterReceiverFilter).asVarying(); const auto shadowItems = task.addJob("FetchShadowSelection", selectionInputs); // Cull objects that are not visible in camera view. Hopefully the cull functor only performs LOD culling, not @@ -259,21 +258,22 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende char jobName[64]; sprintf(jobName, "ShadowCascadeSetup%d", i); const auto cascadeSetupOutput = task.addJob(jobName, i, _cullFunctor, tagBits, tagMask); - const auto shadowFilter = cascadeSetupOutput.getN(0); + const auto shadowRenderFilter = cascadeSetupOutput.getN(0); + const auto shadowBoundsFilter = cascadeSetupOutput.getN(1); auto antiFrustum = render::Varying(ViewFrustumPointer()); - cascadeFrustums[i] = cascadeSetupOutput.getN(1); + cascadeFrustums[i] = cascadeSetupOutput.getN(2); if (i > 1) { antiFrustum = cascadeFrustums[i - 2]; } // CPU jobs: finer grained culling - const auto cullInputs = CullShapeBounds::Inputs(sortedShapes, shadowFilter, antiFrustum).asVarying(); + const auto cullInputs = CullShapeBounds::Inputs(sortedShapes, shadowRenderFilter, shadowBoundsFilter, antiFrustum).asVarying(); const auto culledShadowItemsAndBounds = task.addJob("CullShadowCascade", cullInputs, shadowCullFunctor, RenderDetails::SHADOW); // GPU jobs: Render to shadow map sprintf(jobName, "RenderShadowMap%d", i); task.addJob(jobName, culledShadowItemsAndBounds, shapePlumber, i); - task.addJob("ShadowCascadeTeardown", shadowFilter); + task.addJob("ShadowCascadeTeardown", shadowRenderFilter); } task.addJob("ShadowTeardown", setupOutput); @@ -404,7 +404,11 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon const auto globalShadow = lightStage->getCurrentKeyShadow(); if (globalShadow && _cascadeIndexgetCascadeCount()) { - output.edit0() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(_tagBits, _tagMask).withShadowCaster(); + auto baseFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(_tagBits, _tagMask); + // Second item filter is to filter items to keep in shadow frustum computation (here we need to keep shadow receivers) + output.edit1() = baseFilter; + // First item filter is to filter items to render in shadow map (so only keep casters) + output.edit0() = baseFilter.withShadowCaster(); // Set the keylight render args auto& cascade = globalShadow->getCascade(_cascadeIndex); @@ -417,10 +421,11 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon texelSize *= minTexelCount; _cullFunctor._minSquareSize = texelSize * texelSize; - output.edit1() = cascadeFrustum; + output.edit2() = cascadeFrustum; } else { output.edit0() = ItemFilter::Builder::nothing(); - output.edit1() = ViewFrustumPointer(); + output.edit1() = ItemFilter::Builder::nothing(); + output.edit2() = ViewFrustumPointer(); } } diff --git a/libraries/render-utils/src/RenderShadowTask.h b/libraries/render-utils/src/RenderShadowTask.h index 98b70c0c9f..19ffcb4234 100644 --- a/libraries/render-utils/src/RenderShadowTask.h +++ b/libraries/render-utils/src/RenderShadowTask.h @@ -118,7 +118,7 @@ private: class RenderShadowCascadeSetup { public: - using Outputs = render::VaryingSet2; + using Outputs = render::VaryingSet3; using JobModel = render::Job::ModelO; RenderShadowCascadeSetup(unsigned int cascadeIndex, RenderShadowTask::CullFunctor& cullFunctor, uint8_t tagBits = 0x00, uint8_t tagMask = 0x00) : diff --git a/libraries/render/src/render/CullTask.cpp b/libraries/render/src/render/CullTask.cpp index f04427540a..b5819f114f 100644 --- a/libraries/render/src/render/CullTask.cpp +++ b/libraries/render/src/render/CullTask.cpp @@ -368,17 +368,19 @@ void CullShapeBounds::run(const RenderContextPointer& renderContext, const Input RenderArgs* args = renderContext->args; const auto& inShapes = inputs.get0(); - const auto& filter = inputs.get1(); - const auto& antiFrustum = inputs.get2(); + const auto& cullFilter = inputs.get1(); + const auto& boundsFilter = inputs.get2(); + const auto& antiFrustum = inputs.get3(); auto& outShapes = outputs.edit0(); auto& outBounds = outputs.edit1(); outShapes.clear(); outBounds = AABox(); - if (!filter.selectsNothing()) { + if (!cullFilter.selectsNothing() || !boundsFilter.selectsNothing()) { auto& details = args->_details.edit(_detailType); Test test(_cullFunctor, args, details, antiFrustum); + auto scene = args->_scene; for (auto& inItems : inShapes) { auto key = inItems.first; @@ -393,16 +395,26 @@ void CullShapeBounds::run(const RenderContextPointer& renderContext, const Input if (antiFrustum == nullptr) { for (auto& item : inItems.second) { if (test.solidAngleTest(item.bound) && test.frustumTest(item.bound)) { - outItems->second.emplace_back(item); - outBounds += item.bound; + const auto shapeKey = scene->getItem(item.id).getKey(); + if (cullFilter.test(shapeKey)) { + outItems->second.emplace_back(item); + } + if (boundsFilter.test(shapeKey)) { + outBounds += item.bound; + } } } } else { for (auto& item : inItems.second) { if (test.solidAngleTest(item.bound) && test.frustumTest(item.bound) && test.antiFrustumTest(item.bound)) { - outItems->second.emplace_back(item); - outBounds += item.bound; - } + const auto shapeKey = scene->getItem(item.id).getKey(); + if (cullFilter.test(shapeKey)) { + outItems->second.emplace_back(item); + } + if (boundsFilter.test(shapeKey)) { + outBounds += item.bound; + } + } } } details._rendered += (int)outItems->second.size(); diff --git a/libraries/render/src/render/CullTask.h b/libraries/render/src/render/CullTask.h index 3c5a30de89..47abe8a960 100644 --- a/libraries/render/src/render/CullTask.h +++ b/libraries/render/src/render/CullTask.h @@ -110,7 +110,7 @@ namespace render { class CullShapeBounds { public: - using Inputs = render::VaryingSet3; + using Inputs = render::VaryingSet4; using Outputs = render::VaryingSet2; using JobModel = Job::ModelIO; From d5c252c9ad70cfb2e46c95b75cd3a71d7b8f5196 Mon Sep 17 00:00:00 2001 From: Cristian Duarte Date: Mon, 9 Apr 2018 16:24:03 -0300 Subject: [PATCH 005/192] Use MyAvatar.goToLocation in radar teleport. Use MyAvatar.goToLocation in radar teleport to prevent synchronization issues that make it fail occasionally when directly modifying its world position. It will work just as teleport.js does. --- scripts/system/+android/radar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 120bec33c3..8100cc0887 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -46,11 +46,11 @@ var uniqueColor; function moveTo(position) { if (radar) { - MyAvatar.position = position; + MyAvatar.goToLocation(position, false); Camera.position = { - x : MyAvatar.position.x, + x : position.x, y : radarHeight, - z : MyAvatar.position.z + z : position.z }; } } From 63e17e87b0fa4e00db8b871e731c34684a1f4f08 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Tue, 10 Apr 2018 19:21:23 -0300 Subject: [PATCH 006/192] Fix radar initial position. Clean radar.js --- scripts/system/+android/radar.js | 232 ++----------------------------- 1 file changed, 8 insertions(+), 224 deletions(-) diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 8100cc0887..67ba896207 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -90,46 +90,6 @@ function keyPressEvent(event) { } } -function actionOnObjectFromEvent(event) { - var rayIntersection = findRayIntersection(Camera.computePickRay(event.x, - event.y)); - if (rayIntersection && rayIntersection.intersects - && rayIntersection.overlayID) { - printd("found overlayID touched " + rayIntersection.overlayID); - if (entitiesByOverlayID[rayIntersection.overlayID]) { - var entity = Entities.getEntityProperties( - entitiesByOverlayID[rayIntersection.overlayID], - [ "sourceUrl" ]); - App.openUrl(entity.sourceUrl); - return true; - } - } - if (rayIntersection && rayIntersection.intersects - && rayIntersection.entityID && rayIntersection.properties) { - printd("found " + rayIntersection.entityID + " of type " - + rayIntersection.properties.type); - if (rayIntersection.properties.type == "Web") { - printd("found web element to " - + rayIntersection.properties.sourceUrl); - App.openUrl(rayIntersection.properties.sourceUrl); - return true; - } - } - return false; -} - -function mousePress(event) { - mousePressOrTouchEnd(event); -} - -function mousePressOrTouchEnd(event) { - if (radar) { - if (actionOnObjectFromEvent(event)) { - return; - } - } -} - function toggleRadarMode() { if (radar) { endRadar(); @@ -230,9 +190,6 @@ function touchEnd(event) { if (analyzeDoubleTap(event)) return; // double tap detected, finish - if (radar) { - mousePressOrTouchEnd(event); - } } /** @@ -726,7 +683,7 @@ function Teleporter() { return { dragTeleportBegin : function(event) { printd("[newTeleport] TELEPORT began"); - var overlayDimensions = entityIconModelDimensions(MyAvatar.position.y); + var overlayDimensions = teleportIconModelDimensions(MyAvatar.position.y); // var destination = computeDestination(event, MyAvatar.position, // Camera.position, radarHeight); // Dimension teleport and cancel overlays (not show them yet) @@ -1125,39 +1082,10 @@ function renderAllOthersAvatarIcons() { } } -function entityAdded(entityID) { - printd("Entity added " + entityID); - var props = Entities.getEntityProperties(entityID, [ "type" ]); - printd("Entity added " + entityID + " PROPS " + JSON.stringify(props)); - if (props && props.type == "Web") { - printd("Entity Web added " + entityID); - saveEntityData(entityID, true); - } -} - -function entityRemoved(entityID) { - printd("Entity removed " + entityID); - var props = Entities.getEntityProperties(entityID, [ "type" ]); - if (props && props.type == "Web") { - print("Entity Web removed " + entityID); - removeEntityData(entityID); - } -} - /******************************************************************************* * Entities (to remark) cache structure for showing entities markers ******************************************************************************/ -var entitiesData = {}; // by entityID -var entitiesByOverlayID = {}; // by overlayID -var entitiesIcons = []; // a parallel list of icons (overlays) to easily run - // through - -var ICON_ENTITY_WEB_MODEL_URL = Script.resolvePath("../assets/images/web.svg"); -var ICON_ENTITY_IMG_MODEL_URL = Script - .resolvePath("../assets/models/teleport-cancel.fbx"); // FIXME - use - // correct - // model&texture var ICON_ENTITY_DEFAULT_DIMENSIONS = { x : 0.10, y : 0.00001, @@ -1169,7 +1097,7 @@ var entityIconModelDimensionsVal = { y : 0.00001, z : 0 }; -function entityIconModelDimensions(y) { +function teleportIconModelDimensions(y) { // given the current height, give a size // TODO: receive entity.position.y and substract to radarHeight var xz = -0.002831 * (radarHeight - y) + 0.1; @@ -1178,122 +1106,6 @@ function entityIconModelDimensions(y) { // reuse object return entityIconModelDimensionsVal; } -/* - * entityIconPlaneDimensions: similar to entityIconModelDimensions but using xy - * plane - */ -function entityIconPlaneDimensions(y) { - var dim = entityIconModelDimensions(y); - var z = dim.z; - dim.z = dim.y; - dim.y = z; - return dim; -} - -function currentOverlayForEntity(QUuid) { - if (entitiesData[QUuid] != undefined) { - return entitiesData[QUuid].icon; - } else { - return null; - } -} - -function saveEntityData(QUuid, planar) { - if (QUuid == null) - return; - var entity = Entities.getEntityProperties(QUuid, [ "position" ]); - printd("entity added save entity " + QUuid); - if (entitiesData[QUuid] != undefined) { - entitiesData[QUuid].position = entity.position; - } else { - var entityIcon = Overlays.addOverlay("image3d", { - subImage : { - x : 0, - y : 0, - width : 150, - height : 150 - }, - url : ICON_ENTITY_WEB_MODEL_URL, - dimensions : ICON_ENTITY_DEFAULT_DIMENSIONS, - visible : false, - ignoreRayIntersection : false, - orientation : Quat.fromPitchYawRollDegrees(-90, 0, 0) - }); - - entitiesIcons.push(entityIcon); - entitiesData[QUuid] = { - position : entity.position, - icon : entityIcon - }; - entitiesByOverlayID[entityIcon] = QUuid; - } -} - -function removeEntityData(QUuid) { - if (QUuid == null) - return; - - var itsOverlay = currentOverlayForEntity(QUuid); - if (itsOverlay != null) { - Overlays.deleteOverlay(itsOverlay); - delete entitiesByOverlayID[itsOverlay]; - } - var idx = entitiesIcons.indexOf(itsOverlay); - entitiesIcons.splice(idx, 1); - - delete entitiesData[QUuid]; -} - -/******************************************************************************* - * Entities to remark Icon/Markers rendering - ******************************************************************************/ - -function hideAllEntitiesIcons() { - var len = entitiesIcons.length; - for (var i = 0; i < len; i++) { - Overlays.editOverlay(entitiesIcons[i], { - visible : false - }); - } -} - -function renderAllEntitiesIcons() { - var entityPos; - var entityProps; - - for ( var QUuid in entitiesData) { - if (entitiesData.hasOwnProperty(QUuid)) { - entityProps = Entities.getEntityProperties(QUuid, [ "position", - "visible" ]); - if (entityProps != null) { - entityPos = entityProps.position; - var planeDimensions = entityIconPlaneDimensions(entityPos.y); // plane overlays uses - // xy instead of xz - if (entitiesData[QUuid].icon != undefined && entityPos) { - var iconPos = findLineToHeightIntersectionCoords( - entityPos.x, - entityPos.y - + RADAR_ICONS_APPARENT_DISTANCE_TO_AVATAR_BASE, - entityPos.z, Camera.position.x, Camera.position.y, - Camera.position.z, Camera.position.y - - RADAR_CAMERA_DISTANCE_TO_ICONS); - if (!iconPos) { - printd("entity icon pos bad for " + QUuid); - continue; - } - var iconDimensions = entityIconModelDimensions(entityPos.y); - var dimensions = entitiesData[QUuid].planar ? planeDimensions - : iconDimensions; - Overlays.editOverlay(entitiesData[QUuid].icon, { - visible : entityProps.visible, - dimensions : dimensions, - position : iconPos - }); - } - } - } - } -} /******************************************************************************* * @@ -1304,11 +1116,7 @@ function startRadar() { saveAllOthersAvatarsData(); Camera.mode = "independent"; - Camera.position = { - x : MyAvatar.position.x, - y : radarHeight, - z : MyAvatar.position.z - }; + initCameraOverMyAvatar(); Camera.orientation = Quat.fromPitchYawRollDegrees(-90, 0, 0); radar = true; @@ -1326,7 +1134,6 @@ function endRadar() { Controller.setVPadEnabled(true); disconnectRadarModeEvents(); - hideAllEntitiesIcons(); hideAllAvatarIcons(); } @@ -1360,12 +1167,10 @@ function updateRadar() { // Update avatar icons if (startedDraggingCamera) { hideAllAvatarIcons(); - hideAllEntitiesIcons(); startedDraggingCamera = false; } else if (!draggingCamera) { renderMyAvatarIcon(); renderAllOthersAvatarIcons(); - renderAllEntitiesIcons(); } } @@ -1373,36 +1178,15 @@ function valueIfDefined(value) { return value !== undefined ? value : ""; } -function entitiesAnalysis() { - var ids = Entities.findEntitiesInFrustum(Camera.frustum); - var entities = []; - for (var i = 0; i < ids.length; i++) { - var id = ids[i]; - var properties = Entities.getEntityProperties(id); - entities.push({ - id : id, - name : properties.name, - type : properties.type, - url : properties.type == "Model" ? properties.modelURL : "", - sourceUrl : properties.sourceUrl, - locked : properties.locked, - visible : properties.visible, - drawCalls : valueIfDefined(properties.renderInfo.drawCalls), - hasScript : properties.script !== "" - }); - } -} - function connectRadarModeEvents() { Script.update.connect(updateRadar); // 60Hz loop Controller.keyPressEvent.connect(keyPressEvent); - Controller.mousePressEvent.connect(mousePress); // single click/touch Controller.touchUpdateEvent.connect(touchUpdate); Window.domainChanged.connect(domainChanged); MyAvatar.positionGoneTo.connect(positionGoneTo); } -function domainChanged() { +function initCameraOverMyAvatar() { radarHeight = MyAvatar.position.y + RADAR_HEIGHT_INIT_DELTA; Camera.position = { x : MyAvatar.position.x, @@ -1411,6 +1195,10 @@ function domainChanged() { }; } +function domainChanged() { + initCameraOverMyAvatar(); +} + function positionGoneTo() { Camera.position = { x : MyAvatar.position.x, @@ -1422,7 +1210,6 @@ function positionGoneTo() { function disconnectRadarModeEvents() { Script.update.disconnect(updateRadar); Controller.keyPressEvent.disconnect(keyPressEvent); - Controller.mousePressEvent.disconnect(mousePress); Controller.touchUpdateEvent.disconnect(touchUpdate); MyAvatar.positionGoneTo.disconnect(positionGoneTo); Window.domainChanged.disconnect(domainChanged); @@ -1436,7 +1223,4 @@ function init() { AvatarList.avatarAddedEvent.connect(avatarAdded); AvatarList.avatarRemovedEvent.connect(avatarRemoved); - - Entities.addingEntity.connect(entityAdded); - Entities.deletingEntity.connect(entityRemoved); } From aceaa510c89a9226170de6c60dc7dd21505e50f7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 23 Apr 2018 14:47:17 -0700 Subject: [PATCH 007/192] Added referral to physical memory Test. Added menu items - `close` and `about` --- tools/auto-tester/src/Test.cpp | 78 +++++++++++++++++-------- tools/auto-tester/src/Test.h | 2 + tools/auto-tester/src/ui/AutoTester.cpp | 10 ++++ tools/auto-tester/src/ui/AutoTester.h | 2 + tools/auto-tester/src/ui/AutoTester.ui | 24 ++++++++ 5 files changed, 91 insertions(+), 25 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 99f9025fdd..57806e80f6 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -498,6 +498,12 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { const QString regexAssertGPU(ws + functionAssertGPU + ws + "\\(" + ws + quotedString + ".*"); const QRegularExpression lineAssertGPU = QRegularExpression(regexAssertGPU); + // Assert the correct amount of memory + const QString functionAssertPhysicalMemoryGB(ws + "autoTester" + ws + "\\." + ws + "assertPhysicalMemoryGB"); + const QString regexAssertPhysicalMemoryGB(ws + functionAssertPhysicalMemoryGB + ws + "\\(" + ws + quotedString + ".*"); + const QRegularExpression lineAssertPhysicalMemoryGB = QRegularExpression(regexAssertPhysicalMemoryGB); + + // Each step is either of the following forms: // autoTester.addStepSnapshot("Take snapshot"... // autoTester.addStep("Clean up after test"... @@ -514,18 +520,27 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { if (lineContainingTitle.match(line).hasMatch()) { QStringList tokens = line.split('"'); relevantTextFromTest.title = tokens[1]; + } else if (lineAssertPlatform.match(line).hasMatch()) { QStringList platforms = line.split('"'); relevantTextFromTest.platform = platforms[1]; + } else if (lineAssertDisplay.match(line).hasMatch()) { QStringList displays = line.split('"'); relevantTextFromTest.display = displays[1]; + } else if (lineAssertCPU.match(line).hasMatch()) { QStringList cpus = line.split('"'); relevantTextFromTest.cpu = cpus[1]; + } else if (lineAssertGPU.match(line).hasMatch()) { QStringList gpus = line.split('"'); relevantTextFromTest.gpu = gpus[1]; + + } else if (lineAssertPhysicalMemoryGB.match(line).hasMatch()) { + QStringList physicalMemoryGB = line.split('"'); + relevantTextFromTest.physicalMemoryGB = physicalMemoryGB[1]; + } else if (lineStepSnapshot.match(line).hasMatch()) { QStringList tokens = line.split('"'); QString nameOfStep = tokens[1]; @@ -534,6 +549,7 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { step->text = nameOfStep; step->takeSnapshot = true; relevantTextFromTest.stepList.emplace_back(step); + } else if (lineStep.match(line).hasMatch()) { QStringList tokens = line.split('"'); QString nameOfStep = tokens[1]; @@ -630,62 +646,74 @@ void Test::createMDFile(QString testDirectory) { // Platform QStringList platforms = testScriptLines.platform.split(" ");; - stream << "## Platforms\n"; - stream << "Run the test on each of the following platforms\n"; - for (int i = 0; i < platforms.size(); ++i) { - // Note that the platforms parameter may include extra spaces, these appear as empty strings in the list - if (platforms[i] != QString()) { - stream << " - " << platforms[i] << "\n"; + if (platforms.size() > 0) { + stream << "## Platforms\n"; + stream << "Run the test on each of the following platforms\n"; + for (int i = 0; i < platforms.size(); ++i) { + // Note that the platforms parameter may include extra spaces, these appear as empty strings in the list + if (platforms[i] != QString()) { + stream << " - " << platforms[i] << "\n"; + } } } // Display QStringList displays = testScriptLines.display.split(" "); - stream << "## Displays\n"; - stream << "Run the test on each of the following displays\n"; - for (int i = 0; i < displays.size(); ++i) { - // Note that the displays parameter may include extra spaces, these appear as empty strings in the list - if (displays[i] != QString()) { - stream << " - " << displays[i] << "\n"; + if (displays.size()) { + stream << "## Displays\n"; + stream << "Run the test on each of the following displays\n"; + for (int i = 0; i < displays.size(); ++i) { + // Note that the displays parameter may include extra spaces, these appear as empty strings in the list + if (displays[i] != QString()) { + stream << " - " << displays[i] << "\n"; + } } } // CPU QStringList cpus = testScriptLines.cpu.split(" "); - stream << "## Processors\n"; - stream << "Run the test on each of the following processors\n"; - for (int i = 0; i < cpus.size(); ++i) { - // Note that the cpus parameter may include extra spaces, these appear as empty strings in the list - if (cpus[i] != QString()) { - stream << " - " << cpus[i] << "\n"; + if (cpus.size() > 0) { + stream << "## Processors\n"; + stream << "Run the test on each of the following processors\n"; + for (int i = 0; i < cpus.size(); ++i) { + // Note that the cpus parameter may include extra spaces, these appear as empty strings in the list + if (cpus[i] != QString()) { + stream << " - " << cpus[i] << "\n"; + } } } // GPU QStringList gpus = testScriptLines.gpu.split(" "); - stream << "## Graphics Cards\n"; - stream << "Run the test on graphics cards from each of the following vendors\n"; - for (int i = 0; i < gpus.size(); ++i) { - // Note that the gpus parameter may include extra spaces, these appear as empty strings in the list - if (gpus[i] != QString()) { - stream << " - " << gpus[i] << "\n"; + if (gpus.size() > 0) { + stream << "## Graphics Cards\n"; + stream << "Run the test on graphics cards from each of the following vendors\n"; + for (int i = 0; i < gpus.size(); ++i) { + // Note that the gpus parameter may include extra spaces, these appear as empty strings in the list + if (gpus[i] != QString()) { + stream << " - " << gpus[i] << "\n"; + } } } stream << "## Steps\n"; stream << "Press space bar to advance step by step\n\n"; + // Note that snapshots of step n are taken in step n+1 + // (this implies that if the LAST step requests a snapshot then this will not work - caveat emptor) int snapShotIndex { 0 }; for (size_t i = 0; i < testScriptLines.stepList.size(); ++i) { stream << "### Step " << QString::number(i + 1) << "\n"; stream << "- " << testScriptLines.stepList[i]->text << "\n"; - if (testScriptLines.stepList[i]->takeSnapshot) { + if ((i + 1 < testScriptLines.stepList.size()) && testScriptLines.stepList[i + 1]->takeSnapshot) { stream << "- ![](./ExpectedImage_" << QString::number(snapShotIndex).rightJustified(5, '0') << ".png)\n"; ++snapShotIndex; } } mdFile.close(); + + messageBox.information(0, "Success", "Test MD file " + mdFilename + " has been created"); } void Test::createTestsOutline() { diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index e69459fef2..7f5553f9e3 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -34,6 +34,8 @@ public: QString display; QString cpu; QString gpu; + QString physicalMemoryGB; + StepList stepList; }; diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 21acfe9569..3f7d2cba28 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -10,6 +10,8 @@ // #include "AutoTester.h" +#include + AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); ui.checkBoxInteractiveMode->setChecked(true); @@ -18,6 +20,9 @@ AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { test = new Test(); signalMapper = new QSignalMapper(); + + connect(ui.actionClose, &QAction::triggered, this, &AutoTester::on_closeButton_clicked); + connect(ui.actionAbout, &QAction::triggered, this, &AutoTester::about); } void AutoTester::on_evaluateTestsButton_clicked() { @@ -100,3 +105,8 @@ void AutoTester::saveImage(int index) { ui.progressBar->setValue(_numberOfImagesDownloaded); } } + +void AutoTester::about() { + QMessageBox messageBox; + messageBox.information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); +} \ No newline at end of file diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 1788e97177..03cb7fbcec 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -37,6 +37,8 @@ private slots: void saveImage(int index); + void about(); + private: Ui::AutoTesterClass ui; Test* test; diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index 2eb1314481..c5115d69b2 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -157,6 +157,20 @@ 21 + + + File + + + + + + Help + + + + + @@ -167,6 +181,16 @@ + + + Close + + + + + About + + From b2925c5843ef5da8b40eb59adb8c12c94903f1c2 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 24 Apr 2018 13:32:30 -0700 Subject: [PATCH 008/192] fixing attachments not being visible when coming out of first person --- interface/src/avatar/MyAvatar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 249a765d92..e288528be9 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -2037,12 +2037,12 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) { _attachmentData[i].jointName.compare("RightEye", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) { - + uint32_t renderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE; _attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(), - render::ItemKey::TAG_BITS_NONE, true); + renderTagBits, false); - _attachmentModels[i]->setCanCastShadow(shouldDrawHead, qApp->getMain3DScene(), - render::ItemKey::TAG_BITS_NONE, true); + _attachmentModels[i]->setCanCastShadow(shouldDrawHead, qApp->getMain3DScene(), + renderTagBits, false); } } } From 29fce488e479460437db366fdc2f5edb22e800bf Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 24 Apr 2018 14:00:52 -0700 Subject: [PATCH 009/192] make some changes --- interface/src/avatar/MyAvatar.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index e288528be9..367042bcf9 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -2037,12 +2037,14 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) { _attachmentData[i].jointName.compare("RightEye", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) { - uint32_t renderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE; - _attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(), - renderTagBits, false); + uint8_t modelRenderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE; + modelRenderTagBits |= render::ItemKey::TAG_BITS_1; + _attachmentModels[i]->setVisibleInScene(true, qApp->getMain3DScene(), + modelRenderTagBits, false); - _attachmentModels[i]->setCanCastShadow(shouldDrawHead, qApp->getMain3DScene(), - renderTagBits, false); + uint8_t castShadowRenderTagBits = render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1; + _attachmentModels[i]->setCanCastShadow(true, qApp->getMain3DScene(), + castShadowRenderTagBits, false); } } } From 99ad51189c66ed5e6c2f425c55d39be9953df464 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Tue, 24 Apr 2018 23:03:56 +0100 Subject: [PATCH 010/192] fix browse asset filtering added support for list of filters using formatting consistent with other implementations, e.g: (*.png *.wav) --- .../assetDialog/AssetDialogContent.qml | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml index 84f4c694ff..7c8a735ead 100644 --- a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml +++ b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml @@ -19,14 +19,14 @@ import "../fileDialog" Item { // Set from OffscreenUi::assetDialog() property alias dir: assetTableModel.folder - property alias filter: selectionType.filtersString // FIXME: Currently only supports simple filters, "*.xxx". + property alias filter: selectionType.filtersString property int options // Not used. property bool selectDirectory: false // Not implemented. - //property bool saveDialog: false; - //property bool multiSelect: false; + // property bool saveDialog: false; + // property bool multiSelect: false; property bool singleClickNavigate: false @@ -84,7 +84,7 @@ Item { size: 28 width: height enabled: destination !== "" - //onClicked: d.navigateHome(); + // onClicked: d.navigateHome(); onClicked: assetTableModel.folder = destination; } } @@ -227,7 +227,9 @@ Item { function onGetAllMappings(error, map) { var mappings, - fileTypeFilter, + fileTypeFilters = [], + filterListStart, + filterListEnd, index, path, fileName, @@ -248,7 +250,14 @@ Item { if (error === "") { mappings = Object.keys(map); - fileTypeFilter = filter.replace("*", "").toLowerCase(); + filter = filter.replace(/\s/g, ''); + filterListStart = filter.indexOf("("); + filterListEnd = filter.indexOf(")"); + if (filterListStart !== -1 && filterListEnd !== -1) { + fileTypeFilters = filter.substring(filterListStart + 2, filterListEnd).toLowerCase().split("*"); + } else if (filter !== "") { + fileTypeFilters[0] = filter.replace("*", "").toLowerCase(); + } for (i = 0, length = mappings.length; i < length; i++) { index = mappings[i].lastIndexOf("/"); @@ -259,7 +268,24 @@ Item { fileIsDir = false; isValid = false; - if (fileType.toLowerCase() === fileTypeFilter) { + if (fileTypeFilters.length > 1) { + if (fileTypeFilters.indexOf(fileType.toLowerCase()) !== -1) { + if (path === folder) { + isValid = !selectDirectory; + } else if (path.length > folder.length) { + subDirectory = path.slice(folder.length); + index = subDirectory.indexOf("/"); + if (index === subDirectory.lastIndexOf("/")) { + fileName = subDirectory.slice(0, index); + if (subDirectories.indexOf(fileName) === -1) { + fileIsDir = true; + isValid = true; + subDirectories.push(fileName); + } + } + } + } + } else if (fileType.toLowerCase() === fileTypeFilters[0] || fileTypeFilters.length === 0) { if (path === folder) { isValid = !selectDirectory; } else if (path.length > folder.length) { From 21a9525a737e3db268cabdd82c0c60504a54444f Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Tue, 24 Apr 2018 17:52:12 -0700 Subject: [PATCH 011/192] Version of HMACAuth with exposed lock Client is responsible for locking between adding and retrieving. Fixes a likely race. --- libraries/networking/src/HMACAuth.cpp | 11 ++++++----- libraries/networking/src/HMACAuth.h | 2 ++ libraries/networking/src/LimitedNodeList.cpp | 5 +++-- libraries/networking/src/NLPacket.cpp | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/HMACAuth.cpp b/libraries/networking/src/HMACAuth.cpp index 42b5c48d93..e276e64b40 100644 --- a/libraries/networking/src/HMACAuth.cpp +++ b/libraries/networking/src/HMACAuth.cpp @@ -68,7 +68,7 @@ bool HMACAuth::setKey(const char* keyValue, int keyLen) { return false; } - QMutexLocker lock(&_lock); + //QMutexLocker lock(&_lock); return (bool) HMAC_Init_ex(_hmacContext, keyValue, keyLen, sslStruct, nullptr); } @@ -78,16 +78,17 @@ bool HMACAuth::setKey(const QUuid& uidKey) { } bool HMACAuth::addData(const char* data, int dataLen) { - QMutexLocker lock(&_lock); + //QMutexLocker lock(&_lock); return (bool) HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen); } HMACAuth::HMACHash HMACAuth::result() { HMACHash hashValue(EVP_MAX_MD_SIZE); unsigned int hashLen; - QMutexLocker lock(&_lock); - HMAC_Final(_hmacContext, &hashValue[0], &hashLen); - hashValue.resize((size_t) hashLen); + //QMutexLocker lock(&_lock); + if (HMAC_Final(_hmacContext, &hashValue[0], &hashLen)) { + hashValue.resize((size_t)hashLen); + } // Clear state for possible reuse. HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); return hashValue; diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h index 0bf7a86ec1..ba1ec78214 100644 --- a/libraries/networking/src/HMACAuth.h +++ b/libraries/networking/src/HMACAuth.h @@ -26,6 +26,8 @@ public: explicit HMACAuth(AuthMethod authMethod = MD5); ~HMACAuth(); + QMutex& getLock() { return _lock; } + bool setKey(const char* keyValue, int keyLen); bool setKey(const QUuid& uidKey); bool addData(const char* data, int dataLen); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 8d177ca534..d66dd644d5 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -333,13 +333,14 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe QByteArray packetHeaderHash = NLPacket::verificationHashInHeader(packet); QByteArray expectedHash = NLPacket::hashForPacketAndHMAC(packet, sourceNode->getAuthenticateHash()); - // check if the md5 hash in the header matches the hash we would expect + // check if the HMAC-md5 hash in the header matches the hash we would expect if (packetHeaderHash != expectedHash) { static QMultiMap hashDebugSuppressMap; if (!hashDebugSuppressMap.contains(sourceID, headerType)) { - qCDebug(networking) << packetHeaderHash << expectedHash; qCDebug(networking) << "Packet hash mismatch on" << headerType << "- Sender" << sourceID; + qCDebug(networking) << "Packet len:" << packet.getDataSize() << "Expected hash:" << + expectedHash.toHex() << "Actual:" << packetHeaderHash.toHex(); hashDebugSuppressMap.insert(sourceID, headerType); } diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index 3355e1cd6b..09a7b78840 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -157,6 +157,7 @@ QByteArray NLPacket::hashForPacketAndHMAC(const udt::Packet& packet, HMACAuth& h + NUM_BYTES_LOCALID + NUM_BYTES_MD5_HASH; // add the packet payload and the connection UUID + QMutexLocker hashLock(&hash.getLock()); hash.addData(packet.getData() + offset, packet.getDataSize() - offset); auto hashResult { hash.result() }; return QByteArray((const char*) hashResult.data(), (int) hashResult.size()); From eab7dd60067ff18bab4a3c2f7d7b6c618bcf2945 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Wed, 25 Apr 2018 10:25:34 +0200 Subject: [PATCH 012/192] Fixed procedural shaders --- libraries/render-utils/src/simple.slf | 10 ++++++++++ libraries/render-utils/src/simple_fade.slf | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index ed77777184..338f8607ee 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -16,7 +16,17 @@ // the interpolated normal in vec3 _normalWS; +in vec3 _normalMS; in vec4 _color; +in vec2 _texCoord0; +in vec4 _positionMS; +in vec4 _positionES; + +// For retro-compatibility +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES //PROCEDURAL_COMMON_BLOCK diff --git a/libraries/render-utils/src/simple_fade.slf b/libraries/render-utils/src/simple_fade.slf index 6e7aee2894..1cb4127e7b 100644 --- a/libraries/render-utils/src/simple_fade.slf +++ b/libraries/render-utils/src/simple_fade.slf @@ -19,9 +19,19 @@ // the interpolated normal in vec3 _normalWS; +in vec3 _normalMS; in vec4 _color; +in vec2 _texCoord0; +in vec4 _positionMS; +in vec4 _positionES; in vec4 _positionWS; +// For retro-compatibility +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES + //PROCEDURAL_COMMON_BLOCK #line 1001 From bd72350287c31a12edc65094e05febcf2343f132 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 25 Apr 2018 12:47:55 +0100 Subject: [PATCH 013/192] describe magic number --- .../resources/qml/dialogs/assetDialog/AssetDialogContent.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml index 7c8a735ead..cd9ce226c0 100644 --- a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml +++ b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml @@ -254,7 +254,8 @@ Item { filterListStart = filter.indexOf("("); filterListEnd = filter.indexOf(")"); if (filterListStart !== -1 && filterListEnd !== -1) { - fileTypeFilters = filter.substring(filterListStart + 2, filterListEnd).toLowerCase().split("*"); + var FIRST_EXTENSION_OFFSET = 2; + fileTypeFilters = filter.substring(filterListStart + FIRST_EXTENSION_OFFSET, filterListEnd).toLowerCase().split("*"); } else if (filter !== "") { fileTypeFilters[0] = filter.replace("*", "").toLowerCase(); } From bd6b6c94232d7308842df7bddbff68a9b5e7b1b6 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Wed, 25 Apr 2018 12:57:46 +0100 Subject: [PATCH 014/192] fix content within 128 columns --- .../resources/qml/dialogs/assetDialog/AssetDialogContent.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml index cd9ce226c0..ed442aa191 100644 --- a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml +++ b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml @@ -255,7 +255,8 @@ Item { filterListEnd = filter.indexOf(")"); if (filterListStart !== -1 && filterListEnd !== -1) { var FIRST_EXTENSION_OFFSET = 2; - fileTypeFilters = filter.substring(filterListStart + FIRST_EXTENSION_OFFSET, filterListEnd).toLowerCase().split("*"); + fileTypeFilters = filter.substring(filterListStart + FIRST_EXTENSION_OFFSET + , filterListEnd).toLowerCase().split("*"); } else if (filter !== "") { fileTypeFilters[0] = filter.replace("*", "").toLowerCase(); } From 328f1dec9be27258b154130f51681ece09b76c97 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Wed, 25 Apr 2018 18:56:18 +0200 Subject: [PATCH 015/192] Extended to other shaders --- libraries/render-utils/src/forward_simple.slf | 10 ++++++++++ .../render-utils/src/forward_simple_transparent.slf | 9 +++++++++ libraries/render-utils/src/simple.slf | 8 ++++---- libraries/render-utils/src/simple_fade.slf | 8 ++++---- libraries/render-utils/src/simple_transparent.slf | 10 ++++++++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/libraries/render-utils/src/forward_simple.slf b/libraries/render-utils/src/forward_simple.slf index 587fcbde73..1ac44750a7 100644 --- a/libraries/render-utils/src/forward_simple.slf +++ b/libraries/render-utils/src/forward_simple.slf @@ -16,11 +16,21 @@ <@include ForwardGlobalLight.slh@> <$declareEvalSkyboxGlobalColor()$> + // the interpolated normal in vec3 _normalWS; +in vec3 _normalMS; in vec4 _color; +in vec2 _texCoord0; +in vec4 _positionMS; in vec4 _positionES; +// For retro-compatibility +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES + layout(location = 0) out vec4 _fragColor0; //PROCEDURAL_COMMON_BLOCK diff --git a/libraries/render-utils/src/forward_simple_transparent.slf b/libraries/render-utils/src/forward_simple_transparent.slf index f40ba2ed4f..8be2759571 100644 --- a/libraries/render-utils/src/forward_simple_transparent.slf +++ b/libraries/render-utils/src/forward_simple_transparent.slf @@ -18,9 +18,18 @@ // the interpolated normal in vec3 _normalWS; +in vec3 _normalMS; in vec4 _color; +in vec2 _texCoord0; +in vec4 _positionMS; in vec4 _positionES; +// For retro-compatibility +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES + layout(location = 0) out vec4 _fragColor0; //PROCEDURAL_COMMON_BLOCK diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index 338f8607ee..7591dc1882 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -23,10 +23,10 @@ in vec4 _positionMS; in vec4 _positionES; // For retro-compatibility -#define _normal _normalWS -#define _modelNormal _normalMS -#define _position _positionMS -#define _eyePosition _positionES +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES //PROCEDURAL_COMMON_BLOCK diff --git a/libraries/render-utils/src/simple_fade.slf b/libraries/render-utils/src/simple_fade.slf index 1cb4127e7b..0710c3e10b 100644 --- a/libraries/render-utils/src/simple_fade.slf +++ b/libraries/render-utils/src/simple_fade.slf @@ -27,10 +27,10 @@ in vec4 _positionES; in vec4 _positionWS; // For retro-compatibility -#define _normal _normalWS -#define _modelNormal _normalMS -#define _position _positionMS -#define _eyePosition _positionES +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES //PROCEDURAL_COMMON_BLOCK diff --git a/libraries/render-utils/src/simple_transparent.slf b/libraries/render-utils/src/simple_transparent.slf index c9815e8a80..ee79d2c0c4 100644 --- a/libraries/render-utils/src/simple_transparent.slf +++ b/libraries/render-utils/src/simple_transparent.slf @@ -16,7 +16,17 @@ // the interpolated normal in vec3 _normalWS; +in vec3 _normalMS; in vec4 _color; +in vec2 _texCoord0; +in vec4 _positionMS; +in vec4 _positionES; + +// For retro-compatibility +#define _normal _normalWS +#define _modelNormal _normalMS +#define _position _positionMS +#define _eyePosition _positionES //PROCEDURAL_COMMON_BLOCK From 3233cc43ac8d12a48e500130c6b7a91fbcff448c Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 25 Apr 2018 10:30:50 -0700 Subject: [PATCH 016/192] Revert "Merge pull request #12981 from birarda/bug/revert-hmac" This reverts commit 91b93db0c5f27a5b5c0282780ee56102078224be, reversing changes made to 6062f21da114f34164ba80db7e31bf45b959626e. --- libraries/networking/src/HMACAuth.cpp | 94 +++++++++++++++++++ libraries/networking/src/HMACAuth.h | 40 ++++++++ libraries/networking/src/LimitedNodeList.cpp | 36 +++---- libraries/networking/src/LimitedNodeList.h | 10 +- libraries/networking/src/NLPacket.cpp | 16 ++-- libraries/networking/src/NLPacket.h | 8 +- libraries/networking/src/Node.cpp | 14 ++- libraries/networking/src/Node.h | 5 +- .../networking/src/udt/PacketHeaders.cpp | 2 +- 9 files changed, 186 insertions(+), 39 deletions(-) create mode 100644 libraries/networking/src/HMACAuth.cpp create mode 100644 libraries/networking/src/HMACAuth.h diff --git a/libraries/networking/src/HMACAuth.cpp b/libraries/networking/src/HMACAuth.cpp new file mode 100644 index 0000000000..42b5c48d93 --- /dev/null +++ b/libraries/networking/src/HMACAuth.cpp @@ -0,0 +1,94 @@ +// +// HMACAuth.cpp +// libraries/networking/src +// +// Created by Simon Walton on 3/19/2018. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include + +#include "HMACAuth.h" + +#include + +#if OPENSSL_VERSION_NUMBER >= 0x10100000 +HMACAuth::HMACAuth(AuthMethod authMethod) + : _hmacContext(HMAC_CTX_new()) + , _authMethod(authMethod) { } + +HMACAuth::~HMACAuth() +{ + HMAC_CTX_free(_hmacContext); +} + +#else + +HMACAuth::HMACAuth(AuthMethod authMethod) + : _hmacContext(new HMAC_CTX()) + , _authMethod(authMethod) { + HMAC_CTX_init(_hmacContext); +} + +HMACAuth::~HMACAuth() { + HMAC_CTX_cleanup(_hmacContext); + delete _hmacContext; +} +#endif + +bool HMACAuth::setKey(const char* keyValue, int keyLen) { + const EVP_MD* sslStruct = nullptr; + + switch (_authMethod) { + case MD5: + sslStruct = EVP_md5(); + break; + + case SHA1: + sslStruct = EVP_sha1(); + break; + + case SHA224: + sslStruct = EVP_sha224(); + break; + + case SHA256: + sslStruct = EVP_sha256(); + break; + + case RIPEMD160: + sslStruct = EVP_ripemd160(); + break; + + default: + return false; + } + + QMutexLocker lock(&_lock); + return (bool) HMAC_Init_ex(_hmacContext, keyValue, keyLen, sslStruct, nullptr); +} + +bool HMACAuth::setKey(const QUuid& uidKey) { + const QByteArray rfcBytes(uidKey.toRfc4122()); + return setKey(rfcBytes.constData(), rfcBytes.length()); +} + +bool HMACAuth::addData(const char* data, int dataLen) { + QMutexLocker lock(&_lock); + return (bool) HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen); +} + +HMACAuth::HMACHash HMACAuth::result() { + HMACHash hashValue(EVP_MAX_MD_SIZE); + unsigned int hashLen; + QMutexLocker lock(&_lock); + HMAC_Final(_hmacContext, &hashValue[0], &hashLen); + hashValue.resize((size_t) hashLen); + // Clear state for possible reuse. + HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); + return hashValue; +} diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h new file mode 100644 index 0000000000..0bf7a86ec1 --- /dev/null +++ b/libraries/networking/src/HMACAuth.h @@ -0,0 +1,40 @@ +// +// HMACAuth.h +// libraries/networking/src +// +// Created by Simon Walton on 3/19/2018. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_HMACAuth_h +#define hifi_HMACAuth_h + +#include +#include +#include + +class QUuid; + +class HMACAuth { +public: + enum AuthMethod { MD5, SHA1, SHA224, SHA256, RIPEMD160 }; + using HMACHash = std::vector; + + explicit HMACAuth(AuthMethod authMethod = MD5); + ~HMACAuth(); + + bool setKey(const char* keyValue, int keyLen); + bool setKey(const QUuid& uidKey); + bool addData(const char* data, int dataLen); + HMACHash result(); + +private: + QMutex _lock; + struct hmac_ctx_st* _hmacContext; + AuthMethod _authMethod; +}; + +#endif // hifi_HMACAuth_h diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 92385e99b0..8d177ca534 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -36,6 +36,7 @@ #include "HifiSockAddr.h" #include "NetworkLogging.h" #include "udt/Packet.h" +#include "HMACAuth.h" static Setting::Handle LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.LocalPort", 0); @@ -330,7 +331,7 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe if (verifiedPacket && !ignoreVerification) { QByteArray packetHeaderHash = NLPacket::verificationHashInHeader(packet); - QByteArray expectedHash = NLPacket::hashForPacketAndSecret(packet, sourceNode->getConnectionSecret()); + QByteArray expectedHash = NLPacket::hashForPacketAndHMAC(packet, sourceNode->getAuthenticateHash()); // check if the md5 hash in the header matches the hash we would expect if (packetHeaderHash != expectedHash) { @@ -370,15 +371,15 @@ void LimitedNodeList::collectPacketStats(const NLPacket& packet) { _numCollectedBytes += packet.getDataSize(); } -void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret) { +void LimitedNodeList::fillPacketHeader(const NLPacket& packet, HMACAuth* hmacAuth) { if (!PacketTypeEnum::getNonSourcedPackets().contains(packet.getType())) { packet.writeSourceID(getSessionLocalID()); } - if (!connectionSecret.isNull() + if (hmacAuth && !PacketTypeEnum::getNonSourcedPackets().contains(packet.getType()) && !PacketTypeEnum::getNonVerifiedPackets().contains(packet.getType())) { - packet.writeVerificationHashGivenSecret(connectionSecret); + packet.writeVerificationHash(*hmacAuth); } } @@ -394,17 +395,17 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& emit dataSent(destinationNode.getType(), packet.getDataSize()); destinationNode.recordBytesSent(packet.getDataSize()); - return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret()); + return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), &destinationNode.getAuthenticateHash()); } qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret) { + HMACAuth* hmacAuth) { Q_ASSERT(!packet.isPartOfMessage()); Q_ASSERT_X(!packet.isReliable(), "LimitedNodeList::sendUnreliablePacket", "Trying to send a reliable packet unreliably."); collectPacketStats(packet); - fillPacketHeader(packet, connectionSecret); + fillPacketHeader(packet, hmacAuth); return _nodeSocket.writePacket(packet, sockAddr); } @@ -417,7 +418,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& emit dataSent(destinationNode.getType(), packet->getDataSize()); destinationNode.recordBytesSent(packet->getDataSize()); - return sendPacket(std::move(packet), *activeSocket, destinationNode.getConnectionSecret()); + return sendPacket(std::move(packet), *activeSocket, &destinationNode.getAuthenticateHash()); } else { qCDebug(networking) << "LimitedNodeList::sendPacket called without active socket for node" << destinationNode << "- not sending"; return ERROR_SENDING_PACKET_BYTES; @@ -425,18 +426,18 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& } qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret) { + HMACAuth* hmacAuth) { Q_ASSERT(!packet->isPartOfMessage()); if (packet->isReliable()) { collectPacketStats(*packet); - fillPacketHeader(*packet, connectionSecret); + fillPacketHeader(*packet, hmacAuth); auto size = packet->getDataSize(); _nodeSocket.writePacket(std::move(packet), sockAddr); return size; } else { - return sendUnreliablePacket(*packet, sockAddr, connectionSecret); + return sendUnreliablePacket(*packet, sockAddr, hmacAuth); } } @@ -445,13 +446,14 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi if (activeSocket) { qint64 bytesSent = 0; - auto connectionSecret = destinationNode.getConnectionSecret(); + auto& connectionHash = destinationNode.getAuthenticateHash(); // close the last packet in the list packetList.closeCurrentPacket(); while (!packetList._packets.empty()) { - bytesSent += sendPacket(packetList.takeFront(), *activeSocket, connectionSecret); + bytesSent += sendPacket(packetList.takeFront(), *activeSocket, + &connectionHash); } emit dataSent(destinationNode.getType(), bytesSent); @@ -464,14 +466,14 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi } qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret) { + HMACAuth* hmacAuth) { qint64 bytesSent = 0; // close the last packet in the list packetList.closeCurrentPacket(); while (!packetList._packets.empty()) { - bytesSent += sendPacket(packetList.takeFront(), sockAddr, connectionSecret); + bytesSent += sendPacket(packetList.takeFront(), sockAddr, hmacAuth); } return bytesSent; @@ -499,7 +501,7 @@ qint64 LimitedNodeList::sendPacketList(std::unique_ptr packetList, for (std::unique_ptr& packet : packetList->_packets) { NLPacket* nlPacket = static_cast(packet.get()); collectPacketStats(*nlPacket); - fillPacketHeader(*nlPacket, destinationNode.getConnectionSecret()); + fillPacketHeader(*nlPacket, &destinationNode.getAuthenticateHash()); } return _nodeSocket.writePacketList(std::move(packetList), *activeSocket); @@ -522,7 +524,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket() : overridenSockAddr; - return sendPacket(std::move(packet), destinationSockAddr, destinationNode.getConnectionSecret()); + return sendPacket(std::move(packet), destinationSockAddr, &destinationNode.getAuthenticateHash()); } int LimitedNodeList::updateNodeWithDataFromPacket(QSharedPointer message, SharedNodePointer sendingNode) { diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 3d6fd0cd91..05374bbfbb 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -138,19 +138,17 @@ public: // use sendUnreliablePacket to send an unreliable packet (that you do not need to move) // either to a node (via its active socket) or to a manual sockaddr qint64 sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode); - qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret = QUuid()); + qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr, HMACAuth* hmacAuth = nullptr); // use sendPacket to send a moved unreliable or reliable NL packet to a node's active socket or manual sockaddr qint64 sendPacket(std::unique_ptr packet, const Node& destinationNode); - qint64 sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret = QUuid()); + qint64 sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr, HMACAuth* hmacAuth = nullptr); // use sendUnreliableUnorderedPacketList to unreliably send separate packets from the packet list // either to a node's active socket or to a manual sockaddr qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const Node& destinationNode); qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr, - const QUuid& connectionSecret = QUuid()); + HMACAuth* hmacAuth = nullptr); // use sendPacketList to send reliable packet lists (ordered or unordered) to a node's active socket // or to a manual sock addr @@ -372,7 +370,7 @@ protected: qint64 writePacket(const NLPacket& packet, const HifiSockAddr& destinationSockAddr, const QUuid& connectionSecret = QUuid()); void collectPacketStats(const NLPacket& packet); - void fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret = QUuid()); + void fillPacketHeader(const NLPacket& packet, HMACAuth* hmacAuth = nullptr); void setLocalSocket(const HifiSockAddr& sockAddr); diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index ac3fbc966b..3355e1cd6b 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -11,6 +11,8 @@ #include "NLPacket.h" +#include "HMACAuth.h" + int NLPacket::localHeaderSize(PacketType type) { bool nonSourced = PacketTypeEnum::getNonSourcedPackets().contains(type); bool nonVerified = PacketTypeEnum::getNonVerifiedPackets().contains(type); @@ -150,18 +152,14 @@ QByteArray NLPacket::verificationHashInHeader(const udt::Packet& packet) { return QByteArray(packet.getData() + offset, NUM_BYTES_MD5_HASH); } -QByteArray NLPacket::hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret) { - QCryptographicHash hash(QCryptographicHash::Md5); - +QByteArray NLPacket::hashForPacketAndHMAC(const udt::Packet& packet, HMACAuth& hash) { int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_LOCALID + NUM_BYTES_MD5_HASH; // add the packet payload and the connection UUID hash.addData(packet.getData() + offset, packet.getDataSize() - offset); - hash.addData(connectionSecret.toRfc4122()); - - // return the hash - return hash.result(); + auto hashResult { hash.result() }; + return QByteArray((const char*) hashResult.data(), (int) hashResult.size()); } void NLPacket::writeTypeAndVersion() { @@ -214,14 +212,14 @@ void NLPacket::writeSourceID(LocalID sourceID) const { _sourceID = sourceID; } -void NLPacket::writeVerificationHashGivenSecret(const QUuid& connectionSecret) const { +void NLPacket::writeVerificationHash(HMACAuth& hmacAuth) const { Q_ASSERT(!PacketTypeEnum::getNonSourcedPackets().contains(_type) && !PacketTypeEnum::getNonVerifiedPackets().contains(_type)); auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_LOCALID; - QByteArray verificationHash = hashForPacketAndSecret(*this, connectionSecret); + QByteArray verificationHash = hashForPacketAndHMAC(*this, hmacAuth); memcpy(_packet.get() + offset, verificationHash.data(), verificationHash.size()); } diff --git a/libraries/networking/src/NLPacket.h b/libraries/networking/src/NLPacket.h index 9b07bc6581..4103f2068e 100644 --- a/libraries/networking/src/NLPacket.h +++ b/libraries/networking/src/NLPacket.h @@ -18,6 +18,8 @@ #include "udt/Packet.h" +class HMACAuth; + class NLPacket : public udt::Packet { Q_OBJECT public: @@ -69,7 +71,7 @@ public: static LocalID sourceIDInHeader(const udt::Packet& packet); static QByteArray verificationHashInHeader(const udt::Packet& packet); - static QByteArray hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret); + static QByteArray hashForPacketAndHMAC(const udt::Packet& packet, HMACAuth& hash); PacketType getType() const { return _type; } void setType(PacketType type); @@ -78,9 +80,9 @@ public: void setVersion(PacketVersion version); LocalID getSourceID() const { return _sourceID; } - + void writeSourceID(LocalID sourceID) const; - void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const; + void writeVerificationHash(HMACAuth& hmacAuth) const; protected: diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index 73b7c44e7e..7979b36e30 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -86,10 +86,10 @@ NodeType_t NodeType::fromString(QString type) { Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, - const HifiSockAddr& localSocket, QObject* parent) : + const HifiSockAddr& localSocket, QObject* parent) : NetworkPeer(uuid, publicSocket, localSocket, parent), _type(type), - _pingMs(-1), // "Uninitialized" + _authenticateHash(new HMACAuth), _pingMs(-1), // "Uninitialized" _clockSkewUsec(0), _mutex(), _clockSkewMovingPercentile(30, 0.8f) // moving 80th percentile of 30 samples @@ -108,6 +108,7 @@ void Node::setType(char type) { _symmetricSocket.setObjectName(typeString); } + void Node::updateClockSkewUsec(qint64 clockSkewSample) { _clockSkewMovingPercentile.updatePercentile(clockSkewSample); _clockSkewUsec = (quint64)_clockSkewMovingPercentile.getValueAtPercentile(); @@ -194,3 +195,12 @@ QDebug operator<<(QDebug debug, const Node& node) { debug.nospace() << node.getPublicSocket() << "/" << node.getLocalSocket(); return debug.nospace(); } + +void Node::setConnectionSecret(const QUuid& connectionSecret) { + if (_connectionSecret == connectionSecret) { + return; + } + + _connectionSecret = connectionSecret; + _authenticateHash->setKey(_connectionSecret); +} diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 93b6a649d4..5b3b559582 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -33,6 +33,7 @@ #include "SimpleMovingAverage.h" #include "MovingPercentile.h" #include "NodePermissions.h" +#include "HMACAuth.h" class Node : public NetworkPeer { Q_OBJECT @@ -55,7 +56,8 @@ public: void setIsUpstream(bool isUpstream) { _isUpstream = isUpstream; } const QUuid& getConnectionSecret() const { return _connectionSecret; } - void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; } + void setConnectionSecret(const QUuid& connectionSecret); + HMACAuth& getAuthenticateHash() const { return *_authenticateHash; } NodeData* getLinkedData() const { return _linkedData.get(); } void setLinkedData(std::unique_ptr linkedData) { _linkedData = std::move(linkedData); } @@ -97,6 +99,7 @@ private: NodeType_t _type; QUuid _connectionSecret; + std::unique_ptr _authenticateHash; std::unique_ptr _linkedData; bool _isReplicated { false }; int _pingMs; diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 98b0e1d892..db466a0403 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -91,7 +91,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); default: - return 20; + return 19; } } From 44816941fce7644083171ca8c5b98f0005de3061 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 25 Apr 2018 10:57:57 -0700 Subject: [PATCH 017/192] Fix debug assert in manipulating thread local data to store GL surfaces --- libraries/gl/src/gl/OffscreenGLCanvas.cpp | 45 +++++++++++++++++++---- libraries/gl/src/gl/OffscreenGLCanvas.h | 2 + 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/libraries/gl/src/gl/OffscreenGLCanvas.cpp b/libraries/gl/src/gl/OffscreenGLCanvas.cpp index 4a2c5fd7f7..91f7954943 100644 --- a/libraries/gl/src/gl/OffscreenGLCanvas.cpp +++ b/libraries/gl/src/gl/OffscreenGLCanvas.cpp @@ -17,15 +17,18 @@ #include #include #include +#include +#include #include #include #include +#include + #include "Context.h" #include "GLHelpers.h" #include "GLLogging.h" - OffscreenGLCanvas::OffscreenGLCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface) @@ -33,6 +36,8 @@ OffscreenGLCanvas::OffscreenGLCanvas() : } OffscreenGLCanvas::~OffscreenGLCanvas() { + clearThreadContext(); + // A context with logging enabled needs to be current when it's destroyed _context->makeCurrent(_offscreenSurface); delete _context; @@ -117,25 +122,51 @@ QObject* OffscreenGLCanvas::getContextObject() { } void OffscreenGLCanvas::moveToThreadWithContext(QThread* thread) { + clearThreadContext(); moveToThread(thread); _context->moveToThread(thread); } -static const char* THREAD_CONTEXT_PROPERTY = "offscreenGlCanvas"; +struct ThreadContextStorage : public Dependency { + QThreadStorage> threadContext; +}; void OffscreenGLCanvas::setThreadContext() { - QThread::currentThread()->setProperty(THREAD_CONTEXT_PROPERTY, QVariant::fromValue(this)); + if (!DependencyManager::isSet()) { + DependencyManager::set(); + } + auto threadContextStorage = DependencyManager::get(); + QPointer p(this); + threadContextStorage->threadContext.setLocalData(p); +} + +void OffscreenGLCanvas::clearThreadContext() { + if (!DependencyManager::isSet()) { + return; + } + auto threadContextStorage = DependencyManager::get(); + if (!threadContextStorage->threadContext.hasLocalData()) { + return; + } + auto& threadContext = threadContextStorage->threadContext.localData(); + if (this != threadContext.operator OffscreenGLCanvas *()) { + return; + } + threadContextStorage->threadContext.setLocalData(nullptr); } bool OffscreenGLCanvas::restoreThreadContext() { // Restore the rendering context for this thread - auto threadCanvasVariant = QThread::currentThread()->property(THREAD_CONTEXT_PROPERTY); - if (!threadCanvasVariant.isValid()) { + if (!DependencyManager::isSet()) { return false; } - auto threadCanvasObject = qvariant_cast(threadCanvasVariant); - auto threadCanvas = static_cast(threadCanvasObject); + auto threadContextStorage = DependencyManager::get(); + if (!threadContextStorage->threadContext.hasLocalData()) { + return false; + } + + auto threadCanvas = threadContextStorage->threadContext.localData(); if (!threadCanvas) { return false; } diff --git a/libraries/gl/src/gl/OffscreenGLCanvas.h b/libraries/gl/src/gl/OffscreenGLCanvas.h index ed644b98fb..a4960ae234 100644 --- a/libraries/gl/src/gl/OffscreenGLCanvas.h +++ b/libraries/gl/src/gl/OffscreenGLCanvas.h @@ -39,6 +39,8 @@ private slots: void onMessageLogged(const QOpenGLDebugMessage &debugMessage); protected: + void clearThreadContext(); + std::once_flag _reportOnce; QOpenGLContext* _context{ nullptr }; QOffscreenSurface* _offscreenSurface{ nullptr }; From 4fa11f116fb17847c5bdcee167301f16d94cc2ce Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 25 Apr 2018 14:41:16 -0700 Subject: [PATCH 018/192] Add & use HMACAuth method that calculates hash atomically To avoid issues with race conditions involving separate addData() and result() calls use a method that does both in the lock. --- libraries/networking/src/HMACAuth.cpp | 25 +++++++++++++++++++++---- libraries/networking/src/HMACAuth.h | 5 +++-- libraries/networking/src/NLPacket.cpp | 7 ++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/libraries/networking/src/HMACAuth.cpp b/libraries/networking/src/HMACAuth.cpp index e276e64b40..8aa2fea6a9 100644 --- a/libraries/networking/src/HMACAuth.cpp +++ b/libraries/networking/src/HMACAuth.cpp @@ -68,7 +68,7 @@ bool HMACAuth::setKey(const char* keyValue, int keyLen) { return false; } - //QMutexLocker lock(&_lock); + QMutexLocker lock(&_lock); return (bool) HMAC_Init_ex(_hmacContext, keyValue, keyLen, sslStruct, nullptr); } @@ -78,14 +78,14 @@ bool HMACAuth::setKey(const QUuid& uidKey) { } bool HMACAuth::addData(const char* data, int dataLen) { - //QMutexLocker lock(&_lock); + QMutexLocker lock(&_lock); return (bool) HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen); } HMACAuth::HMACHash HMACAuth::result() { HMACHash hashValue(EVP_MAX_MD_SIZE); - unsigned int hashLen; - //QMutexLocker lock(&_lock); + unsigned int hashLen; + QMutexLocker lock(&_lock); if (HMAC_Final(_hmacContext, &hashValue[0], &hashLen)) { hashValue.resize((size_t)hashLen); } @@ -93,3 +93,20 @@ HMACAuth::HMACHash HMACAuth::result() { HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); return hashValue; } + +bool HMACAuth::calculateHash(HMACHash& hashResult, const char* data, int dataLen) { + QMutexLocker lock(&_lock); + if (!HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen)) { + return false; + } + + hashResult.resize(EVP_MAX_MD_SIZE); + unsigned int hashLen; + if (HMAC_Final(_hmacContext, &hashResult[0], &hashLen)) { + hashResult.resize((size_t)hashLen); + // Clear state for possible reuse. + HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); + return true; + } + return false; +} diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h index ba1ec78214..ec06bfbda2 100644 --- a/libraries/networking/src/HMACAuth.h +++ b/libraries/networking/src/HMACAuth.h @@ -26,10 +26,11 @@ public: explicit HMACAuth(AuthMethod authMethod = MD5); ~HMACAuth(); - QMutex& getLock() { return _lock; } - bool setKey(const char* keyValue, int keyLen); bool setKey(const QUuid& uidKey); + // Calculate complete hash in one. + bool calculateHash(HMACHash& hashResult, const char* data, int dataLen); + // Append data to be hashed. bool addData(const char* data, int dataLen); HMACHash result(); diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index 09a7b78840..f946e97bf4 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -157,9 +157,10 @@ QByteArray NLPacket::hashForPacketAndHMAC(const udt::Packet& packet, HMACAuth& h + NUM_BYTES_LOCALID + NUM_BYTES_MD5_HASH; // add the packet payload and the connection UUID - QMutexLocker hashLock(&hash.getLock()); - hash.addData(packet.getData() + offset, packet.getDataSize() - offset); - auto hashResult { hash.result() }; + HMACAuth::HMACHash hashResult; + if (!hash.calculateHash(hashResult, packet.getData() + offset, packet.getDataSize() - offset)) { + return QByteArray(); + } return QByteArray((const char*) hashResult.data(), (int) hashResult.size()); } From 66bd424ae4002a75cd3003f4e97df1322dd2143f Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 25 Apr 2018 14:51:11 -0700 Subject: [PATCH 019/192] Bump default packet version for new HMAC --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index db466a0403..98b0e1d892 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -91,7 +91,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); default: - return 19; + return 20; } } From 9ef56c44a3da38161741cf4dc62f49e786c8e5b1 Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 25 Apr 2018 17:08:08 -0700 Subject: [PATCH 020/192] Merge PR12964 to not use verification if not keyed https://github.com/highfidelity/hifi/pull/12964 --- libraries/networking/src/HMACAuth.cpp | 20 +++++++++++++++++--- libraries/networking/src/LimitedNodeList.cpp | 20 ++++++++++++-------- libraries/networking/src/Node.cpp | 6 +++++- libraries/networking/src/Node.h | 4 ++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/libraries/networking/src/HMACAuth.cpp b/libraries/networking/src/HMACAuth.cpp index 8aa2fea6a9..8e57978b5a 100644 --- a/libraries/networking/src/HMACAuth.cpp +++ b/libraries/networking/src/HMACAuth.cpp @@ -9,12 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HMACAuth.h" + #include #include -#include "HMACAuth.h" - #include +#include "NetworkLogging.h" +#include #if OPENSSL_VERSION_NUMBER >= 0x10100000 HMACAuth::HMACAuth(AuthMethod authMethod) @@ -86,9 +88,17 @@ HMACAuth::HMACHash HMACAuth::result() { HMACHash hashValue(EVP_MAX_MD_SIZE); unsigned int hashLen; QMutexLocker lock(&_lock); - if (HMAC_Final(_hmacContext, &hashValue[0], &hashLen)) { + + auto hmacResult = HMAC_Final(_hmacContext, &hashValue[0], &hashLen); + + if (hmacResult) { hashValue.resize((size_t)hashLen); + } else { + // the HMAC_FINAL call failed - should not be possible to get into this state + qCWarning(networking) << "Error occured calling HMAC_Final"; + assert(hmacResult); } + // Clear state for possible reuse. HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); return hashValue; @@ -97,6 +107,8 @@ HMACAuth::HMACHash HMACAuth::result() { bool HMACAuth::calculateHash(HMACHash& hashResult, const char* data, int dataLen) { QMutexLocker lock(&_lock); if (!HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen)) { + qCWarning(networking) << "Error occured calling HMAC_Update"; + assert(false); return false; } @@ -108,5 +120,7 @@ bool HMACAuth::calculateHash(HMACHash& hashResult, const char* data, int dataLen HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); return true; } + qCWarning(networking) << "Error occured calling HMAC_Final"; + assert(false); return false; } diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index d66dd644d5..5457e206f5 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -331,10 +331,14 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe if (verifiedPacket && !ignoreVerification) { QByteArray packetHeaderHash = NLPacket::verificationHashInHeader(packet); - QByteArray expectedHash = NLPacket::hashForPacketAndHMAC(packet, sourceNode->getAuthenticateHash()); + QByteArray expectedHash; + auto sourceNodeHMACAuth = sourceNode->getAuthenticateHash(); + if (sourceNode->getAuthenticateHash()) { + expectedHash = NLPacket::hashForPacketAndHMAC(packet, *sourceNodeHMACAuth); + } // check if the HMAC-md5 hash in the header matches the hash we would expect - if (packetHeaderHash != expectedHash) { + if (!sourceNodeHMACAuth || packetHeaderHash != expectedHash) { static QMultiMap hashDebugSuppressMap; if (!hashDebugSuppressMap.contains(sourceID, headerType)) { @@ -396,7 +400,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& emit dataSent(destinationNode.getType(), packet.getDataSize()); destinationNode.recordBytesSent(packet.getDataSize()); - return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), &destinationNode.getAuthenticateHash()); + return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getAuthenticateHash()); } qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr, @@ -419,7 +423,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& emit dataSent(destinationNode.getType(), packet->getDataSize()); destinationNode.recordBytesSent(packet->getDataSize()); - return sendPacket(std::move(packet), *activeSocket, &destinationNode.getAuthenticateHash()); + return sendPacket(std::move(packet), *activeSocket, destinationNode.getAuthenticateHash()); } else { qCDebug(networking) << "LimitedNodeList::sendPacket called without active socket for node" << destinationNode << "- not sending"; return ERROR_SENDING_PACKET_BYTES; @@ -447,14 +451,14 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi if (activeSocket) { qint64 bytesSent = 0; - auto& connectionHash = destinationNode.getAuthenticateHash(); + auto connectionHash = destinationNode.getAuthenticateHash(); // close the last packet in the list packetList.closeCurrentPacket(); while (!packetList._packets.empty()) { bytesSent += sendPacket(packetList.takeFront(), *activeSocket, - &connectionHash); + connectionHash); } emit dataSent(destinationNode.getType(), bytesSent); @@ -502,7 +506,7 @@ qint64 LimitedNodeList::sendPacketList(std::unique_ptr packetList, for (std::unique_ptr& packet : packetList->_packets) { NLPacket* nlPacket = static_cast(packet.get()); collectPacketStats(*nlPacket); - fillPacketHeader(*nlPacket, &destinationNode.getAuthenticateHash()); + fillPacketHeader(*nlPacket, destinationNode.getAuthenticateHash()); } return _nodeSocket.writePacketList(std::move(packetList), *activeSocket); @@ -525,7 +529,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket() : overridenSockAddr; - return sendPacket(std::move(packet), destinationSockAddr, &destinationNode.getAuthenticateHash()); + return sendPacket(std::move(packet), destinationSockAddr, destinationNode.getAuthenticateHash()); } int LimitedNodeList::updateNodeWithDataFromPacket(QSharedPointer message, SharedNodePointer sendingNode) { diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index 7979b36e30..8fd8131b10 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -89,7 +89,7 @@ Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, QObject* parent) : NetworkPeer(uuid, publicSocket, localSocket, parent), _type(type), - _authenticateHash(new HMACAuth), _pingMs(-1), // "Uninitialized" + _pingMs(-1), // "Uninitialized" _clockSkewUsec(0), _mutex(), _clockSkewMovingPercentile(30, 0.8f) // moving 80th percentile of 30 samples @@ -201,6 +201,10 @@ void Node::setConnectionSecret(const QUuid& connectionSecret) { return; } + if (!_authenticateHash) { + _authenticateHash.reset(new HMACAuth()); + } + _connectionSecret = connectionSecret; _authenticateHash->setKey(_connectionSecret); } diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 5b3b559582..bcfe525aa8 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -57,7 +57,7 @@ public: const QUuid& getConnectionSecret() const { return _connectionSecret; } void setConnectionSecret(const QUuid& connectionSecret); - HMACAuth& getAuthenticateHash() const { return *_authenticateHash; } + HMACAuth* getAuthenticateHash() const { return _authenticateHash.get(); } NodeData* getLinkedData() const { return _linkedData.get(); } void setLinkedData(std::unique_ptr linkedData) { _linkedData = std::move(linkedData); } @@ -99,7 +99,7 @@ private: NodeType_t _type; QUuid _connectionSecret; - std::unique_ptr _authenticateHash; + std::unique_ptr _authenticateHash { nullptr }; std::unique_ptr _linkedData; bool _isReplicated { false }; int _pingMs; From 496b638a885ef34cf66fe541e925aa61cef37b59 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 26 Apr 2018 14:31:31 -0700 Subject: [PATCH 021/192] Fix log file directory not being capped at 50MB --- libraries/shared/src/shared/FileLogger.cpp | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 8ceb378574..4f4a9ab6dd 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -36,17 +36,15 @@ protected: private: const FileLogger& _logger; QMutex _fileMutex; - uint64_t _lastRollTime; + std::chrono::system_clock::time_point _lastRollTime; }; - - static const QString FILENAME_FORMAT = "hifi-log_%1%2.txt"; static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss"; static const QString LOGS_DIRECTORY = "Logs"; -static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; -static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; -static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; +static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[01][0-9]-[0-3][0-9]_[0-2][0-9]\\.[0-6][0-9]\\.[0-6][0-9]"; +static const QString SESSION_WILDCARD = "[0-9a-z]{8}(-[0-9a-z]{4}){3}-[0-9a-z]{12}"; +static QRegExp LOG_FILENAME_REGEX { "hifi-log_" + DATETIME_WILDCARD + "(_" + SESSION_WILDCARD + ")?\.txt" }; static QUuid SESSION_ID; // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively @@ -104,20 +102,21 @@ void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfR _lastRollTime = now; } - QStringList nameFilters; - nameFilters << FILENAME_WILDCARD; - QDir logQDir(FileUtils::standardPath(LOGS_DIRECTORY)); - logQDir.setNameFilters(nameFilters); - logQDir.setSorting(QDir::Time); - QFileInfoList filesInDir = logQDir.entryInfoList(); + QDir logDir(FileUtils::standardPath(LOGS_DIRECTORY)); + logDir.setSorting(QDir::Time); + logDir.setFilter(QDir::Files); qint64 totalSizeOfDir = 0; - foreach(QFileInfo dirItm, filesInDir){ - if (totalSizeOfDir < MAX_LOG_DIR_SIZE){ - totalSizeOfDir += dirItm.size(); - } else { - QFile file(dirItm.filePath()); - file.remove(); + QFileInfoList filesInDir = logDir.entryInfoList(); + for (auto& fileInfo : filesInDir) { + if (!LOG_FILENAME_REGEX.exactMatch(fileInfo.fileName())) { + continue; + } + totalSizeOfDir += fileInfo.size(); + if (totalSizeOfDir > MAX_LOG_DIR_SIZE){ + qDebug() << "Removing log file: " << fileInfo.fileName(); + QFile oldLogFile(fileInfo.filePath()); + oldLogFile.remove(); } } } From 1448f3959ebe541fe9457e70b2aae0e0598e6b04 Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Thu, 26 Apr 2018 17:11:17 -0700 Subject: [PATCH 022/192] Add a utility function to dump ConnectionStats --- .../networking/src/udt/ConnectionStats.cpp | 29 +++++++++++++++++++ .../networking/src/udt/ConnectionStats.h | 3 ++ 2 files changed, 32 insertions(+) diff --git a/libraries/networking/src/udt/ConnectionStats.cpp b/libraries/networking/src/udt/ConnectionStats.cpp index e7efe3d5af..46d88e680f 100644 --- a/libraries/networking/src/udt/ConnectionStats.cpp +++ b/libraries/networking/src/udt/ConnectionStats.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include "ConnectionStats.h" using namespace udt; @@ -112,3 +113,31 @@ void ConnectionStats::recordPacketSendPeriod(int sample) { _currentSample.packetSendPeriod = sample; _total.packetSendPeriod = (int)((_total.packetSendPeriod * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT)); } + +QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats) { + debug << "Connection stats:\n"; +#define HIFI_LOG_EVENT(x) << " " #x " events: " << stats.events[ConnectionStats::Stats::Event::x] << "\n" + debug + HIFI_LOG_EVENT(SentACK) + HIFI_LOG_EVENT(ReceivedACK) + HIFI_LOG_EVENT(ProcessedACK) + HIFI_LOG_EVENT(SentLightACK) + HIFI_LOG_EVENT(ReceivedLightACK) + HIFI_LOG_EVENT(SentACK2) + HIFI_LOG_EVENT(ReceivedACK2) + HIFI_LOG_EVENT(SentNAK) + HIFI_LOG_EVENT(ReceivedNAK) + HIFI_LOG_EVENT(SentTimeoutNAK) + HIFI_LOG_EVENT(ReceivedTimeoutNAK) + HIFI_LOG_EVENT(Retransmission) + HIFI_LOG_EVENT(Duplicate) + ; +#undef HIFI_LOG_EVENT + + debug << " Sent packets: " << stats.sentPackets; + debug << "\n Received packets: " << stats.receivedPackets; + debug << "\n Sent util bytes: " << stats.sentUtilBytes; + debug << "\n Sent bytes: " << stats.sentBytes; + debug << "\n Received bytes: " << stats.receivedBytes << "\n"; + return debug; +} diff --git a/libraries/networking/src/udt/ConnectionStats.h b/libraries/networking/src/udt/ConnectionStats.h index 84cd6b2486..7ec7b163ee 100644 --- a/libraries/networking/src/udt/ConnectionStats.h +++ b/libraries/networking/src/udt/ConnectionStats.h @@ -101,4 +101,7 @@ private: } +class QDebug; +QDebug& operator<<(QDebug&& debug, const udt::ConnectionStats::Stats& stats); + #endif // hifi_ConnectionStats_h From 290c31d9162a6e81adbf57530feeff9393d2c732 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 27 Apr 2018 11:33:45 -0700 Subject: [PATCH 023/192] don't spam resetSensors --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c38caca090..18ba4958aa 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3554,7 +3554,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } else { showCursor(Cursor::Icon::DEFAULT); } - } else { + } else if (!event->isAutoRepeat()){ resetSensors(true); } break; From bfbded7beca85e58c1b87801f715d3cee678f027 Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Fri, 27 Apr 2018 16:57:24 -0700 Subject: [PATCH 024/192] Reset pending domain checkins in more locations --- libraries/networking/src/DomainHandler.cpp | 3 +++ libraries/networking/src/DomainHandler.h | 2 +- libraries/networking/src/NodeList.cpp | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index cd8064c4c0..84af21004d 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -239,6 +239,7 @@ void DomainHandler::activateICELocalSocket() { _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); + clearPendingCheckins(); // Clear outstanding count. } void DomainHandler::activateICEPublicSocket() { @@ -248,6 +249,7 @@ void DomainHandler::activateICEPublicSocket() { _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); + clearPendingCheckins(); // Clear outstanding count. } QString DomainHandler::getViewPointFromNamedPath(QString namedPath) { @@ -339,6 +341,7 @@ void DomainHandler::processSettingsPacketList(QSharedPointer pa qCDebug(networking) << "Received domain settings: \n" << _settingsObject; } + clearPendingCheckins(); // Reset outstanding check-ins. emit settingsReceived(_settingsObject); } diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index 2d4712209d..08908dbaf6 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -97,7 +97,7 @@ public: int getCheckInPacketsSinceLastReply() const { return _checkInPacketsSinceLastReply; } void sentCheckInPacket(); - void domainListReceived() { _checkInPacketsSinceLastReply = 0; } + void clearPendingCheckins() { _checkInPacketsSinceLastReply = 0; } /**jsdoc *

The reasons that you may be refused connection to a domain are defined by numeric values:

diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 04e32f50cb..9d3e5f0e91 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -534,6 +534,8 @@ void NodeList::processDomainServerPathResponse(QSharedPointer m qCDebug(networking) << "Could not go to viewpoint" << viewpoint << "which was the lookup result for path" << pathQuery; } + + _domainHandler.clearPendingCheckins(); } void NodeList::handleICEConnectionToDomainServer() { @@ -594,6 +596,8 @@ void NodeList::processDomainServerConnectionTokenPacket(QSharedPointerreadWithoutCopy(NUM_BYTES_RFC4122_UUID))); + + _domainHandler.clearPendingCheckins(); sendDomainServerCheckIn(); } @@ -605,7 +609,7 @@ void NodeList::processDomainServerList(QSharedPointer message) } // this is a packet from the domain server, reset the count of un-replied check-ins - _domainHandler.domainListReceived(); + _domainHandler.clearPendingCheckins(); // emit our signal so listeners know we just heard from the DS emit receivedDomainServerList(); From cf9b089a3c523c26fbe0a60ee142702ee5969971 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 27 Apr 2018 17:18:16 -0700 Subject: [PATCH 025/192] Added option to set snapshot location (for this execution only) from the command line. --- interface/src/Application.cpp | 15 ++++++++++++--- interface/src/Application.h | 2 ++ interface/src/ui/Snapshot.cpp | 12 +++++++++--- interface/src/ui/Snapshot.h | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c38caca090..c0fe84894d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -986,13 +986,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); setProperty(hifi::properties::CRASHED, _previousSessionCrashed); { - const QString TEST_SCRIPT = "--testScript"; + const QString TEST_SCRIPT { "--testScript" }; + const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" }; + const QStringList args = arguments(); for (int i = 0; i < args.size() - 1; ++i) { if (args.at(i) == TEST_SCRIPT) { QString testScriptPath = args.at(i + 1); if (QFileInfo(testScriptPath).exists()) { setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); + } + } else if (args.at(i) == TEST_SNAPSHOT_LOCATION) { + // Set test snapshot location only if it is a writeable directory + QString pathname(args.at(i + 1)); + QFileInfo fileInfo(pathname); + if (fileInfo.isDir() && fileInfo.isWritable()) { + testSnapshotLocation = pathname; } } } @@ -7259,7 +7268,7 @@ void Application::loadAvatarBrowser() const { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { // Get a screenshot and save it - QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename); + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, QString()); // If we're not doing an animated snapshot as well... if (!includeAnimated) { // Tell the dependency manager that the capture of the still snapshot has taken place. @@ -7273,7 +7282,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa void Application::takeSecondaryCameraSnapshot(const QString& filename) { postLambdaEvent([filename, this] { - QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename); + QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation); emit DependencyManager::get()->stillSnapshotTaken(snapshotPath, true); }); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 74b0e5a110..341560bc5b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -719,5 +719,7 @@ private: std::atomic _pendingIdleEvent { true }; std::atomic _pendingRenderEvent { true }; + + QString testSnapshotLocation { QString() }; }; #endif // hifi_Application_h diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 69103a40b5..9eb64dcb14 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -89,10 +89,10 @@ QString Snapshot::saveSnapshot(QImage image, const QString& filename) { QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { // return whatever we get back from saved file for snapshot - return static_cast(savedFileForSnapshot(image, true)); + return static_cast(savedFileForSnapshot(image, true, QString(), QString())); } -QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename) { +QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname) { // adding URL to snapshot QUrl currentURL = DependencyManager::get()->currentPublicAddress(); @@ -117,7 +117,13 @@ QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QSt const int IMAGE_QUALITY = 100; if (!isTemporary) { - QString snapshotFullPath = snapshotsLocation.get(); + // If user has requested specific path then use it, else use the application value + QString snapshotFullPath; + if (!userSelectedPathname.isNull()) { + snapshotFullPath = userSelectedPathname; + } else { + snapshotFullPath = snapshotsLocation.get(); + } if (snapshotFullPath.isEmpty()) { snapshotFullPath = OffscreenUi::getExistingDirectory(nullptr, "Choose Snapshots Directory", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 62d3ed3db8..20e9e8339f 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -37,7 +37,7 @@ class Snapshot : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: - static QString saveSnapshot(QImage image, const QString& filename); + static QString saveSnapshot(QImage image, const QString& filename, const QString& pathname); static QTemporaryFile* saveTempSnapshot(QImage image); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); @@ -51,7 +51,7 @@ public slots: Q_INVOKABLE QString getSnapshotsLocation(); Q_INVOKABLE void setSnapshotsLocation(const QString& location); private: - static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename = QString()); + static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname); }; #endif // hifi_Snapshot_h From 2cc3ed6287afbd5df4cb65a6f42f6389671eeabe Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 28 Apr 2018 20:00:28 +1200 Subject: [PATCH 026/192] List which contexts each namespace and object is available in --- interface/src/AvatarBookmarks.h | 4 ++++ interface/src/LODManager.h | 5 ++++- interface/src/SpeechRecognizer.h | 3 +++ interface/src/audio/AudioScope.h | 4 ++++ interface/src/avatar/AvatarManager.h | 3 +++ interface/src/devices/DdeFaceTracker.h | 3 +++ interface/src/raypick/PickScriptingInterface.h | 4 ++++ interface/src/raypick/PointerScriptingInterface.h | 3 +++ .../src/scripting/AccountServicesScriptingInterface.h | 3 +++ interface/src/scripting/Audio.h | 8 +++++++- interface/src/scripting/ClipboardScriptingInterface.h | 3 +++ .../src/scripting/ControllerScriptingInterface.h | 5 ++++- .../src/scripting/GooglePolyScriptingInterface.h | 3 +++ interface/src/scripting/HMDScriptingInterface.h | 6 +++++- interface/src/scripting/MenuScriptingInterface.h | 3 +++ interface/src/scripting/SelectionScriptingInterface.h | 3 +++ interface/src/scripting/SettingsScriptingInterface.h | 3 +++ interface/src/scripting/WindowScriptingInterface.h | 6 +++++- interface/src/ui/AvatarInputs.h | 4 ++++ interface/src/ui/overlays/ContextOverlayInterface.h | 3 --- interface/src/ui/overlays/Overlays.h | 4 ++++ libraries/animation/src/AnimationCache.h | 4 ++++ libraries/audio-client/src/AudioIOStats.h | 8 ++++++++ libraries/audio/src/SoundCache.h | 5 +++++ .../src/controllers/impl/MappingBuilderProxy.h | 5 ++++- .../src/controllers/impl/RouteBuilderProxy.h | 3 +++ .../src/display-plugins/CompositorHelper.h | 4 ++++ libraries/entities/src/EntityScriptingInterface.h | 6 ++++++ .../graphics-scripting/GraphicsScriptingInterface.h | 3 +++ .../src/model-networking/ModelCache.h | 3 +++ .../src/model-networking/TextureCache.h | 3 +++ libraries/networking/src/AddressManager.h | 5 +++++ libraries/networking/src/MessagesClient.h | 5 +++++ libraries/networking/src/ResourceCache.h | 6 ++++++ libraries/script-engine/src/AssetScriptingInterface.h | 5 +++++ libraries/script-engine/src/Quat.h | 6 ++++++ .../script-engine/src/RecordingScriptingInterface.h | 4 ++++ libraries/script-engine/src/SceneScriptingInterface.h | 8 ++++++++ libraries/script-engine/src/ScriptEngine.h | 6 ++++++ libraries/script-engine/src/ScriptEngines.h | 4 ++++ libraries/script-engine/src/ScriptUUID.h | 6 ++++++ libraries/script-engine/src/ScriptsModel.h | 3 +++ libraries/script-engine/src/ScriptsModelFilter.h | 3 +++ libraries/script-engine/src/UsersScriptingInterface.h | 7 ++++++- libraries/script-engine/src/Vec3.h | 6 ++++++ libraries/shared/src/DebugDraw.h | 5 +++++ libraries/shared/src/PathUtils.h | 4 ++++ libraries/shared/src/RegisteredMetaTypes.h | 6 ++++++ libraries/shared/src/shared/Camera.h | 4 ++++ libraries/ui/src/ui/TabletScriptingInterface.h | 11 +++++++++++ 50 files changed, 221 insertions(+), 10 deletions(-) diff --git a/interface/src/AvatarBookmarks.h b/interface/src/AvatarBookmarks.h index 177e6e493e..7b47ea8af7 100644 --- a/interface/src/AvatarBookmarks.h +++ b/interface/src/AvatarBookmarks.h @@ -18,6 +18,10 @@ /**jsdoc * This API helps manage adding and deleting avatar bookmarks. * @namespace AvatarBookmarks + * + * @hifi-interface + * @hifi-client-entity + * */ class AvatarBookmarks: public Bookmarks, public Dependency { diff --git a/interface/src/LODManager.h b/interface/src/LODManager.h index e8737d92ae..889fff3153 100644 --- a/interface/src/LODManager.h +++ b/interface/src/LODManager.h @@ -10,8 +10,11 @@ // /**jsdoc - * The LOD class manages your Level of Detail functions within interface + * The LODManager API manages your Level of Detail functions within interface. * @namespace LODManager + * + * @hifi-interface + * @hifi-client-entity */ #ifndef hifi_LODManager_h diff --git a/interface/src/SpeechRecognizer.h b/interface/src/SpeechRecognizer.h index d5f9031cfc..b22ab73837 100644 --- a/interface/src/SpeechRecognizer.h +++ b/interface/src/SpeechRecognizer.h @@ -24,6 +24,9 @@ /**jsdoc * @namespace SpeechRecognizer + * + * @hifi-interface + * @hifi-client-entity */ class SpeechRecognizer : public QObject, public Dependency { Q_OBJECT diff --git a/interface/src/audio/AudioScope.h b/interface/src/audio/AudioScope.h index ff8bfda6dd..41cee8d17d 100644 --- a/interface/src/audio/AudioScope.h +++ b/interface/src/audio/AudioScope.h @@ -28,6 +28,10 @@ class AudioScope : public QObject, public Dependency { /**jsdoc * The AudioScope API helps control the Audio Scope features in Interface * @namespace AudioScope + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} scopeInput Read-only. * @property {number} scopeOutputLeft Read-only. * @property {number} scopeOutputRight Read-only. diff --git a/interface/src/avatar/AvatarManager.h b/interface/src/avatar/AvatarManager.h index d2655914d2..7f5aa00466 100644 --- a/interface/src/avatar/AvatarManager.h +++ b/interface/src/avatar/AvatarManager.h @@ -30,6 +30,9 @@ /**jsdoc * The AvatarManager API has properties and methods which manage Avatars within the same domain. * @namespace AvatarManager + * + * @hifi-interface + * @hifi-client-entity */ class AvatarManager : public AvatarHashMap { diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index d4af0bbd37..4fe36b582e 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -29,6 +29,9 @@ /**jsdoc * The FaceTracker API helps manage facial tracking hardware. * @namespace FaceTracker + * + * @hifi-interface + * @hifi-client-entity */ class DdeFaceTracker : public FaceTracker, public Dependency { diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h index f2cd9287a5..2568dd8457 100644 --- a/interface/src/raypick/PickScriptingInterface.h +++ b/interface/src/raypick/PickScriptingInterface.h @@ -18,6 +18,10 @@ * The Picks API lets you create and manage objects for repeatedly calculating intersections in different ways. * * @namespace Picks + * + * @hifi-interface + * @hifi-client-entity + * * @property PICK_NOTHING {number} A filter flag. Don't intersect with anything. * @property PICK_ENTITIES {number} A filter flag. Include entities when intersecting. * @property PICK_OVERLAYS {number} A filter flag. Include overlays when intersecting. diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h index 1cc7b56503..e7acfd4037 100644 --- a/interface/src/raypick/PointerScriptingInterface.h +++ b/interface/src/raypick/PointerScriptingInterface.h @@ -19,6 +19,9 @@ * Pointers can also be configured to automatically generate PointerEvents. * * @namespace Pointers + * + * @hifi-interface + * @hifi-client-entity */ class PointerScriptingInterface : public QObject, public Dependency { diff --git a/interface/src/scripting/AccountServicesScriptingInterface.h b/interface/src/scripting/AccountServicesScriptingInterface.h index d38a84d8fa..5774ee1da5 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.h +++ b/interface/src/scripting/AccountServicesScriptingInterface.h @@ -38,6 +38,9 @@ class AccountServicesScriptingInterface : public QObject { /**jsdoc * The AccountServices API contains helper functions related to user connectivity * + * @hifi-interface + * @hifi-client-entity + * * @namespace AccountServices * @property {string} username Read-only. * @property {boolean} loggedIn Read-only. diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index c77d1522b5..f0a4328c2f 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -27,8 +27,14 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable { /**jsdoc * The Audio API features tools to help control audio contexts and settings. - * + * * @namespace Audio + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {boolean} muted * @property {boolean} noiseReduction * @property {number} inputVolume diff --git a/interface/src/scripting/ClipboardScriptingInterface.h b/interface/src/scripting/ClipboardScriptingInterface.h index cce300e831..32b8c64a7d 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.h +++ b/interface/src/scripting/ClipboardScriptingInterface.h @@ -21,6 +21,9 @@ * The Clipboard API enables you to export and import entities to and from JSON files. * * @namespace Clipboard + * + * @hifi-interface + * @hifi-client-entity */ class ClipboardScriptingInterface : public QObject { Q_OBJECT diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h index f19caa8478..42bb648abf 100644 --- a/interface/src/scripting/ControllerScriptingInterface.h +++ b/interface/src/scripting/ControllerScriptingInterface.h @@ -145,7 +145,10 @@ class ScriptEngine; * * @namespace Controller * - * @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end + * @hifi-interface + * @hifi-client-entity + * + * @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end * points in a {@link RouteObject} mapping. A synonym for Controller.Hardware.Actions. * Read-only.
* Default mappings are provided from the Controller.Hardware.Keyboard and Controller.Standard to diff --git a/interface/src/scripting/GooglePolyScriptingInterface.h b/interface/src/scripting/GooglePolyScriptingInterface.h index 5c37b394fa..fb5aed9759 100644 --- a/interface/src/scripting/GooglePolyScriptingInterface.h +++ b/interface/src/scripting/GooglePolyScriptingInterface.h @@ -18,6 +18,9 @@ /**jsdoc * The GooglePoly API allows you to interact with Google Poly models direct from inside High Fidelity. * @namespace GooglePoly + * + * @hifi-interface + * @hifi-client-entity */ class GooglePolyScriptingInterface : public QObject, public Dependency { diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 9b2482e73a..d2a272851f 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -28,7 +28,11 @@ class QScriptEngine; * The HMD API provides access to the HMD used in VR display mode. * * @namespace HMD - * @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise + * + * @hifi-interface + * @hifi-client-entity + * + * @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise * {@link Vec3(0)|Vec3.ZERO}. Read-only. * @property {Quat} orientation - The orientation of the HMD if currently in VR display mode, otherwise * {@link Quat(0)|Quat.IDENTITY}. Read-only. diff --git a/interface/src/scripting/MenuScriptingInterface.h b/interface/src/scripting/MenuScriptingInterface.h index 649c444eaf..81cf775de8 100644 --- a/interface/src/scripting/MenuScriptingInterface.h +++ b/interface/src/scripting/MenuScriptingInterface.h @@ -32,6 +32,9 @@ class MenuItemProperties; * If a menu item doesn't belong to a group it is always displayed. * * @namespace Menu + * + * @hifi-interface + * @hifi-client-entity */ /** diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 71ff41248a..df92250c28 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -86,6 +86,9 @@ protected: * The Selection API provides a means of grouping together avatars, entities, and overlays in named lists. * @namespace Selection * + * @hifi-interface + * @hifi-client-entity + * * @example Outline an entity when it is grabbed by a controller. * // Create a box and copy the following text into the entity's "Script URL" field. * (function () { diff --git a/interface/src/scripting/SettingsScriptingInterface.h b/interface/src/scripting/SettingsScriptingInterface.h index 9e0271601b..32d868bb24 100644 --- a/interface/src/scripting/SettingsScriptingInterface.h +++ b/interface/src/scripting/SettingsScriptingInterface.h @@ -18,6 +18,9 @@ /**jsdoc * The Settings API provides a facility to store and retrieve values that persist between Interface runs. * @namespace Settings + * + * @hifi-interface + * @hifi-client-entity */ class SettingsScriptingInterface : public QObject { diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 0b766d2097..348882e0f8 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -28,7 +28,11 @@ * physics. * * @namespace Window - * @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other + * + * @hifi-interface + * @hifi-client-entity + * + * @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other * chrome), in pixels. Read-only. * @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other * chrome), in pixels. Read-only. diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index a9d1509770..e67d35e59f 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -26,6 +26,10 @@ class AvatarInputs : public QObject { /**jsdoc * API to help manage your Avatar's input * @namespace AvatarInputs + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} cameraEnabled Read-only. * @property {boolean} cameraMuted Read-only. * @property {boolean} isHMD Read-only. diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index b80a3a70fb..808c3a4ee3 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -31,9 +31,6 @@ #include "EntityTree.h" #include "ContextOverlayLogging.h" -/**jsdoc -* @namespace ContextOverlay -*/ class ContextOverlayInterface : public QObject, public Dependency { Q_OBJECT diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index c2f6e3e693..cf1151b46a 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -76,6 +76,10 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R * The Overlays API provides facilities to create and interact with overlays. Overlays are 2D and 3D objects visible only to * yourself and that aren't persisted to the domain. They are used for UI. * @namespace Overlays + * + * @hifi-interface + * @hifi-client-entity + * * @property {Uuid} keyboardFocusOverlay - Get or set the {@link Overlays.OverlayType|web3d} overlay that has keyboard focus. * If no overlay has keyboard focus, get returns null; set to null or {@link Uuid|Uuid.NULL} to * clear keyboard focus. diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h index 03b37aef2f..4db009f592 100644 --- a/libraries/animation/src/AnimationCache.h +++ b/libraries/animation/src/AnimationCache.h @@ -37,6 +37,10 @@ public: * API to manage animation cache resources. * @namespace AnimationCache * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/audio-client/src/AudioIOStats.h b/libraries/audio-client/src/AudioIOStats.h index 89db4942ec..45fcf365da 100644 --- a/libraries/audio-client/src/AudioIOStats.h +++ b/libraries/audio-client/src/AudioIOStats.h @@ -41,6 +41,10 @@ class AudioStreamStatsInterface : public QObject { /**jsdoc * @class AudioStats.AudioStreamStats + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} lossRate Read-only. * @property {number} lossCount Read-only. * @property {number} lossRateWindow Read-only. @@ -185,6 +189,10 @@ class AudioStatsInterface : public QObject { /**jsdoc * Audio stats from the client. * @namespace AudioStats + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} pingMs Read-only. * @property {number} inputReadMsMax Read-only. * @property {number} inputUnplayedMsMax Read-only. diff --git a/libraries/audio/src/SoundCache.h b/libraries/audio/src/SoundCache.h index d8c52635e0..0874cef90e 100644 --- a/libraries/audio/src/SoundCache.h +++ b/libraries/audio/src/SoundCache.h @@ -29,6 +29,11 @@ public: * API to manage sound cache resources. * @namespace SoundCache * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h b/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h index 86a43c0c13..4521c89afd 100644 --- a/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h +++ b/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h @@ -49,9 +49,12 @@ class UserInputMapper; * output that already has a route the new route is ignored. *
  • New mappings override previous mappings: each output is processed using the route in the most recently enabled * mapping that contains that output.
  • - *

    + * * * @class MappingObject + * + * @hifi-interface + * @hifi-client-entity */ /**jsdoc diff --git a/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h b/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h index 0336638068..3204e0502f 100644 --- a/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h +++ b/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h @@ -35,6 +35,9 @@ class ScriptingInterface; * types.

    * * @class RouteObject + * + * @hifi-interface + * @hifi-client-entity */ // TODO migrate functionality to a RouteBuilder class and make the proxy defer to that diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.h b/libraries/display-plugins/src/display-plugins/CompositorHelper.h index bc6ed63363..fb712c26fa 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.h +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.h @@ -174,6 +174,10 @@ private: /**jsdoc * @namespace Reticle + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} allowMouseCapture * @property {number} depth * @property {Vec2} maximumPosition diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index d4a8b11453..2491d4bbbd 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -94,6 +94,12 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra * Interface has displayed and so knows about. * * @namespace Entities + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {Uuid} keyboardFocusEntity - Get or set the {@link Entities.EntityType|Web} entity that has keyboard focus. * If no entity has keyboard focus, get returns null; set to null or {@link Uuid|Uuid.NULL} to * clear keyboard focus. diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h index 526352804b..8b76491229 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h @@ -24,6 +24,9 @@ /**jsdoc * The experimental Graphics API (experimental) lets you query and manage certain graphics-related structures (like underlying meshes and textures) from scripting. * @namespace Graphics + * + * @hifi-interface + * @hifi-client-entity */ class GraphicsScriptingInterface : public QObject, public QScriptable, public Dependency { diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 9532f39ce0..cda825e5fb 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -144,6 +144,9 @@ public: * API to manage model cache resources. * @namespace ModelCache * + * @hifi-interface + * @hifi-client-entity + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 3f46dc3074..ef911103c3 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -151,6 +151,9 @@ public: * API to manage texture cache resources. * @namespace TextureCache * + * @hifi-interface + * @hifi-client-entity + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 94eff46bda..94fb25812f 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -33,6 +33,11 @@ const QString GET_PLACE = "/api/v1/places/%1"; * The location API provides facilities related to your current location in the metaverse. * * @namespace location + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * * @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not * connected to the domain or are in a serverless domain. * Read-only. diff --git a/libraries/networking/src/MessagesClient.h b/libraries/networking/src/MessagesClient.h index 6ef3777d8c..f2ccfe33f4 100644 --- a/libraries/networking/src/MessagesClient.h +++ b/libraries/networking/src/MessagesClient.h @@ -37,6 +37,11 @@ * * * @namespace Messages + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class MessagesClient : public QObject, public Dependency { Q_OBJECT diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 609483bc56..799d2c7f59 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -89,6 +89,12 @@ class ScriptableResource : public QObject { /**jsdoc * @constructor Resource + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {string} url - URL of this resource. * @property {Resource.State} state - Current loading state. */ diff --git a/libraries/script-engine/src/AssetScriptingInterface.h b/libraries/script-engine/src/AssetScriptingInterface.h index 5cb1136b74..eb9a628ae3 100644 --- a/libraries/script-engine/src/AssetScriptingInterface.h +++ b/libraries/script-engine/src/AssetScriptingInterface.h @@ -27,6 +27,11 @@ /**jsdoc * The Assets API allows you to communicate with the Asset Browser. * @namespace Assets + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class AssetScriptingInterface : public BaseAssetScriptingInterface, QScriptable { Q_OBJECT diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index e6e395d9bf..254757dece 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -35,6 +35,12 @@ * of gimbal lock. * @namespace Quat * @variation 0 + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property IDENTITY {Quat} { x: 0, y: 0, z: 0, w: 1 } : The identity rotation, i.e., no rotation. * Read-only. * @example Print the IDENTITY value. diff --git a/libraries/script-engine/src/RecordingScriptingInterface.h b/libraries/script-engine/src/RecordingScriptingInterface.h index 0e4f90b928..29d9b31049 100644 --- a/libraries/script-engine/src/RecordingScriptingInterface.h +++ b/libraries/script-engine/src/RecordingScriptingInterface.h @@ -25,6 +25,10 @@ class QScriptValue; /**jsdoc * @namespace Recording + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client */ class RecordingScriptingInterface : public QObject, public Dependency { Q_OBJECT diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index c69cd7090d..fdfbc6f6c0 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -112,6 +112,10 @@ namespace SceneScripting { /**jsdoc * @class Scene.Stage + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} backgroundMode * @property {Scene.Stage.KeyLight} keyLight * @property {Scene.Stage.Location} location @@ -171,6 +175,10 @@ namespace SceneScripting { /**jsdoc * @namespace Scene + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} shouldRenderAvatars * @property {boolean} shouldRenderEntities * @property {Scene.Stage} stage diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 63a4ba4f90..af4d04a706 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -89,6 +89,12 @@ public: /**jsdoc * @namespace Script + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {string} context */ class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvider { diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 1200168420..da6fe521c9 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -29,6 +29,10 @@ class ScriptEngine; /**jsdoc * @namespace ScriptDiscoveryService + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} debugScriptUrl * @property {string} defaultScriptsPath * @property {ScriptsModel} scriptsModel diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index 303a871d1d..9b61f451c5 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -23,6 +23,12 @@ * hexadecimal digits. * * @namespace Uuid + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property NULL {Uuid} The null UUID, {00000000-0000-0000-0000-000000000000}. */ diff --git a/libraries/script-engine/src/ScriptsModel.h b/libraries/script-engine/src/ScriptsModel.h index a4ffc192f9..2466347baa 100644 --- a/libraries/script-engine/src/ScriptsModel.h +++ b/libraries/script-engine/src/ScriptsModel.h @@ -68,6 +68,9 @@ public: *

    Has properties and functions below in addition to those of * http://doc.qt.io/qt-5/qabstractitemmodel.html.

    * @class ScriptsModel + * + * @hifi-interface + * @hifi-client-entity */ class ScriptsModel : public QAbstractItemModel { Q_OBJECT diff --git a/libraries/script-engine/src/ScriptsModelFilter.h b/libraries/script-engine/src/ScriptsModelFilter.h index 26efde02e8..05a76334bb 100644 --- a/libraries/script-engine/src/ScriptsModelFilter.h +++ b/libraries/script-engine/src/ScriptsModelFilter.h @@ -20,6 +20,9 @@ *

    Has properties and functions per * http://doc.qt.io/qt-5/qsortfilterproxymodel.html.

    * @class ScriptsModelFilter + * + * @hifi-interface + * @hifi-client-entity */ class ScriptsModelFilter : public QSortFilterProxyModel { Q_OBJECT diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 6728c471f6..f214c3f11c 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -18,7 +18,12 @@ /**jsdoc * @namespace Users - * @property {boolean} canKick - true if the domain server allows the node or avatar to kick (ban) avatars, + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * + * @property {boolean} canKick - true if the domain server allows the node or avatar to kick (ban) avatars, * otherwise false. Read-only. * @property {boolean} requestsDomainListData - true if the avatar requests extra data from the mixers (such as * positional data of an avatar you've ignored). Read-only. diff --git a/libraries/script-engine/src/Vec3.h b/libraries/script-engine/src/Vec3.h index 635f2a530c..eb9438c5c2 100644 --- a/libraries/script-engine/src/Vec3.h +++ b/libraries/script-engine/src/Vec3.h @@ -47,6 +47,12 @@ * * @namespace Vec3 * @variation 0 + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {Vec3} UNIT_X - { x: 1, y: 0, z: 0 } : Unit vector in the x-axis direction. Read-only. * @property {Vec3} UNIT_Y - { x: 0, y: 1, z: 0 } : Unit vector in the y-axis direction. Read-only. * @property {Vec3} UNIT_Z - { x: 0, y: 0, z: 1 } : Unit vector in the z-axis direction. Read-only. diff --git a/libraries/shared/src/DebugDraw.h b/libraries/shared/src/DebugDraw.h index 64327585fb..7dd19415c9 100644 --- a/libraries/shared/src/DebugDraw.h +++ b/libraries/shared/src/DebugDraw.h @@ -25,6 +25,11 @@ * Helper functions to render ephemeral debug markers and lines. * DebugDraw markers and lines are only visible locally, they are not visible by other users. * @namespace DebugDraw + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class DebugDraw : public QObject { Q_OBJECT diff --git a/libraries/shared/src/PathUtils.h b/libraries/shared/src/PathUtils.h index d879ac968d..fc933b6b8c 100644 --- a/libraries/shared/src/PathUtils.h +++ b/libraries/shared/src/PathUtils.h @@ -22,6 +22,10 @@ * The Paths API provides absolute paths to the scripts and resources directories. * * @namespace Paths + * + * @hifi-interface + * @hifi-client-entity + * * @deprecated The Paths API is deprecated. Use {@link Script.resolvePath} and {@link Script.resourcesPath} instead. * @readonly * @property {string} defaultScripts - The path to the scripts directory. Read-only. diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 689d1a3f42..467d6374a5 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -361,6 +361,12 @@ using MeshPointer = std::shared_ptr; /**jsdoc * A handle for a mesh in an entity, such as returned by {@link Entities.getMeshes}. * @class MeshProxy + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @deprecated Use the {@link Graphics} API instead. */ class MeshProxy : public QObject { diff --git a/libraries/shared/src/shared/Camera.h b/libraries/shared/src/shared/Camera.h index ea2e9cddab..32e753d0f9 100644 --- a/libraries/shared/src/shared/Camera.h +++ b/libraries/shared/src/shared/Camera.h @@ -40,6 +40,10 @@ class Camera : public QObject { * The Camera API provides access to the "camera" that defines your view in desktop and HMD display modes. * * @namespace Camera + * + * @hifi-interface + * @hifi-client-entity + * * @property position {Vec3} The position of the camera. You can set this value only when the camera is in independent mode. * @property orientation {Quat} The orientation of the camera. You can set this value only when the camera is in independent * mode. diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h index bab15fc7b6..e74b846f02 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.h +++ b/libraries/ui/src/ui/TabletScriptingInterface.h @@ -40,6 +40,9 @@ class OffscreenQmlSurface; /**jsdoc * @namespace Tablet + * + * @hifi-interface + * @hifi-client-entity */ class TabletScriptingInterface : public QObject, public Dependency { Q_OBJECT @@ -176,6 +179,10 @@ Q_DECLARE_METATYPE(TabletButtonsProxyModel*); /**jsdoc * @class TabletProxy + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} name - Name of this tablet. Read-only. * @property {boolean} toolbarMode - Used to transition this tablet into and out of toolbar mode. * When tablet is in toolbar mode, all its buttons will appear in a floating toolbar. @@ -410,6 +417,10 @@ Q_DECLARE_METATYPE(TabletProxy*); /**jsdoc * @class TabletButtonProxy + * + * @hifi-interface + * @hifi-client-entity + * * @property {Uuid} uuid - Uniquely identifies this button. Read-only. * @property {TabletButtonProxy.ButtonProperties} properties */ From b994776ebd98314025ecdc86fdffc91ebb42eba1 Mon Sep 17 00:00:00 2001 From: Liv Erickson Date: Mon, 30 Apr 2018 12:01:37 -0700 Subject: [PATCH 027/192] do not open help on first run --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cd4562da54..6c11286d03 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3166,9 +3166,6 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { // If this is a first run we short-circuit the address passed in if (firstRun.get()) { -#if !defined(Q_OS_ANDROID) - showHelp(); -#endif DependencyManager::get()->goToEntry(); sentTo = SENT_TO_ENTRY; firstRun.set(false); From 5ab16302cac5a63f6ac3aa084850a145b43f4785 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 24 Apr 2018 15:09:30 -0700 Subject: [PATCH 028/192] Keep CrashpadClient around --- interface/src/Crashpad.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/interface/src/Crashpad.cpp b/interface/src/Crashpad.cpp index e39cd42d81..27b6f4b937 100644 --- a/interface/src/Crashpad.cpp +++ b/interface/src/Crashpad.cpp @@ -11,6 +11,8 @@ #include "Crashpad.h" +#include + #include #if HAS_CRASHPAD @@ -20,7 +22,7 @@ #include #include -#include +#include #include #include @@ -28,28 +30,26 @@ #include #include +#include + using namespace crashpad; static const std::string BACKTRACE_URL { CMAKE_BACKTRACE_URL }; static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN }; -static std::wstring gIPCPipe; - extern QString qAppFileName(); std::mutex annotationMutex; crashpad::SimpleStringDictionary* crashpadAnnotations { nullptr }; -#include + +std::unique_ptr client; LONG WINAPI vectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) { if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION || pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_STACK_BUFFER_OVERRUN) { - CrashpadClient client; - if (gIPCPipe.length()) { - client.SetHandlerIPCPipe(gIPCPipe); - } - client.DumpAndCrash(pExceptionInfo); + assert(client); + client->DumpAndCrash(pExceptionInfo); } return EXCEPTION_CONTINUE_SEARCH; @@ -60,7 +60,7 @@ bool startCrashHandler() { return false; } - CrashpadClient client; + client.reset(new CrashpadClient()); std::vector arguments; std::map annotations; @@ -96,12 +96,9 @@ bool startCrashHandler() { // Enable automated uploads. database->GetSettings()->SetUploadsEnabled(true); - bool result = client.StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true); - gIPCPipe = client.GetHandlerIPCPipe(); - AddVectoredExceptionHandler(0, vectoredExceptionHandler); - return result; + return client->StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true); } void setCrashAnnotation(std::string name, std::string value) { From 250806252e526889820549e6ac13ce259a340ebd Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 24 Apr 2018 15:09:30 -0700 Subject: [PATCH 029/192] Don't use unique_ptr to store CrashpadClient --- interface/src/Crashpad.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/src/Crashpad.cpp b/interface/src/Crashpad.cpp index 27b6f4b937..45f1d0778f 100644 --- a/interface/src/Crashpad.cpp +++ b/interface/src/Crashpad.cpp @@ -39,16 +39,17 @@ static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN }; extern QString qAppFileName(); +CrashpadClient* client { nullptr }; std::mutex annotationMutex; crashpad::SimpleStringDictionary* crashpadAnnotations { nullptr }; - -std::unique_ptr client; - LONG WINAPI vectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) { + if (!client) { + return EXCEPTION_CONTINUE_SEARCH; + } + if (pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION || pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_STACK_BUFFER_OVERRUN) { - assert(client); client->DumpAndCrash(pExceptionInfo); } @@ -60,7 +61,8 @@ bool startCrashHandler() { return false; } - client.reset(new CrashpadClient()); + assert(!client); + client = new CrashpadClient(); std::vector arguments; std::map annotations; From cfc5892d63f342949bf886dc45e99e07809aa0db Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Mon, 30 Apr 2018 13:41:56 -0700 Subject: [PATCH 030/192] Only clear check-in count on Domain Query related responses --- libraries/networking/src/DomainHandler.cpp | 3 --- libraries/networking/src/NodeList.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 84af21004d..cd8064c4c0 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -239,7 +239,6 @@ void DomainHandler::activateICELocalSocket() { _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); - clearPendingCheckins(); // Clear outstanding count. } void DomainHandler::activateICEPublicSocket() { @@ -249,7 +248,6 @@ void DomainHandler::activateICEPublicSocket() { _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); - clearPendingCheckins(); // Clear outstanding count. } QString DomainHandler::getViewPointFromNamedPath(QString namedPath) { @@ -341,7 +339,6 @@ void DomainHandler::processSettingsPacketList(QSharedPointer pa qCDebug(networking) << "Received domain settings: \n" << _settingsObject; } - clearPendingCheckins(); // Reset outstanding check-ins. emit settingsReceived(_settingsObject); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 9d3e5f0e91..4920ea97c7 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -534,8 +534,6 @@ void NodeList::processDomainServerPathResponse(QSharedPointer m qCDebug(networking) << "Could not go to viewpoint" << viewpoint << "which was the lookup result for path" << pathQuery; } - - _domainHandler.clearPendingCheckins(); } void NodeList::handleICEConnectionToDomainServer() { From 73cea112eefa7541a05394426f74e0652cb07efb Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 26 Apr 2018 15:49:34 -0700 Subject: [PATCH 031/192] Update FilePersistThread to use std::chrono instead of usecTimestampNow --- libraries/shared/src/shared/FileLogger.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 4f4a9ab6dd..1e17ee9e7c 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -44,7 +44,7 @@ static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss"; static const QString LOGS_DIRECTORY = "Logs"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[01][0-9]-[0-3][0-9]_[0-2][0-9]\\.[0-6][0-9]\\.[0-6][0-9]"; static const QString SESSION_WILDCARD = "[0-9a-z]{8}(-[0-9a-z]{4}){3}-[0-9a-z]{12}"; -static QRegExp LOG_FILENAME_REGEX { "hifi-log_" + DATETIME_WILDCARD + "(_" + SESSION_WILDCARD + ")?\.txt" }; +static QRegExp LOG_FILENAME_REGEX { "hifi-log_" + DATETIME_WILDCARD + "(_" + SESSION_WILDCARD + ")?\\.txt" }; static QUuid SESSION_ID; // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively @@ -52,8 +52,7 @@ static QUuid SESSION_ID; static const qint64 MAX_LOG_SIZE = 512 * 1024; // Max log files found in the log directory is 100. static const qint64 MAX_LOG_DIR_SIZE = 512 * 1024 * 100; -// Max log age is 1 hour -static const uint64_t MAX_LOG_AGE_USECS = USECS_PER_SECOND * 3600; +static const std::chrono::minutes MAX_LOG_AGE { 60 }; static FilePersistThread* _persistThreadInstance; @@ -84,23 +83,22 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger) if (file.exists()) { rollFileIfNecessary(file, false); } - _lastRollTime = usecTimestampNow(); + _lastRollTime = std::chrono::system_clock::now(); } void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) { - uint64_t now = usecTimestampNow(); - if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE_USECS) { + auto now = std::chrono::system_clock::now(); + if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE) { QString newFileName = getLogRollerFilename(); if (file.copy(newFileName)) { file.open(QIODevice::WriteOnly | QIODevice::Truncate); file.close(); - qCDebug(shared) << "Rolled log file:" << newFileName; if (notifyListenersIfRolled) { emit rollingLogFile(newFileName); } - _lastRollTime = now; + _lastRollTime = std::chrono::system_clock::now(); } QDir logDir(FileUtils::standardPath(LOGS_DIRECTORY)); @@ -128,7 +126,7 @@ bool FilePersistThread::processQueueItems(const Queue& messages) { rollFileIfNecessary(file); if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { QTextStream out(&file); - foreach(const QString& message, messages) { + for (const QString& message : messages) { out << message; } } From f3fe1f3e58386363ddb2e2b5a48e5a08bd73f4c3 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 30 Apr 2018 13:51:53 -0700 Subject: [PATCH 032/192] Force crash helpers not inlined --- libraries/shared/src/CrashHelpers.cpp | 77 +++++++++++++++++++++++++++ libraries/shared/src/CrashHelpers.h | 66 +++-------------------- 2 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 libraries/shared/src/CrashHelpers.cpp diff --git a/libraries/shared/src/CrashHelpers.cpp b/libraries/shared/src/CrashHelpers.cpp new file mode 100644 index 0000000000..f8ca90bc4c --- /dev/null +++ b/libraries/shared/src/CrashHelpers.cpp @@ -0,0 +1,77 @@ +// +// CrashHelpers.cpp +// libraries/shared/src +// +// Created by Clement Brisset on 4/30/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "CrashHelpers.h" + +namespace crash { + +class B; +class A { +public: + A(B* b) : _b(b) { } + ~A(); + virtual void virtualFunction() = 0; + +private: + B* _b; +}; + +class B : public A { +public: + B() : A(this) { } + virtual void virtualFunction() override { } +}; + +A::~A() { + _b->virtualFunction(); +} + +void pureVirtualCall() { + qCDebug(shared) << "About to make a pure virtual call"; + B b; +} + +void doubleFree() { + qCDebug(shared) << "About to double delete memory"; + int* blah = new int(200); + delete blah; + delete blah; +} + +void nullDeref() { + qCDebug(shared) << "About to dereference a null pointer"; + int* p = nullptr; + *p = 1; +} + +void doAbort() { + qCDebug(shared) << "About to abort"; + abort(); +} + +void outOfBoundsVectorCrash() { + qCDebug(shared) << "std::vector out of bounds crash!"; + std::vector v; + v[0] = 42; +} + +void newFault() { + qCDebug(shared) << "About to crash inside new fault"; + + // Force crash with multiple large allocations + while (true) { + const size_t GIGABYTE = 1024 * 1024 * 1024; + new char[GIGABYTE]; + } + +} + +} diff --git a/libraries/shared/src/CrashHelpers.h b/libraries/shared/src/CrashHelpers.h index 1cc6749182..ad988c8906 100644 --- a/libraries/shared/src/CrashHelpers.h +++ b/libraries/shared/src/CrashHelpers.h @@ -18,66 +18,12 @@ namespace crash { -class B; -class A { -public: - A(B* b) : _b(b) { } - ~A(); - virtual void virtualFunction() = 0; - -private: - B* _b; -}; - -class B : public A { -public: - B() : A(this) { } - virtual void virtualFunction() override { } -}; - -A::~A() { - _b->virtualFunction(); -} - -void pureVirtualCall() { - qCDebug(shared) << "About to make a pure virtual call"; - B b; -} - -void doubleFree() { - qCDebug(shared) << "About to double delete memory"; - int* blah = new int(200); - delete blah; - delete blah; -} - -void nullDeref() { - qCDebug(shared) << "About to dereference a null pointer"; - int* p = nullptr; - *p = 1; -} - -void doAbort() { - qCDebug(shared) << "About to abort"; - abort(); -} - -void outOfBoundsVectorCrash() { - qCDebug(shared) << "std::vector out of bounds crash!"; - std::vector v; - v[0] = 42; -} - -void newFault() { - qCDebug(shared) << "About to crash inside new fault"; - - // Force crash with multiple large allocations - while (true) { - const size_t GIGABYTE = 1024 * 1024 * 1024; - new char[GIGABYTE]; - } - -} +void pureVirtualCall(); +void doubleFree(); +void nullDeref(); +void doAbort(); +void outOfBoundsVectorCrash(); +void newFault(); } From c01fd02de2c5f427e56d75b29b57fcd4122e6d0c Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 30 Apr 2018 17:23:49 -0700 Subject: [PATCH 033/192] Corrected parameter type. --- interface/src/ui/Snapshot.cpp | 2 +- interface/src/ui/Snapshot.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 9eb64dcb14..1af7086933 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -92,7 +92,7 @@ QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { return static_cast(savedFileForSnapshot(image, true, QString(), QString())); } -QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname) { +QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname) { // adding URL to snapshot QUrl currentURL = DependencyManager::get()->currentPublicAddress(); diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 20e9e8339f..86c860cfcb 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -51,7 +51,7 @@ public slots: Q_INVOKABLE QString getSnapshotsLocation(); Q_INVOKABLE void setSnapshotsLocation(const QString& location); private: - static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename, QString userSelectedPathname); + static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname); }; #endif // hifi_Snapshot_h From d5610a2f37885a0748129bc3de9dd77261ad12b0 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 30 Apr 2018 17:52:44 -0700 Subject: [PATCH 034/192] WTF... --- interface/src/ui/Snapshot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 1af7086933..d52f01223c 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -73,9 +73,9 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { return data; } -QString Snapshot::saveSnapshot(QImage image, const QString& filename) { +QString Snapshot::saveSnapshot(QImage image, const QString& filename, const QString& pathname) { - QFile* snapshotFile = savedFileForSnapshot(image, false, filename); + QFile* snapshotFile = savedFileForSnapshot(image, false, filename, pathname); // we don't need the snapshot file, so close it, grab its filename and delete it snapshotFile->close(); From 24ac342c6bc3cc5feeed186a2f55c4631d1b5128 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Apr 2018 11:41:59 -0700 Subject: [PATCH 035/192] Add support for client texture selection --- interface/src/Application.cpp | 1 + libraries/baking/src/FBXBaker.cpp | 87 +++++++----- libraries/baking/src/FBXBaker.h | 4 +- libraries/baking/src/ModelBaker.cpp | 126 +++++++++++++++--- libraries/baking/src/ModelBaker.h | 8 +- libraries/baking/src/OBJBaker.cpp | 57 +++----- libraries/baking/src/OBJBaker.h | 5 +- libraries/baking/src/TextureBaker.cpp | 63 +++++++-- libraries/baking/src/TextureBaker.h | 14 +- libraries/fbx/src/FBXReader.cpp | 1 + libraries/fbx/src/FBXReader_Material.cpp | 4 + libraries/gpu-gl/src/gpu/gl41/GL41Backend.h | 4 +- libraries/gpu-gl/src/gpu/gl45/GL45Backend.h | 2 + .../src/gpu/gl45/GL45BackendTexture.cpp | 18 +++ libraries/gpu-gles/src/gpu/gles/GLESBackend.h | 3 +- libraries/gpu/src/gpu/Context.h | 2 + libraries/gpu/src/gpu/Texture.h | 5 + libraries/gpu/src/gpu/Texture_ktx.cpp | 77 ++++++----- libraries/ktx/src/TextureMeta.cpp | 58 ++++++++ libraries/ktx/src/TextureMeta.h | 42 ++++++ libraries/ktx/src/khronos/KHR.h | 59 ++++++++ .../src/model-networking/ModelCache.cpp | 5 +- .../src/model-networking/TextureCache.cpp | 114 +++++++++++++--- .../src/model-networking/TextureCache.h | 22 ++- libraries/networking/src/ResourceCache.cpp | 6 +- tools/oven/src/DomainBaker.cpp | 2 +- 26 files changed, 614 insertions(+), 175 deletions(-) create mode 100644 libraries/ktx/src/TextureMeta.cpp create mode 100644 libraries/ktx/src/TextureMeta.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c38caca090..6756fbe255 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1296,6 +1296,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Create the main thread context, the GPU backend, and the display plugins initializeGL(); + DependencyManager::get()->setGPUContext(_gpuContext); qCDebug(interfaceapp, "Initialized Display."); // Create the rendering engine. This can be slow on some machines due to lots of // GPU pipeline creation. diff --git a/libraries/baking/src/FBXBaker.cpp b/libraries/baking/src/FBXBaker.cpp index 0407c8508c..175698eeea 100644 --- a/libraries/baking/src/FBXBaker.cpp +++ b/libraries/baking/src/FBXBaker.cpp @@ -70,17 +70,66 @@ void FBXBaker::bakeSourceCopy() { return; } - // export the FBX with re-written texture references - exportScene(); - - if (shouldStop()) { - return; - } - // check if we're already done with textures (in case we had none to re-write) checkIfTexturesFinished(); } +void FBXBaker::embedTextureMetaData() { + std::vector embeddedTextureNodes; + + for (FBXNode& rootChild : _rootNode.children) { + if (rootChild.name == "Objects") { + qlonglong maxId = 0; + for (auto &child : rootChild.children) { + if (child.properties.length() == 3) { + maxId = std::max(maxId, child.properties[0].toLongLong()); + } + } + + for (auto& object : rootChild.children) { + if (object.name == "Texture") { + QVariant relativeFilename; + for (auto& child : object.children) { + if (child.name == "RelativeFilename") { + relativeFilename = child.properties[0]; + break; + } + } + + if (relativeFilename.isNull() || !relativeFilename.toString().endsWith(BAKED_META_TEXTURE_SUFFIX)) { + continue; + } + + FBXNode videoNode; + videoNode.name = "Video"; + videoNode.properties.append(++maxId); + videoNode.properties.append(object.properties[1]); + videoNode.properties.append("Clip"); + + QString bakedTextureFilePath { + _bakedOutputDir + "/" + relativeFilename.toString() + }; + qDebug() << "Location of texture: " << bakedTextureFilePath; + + QFile textureFile { bakedTextureFilePath }; + if (!textureFile.open(QIODevice::ReadOnly)) { + qWarning() << "Failed to open: " << bakedTextureFilePath; + continue; + } + + videoNode.children.append({ "RelativeFilename", { relativeFilename }, { } }); + videoNode.children.append({ "Content", { textureFile.readAll() }, { } }); + + rootChild.children.append(videoNode); + + textureFile.close(); + } + } + } + } + +} + void FBXBaker::setupOutputFolder() { // make sure there isn't already an output directory using the same name if (QDir(_bakedOutputDir).exists()) { @@ -352,27 +401,3 @@ void FBXBaker::rewriteAndBakeSceneTextures() { } } } - -void FBXBaker::exportScene() { - // save the relative path to this FBX inside our passed output folder - auto fileName = _modelURL.fileName(); - auto baseName = fileName.left(fileName.lastIndexOf('.')); - auto bakedFilename = baseName + BAKED_FBX_EXTENSION; - - _bakedModelFilePath = _bakedOutputDir + "/" + bakedFilename; - - auto fbxData = FBXWriter::encodeFBX(_rootNode); - - QFile bakedFile(_bakedModelFilePath); - - if (!bakedFile.open(QIODevice::WriteOnly)) { - handleError("Error opening " + _bakedModelFilePath + " for writing"); - return; - } - - bakedFile.write(fbxData); - - _outputFiles.push_back(_bakedModelFilePath); - - qCDebug(model_baking) << "Exported" << _modelURL << "with re-written paths to" << _bakedModelFilePath; -} diff --git a/libraries/baking/src/FBXBaker.h b/libraries/baking/src/FBXBaker.h index 2888a60f73..58a7bffa18 100644 --- a/libraries/baking/src/FBXBaker.h +++ b/libraries/baking/src/FBXBaker.h @@ -26,8 +26,6 @@ #include -static const QString BAKED_FBX_EXTENSION = ".baked.fbx"; - using TextureBakerThreadGetter = std::function; class FBXBaker : public ModelBaker { @@ -51,11 +49,11 @@ private: void loadSourceFBX(); void importScene(); + void embedTextureMetaData(); void rewriteAndBakeSceneModels(); void rewriteAndBakeSceneTextures(); void exportScene(); - FBXNode _rootNode; FBXGeometry* _geometry; QHash _textureNameMatchCount; QHash _remappedTexturePaths; diff --git a/libraries/baking/src/ModelBaker.cpp b/libraries/baking/src/ModelBaker.cpp index 16a0c89c7f..020a0dbfc2 100644 --- a/libraries/baking/src/ModelBaker.cpp +++ b/libraries/baking/src/ModelBaker.cpp @@ -248,7 +248,7 @@ QString ModelBaker::compressTexture(QString modelTextureFileName, image::Texture QFileInfo modelTextureFileInfo{ modelTextureFileName.replace("\\", "/") }; - if (modelTextureFileInfo.suffix() == BAKED_TEXTURE_EXT.mid(1)) { + if (modelTextureFileInfo.suffix() == BAKED_TEXTURE_KTX_EXT.mid(1)) { // re-baking a model that already references baked textures // this is an error - return from here handleError("Cannot re-bake a file that already references compressed textures"); @@ -273,31 +273,31 @@ QString ModelBaker::compressTexture(QString modelTextureFileName, image::Texture } auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull()); - QString bakedTextureFileName; + QString baseTextureFileName; if (_remappedTexturePaths.contains(urlToTexture)) { - bakedTextureFileName = _remappedTexturePaths[urlToTexture]; + baseTextureFileName = _remappedTexturePaths[urlToTexture]; } else { // construct the new baked texture file name and file path // ensuring that the baked texture will have a unique name // even if there was another texture with the same name at a different path - bakedTextureFileName = createBakedTextureFileName(modelTextureFileInfo); - _remappedTexturePaths[urlToTexture] = bakedTextureFileName; + baseTextureFileName = createBaseTextureFileName(modelTextureFileInfo); + _remappedTexturePaths[urlToTexture] = baseTextureFileName; } qCDebug(model_baking).noquote() << "Re-mapping" << modelTextureFileName - << "to" << bakedTextureFileName; + << "to" << baseTextureFileName; - QString bakedTextureFilePath{ - _bakedOutputDir + "/" + bakedTextureFileName + QString bakedTextureFilePath { + _bakedOutputDir + "/" + baseTextureFileName + BAKED_META_TEXTURE_SUFFIX }; - textureChild = bakedTextureFileName; + textureChild = baseTextureFileName + BAKED_META_TEXTURE_SUFFIX; if (!_bakingTextures.contains(urlToTexture)) { _outputFiles.push_back(bakedTextureFilePath); // bake this texture asynchronously - bakeTexture(urlToTexture, textureType, _bakedOutputDir, bakedTextureFileName, textureContent); + bakeTexture(urlToTexture, textureType, _bakedOutputDir, baseTextureFileName, textureContent); } } @@ -309,7 +309,7 @@ void ModelBaker::bakeTexture(const QUrl& textureURL, image::TextureUsage::Type t // start a bake for this texture and add it to our list to keep track of QSharedPointer bakingTexture{ - new TextureBaker(textureURL, textureType, outputDir, bakedFilename, textureContent), + new TextureBaker(textureURL, textureType, outputDir, "../", bakedFilename, textureContent), &TextureBaker::deleteLater }; @@ -484,30 +484,30 @@ void ModelBaker::checkIfTexturesFinished() { } else { qCDebug(model_baking) << "Finished baking, emitting finished" << _modelURL; + texturesFinished(); + setIsFinished(true); } } } -QString ModelBaker::createBakedTextureFileName(const QFileInfo& textureFileInfo) { +QString ModelBaker::createBaseTextureFileName(const QFileInfo& textureFileInfo) { // first make sure we have a unique base name for this texture // in case another texture referenced by this model has the same base name auto& nameMatches = _textureNameMatchCount[textureFileInfo.baseName()]; - QString bakedTextureFileName{ textureFileInfo.completeBaseName() }; + QString baseTextureFileName{ textureFileInfo.completeBaseName() }; if (nameMatches > 0) { // there are already nameMatches texture with this name // append - and that number to our baked texture file name so that it is unique - bakedTextureFileName += "-" + QString::number(nameMatches); + baseTextureFileName += "-" + QString::number(nameMatches); } - bakedTextureFileName += BAKED_TEXTURE_EXT; - // increment the number of name matches ++nameMatches; - return bakedTextureFileName; + return baseTextureFileName; } void ModelBaker::setWasAborted(bool wasAborted) { @@ -519,3 +519,95 @@ void ModelBaker::setWasAborted(bool wasAborted) { } } } + +void ModelBaker::texturesFinished() { + embedTextureMetaData(); + exportScene(); +} + +void ModelBaker::embedTextureMetaData() { + std::vector embeddedTextureNodes; + + for (FBXNode& rootChild : _rootNode.children) { + if (rootChild.name == "Objects") { + qlonglong maxId = 0; + for (auto &child : rootChild.children) { + if (child.properties.length() == 3) { + maxId = std::max(maxId, child.properties[0].toLongLong()); + } + } + + qDebug() << "Max id found was: " << maxId; + + for (auto& object : rootChild.children) { + if (object.name == "Texture") { + QVariant relativeFilename; + for (auto& child : object.children) { + if (child.name == "RelativeFilename") { + relativeFilename = child.properties[0]; + break; + } + } + + if (relativeFilename.isNull() + || !relativeFilename.toString().endsWith(BAKED_META_TEXTURE_SUFFIX)) { + continue; + } + if (object.properties.length() < 2) { + qWarning() << "Found texture with unexpected number of properties: " << object.name; + continue; + } + + FBXNode videoNode; + videoNode.name = "Video"; + videoNode.properties.append(++maxId); + videoNode.properties.append(object.properties[1]); + videoNode.properties.append("Clip"); + + QString bakedTextureFilePath { + _bakedOutputDir + "/" + relativeFilename.toString() + }; + qDebug() << "Location of texture: " << bakedTextureFilePath; + + QFile textureFile { bakedTextureFilePath }; + if (!textureFile.open(QIODevice::ReadOnly)) { + qWarning() << "Failed to open: " << bakedTextureFilePath; + continue; + } + + videoNode.children.append({ "RelativeFilename", { relativeFilename }, { } }); + videoNode.children.append({ "Content", { textureFile.readAll() }, { } }); + + rootChild.children.append(videoNode); + + textureFile.close(); + } + } + } + } + +} + +void ModelBaker::exportScene() { + // save the relative path to this FBX inside our passed output folder + auto fileName = _modelURL.fileName(); + auto baseName = fileName.left(fileName.lastIndexOf('.')); + auto bakedFilename = baseName + BAKED_FBX_EXTENSION; + + _bakedModelFilePath = _bakedOutputDir + "/" + bakedFilename; + + auto fbxData = FBXWriter::encodeFBX(_rootNode); + + QFile bakedFile(_bakedModelFilePath); + + if (!bakedFile.open(QIODevice::WriteOnly)) { + handleError("Error opening " + _bakedModelFilePath + " for writing"); + return; + } + + bakedFile.write(fbxData); + + _outputFiles.push_back(_bakedModelFilePath); + + qCDebug(model_baking) << "Exported" << _modelURL << "with re-written paths to" << _bakedModelFilePath; +} diff --git a/libraries/baking/src/ModelBaker.h b/libraries/baking/src/ModelBaker.h index 6fd529af92..1fd77ab761 100644 --- a/libraries/baking/src/ModelBaker.h +++ b/libraries/baking/src/ModelBaker.h @@ -29,6 +29,8 @@ using TextureBakerThreadGetter = std::function; using GetMaterialIDCallback = std::function ; +static const QString BAKED_FBX_EXTENSION = ".baked.fbx"; + class ModelBaker : public Baker { Q_OBJECT @@ -49,7 +51,11 @@ public slots: protected: void checkIfTexturesFinished(); + void texturesFinished(); + void embedTextureMetaData(); + void exportScene(); + FBXNode _rootNode; QHash _textureContentMap; QUrl _modelURL; QString _bakedOutputDir; @@ -63,7 +69,7 @@ private slots: void handleAbortedTexture(); private: - QString createBakedTextureFileName(const QFileInfo & textureFileInfo); + QString createBaseTextureFileName(const QFileInfo & textureFileInfo); QUrl getTextureURL(const QFileInfo& textureFileInfo, QString relativeFileName, bool isEmbedded = false); void bakeTexture(const QUrl & textureURL, image::TextureUsage::Type textureType, const QDir & outputDir, const QString & bakedFilename, const QByteArray & textureContent); diff --git a/libraries/baking/src/OBJBaker.cpp b/libraries/baking/src/OBJBaker.cpp index 85771ff2e3..1fe53f26eb 100644 --- a/libraries/baking/src/OBJBaker.cpp +++ b/libraries/baking/src/OBJBaker.cpp @@ -147,31 +147,7 @@ void OBJBaker::bakeOBJ() { auto geometry = reader.readOBJ(objData, QVariantHash(), combineParts, _modelURL); // Write OBJ Data as FBX tree nodes - FBXNode rootNode; - createFBXNodeTree(rootNode, *geometry); - - // Serialize the resultant FBX tree - auto encodedFBX = FBXWriter::encodeFBX(rootNode); - - // Export as baked FBX - auto fileName = _modelURL.fileName(); - auto baseName = fileName.left(fileName.lastIndexOf('.')); - auto bakedFilename = baseName + ".baked.fbx"; - - _bakedModelFilePath = _bakedOutputDir + "/" + bakedFilename; - - QFile bakedFile; - bakedFile.setFileName(_bakedModelFilePath); - if (!bakedFile.open(QIODevice::WriteOnly)) { - handleError("Error opening " + _bakedModelFilePath + " for writing"); - return; - } - - bakedFile.write(encodedFBX); - - // Export successful - _outputFiles.push_back(_bakedModelFilePath); - qCDebug(model_baking) << "Exported" << _modelURL << "to" << _bakedModelFilePath; + createFBXNodeTree(_rootNode, *geometry); checkIfTexturesFinished(); } @@ -203,15 +179,17 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { globalSettingsNode.children = { properties70Node }; // Generating Object node - _objectNode.name = OBJECTS_NODE_NAME; + FBXNode objectNode; + objectNode.name = OBJECTS_NODE_NAME; // Generating Object node's child - Geometry node FBXNode geometryNode; geometryNode.name = GEOMETRY_NODE_NAME; + NodeID geometryID; { - _geometryID = nextNodeID(); + geometryID = nextNodeID(); geometryNode.properties = { - _geometryID, + geometryID, GEOMETRY_NODE_NAME, MESH }; @@ -226,12 +204,13 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { // Generating Object node's child - Model node FBXNode modelNode; modelNode.name = MODEL_NODE_NAME; + NodeID modelID; { - _modelID = nextNodeID(); - modelNode.properties = { _modelID, MODEL_NODE_NAME, MESH }; + modelID = nextNodeID(); + modelNode.properties = { modelID, MODEL_NODE_NAME, MESH }; } - _objectNode.children = { geometryNode, modelNode }; + objectNode.children = { geometryNode, modelNode }; // Generating Objects node's child - Material node auto& meshParts = geometry.meshes[0].parts; @@ -247,7 +226,7 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { setMaterialNodeProperties(materialNode, meshPart.materialID, geometry); } - _objectNode.children.append(materialNode); + objectNode.children.append(materialNode); } // Generating Texture Node @@ -257,13 +236,13 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { QString material = meshParts[i].materialID; FBXMaterial currentMaterial = geometry.materials[material]; if (!currentMaterial.albedoTexture.filename.isEmpty() || !currentMaterial.specularTexture.filename.isEmpty()) { - _textureID = nextNodeID(); - _mapTextureMaterial.emplace_back(_textureID, i); + auto textureID = nextNodeID(); + _mapTextureMaterial.emplace_back(textureID, i); FBXNode textureNode; { textureNode.name = TEXTURE_NODE_NAME; - textureNode.properties = { _textureID }; + textureNode.properties = { textureID, "texture" + QString::number(textureID) }; } // Texture node child - TextureName node @@ -295,7 +274,7 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { textureNode.children = { textureNameNode, relativeFilenameNode }; - _objectNode.children.append(textureNode); + objectNode.children.append(textureNode); } } @@ -306,14 +285,14 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { // connect Geometry to Model FBXNode cNode; cNode.name = C_NODE_NAME; - cNode.properties = { CONNECTIONS_NODE_PROPERTY, _geometryID, _modelID }; + cNode.properties = { CONNECTIONS_NODE_PROPERTY, geometryID, modelID }; connectionsNode.children = { cNode }; // connect all materials to model for (auto& materialID : _materialIDs) { FBXNode cNode; cNode.name = C_NODE_NAME; - cNode.properties = { CONNECTIONS_NODE_PROPERTY, materialID, _modelID }; + cNode.properties = { CONNECTIONS_NODE_PROPERTY, materialID, modelID }; connectionsNode.children.append(cNode); } @@ -341,7 +320,7 @@ void OBJBaker::createFBXNodeTree(FBXNode& rootNode, FBXGeometry& geometry) { } // Make all generated nodes children of rootNode - rootNode.children = { globalSettingsNode, _objectNode, connectionsNode }; + rootNode.children = { globalSettingsNode, objectNode, connectionsNode }; } // Set properties for material nodes diff --git a/libraries/baking/src/OBJBaker.h b/libraries/baking/src/OBJBaker.h index e888c7b1d8..8e49692d35 100644 --- a/libraries/baking/src/OBJBaker.h +++ b/libraries/baking/src/OBJBaker.h @@ -43,12 +43,9 @@ private: void setMaterialNodeProperties(FBXNode& materialNode, QString material, FBXGeometry& geometry); NodeID nextNodeID() { return _nodeID++; } + NodeID _nodeID { 0 }; - NodeID _geometryID; - NodeID _modelID; std::vector _materialIDs; - NodeID _textureID; std::vector> _mapTextureMaterial; - FBXNode _objectNode; }; #endif // hifi_OBJBaker_h diff --git a/libraries/baking/src/TextureBaker.cpp b/libraries/baking/src/TextureBaker.cpp index b6edd07965..7a5dc85a61 100644 --- a/libraries/baking/src/TextureBaker.cpp +++ b/libraries/baking/src/TextureBaker.cpp @@ -18,26 +18,30 @@ #include #include #include +#include #include "ModelBakingLoggingCategory.h" #include "TextureBaker.h" -const QString BAKED_TEXTURE_EXT = ".ktx"; +const QString BAKED_TEXTURE_KTX_EXT = ".ktx"; +const QString BAKED_TEXTURE_BCN_SUFFIX = "_bcn.ktx"; +const QString BAKED_META_TEXTURE_SUFFIX = ".texmeta.json"; TextureBaker::TextureBaker(const QUrl& textureURL, image::TextureUsage::Type textureType, - const QDir& outputDirectory, const QString& bakedFilename, - const QByteArray& textureContent) : + const QDir& outputDirectory, const QString& metaTexturePathPrefix, + const QString& baseFilename, const QByteArray& textureContent) : _textureURL(textureURL), _originalTexture(textureContent), _textureType(textureType), + _baseFilename(baseFilename), _outputDirectory(outputDirectory), - _bakedTextureFileName(bakedFilename) + _metaTexturePathPrefix(metaTexturePathPrefix) { - if (bakedFilename.isEmpty()) { + if (baseFilename.isEmpty()) { // figure out the baked texture filename auto originalFilename = textureURL.fileName(); - _bakedTextureFileName = originalFilename.left(originalFilename.lastIndexOf('.')) + BAKED_TEXTURE_EXT; + _baseFilename = originalFilename.left(originalFilename.lastIndexOf('.')); } } @@ -118,6 +122,19 @@ void TextureBaker::processTexture() { auto hashData = QCryptographicHash::hash(_originalTexture, QCryptographicHash::Md5); std::string hash = hashData.toHex().toStdString(); + TextureMeta meta; + + { + auto filePath = _outputDirectory.absoluteFilePath(_textureURL.fileName()); + QFile file { filePath }; + if (!file.open(QIODevice::WriteOnly) || file.write(_originalTexture) == -1) { + handleError("Could not write meta texture for " + _textureURL.toString()); + return; + } + _outputFiles.push_back(filePath); + meta.original =_metaTexturePathPrefix +_textureURL.fileName(); + } + // IMPORTANT: _originalTexture is empty past this point auto processedTexture = image::processImage(std::move(_originalTexture), _textureURL.toString().toStdString(), ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, _abortProcessing); @@ -142,15 +159,37 @@ void TextureBaker::processTexture() { const char* data = reinterpret_cast(memKTX->_storage->data()); const size_t length = memKTX->_storage->size(); + const char* name = khronos::gl::texture::toString(memKTX->_header.getGLInternaFormat()); + if (name == nullptr) { + handleError("Could not determine internal format for compressed KTX: " + _textureURL.toString()); + return; + } + + qDebug() << "Found type: " << name; // attempt to write the baked texture to the destination file path - auto filePath = _outputDirectory.absoluteFilePath(_bakedTextureFileName); - QFile bakedTextureFile { filePath }; - - if (!bakedTextureFile.open(QIODevice::WriteOnly) || bakedTextureFile.write(data, length) == -1) { - handleError("Could not write baked texture for " + _textureURL.toString()); - } else { + { + auto fileName = _baseFilename + BAKED_TEXTURE_BCN_SUFFIX; + auto filePath = _outputDirectory.absoluteFilePath(fileName); + QFile bakedTextureFile { filePath }; + if (!bakedTextureFile.open(QIODevice::WriteOnly) || bakedTextureFile.write(data, length) == -1) { + handleError("Could not write baked texture for " + _textureURL.toString()); + return; + } _outputFiles.push_back(filePath); + meta.availableTextureTypes[memKTX->_header.getGLInternaFormat()] = _metaTexturePathPrefix + fileName; + } + + + { + auto data = meta.serialize(); + _metaTextureFileName = _outputDirectory.absoluteFilePath(_baseFilename + BAKED_META_TEXTURE_SUFFIX); + QFile file { _metaTextureFileName }; + if (!file.open(QIODevice::WriteOnly) || file.write(data) == -1) { + handleError("Could not write meta texture for " + _textureURL.toString()); + } else { + _outputFiles.push_back(_metaTextureFileName); + } } qCDebug(model_baking) << "Baked texture" << _textureURL; diff --git a/libraries/baking/src/TextureBaker.h b/libraries/baking/src/TextureBaker.h index 90ecfe52f7..93b01080cd 100644 --- a/libraries/baking/src/TextureBaker.h +++ b/libraries/baking/src/TextureBaker.h @@ -21,22 +21,22 @@ #include "Baker.h" -extern const QString BAKED_TEXTURE_EXT; +extern const QString BAKED_TEXTURE_KTX_EXT; +extern const QString BAKED_META_TEXTURE_SUFFIX; class TextureBaker : public Baker { Q_OBJECT public: TextureBaker(const QUrl& textureURL, image::TextureUsage::Type textureType, - const QDir& outputDirectory, const QString& bakedFilename = QString(), - const QByteArray& textureContent = QByteArray()); + const QDir& outputDirectory, const QString& metaTexturePathPrefix = "", + const QString& baseFilename = QString(), const QByteArray& textureContent = QByteArray()); const QByteArray& getOriginalTexture() const { return _originalTexture; } QUrl getTextureURL() const { return _textureURL; } - QString getDestinationFilePath() const { return _outputDirectory.absoluteFilePath(_bakedTextureFileName); } - QString getBakedTextureFileName() const { return _bakedTextureFileName; } + QString getMetaTextureFileName() const { return _metaTextureFileName; } virtual void setWasAborted(bool wasAborted) override; @@ -58,8 +58,10 @@ private: QByteArray _originalTexture; image::TextureUsage::Type _textureType; + QString _baseFilename; QDir _outputDirectory; - QString _bakedTextureFileName; + QString _metaTextureFileName; + QString _metaTexturePathPrefix; std::atomic _abortProcessing { false }; }; diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 1e59646795..1f237edfb0 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1101,6 +1101,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS } if (!content.isEmpty()) { _textureContent.insert(filepath, content); + qDebug() << "Adding content: " << filepath << content.length(); } } else if (object.name == "Material") { FBXMaterial material; diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index 4aa3044934..88dc7f599d 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -85,12 +85,16 @@ FBXTexture FBXReader::getTexture(const QString& textureID) { FBXTexture texture; const QByteArray& filepath = _textureFilepaths.value(textureID); texture.content = _textureContent.value(filepath); + qDebug() << "Getting texture: " << textureID << filepath << texture.content.length(); if (texture.content.isEmpty()) { // the content is not inlined + qDebug() << "Texture is not inlined"; texture.filename = _textureFilenames.value(textureID); } else { // use supplied filepath for inlined content + qDebug() << "Texture is inlined"; texture.filename = filepath; } + qDebug() << "Path: " << texture.filename; texture.id = textureID; texture.name = _textureNames.value(textureID); diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h index 9479321747..f3b452b1f9 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h +++ b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h @@ -52,6 +52,8 @@ public: static const std::string GL41_VERSION; const std::string& getVersion() const override { return GL41_VERSION; } + bool supportedTextureFormat(const gpu::Element& format) override; + class GL41Texture : public GLTexture { using Parent = GLTexture; friend class GL41Backend; @@ -173,8 +175,6 @@ protected: void makeProgramBindings(ShaderObject& shaderObject) override; int makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) override; - static bool supportedTextureFormat(const gpu::Element& format); - }; } } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h index c23a83eaf9..616b6d1075 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h +++ b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h @@ -54,6 +54,8 @@ public: static const std::string GL45_VERSION; const std::string& getVersion() const override { return GL45_VERSION; } + bool supportedTextureFormat(const gpu::Element& format) override; + class GL45Texture : public GLTexture { using Parent = GLTexture; friend class GL45Backend; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index 4d5ffefa67..6b3c99ccc3 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -32,6 +32,24 @@ using namespace gpu::gl45; #define FORCE_STRICT_TEXTURE 0 #define ENABLE_SPARSE_TEXTURE 0 +bool GL45Backend::supportedTextureFormat(const gpu::Element& format) { + switch (format.getSemantic()) { + case gpu::Semantic::COMPRESSED_ETC2_RGB: + case gpu::Semantic::COMPRESSED_ETC2_SRGB: + case gpu::Semantic::COMPRESSED_ETC2_RGB_PUNCHTHROUGH_ALPHA: + case gpu::Semantic::COMPRESSED_ETC2_SRGB_PUNCHTHROUGH_ALPHA: + case gpu::Semantic::COMPRESSED_ETC2_RGBA: + case gpu::Semantic::COMPRESSED_ETC2_SRGBA: + case gpu::Semantic::COMPRESSED_EAC_RED: + case gpu::Semantic::COMPRESSED_EAC_RED_SIGNED: + case gpu::Semantic::COMPRESSED_EAC_XY: + case gpu::Semantic::COMPRESSED_EAC_XY_SIGNED: + return false; + default: + return true; + } +} + GLTexture* GL45Backend::syncGPUObject(const TexturePointer& texturePointer) { if (!texturePointer) { return nullptr; diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackend.h b/libraries/gpu-gles/src/gpu/gles/GLESBackend.h index 38e28e630a..47a123718a 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackend.h +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackend.h @@ -32,7 +32,6 @@ public: static const GLint RESOURCE_TRANSFER_EXTRA_TEX_UNIT { 33 }; static const GLint RESOURCE_BUFFER_TEXBUF_TEX_UNIT { 34 }; static const GLint RESOURCE_BUFFER_SLOT0_TEX_UNIT { 35 }; - static bool supportedTextureFormat(const gpu::Element& format); explicit GLESBackend(bool syncCache) : Parent(syncCache) {} GLESBackend() : Parent() {} virtual ~GLESBackend() { @@ -40,6 +39,8 @@ public: // which is pure virtual from GLBackend's dtor. resetStages(); } + + bool supportedTextureFormat(const gpu::Element& format) override; static const std::string GLES_VERSION; const std::string& getVersion() const override { return GLES_VERSION; } diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index eda8fee596..8c5a4d493e 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -64,6 +64,8 @@ public: virtual void recycle() const = 0; virtual void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) = 0; + virtual bool supportedTextureFormat(const gpu::Element& format) = 0; + // Shared header between C++ and GLSL #include "TransformCamera_shared.slh" diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 4d82aba595..09b2bc9475 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -37,6 +37,10 @@ namespace ktx { using KeyValues = std::list; } +namespace khronos { namespace gl { namespace texture { + enum class InternalFormat: uint32_t; +}}} + namespace gpu { @@ -565,6 +569,7 @@ public: static bool evalKTXFormat(const Element& mipFormat, const Element& texelFormat, ktx::Header& header); static bool evalTextureFormat(const ktx::Header& header, Element& mipFormat, Element& texelFormat); + static bool getCompressedFormat(khronos::gl::texture::InternalFormat format, Element& elFormat); protected: const TextureUsageType _usageType; diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 5e354c0a5c..0822af3cfb 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -619,6 +619,47 @@ bool Texture::evalKTXFormat(const Element& mipFormat, const Element& texelFormat return true; } +bool Texture::getCompressedFormat(ktx::GLInternalFormat format, Element& elFormat) { + if (format == ktx::GLInternalFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT) { + elFormat = Format::COLOR_COMPRESSED_BCX_SRGB; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) { + elFormat = Format::COLOR_COMPRESSED_BCX_SRGBA_MASK; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) { + elFormat = Format::COLOR_COMPRESSED_BCX_SRGBA; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RED_RGTC1) { + elFormat = Format::COLOR_COMPRESSED_BCX_RED; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RG_RGTC2) { + elFormat = Format::COLOR_COMPRESSED_BCX_XY; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_BPTC_UNORM) { + elFormat = Format::COLOR_COMPRESSED_BCX_SRGBA_HIGH; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT) { + elFormat = Format::COLOR_COMPRESSED_BCX_HDR_RGB; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RGB8_ETC2) { + elFormat = Format::COLOR_COMPRESSED_ETC2_RGB; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB8_ETC2) { + elFormat = Format::COLOR_COMPRESSED_ETC2_SRGB; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2) { + elFormat = Format::COLOR_COMPRESSED_ETC2_RGB_PUNCHTHROUGH_ALPHA; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2) { + elFormat = Format::COLOR_COMPRESSED_ETC2_SRGB_PUNCHTHROUGH_ALPHA; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RGBA8_ETC2_EAC) { + elFormat = Format::COLOR_COMPRESSED_ETC2_RGBA; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) { + elFormat = Format::COLOR_COMPRESSED_ETC2_SRGBA; + } else if (format == ktx::GLInternalFormat::COMPRESSED_R11_EAC) { + elFormat = Format::COLOR_COMPRESSED_EAC_RED; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SIGNED_R11_EAC) { + elFormat = Format::COLOR_COMPRESSED_EAC_RED_SIGNED; + } else if (format == ktx::GLInternalFormat::COMPRESSED_RG11_EAC) { + elFormat = Format::COLOR_COMPRESSED_EAC_XY; + } else if (format == ktx::GLInternalFormat::COMPRESSED_SIGNED_RG11_EAC) { + elFormat = Format::COLOR_COMPRESSED_EAC_XY_SIGNED; + } else { + return false; + } + return true; +} + bool Texture::evalTextureFormat(const ktx::Header& header, Element& mipFormat, Element& texelFormat) { if (header.getGLFormat() == ktx::GLFormat::BGRA && header.getGLType() == ktx::GLType::UNSIGNED_BYTE && header.getTypeSize() == 1) { if (header.getGLInternaFormat() == ktx::GLInternalFormat::RGBA8) { @@ -661,41 +702,7 @@ bool Texture::evalTextureFormat(const ktx::Header& header, Element& mipFormat, E mipFormat = Format::COLOR_RGB9E5; texelFormat = Format::COLOR_RGB9E5; } else if (header.isCompressed()) { - if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT) { - texelFormat = Format::COLOR_COMPRESSED_BCX_SRGB; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) { - texelFormat = Format::COLOR_COMPRESSED_BCX_SRGBA_MASK; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) { - texelFormat = Format::COLOR_COMPRESSED_BCX_SRGBA; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RED_RGTC1) { - texelFormat = Format::COLOR_COMPRESSED_BCX_RED; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RG_RGTC2) { - texelFormat = Format::COLOR_COMPRESSED_BCX_XY; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB_ALPHA_BPTC_UNORM) { - texelFormat = Format::COLOR_COMPRESSED_BCX_SRGBA_HIGH; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT) { - texelFormat = Format::COLOR_COMPRESSED_BCX_HDR_RGB; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RGB8_ETC2) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_RGB; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB8_ETC2) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_SRGB; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_RGB_PUNCHTHROUGH_ALPHA; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_SRGB_PUNCHTHROUGH_ALPHA; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RGBA8_ETC2_EAC) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_RGBA; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) { - texelFormat = Format::COLOR_COMPRESSED_ETC2_SRGBA; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_R11_EAC) { - texelFormat = Format::COLOR_COMPRESSED_EAC_RED; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SIGNED_R11_EAC) { - texelFormat = Format::COLOR_COMPRESSED_EAC_RED_SIGNED; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_RG11_EAC) { - texelFormat = Format::COLOR_COMPRESSED_EAC_XY; - } else if (header.getGLInternaFormat() == ktx::GLInternalFormat::COMPRESSED_SIGNED_RG11_EAC) { - texelFormat = Format::COLOR_COMPRESSED_EAC_XY_SIGNED; - } else { + if (!getCompressedFormat(header.getGLInternaFormat(), texelFormat)) { return false; } mipFormat = texelFormat; diff --git a/libraries/ktx/src/TextureMeta.cpp b/libraries/ktx/src/TextureMeta.cpp new file mode 100644 index 0000000000..88235d8a4b --- /dev/null +++ b/libraries/ktx/src/TextureMeta.cpp @@ -0,0 +1,58 @@ +// +// TextureMeta.cpp +// libraries/shared/src +// +// Created by Ryan Huffman on 04/10/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TextureMeta.h" + +#include +#include + +const QString TEXTURE_META_EXTENSION = ".texmeta.json"; + +bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) { + QJsonParseError error; + auto doc = QJsonDocument::fromJson(data, &error); + if (!doc.isObject()) { + return false; + } + + auto root = doc.object(); + if (root.contains("original")) { + meta->original = root["original"].toString(); + } + if (root.contains("compressed")) { + auto compressed = root["compressed"].toObject(); + for (auto it = compressed.constBegin(); it != compressed.constEnd(); it++) { + khronos::gl::texture::InternalFormat format; + auto formatName = it.key().toLatin1(); + if (khronos::gl::texture::fromString(formatName.constData(), &format)) { + meta->availableTextureTypes[format] = it.value().toString(); + } + } + } + + return true; +} + +QByteArray TextureMeta::serialize() { + QJsonDocument doc; + QJsonObject root; + QJsonObject compressed; + + for (auto kv : availableTextureTypes) { + const char* name = khronos::gl::texture::toString(kv.first); + compressed[name] = kv.second.toString(); + } + root["original"] = original.toString(); + root["compressed"] = compressed; + doc.setObject(root); + + return doc.toJson(); +} diff --git a/libraries/ktx/src/TextureMeta.h b/libraries/ktx/src/TextureMeta.h new file mode 100644 index 0000000000..6582c29e70 --- /dev/null +++ b/libraries/ktx/src/TextureMeta.h @@ -0,0 +1,42 @@ +// +// TextureMeta.h +// libraries/shared/src +// +// Created by Ryan Huffman on 04/10/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_TextureMeta_h +#define hifi_TextureMeta_h + +#include +#include +#include + +#include "khronos/KHR.h" + +extern const QString TEXTURE_META_EXTENSION; + +namespace std { + template<> struct hash { + using enum_type = std::underlying_type::type; + typedef std::size_t result_type; + result_type operator()(khronos::gl::texture::InternalFormat const& v) const noexcept { + return std::hash()(static_cast(v)); + } + }; +} + +struct TextureMeta { + static bool deserialize(const QByteArray& data, TextureMeta* meta); + QByteArray serialize(); + + QUrl original; + std::unordered_map availableTextureTypes; +}; + + +#endif // hifi_TextureMeta_h diff --git a/libraries/ktx/src/khronos/KHR.h b/libraries/ktx/src/khronos/KHR.h index 4ee893e4fc..617e40ce06 100644 --- a/libraries/ktx/src/khronos/KHR.h +++ b/libraries/ktx/src/khronos/KHR.h @@ -10,6 +10,8 @@ #ifndef khronos_khr_hpp #define khronos_khr_hpp +#include + namespace khronos { namespace gl { @@ -209,6 +211,63 @@ namespace khronos { COMPRESSED_SIGNED_RG11_EAC = 0x9273, }; + static std::unordered_map nameToFormat { + { "COMPRESSED_RED", InternalFormat::COMPRESSED_RED }, + { "COMPRESSED_RG", InternalFormat::COMPRESSED_RG }, + { "COMPRESSED_RGB", InternalFormat::COMPRESSED_RGB }, + { "COMPRESSED_RGBA", InternalFormat::COMPRESSED_RGBA }, + + { "COMPRESSED_SRGB", InternalFormat::COMPRESSED_SRGB }, + { "COMPRESSED_SRGB_ALPHA", InternalFormat::COMPRESSED_SRGB_ALPHA }, + + { "COMPRESSED_ETC1_RGB8_OES", InternalFormat::COMPRESSED_ETC1_RGB8_OES }, + + { "COMPRESSED_SRGB_S3TC_DXT1_EXT", InternalFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT }, + { "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", InternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT }, + { "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", InternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT }, + { "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", InternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT }, + + { "COMPRESSED_RED_RGTC1", InternalFormat::COMPRESSED_RED_RGTC1 }, + { "COMPRESSED_SIGNED_RED_RGTC1", InternalFormat::COMPRESSED_SIGNED_RED_RGTC1 }, + { "COMPRESSED_RG_RGTC2", InternalFormat::COMPRESSED_RG_RGTC2 }, + { "COMPRESSED_SIGNED_RG_RGTC2", InternalFormat::COMPRESSED_SIGNED_RG_RGTC2 }, + + { "COMPRESSED_RGBA_BPTC_UNORM", InternalFormat::COMPRESSED_RGBA_BPTC_UNORM }, + { "COMPRESSED_SRGB_ALPHA_BPTC_UNORM", InternalFormat::COMPRESSED_SRGB_ALPHA_BPTC_UNORM }, + { "COMPRESSED_RGB_BPTC_SIGNED_FLOAT", InternalFormat::COMPRESSED_RGB_BPTC_SIGNED_FLOAT }, + { "COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT", InternalFormat::COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT }, + + { "COMPRESSED_RGB8_ETC2", InternalFormat::COMPRESSED_RGB8_ETC2 }, + { "COMPRESSED_SRGB8_ETC2", InternalFormat::COMPRESSED_SRGB8_ETC2 }, + { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", InternalFormat::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 }, + { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", InternalFormat::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 }, + { "COMPRESSED_RGBA8_ETC2_EAC", InternalFormat::COMPRESSED_RGBA8_ETC2_EAC }, + { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", InternalFormat::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC }, + + { "COMPRESSED_R11_EAC", InternalFormat::COMPRESSED_R11_EAC }, + { "COMPRESSED_SIGNED_R11_EAC", InternalFormat::COMPRESSED_SIGNED_R11_EAC }, + { "COMPRESSED_RG11_EAC", InternalFormat::COMPRESSED_RG11_EAC }, + { "COMPRESSED_SIGNED_RG11_EAC", InternalFormat::COMPRESSED_SIGNED_RG11_EAC } + }; + + inline const char* toString(InternalFormat format) { + for (auto& pair : nameToFormat) { + if (pair.second == format) { + return pair.first.data(); + } + } + return nullptr; + } + + inline bool fromString(const char* name, InternalFormat* format) { + auto it = nameToFormat.find(name); + if (it == nameToFormat.end()) { + return false; + } + *format = it->second; + return true; + } + inline uint8_t evalUncompressedBlockBitSize(InternalFormat format) { switch (format) { case InternalFormat::R8: diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index f17cdbb7e8..6756941520 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -517,10 +517,11 @@ QUrl NetworkMaterial::getTextureUrl(const QUrl& baseUrl, const FBXTexture& textu // Inlined file: cache under the fbx file to avoid namespace clashes // NOTE: We cannot resolve the path because filename may be an absolute path assert(texture.filename.size() > 0); + auto baseUrlStripped = baseUrl.toDisplayString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveUserInfo); if (texture.filename.at(0) == '/') { - return baseUrl.toString() + texture.filename; + return baseUrlStripped + texture.filename; } else { - return baseUrl.toString() + '/' + texture.filename; + return baseUrlStripped + '/' + texture.filename; } } } diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 04696cea1a..54b654c56b 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -48,6 +48,8 @@ #include #include +#include + Q_LOGGING_CATEGORY(trace_resource_parse_image, "trace.resource.parse.image") Q_LOGGING_CATEGORY(trace_resource_parse_image_raw, "trace.resource.parse.image.raw") Q_LOGGING_CATEGORY(trace_resource_parse_image_ktx, "trace.resource.parse.image.ktx") @@ -293,7 +295,6 @@ int networkTexturePointerMetaTypeId = qRegisterMetaType(url); @@ -309,17 +310,25 @@ static bool isLocalUrl(const QUrl& url) { NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels) : Resource(url), _type(type), - _sourceIsKTX(url.path().endsWith(".ktx")), _maxNumPixels(maxNumPixels) { _textureSource = std::make_shared(url, (int)type); _lowestRequestedMipLevel = 0; - _shouldFailOnRedirect = !_sourceIsKTX; + qDebug() << "Creating networktexture: " << url; + if (url.fileName().endsWith(TEXTURE_META_EXTENSION)) { + _currentlyLoadingResourceType = ResourceType::META; + } else if (url.fileName().endsWith(".ktx")) { + _currentlyLoadingResourceType = ResourceType::KTX; + } else { + _currentlyLoadingResourceType = ResourceType::ORIGINAL; + } + + _shouldFailOnRedirect = _currentlyLoadingResourceType != ResourceType::KTX; if (type == image::TextureUsage::CUBE_TEXTURE) { setLoadPriority(this, SKYBOX_LOAD_PRIORITY); - } else if (_sourceIsKTX) { + } else if (_currentlyLoadingResourceType == ResourceType::KTX) { setLoadPriority(this, HIGH_MIPS_LOAD_PRIORITY); } @@ -330,7 +339,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type, // if we have content, load it after we have our self pointer if (!content.isEmpty()) { _startedLoading = true; - QMetaObject::invokeMethod(this, "loadContent", Qt::QueuedConnection, Q_ARG(const QByteArray&, content)); + QMetaObject::invokeMethod(this, "downloadFinished", Qt::QueuedConnection, Q_ARG(const QByteArray&, content)); } } @@ -393,12 +402,13 @@ NetworkTexture::~NetworkTexture() { const uint16_t NetworkTexture::NULL_MIP_LEVEL = std::numeric_limits::max(); void NetworkTexture::makeRequest() { - if (!_sourceIsKTX) { + qDebug() << "In makeRequest for " << _activeUrl << (int)_currentlyLoadingResourceType; + if (_currentlyLoadingResourceType != ResourceType::KTX) { Resource::makeRequest(); return; } - if (isLocalUrl(_url)) { + if (isLocalUrl(_activeUrl)) { auto self = _self; QtConcurrent::run(QThreadPool::globalInstance(), [self] { auto resource = self.lock(); @@ -444,6 +454,7 @@ void NetworkTexture::makeRequest() { _ktxHeaderRequest->send(); + qDebug() << "Starting mip range request"; startMipRangeRequest(NULL_MIP_LEVEL, NULL_MIP_LEVEL); } else if (_ktxResourceState == PENDING_MIP_REQUEST) { if (_lowestKnownPopulatedMip > 0) { @@ -466,12 +477,12 @@ void NetworkTexture::handleLocalRequestCompleted() { } void NetworkTexture::makeLocalRequest() { - const QString scheme = _url.scheme(); + const QString scheme = _activeUrl.scheme(); QString path; if (scheme == URL_SCHEME_FILE) { - path = PathUtils::expandToLocalDataAbsolutePath(_url).toLocalFile(); + path = PathUtils::expandToLocalDataAbsolutePath(_activeUrl).toLocalFile(); } else { - path = ":" + _url.path(); + path = ":" + _activeUrl.path(); } connect(this, &Resource::finished, this, &NetworkTexture::handleLocalRequestCompleted); @@ -497,7 +508,7 @@ void NetworkTexture::makeLocalRequest() { }); if (found == ktxDescriptor->keyValues.end() || found->_value.size() != gpu::SOURCE_HASH_BYTES) { - hash = _url.toString().toLocal8Bit().toHex().toStdString(); + hash = _activeUrl.toString().toLocal8Bit().toHex().toStdString(); } else { // at this point the source hash is in binary 16-byte form // and we need it in a hexadecimal string @@ -536,11 +547,13 @@ void NetworkTexture::makeLocalRequest() { } bool NetworkTexture::handleFailedRequest(ResourceRequest::Result result) { - if (!_sourceIsKTX && result == ResourceRequest::Result::RedirectFail) { + if (_currentlyLoadingResourceType != ResourceType::KTX + && result == ResourceRequest::Result::RedirectFail) { + auto newPath = _request->getRelativePathUrl(); if (newPath.fileName().endsWith(".ktx")) { qDebug() << "Redirecting to" << newPath << "from" << _url; - _sourceIsKTX = true; + _currentlyLoadingResourceType = ResourceType::KTX; _activeUrl = newPath; _shouldFailOnRedirect = false; makeRequest(); @@ -581,6 +594,7 @@ void NetworkTexture::startMipRangeRequest(uint16_t low, uint16_t high) { bool isHighMipRequest = low == NULL_MIP_LEVEL && high == NULL_MIP_LEVEL; + qDebug() << "Making ktx mip request to: " << _activeUrl; _ktxMipRequest = DependencyManager::get()->createResourceRequest(this, _activeUrl); if (!_ktxMipRequest) { @@ -930,11 +944,79 @@ void NetworkTexture::handleFinishedInitialLoad() { } void NetworkTexture::downloadFinished(const QByteArray& data) { - loadContent(data); + qDebug() << "Loading content: " << _activeUrl; + if (_currentlyLoadingResourceType == ResourceType::META) { + qDebug() << "Loading meta content: " << _activeUrl; + loadMetaContent(data); + } else if (_currentlyLoadingResourceType == ResourceType::ORIGINAL) { + loadTextureContent(data); + } else { + TextureCache::requestCompleted(_self); + Resource::handleFailedRequest(ResourceRequest::Error); + } } -void NetworkTexture::loadContent(const QByteArray& content) { - if (_sourceIsKTX) { +void NetworkTexture::loadMetaContent(const QByteArray& content) { + if (_currentlyLoadingResourceType != ResourceType::META) { + qWarning() << "Trying to load meta content when current resource type is not META"; + assert(false); + return; + } + + TextureMeta meta; + if (!TextureMeta::deserialize(content, &meta)) { + qWarning() << "Failed to read texture meta from " << _url; + return; + } + + + auto& backend = DependencyManager::get()->getGPUContext()->getBackend(); + for (auto pair : meta.availableTextureTypes) { + gpu::Element elFormat; + + if (gpu::Texture::getCompressedFormat(pair.first, elFormat)) { + if (backend->supportedTextureFormat(elFormat)) { + auto url = pair.second; + if (url.fileName().endsWith(TEXTURE_META_EXTENSION)) { + qWarning() << "Found a texture meta URL inside of the texture meta file at" << _activeUrl; + continue; + } + + _currentlyLoadingResourceType = ResourceType::KTX; + _activeUrl = _activeUrl.resolved(url); + qDebug() << "Active url is now: " << _activeUrl; + auto textureCache = DependencyManager::get(); + auto self = _self.lock(); + if (!self) { + return; + } + QMetaObject::invokeMethod(this, "attemptRequest", Qt::QueuedConnection); + return; + } + } + } + + if (!meta.original.isEmpty()) { + _currentlyLoadingResourceType = ResourceType::ORIGINAL; + _activeUrl = _activeUrl.resolved(meta.original); + + auto textureCache = DependencyManager::get(); + auto self = _self.lock(); + if (!self) { + return; + } + QMetaObject::invokeMethod(this, "attemptRequest", Qt::QueuedConnection); + return; + } + + qWarning() << "Failed to find supported texture type in " << _activeUrl; + //TextureCache::requestCompleted(_self); + Resource::handleFailedRequest(ResourceRequest::NotFound); +} + +void NetworkTexture::loadTextureContent(const QByteArray& content) { + if (_currentlyLoadingResourceType != ResourceType::ORIGINAL) { + qWarning() << "Trying to load texture content when currentl resource type is not ORIGINAL"; assert(false); return; } diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 3f46dc3074..d93ddb461e 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -24,7 +24,9 @@ #include #include #include +#include +#include #include "KTXCache.h" namespace gpu { @@ -75,11 +77,13 @@ protected: virtual bool isCacheable() const override { return _loaded; } - virtual void downloadFinished(const QByteArray& data) override; + Q_INVOKABLE virtual void downloadFinished(const QByteArray& data) override; bool handleFailedRequest(ResourceRequest::Result result) override; - Q_INVOKABLE void loadContent(const QByteArray& content); + Q_INVOKABLE void loadMetaContent(const QByteArray& content); + Q_INVOKABLE void loadTextureContent(const QByteArray& content); + Q_INVOKABLE void setImage(gpu::TexturePointer texture, int originalWidth, int originalHeight); Q_INVOKABLE void startRequestForNextMipLevel(); @@ -93,6 +97,14 @@ private: image::TextureUsage::Type _type; + enum class ResourceType { + META, + ORIGINAL, + KTX + }; + + ResourceType _currentlyLoadingResourceType { ResourceType::META }; + static const uint16_t NULL_MIP_LEVEL; enum KTXResourceState { PENDING_INITIAL_LOAD = 0, @@ -103,7 +115,6 @@ private: FAILED_TO_LOAD }; - bool _sourceIsKTX { false }; KTXResourceState _ktxResourceState { PENDING_INITIAL_LOAD }; // The current mips that are currently being requested w/ _ktxMipRequest @@ -236,6 +247,9 @@ public: static const int DEFAULT_SPECTATOR_CAM_WIDTH { 2048 }; static const int DEFAULT_SPECTATOR_CAM_HEIGHT { 1024 }; + void setGPUContext(const gpu::ContextPointer& context) { _gpuContext = context; } + gpu::ContextPointer getGPUContext() const { return _gpuContext; } + signals: /**jsdoc * @function TextureCache.spectatorCameraFramebufferReset @@ -268,6 +282,8 @@ private: static const std::string KTX_DIRNAME; static const std::string KTX_EXT; + gpu::ContextPointer _gpuContext { nullptr }; + std::shared_ptr _ktxCache { std::make_shared(KTX_DIRNAME, KTX_EXT) }; // Map from image hashes to texture weak pointers diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 7ba7cca96d..4d3ba9da25 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -581,6 +581,7 @@ void Resource::refresh() { ResourceCache::requestCompleted(_self); } + _activeUrl = _url; init(); ensureLoading(); emit onRefresh(); @@ -618,7 +619,7 @@ void Resource::init(bool resetLoaded) { _loaded = false; } _attempts = 0; - _activeUrl = _url; + qDebug() << "Initting resource: " << _url; if (_url.isEmpty()) { _startedLoading = _loaded = true; @@ -671,6 +672,7 @@ void Resource::makeRequest() { PROFILE_ASYNC_BEGIN(resource, "Resource:" + getType(), QString::number(_requestID), { { "url", _url.toString() }, { "activeURL", _activeUrl.toString() } }); + qDebug() << "Making request to " << _activeUrl; _request = DependencyManager::get()->createResourceRequest(this, _activeUrl); if (!_request) { @@ -724,7 +726,7 @@ void Resource::handleReplyFinished() { auto result = _request->getResult(); if (result == ResourceRequest::Success) { auto extraInfo = _url == _activeUrl ? "" : QString(", %1").arg(_activeUrl.toDisplayString()); - qCDebug(networking).noquote() << QString("Request finished for %1%2").arg(_url.toDisplayString(), extraInfo); + qCDebug(networking).noquote() << QString("Request finished for %1%2").arg(_activeUrl.toDisplayString(), extraInfo); auto relativePathURL = _request->getRelativePathUrl(); if (!relativePathURL.isEmpty()) { diff --git a/tools/oven/src/DomainBaker.cpp b/tools/oven/src/DomainBaker.cpp index 3c6799db88..0a75c72f9a 100644 --- a/tools/oven/src/DomainBaker.cpp +++ b/tools/oven/src/DomainBaker.cpp @@ -464,7 +464,7 @@ bool DomainBaker::rewriteSkyboxURL(QJsonValueRef urlValue, TextureBaker* baker) if (oldSkyboxURL.matches(baker->getTextureURL(), QUrl::RemoveQuery | QUrl::RemoveFragment)) { // change the URL to point to the baked texture with its original query and fragment - auto newSkyboxURL = _destinationPath.resolved(baker->getBakedTextureFileName()); + auto newSkyboxURL = _destinationPath.resolved(baker->getMetaTextureFileName()); newSkyboxURL.setQuery(oldSkyboxURL.query()); newSkyboxURL.setFragment(oldSkyboxURL.fragment()); newSkyboxURL.setUserInfo(oldSkyboxURL.userInfo()); From 12d4cf12cf6790a5d9549df29bc3718648a32994 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 May 2018 14:11:50 -0700 Subject: [PATCH 036/192] Bump model and texture baking versions in AssetServer --- assignment-client/src/assets/AssetServer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index fb88df0171..c4b1ff07e5 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -36,10 +36,11 @@ enum class BakedAssetType : int { Undefined }; -// ATTENTION! If you change the current version for an asset type, you will also -// need to update the function currentBakeVersionForAssetType() inside of AssetServer.cpp. +// ATTENTION! Do not remove baking versions, and do not reorder them. If you add +// a new value, it will immediately become the "current" version. enum class ModelBakeVersion : BakeVersion { Initial = INITIAL_BAKE_VERSION, + MetaTextureJson, COUNT }; @@ -47,6 +48,7 @@ enum class ModelBakeVersion : BakeVersion { // ATTENTION! See above. enum class TextureBakeVersion : BakeVersion { Initial = INITIAL_BAKE_VERSION, + MetaTextureJson, COUNT }; From b722c80b3f9f367fdc5758064c4110ecc8216221 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 1 May 2018 14:25:33 -0700 Subject: [PATCH 037/192] WIP --- tools/auto-tester/src/ui/AutoTester.cpp | 12 ++++++++---- tools/auto-tester/src/ui/AutoTester.h | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 3f7d2cba28..860868565a 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -10,8 +10,6 @@ // #include "AutoTester.h" -#include - AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); ui.checkBoxInteractiveMode->setChecked(true); @@ -91,11 +89,17 @@ void AutoTester::saveImage(int index) { QPixmap pixmap; pixmap.loadFromData(downloaders[index]->downloadedData()); + int sdf = pixmap.width(); QImage image = pixmap.toImage(); image = image.convertToFormat(QImage::Format_ARGB32); QString fullPathname = _directoryName + "/" + _filenames[index]; - image.save(fullPathname, 0, 100); + if (!image.save(fullPathname, 0, 100)) { + QMessageBox messageBox; + messageBox.information(0, "Test Aborted", "Failed to save image: " + _filenames[index]); + ui.progressBar->setVisible(false); + return; + } ++_numberOfImagesDownloaded; @@ -109,4 +113,4 @@ void AutoTester::saveImage(int index) { void AutoTester::about() { QMessageBox messageBox; messageBox.information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); -} \ No newline at end of file +} diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 03cb7fbcec..d911b6aaff 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -52,9 +52,9 @@ private: // Used to enable passing a parameter to slots QSignalMapper* signalMapper; - int _numberOfImagesToDownload; - int _numberOfImagesDownloaded; - int _index; + int _numberOfImagesToDownload { 0 }; + int _numberOfImagesDownloaded { 0 }; + int _index { 0 }; }; #endif // hifi_AutoTester_h \ No newline at end of file From 0653f49efe1b2ff75c4f8ad7ef4045d89b2c02f4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 09:31:24 +1200 Subject: [PATCH 038/192] Remove deprecated location.domainId from API location.domainID is available, instead. --- libraries/networking/src/AddressManager.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 94eff46bda..95bf0c18a8 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -36,8 +36,6 @@ const QString GET_PLACE = "/api/v1/places/%1"; * @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not * connected to the domain or are in a serverless domain. * Read-only. - * @property {Uuid} domainId - Synonym for domainId. Read-only. Deprecated: This property - * is deprecated and will soon be removed. * @property {string} hostname - The name of the domain for your current metaverse address (e.g., "AvatarIsland", * localhost, or an IP address). Is blank if you're in a serverless domain. * Read-only. @@ -68,7 +66,6 @@ class AddressManager : public QObject, public Dependency { Q_PROPERTY(QString pathname READ currentPath) Q_PROPERTY(QString placename READ getPlaceName) Q_PROPERTY(QString domainID READ getDomainID) - Q_PROPERTY(QString domainId READ getDomainID) public: using PositionGetter = std::function; using OrientationGetter = std::function; From d1bb37874d0ca832fea0d3d78472ce14b3115ef8 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 30 Apr 2018 17:13:44 -0700 Subject: [PATCH 039/192] Prevent crash in ImageProvider when tablet isn't yet initialized --- interface/src/commerce/Wallet.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 3e0e4adf18..42c8b9973d 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -615,9 +615,12 @@ void Wallet::updateImageProvider() { securityImageProvider->setSecurityImage(_securityImage); // inform tablet security image provider - QQmlEngine* tabletEngine = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")->getTabletSurface()->getSurfaceContext()->engine(); - securityImageProvider = reinterpret_cast(tabletEngine->imageProvider(SecurityImageProvider::PROVIDER_NAME)); - securityImageProvider->setSecurityImage(_securityImage); + auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + if (tablet) { + QQmlEngine* tabletEngine = tablet->getTabletSurface()->getSurfaceContext()->engine(); + securityImageProvider = reinterpret_cast(tabletEngine->imageProvider(SecurityImageProvider::PROVIDER_NAME)); + securityImageProvider->setSecurityImage(_securityImage); + } } void Wallet::chooseSecurityImage(const QString& filename) { From d5f809c3c08730a3016c772a4b710fd8e7b10d85 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 1 May 2018 09:54:23 -0700 Subject: [PATCH 040/192] Actually fix --- interface/src/commerce/Wallet.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 42c8b9973d..35e6ca1c92 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -615,11 +615,14 @@ void Wallet::updateImageProvider() { securityImageProvider->setSecurityImage(_securityImage); // inform tablet security image provider - auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + TabletProxy* tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); if (tablet) { - QQmlEngine* tabletEngine = tablet->getTabletSurface()->getSurfaceContext()->engine(); - securityImageProvider = reinterpret_cast(tabletEngine->imageProvider(SecurityImageProvider::PROVIDER_NAME)); - securityImageProvider->setSecurityImage(_securityImage); + OffscreenQmlSurface* tabletSurface = tablet->getTabletSurface(); + if (tabletSurface) { + QQmlEngine* tabletEngine = tabletSurface->getSurfaceContext()->engine(); + securityImageProvider = reinterpret_cast(tabletEngine->imageProvider(SecurityImageProvider::PROVIDER_NAME)); + securityImageProvider->setSecurityImage(_securityImage); + } } } From a3e4fa84292ab1607ed6cca3a10003ed75825595 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 1 May 2018 15:27:29 -0700 Subject: [PATCH 041/192] Corrected download of images. --- tools/auto-tester/src/Downloader.cpp | 9 +++++++++ tools/auto-tester/src/Test.cpp | 7 +++++-- tools/auto-tester/src/ui/AutoTester.cpp | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/auto-tester/src/Downloader.cpp b/tools/auto-tester/src/Downloader.cpp index 030aa95a19..e66b498bd5 100644 --- a/tools/auto-tester/src/Downloader.cpp +++ b/tools/auto-tester/src/Downloader.cpp @@ -9,6 +9,8 @@ // #include "Downloader.h" +#include + Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { connect( &_networkAccessManager, SIGNAL (finished(QNetworkReply*)), @@ -20,6 +22,13 @@ Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { } void Downloader::fileDownloaded(QNetworkReply* reply) { + QNetworkReply::NetworkError error = reply->error(); + if (error != QNetworkReply::NetworkError::NoError) { + QMessageBox messageBox; + messageBox.information(0, "Test Aborted", "Failed to download image: " + reply->errorString()); + return; + } + _downloadedData = reply->readAll(); //emit a signal diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 57806e80f6..d0a1606cd8 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -221,8 +221,11 @@ void Test::startTestsEvaluation() { QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS); QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png"; - QString imageURLString("https://github.com/" + githubUser + "/hifi_tests/blob/" + gitHubBranch + "/" + - expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename + "?raw=true"); + //https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/content/entity/zone/zoneOrientation/ExpectedImage_00001.png + + + QString imageURLString("https://raw.githubusercontent.com/" + githubUser + "/hifi_tests/" + gitHubBranch + "/" + + expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename); expectedImagesURLs << imageURLString; diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 860868565a..17b1513467 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -86,6 +86,7 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director } void AutoTester::saveImage(int index) { + QByteArray q = downloaders[index]->downloadedData(); QPixmap pixmap; pixmap.loadFromData(downloaders[index]->downloadedData()); From 521ae36cbf9fb2f8dc197e150e2b28c1a78e1f40 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 15:29:22 -0700 Subject: [PATCH 042/192] Make resource swapchains immutable, fix for 14638 --- .../src/gpu/gl/GLBackendOutput.cpp | 4 ++-- .../src/gpu/gl/GLBackendPipeline.cpp | 9 ++++---- libraries/gpu/src/gpu/ResourceSwapChain.h | 19 +++++++---------- .../render-utils/src/AntialiasingEffect.cpp | 21 +++++++++---------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp index 2285b0e486..d1ab34da90 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp @@ -46,10 +46,10 @@ void GLBackend::do_setFramebuffer(const Batch& batch, size_t paramOffset) { } void GLBackend::do_setFramebufferSwapChain(const Batch& batch, size_t paramOffset) { - auto swapChain = batch._swapChains.get(batch._params[paramOffset]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset]._uint)); if (swapChain) { auto index = batch._params[paramOffset + 1]._uint; - FramebufferPointer framebuffer = static_cast(swapChain.get())->get(index); + const auto& framebuffer = swapChain->get(index); setFramebuffer(framebuffer); } } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp index 237b8bc1e9..d5cb331a4a 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp @@ -1,4 +1,4 @@ -// +// // GLBackendPipeline.cpp // libraries/gpu/src/gpu // @@ -263,7 +263,7 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si return; } - SwapChainPointer swapChain = batch._swapChains.get(batch._params[paramOffset + 0]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset + 0]._uint)); if (!swapChain) { releaseResourceTexture(slot); @@ -271,9 +271,8 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si } auto index = batch._params[paramOffset + 2]._uint; auto renderBufferSlot = batch._params[paramOffset + 3]._uint; - FramebufferPointer resourceFramebuffer = static_cast(swapChain.get())->get(index); - TexturePointer resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); - + auto resourceFramebuffer = swapChain->get(index); + auto resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); setResourceTexture(slot, resourceTexture); } diff --git a/libraries/gpu/src/gpu/ResourceSwapChain.h b/libraries/gpu/src/gpu/ResourceSwapChain.h index 7b46b35521..84e8ec7c74 100644 --- a/libraries/gpu/src/gpu/ResourceSwapChain.h +++ b/libraries/gpu/src/gpu/ResourceSwapChain.h @@ -15,18 +15,18 @@ namespace gpu { class SwapChain { public: - SwapChain(unsigned int size = 2U) : _size{ size } {} + SwapChain(size_t size = 2U) : _size{ size } {} virtual ~SwapChain() {} void advance() { _frontIndex = (_frontIndex + 1) % _size; } - unsigned int getSize() const { return _size; } + size_t getSize() const { return _size; } protected: - unsigned int _size; - unsigned int _frontIndex{ 0U }; + const size_t _size; + size_t _frontIndex{ 0U }; }; typedef std::shared_ptr SwapChainPointer; @@ -41,16 +41,13 @@ namespace gpu { using Type = R; using TypePointer = std::shared_ptr; + using TypeConstPointer = std::shared_ptr; - ResourceSwapChain(unsigned int size = 2U) : SwapChain{ size } {} - - void reset() { - for (auto& ptr : _resources) { - ptr.reset(); + ResourceSwapChain(const std::vector& v) : SwapChain{ std::min(v.size(), MAX_SIZE) } { + for (size_t i = 0; i < _size; ++i) { + _resources[i] = v[i]; } } - - TypePointer& edit(unsigned int index) { return _resources[(index + _frontIndex) % _size]; } const TypePointer& get(unsigned int index) const { return _resources[(index + _frontIndex) % _size]; } private: diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index ba5036ad68..357782a321 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -188,7 +188,6 @@ const int AntialiasingPass_NextMapSlot = 4; Antialiasing::Antialiasing() { - _antialiasingBuffers = std::make_shared(2U); } Antialiasing::~Antialiasing() { @@ -317,25 +316,25 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const int width = sourceBuffer->getWidth(); int height = sourceBuffer->getHeight(); - if (_antialiasingBuffers->get(0)) { - if (_antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) {// || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) { - _antialiasingBuffers->edit(0).reset(); - _antialiasingBuffers->edit(1).reset(); - _antialiasingTextures[0].reset(); - _antialiasingTextures[1].reset(); - } + if (_antialiasingBuffers && _antialiasingBuffers->get(0) && _antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) { + _antialiasingBuffers.reset(); + _antialiasingTextures[0].reset(); + _antialiasingTextures[1].reset(); } - if (!_antialiasingBuffers->get(0)) { + + if (!_antialiasingBuffers) { + std::vector antiAliasingBuffers; // Link the antialiasing FBO to texture for (int i = 0; i < 2; i++) { - auto& antiAliasingBuffer = _antialiasingBuffers->edit(i); - antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing")); + antiAliasingBuffers.emplace_back(gpu::Framebuffer::create("antialiasing")); + const auto& antiAliasingBuffer = antiAliasingBuffers.back(); auto format = gpu::Element::COLOR_SRGBA_32; // DependencyManager::get()->getLightingTexture()->getTexelFormat(); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR); _antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler); antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]); } + _antialiasingBuffers = std::make_shared(antiAliasingBuffers); } gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) { From fb929da2280ad3a45c32a41130a5ebeeb31e6160 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 16:54:26 -0700 Subject: [PATCH 043/192] Change type used for swap chain count --- libraries/gpu/src/gpu/ResourceSwapChain.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/gpu/src/gpu/ResourceSwapChain.h b/libraries/gpu/src/gpu/ResourceSwapChain.h index 84e8ec7c74..28c5ff2ed3 100644 --- a/libraries/gpu/src/gpu/ResourceSwapChain.h +++ b/libraries/gpu/src/gpu/ResourceSwapChain.h @@ -15,18 +15,18 @@ namespace gpu { class SwapChain { public: - SwapChain(size_t size = 2U) : _size{ size } {} + SwapChain(uint8_t size = 2U) : _size{ size } {} virtual ~SwapChain() {} void advance() { _frontIndex = (_frontIndex + 1) % _size; } - size_t getSize() const { return _size; } + uint8_t getSize() const { return _size; } protected: - const size_t _size; - size_t _frontIndex{ 0U }; + const uint8_t _size; + uint8_t _frontIndex{ 0U }; }; typedef std::shared_ptr SwapChainPointer; @@ -43,7 +43,7 @@ namespace gpu { using TypePointer = std::shared_ptr; using TypeConstPointer = std::shared_ptr; - ResourceSwapChain(const std::vector& v) : SwapChain{ std::min(v.size(), MAX_SIZE) } { + ResourceSwapChain(const std::vector& v) : SwapChain{ std::min((uint8_t)v.size(), MAX_SIZE) } { for (size_t i = 0; i < _size; ++i) { _resources[i] = v[i]; } From 93afbcdc08f42f68e4c0f9417279bd012f69643f Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 1 May 2018 17:59:07 -0700 Subject: [PATCH 044/192] First success with running from command line. --- tools/auto-tester/src/Test.cpp | 53 ++++++++++++++----------- tools/auto-tester/src/Test.h | 29 +++++++------- tools/auto-tester/src/main.cpp | 15 ++++++- tools/auto-tester/src/ui/AutoTester.cpp | 12 ++++-- tools/auto-tester/src/ui/AutoTester.h | 5 +++ 5 files changed, 70 insertions(+), 44 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index d0a1606cd8..7139f0a43c 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -27,7 +27,7 @@ Test::Test() { mismatchWindow.setModal(true); } -bool Test::createTestResultsFolderPath(QString directory) { +bool Test::createTestResultsFolderPath(const QString& directory) { QDateTime now = QDateTime::currentDateTime(); testResultsFolderPath = directory + "/" + TEST_RESULTS_FOLDER + "--" + now.toString(DATETIME_FORMAT); QDir testResultsFolder(testResultsFolderPath); @@ -125,7 +125,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) return success; } -void Test::appendTestResultsToFile(QString testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage) { +void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage) { if (!QDir().exists(testResultsFolderPath)) { messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Folder " + testResultsFolderPath + " not found"); exit(-1); @@ -174,10 +174,16 @@ void Test::appendTestResultsToFile(QString testResultsFolderPath, TestFailure te comparisonImage.save(failureFolderPath + "/" + "Difference Image.jpg"); } -void Test::startTestsEvaluation() { - // Get list of JPEG images in folder, sorted by name - pathToTestResultsDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly); - if (pathToTestResultsDirectory == "") { +void Test::startTestsEvaluation(const QString& testFolder) { + QString pathToTestResultsDirectory; + if (testFolder.isNull()) { + // Get list of JPEG images in folder, sorted by name + pathToTestResultsDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly); + } else { + pathToTestResultsDirectory = testFolder; + } + + if (pathToTestResultsDirectory == QString()) { return; } @@ -221,9 +227,6 @@ void Test::startTestsEvaluation() { QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS); QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png"; - //https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/content/entity/zone/zoneOrientation/ExpectedImage_00001.png - - QString imageURLString("https://raw.githubusercontent.com/" + githubUser + "/hifi_tests/" + gitHubBranch + "/" + expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename); @@ -240,19 +243,21 @@ void Test::startTestsEvaluation() { autoTester->downloadImages(expectedImagesURLs, pathToTestResultsDirectory, expectedImagesFilenames); } -void Test::finishTestsEvaluation(bool interactiveMode, QProgressBar* progressBar) { - bool success = compareImageLists(interactiveMode, progressBar); +void Test::finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar) { + bool success = compareImageLists((!isRunningFromCommandline && interactiveMode), progressBar); - if (success) { - messageBox.information(0, "Success", "All images are as expected"); - } else { - messageBox.information(0, "Failure", "One or more images are not as expected"); + if (!isRunningFromCommandline) { + if (success) { + messageBox.information(0, "Success", "All images are as expected"); + } else { + messageBox.information(0, "Failure", "One or more images are not as expected"); + } } zipAndDeleteTestResultsFolder(); } -bool Test::isAValidDirectory(QString pathname) { +bool Test::isAValidDirectory(const QString& pathname) { // Only process directories QDir dir(pathname); if (!dir.exists()) { @@ -267,7 +272,7 @@ bool Test::isAValidDirectory(QString pathname) { return true; } -QString Test::extractPathFromTestsDown(QString fullPath) { +QString Test::extractPathFromTestsDown(const QString& fullPath) { // `fullPath` includes the full path to the test. We need the portion below (and including) `tests` QStringList pathParts = fullPath.split('/'); int i{ 0 }; @@ -348,7 +353,7 @@ void Test::createAllRecursiveScripts() { messageBox.information(0, "Success", "Scripts have been created"); } -void Test::createRecursiveScript(QString topLevelDirectory, bool interactiveMode) { +void Test::createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode) { const QString recursiveTestsFilename("testRecursive.js"); QFile allTestsFilename(topLevelDirectory + "/" + recursiveTestsFilename); if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -615,7 +620,7 @@ void Test::createAllMDFiles() { messageBox.information(0, "Success", "MD files have been created"); } -void Test::createMDFile(QString testDirectory) { +void Test::createMDFile(const QString& testDirectory) { // Verify folder contains test.js file QString testFileName(testDirectory + "/" + TEST_FILENAME); QFileInfo testFileInfo(testFileName); @@ -790,7 +795,7 @@ void Test::createTestsOutline() { messageBox.information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created"); } -void Test::copyJPGtoPNG(QString sourceJPGFullFilename, QString destinationPNGFullFilename) { +void Test::copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename) { QFile::remove(destinationPNGFullFilename); QImageReader reader; @@ -803,7 +808,7 @@ void Test::copyJPGtoPNG(QString sourceJPGFullFilename, QString destinationPNGFul writer.write(image); } -QStringList Test::createListOfAll_imagesInDirectory(QString imageFormat, QString pathToImageDirectory) { +QStringList Test::createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory) { imageDirectory = QDir(pathToImageDirectory); QStringList nameFilters; nameFilters << "*." + imageFormat; @@ -816,7 +821,7 @@ QStringList Test::createListOfAll_imagesInDirectory(QString imageFormat, QString // Filename (i.e. without extension) contains _tests_ (this is based on all test scripts being within the tests folder // Last 5 characters in filename are digits // Extension is jpg -bool Test::isInSnapshotFilenameFormat(QString imageFormat, QString filename) { +bool Test::isInSnapshotFilenameFormat(const QString& imageFormat, const QString& filename) { QStringList filenameParts = filename.split("."); bool filnameHasNoPeriods = (filenameParts.size() == 2); @@ -833,7 +838,7 @@ bool Test::isInSnapshotFilenameFormat(QString imageFormat, QString filename) { // For a file named "D_GitHub_hifi-tests_tests_content_entity_zone_create_0.jpg", the test directory is // D:/GitHub/hifi-tests/tests/content/entity/zone/create // This method assumes the filename is in the correct format -QString Test::getExpectedImageDestinationDirectory(QString filename) { +QString Test::getExpectedImageDestinationDirectory(const QString& filename) { QString filenameWithoutExtension = filename.split(".")[0]; QStringList filenameParts = filenameWithoutExtension.split("_"); @@ -850,7 +855,7 @@ QString Test::getExpectedImageDestinationDirectory(QString filename) { // is ...tests/content/entity/zone/create // This is used to create the full URL // This method assumes the filename is in the correct format -QString Test::getExpectedImagePartialSourceDirectory(QString filename) { +QString Test::getExpectedImagePartialSourceDirectory(const QString& filename) { QString filenameWithoutExtension = filename.split(".")[0]; QStringList filenameParts = filenameWithoutExtension.split("_"); diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 7f5553f9e3..02cab53381 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -43,39 +43,39 @@ class Test { public: Test(); - void startTestsEvaluation(); - void finishTestsEvaluation(bool interactiveMode, QProgressBar* progressBar); + void startTestsEvaluation(const QString& testFolder = QString()); + void finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar); void createRecursiveScript(); void createAllRecursiveScripts(); - void createRecursiveScript(QString topLevelDirectory, bool interactiveMode); + void createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode); void createTest(); void createMDFile(); void createAllMDFiles(); - void createMDFile(QString topLevelDirectory); + void createMDFile(const QString& topLevelDirectory); void createTestsOutline(); bool compareImageLists(bool isInteractiveMode, QProgressBar* progressBar); - QStringList createListOfAll_imagesInDirectory(QString imageFormat, QString pathToImageDirectory); + QStringList createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory); - bool isInSnapshotFilenameFormat(QString imageFormat, QString filename); + bool isInSnapshotFilenameFormat(const QString& imageFormat, const QString& filename); void importTest(QTextStream& textStream, const QString& testPathname); - void appendTestResultsToFile(QString testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage); + void appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage); - bool createTestResultsFolderPath(QString directory); + bool createTestResultsFolderPath(const QString& directory); void zipAndDeleteTestResultsFolder(); - bool isAValidDirectory(QString pathname); - QString extractPathFromTestsDown(QString fullPath); - QString getExpectedImageDestinationDirectory(QString filename); - QString getExpectedImagePartialSourceDirectory(QString filename); + bool isAValidDirectory(const QString& pathname); + QString extractPathFromTestsDown(const QString& fullPath); + QString getExpectedImageDestinationDirectory(const QString& filename); + QString getExpectedImagePartialSourceDirectory(const QString& filename); - void copyJPGtoPNG(QString sourceJPGFullFilename, QString destinationPNGFullFilename); + void copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename); private: const QString TEST_FILENAME { "test.js" }; @@ -90,14 +90,13 @@ private: ImageComparer imageComparer; - QString testResultsFolderPath { "" }; + QString testResultsFolderPath; int index { 1 }; // Expected images are in the format ExpectedImage_dddd.jpg (d == decimal digit) const int NUM_DIGITS { 5 }; const QString EXPECTED_IMAGE_PREFIX { "ExpectedImage_" }; - QString pathToTestResultsDirectory; QStringList expectedImagesFilenames; QStringList expectedImagesFullFilenames; QStringList resultImagesFullFilenames; diff --git a/tools/auto-tester/src/main.cpp b/tools/auto-tester/src/main.cpp index cd0ce22b13..ffa7a0b237 100644 --- a/tools/auto-tester/src/main.cpp +++ b/tools/auto-tester/src/main.cpp @@ -13,10 +13,23 @@ AutoTester* autoTester; int main(int argc, char *argv[]) { + // Only parameter is "--testFolder" + QString testFolder; + if (argc == 3) { + if (QString(argv[1]) == "--testFolder") { + testFolder = QString(argv[2]); + } + } + QApplication application(argc, argv); autoTester = new AutoTester(); - autoTester->show(); + + if (!testFolder.isNull()) { + autoTester->runFromCommandLine(testFolder); + } else { + autoTester->show(); + } return application.exec(); } diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 17b1513467..e0f92664ef 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -15,12 +15,17 @@ AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { ui.checkBoxInteractiveMode->setChecked(true); ui.progressBar->setVisible(false); - test = new Test(); - signalMapper = new QSignalMapper(); connect(ui.actionClose, &QAction::triggered, this, &AutoTester::on_closeButton_clicked); connect(ui.actionAbout, &QAction::triggered, this, &AutoTester::about); + + test = new Test(); +} + +void AutoTester::runFromCommandLine(const QString& testFolder) { + isRunningFromCommandline = true; + test->startTestsEvaluation(testFolder); } void AutoTester::on_evaluateTestsButton_clicked() { @@ -86,7 +91,6 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director } void AutoTester::saveImage(int index) { - QByteArray q = downloaders[index]->downloadedData(); QPixmap pixmap; pixmap.loadFromData(downloaders[index]->downloadedData()); @@ -105,7 +109,7 @@ void AutoTester::saveImage(int index) { ++_numberOfImagesDownloaded; if (_numberOfImagesDownloaded == _numberOfImagesToDownload) { - test->finishTestsEvaluation(ui.checkBoxInteractiveMode->isChecked(), ui.progressBar); + test->finishTestsEvaluation(isRunningFromCommandline, ui.checkBoxInteractiveMode->isChecked(), ui.progressBar); } else { ui.progressBar->setValue(_numberOfImagesDownloaded); } diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index d911b6aaff..fe37f2298d 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -22,6 +22,9 @@ class AutoTester : public QMainWindow { public: AutoTester(QWidget *parent = Q_NULLPTR); + + void runFromCommandLine(const QString& testFolder); + void downloadImage(const QUrl& url); void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); @@ -55,6 +58,8 @@ private: int _numberOfImagesToDownload { 0 }; int _numberOfImagesDownloaded { 0 }; int _index { 0 }; + + bool isRunningFromCommandline { false }; }; #endif // hifi_AutoTester_h \ No newline at end of file From 49fad3d8685dc7a5d430b27574ee4b7525d0c7d8 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 13 Apr 2018 18:01:54 -0700 Subject: [PATCH 045/192] EntityServer traversal aware of all ViewFrustums --- .../src/entities/EntityPriorityQueue.cpp | 23 +++- .../src/entities/EntityPriorityQueue.h | 16 ++- .../src/entities/EntityTreeSendThread.cpp | 100 +++++++-------- .../src/entities/EntityTreeSendThread.h | 3 +- .../src/octree/OctreeHeadlessViewer.cpp | 9 +- .../src/octree/OctreeSendThread.cpp | 6 +- .../src/scripts/EntityScriptServer.cpp | 1 - interface/src/Application.cpp | 10 +- libraries/entities/src/DiffTraversal.cpp | 121 +++++++++++++----- libraries/entities/src/DiffTraversal.h | 20 +-- libraries/octree/src/Octree.h | 1 - libraries/octree/src/OctreeQuery.cpp | 107 +++++++--------- libraries/octree/src/OctreeQuery.h | 63 +++------ libraries/octree/src/OctreeQueryNode.cpp | 111 +++++++--------- libraries/octree/src/OctreeQueryNode.h | 9 +- libraries/octree/src/OctreeUtils.cpp | 9 +- libraries/octree/src/OctreeUtils.h | 3 + libraries/shared/src/ViewFrustum.cpp | 4 +- libraries/shared/src/ViewFrustum.h | 2 +- 19 files changed, 322 insertions(+), 296 deletions(-) diff --git a/assignment-client/src/entities/EntityPriorityQueue.cpp b/assignment-client/src/entities/EntityPriorityQueue.cpp index 999a05f2e2..a38d537649 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.cpp +++ b/assignment-client/src/entities/EntityPriorityQueue.cpp @@ -15,7 +15,7 @@ const float PrioritizedEntity::DO_NOT_SEND = -1.0e-6f; const float PrioritizedEntity::FORCE_REMOVE = -1.0e-5f; const float PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY = 1.0f; -void ConicalView::set(const ViewFrustum& viewFrustum) { +void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) { // The ConicalView has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part. // Why? Because approximate intersection tests are much faster to compute for a cone than for a frustum. _position = viewFrustum.getPosition(); @@ -31,7 +31,7 @@ void ConicalView::set(const ViewFrustum& viewFrustum) { _radius = viewFrustum.getCenterRadius(); } -float ConicalView::computePriority(const AACube& cube) const { +float ConicalViewFrustum::computePriority(const AACube& cube) const { glm::vec3 p = cube.calcCenter() - _position; // position of bounding sphere in view-frame float d = glm::length(p); // distance to center of bounding sphere float r = 0.5f * cube.getScale(); // radius of bounding sphere @@ -51,3 +51,22 @@ float ConicalView::computePriority(const AACube& cube) const { } return PrioritizedEntity::DO_NOT_SEND; } + + +void ConicalView::set(const DiffTraversal::View& view) { + auto size = view.viewFrustums.size(); + _conicalViewFrustums.resize(size); + for (size_t i = 0; i < size; ++i) { + _conicalViewFrustums[i].set(view.viewFrustums[i]); + } +} + +float ConicalView::computePriority(const AACube& cube) const { + float priority = PrioritizedEntity::DO_NOT_SEND; + + for (const auto& view : _conicalViewFrustums) { + priority = std::max(priority, view.computePriority(cube)); + } + + return priority; +} diff --git a/assignment-client/src/entities/EntityPriorityQueue.h b/assignment-client/src/entities/EntityPriorityQueue.h index e308d9b549..4068b4dc4b 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.h +++ b/assignment-client/src/entities/EntityPriorityQueue.h @@ -15,16 +15,17 @@ #include #include +#include #include const float SQRT_TWO_OVER_TWO = 0.7071067811865f; const float DEFAULT_VIEW_RADIUS = 10.0f; // ConicalView is an approximation of a ViewFrustum for fast calculation of sort priority. -class ConicalView { +class ConicalViewFrustum { public: - ConicalView() {} - ConicalView(const ViewFrustum& viewFrustum) { set(viewFrustum); } + ConicalViewFrustum() {} + ConicalViewFrustum(const ViewFrustum& viewFrustum) { set(viewFrustum); } void set(const ViewFrustum& viewFrustum); float computePriority(const AACube& cube) const; private: @@ -35,6 +36,15 @@ private: float _radius { DEFAULT_VIEW_RADIUS }; }; +class ConicalView { +public: + ConicalView() {} + void set(const DiffTraversal::View& view); + float computePriority(const AACube& cube) const; +private: + std::vector _conicalViewFrustums; +}; + // PrioritizedEntity is a placeholder in a sorted queue. class PrioritizedEntity { public: diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index 4aa52922c0..d14d31bd09 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -103,11 +103,25 @@ void EntityTreeSendThread::preDistributionProcessing() { void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, OctreeQueryNode* nodeData, bool viewFrustumChanged, bool isFullScene) { if (viewFrustumChanged || _traversal.finished()) { - ViewFrustum viewFrustum; - nodeData->copyCurrentViewFrustum(viewFrustum); EntityTreeElementPointer root = std::dynamic_pointer_cast(_myServer->getOctree()->getRoot()); + + + DiffTraversal::View newView; + + ViewFrustum viewFrustum; + if (nodeData->hasMainViewFrustum()) { + nodeData->copyCurrentMainViewFrustum(viewFrustum); + newView.viewFrustums.push_back(viewFrustum); + } + if (nodeData->hasSecondaryViewFrustum()) { + nodeData->copyCurrentSecondaryViewFrustum(viewFrustum); + newView.viewFrustums.push_back(viewFrustum); + } + int32_t lodLevelOffset = nodeData->getBoundaryLevelAdjust() + (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST); - startNewTraversal(viewFrustum, root, lodLevelOffset, nodeData->getUsesFrustum()); + newView.lodScaleFactor = powf(2.0f, lodLevelOffset); + + startNewTraversal(newView, root); // When the viewFrustum changed the sort order may be incorrect, so we re-sort // and also use the opportunity to cull anything no longer in view @@ -116,8 +130,6 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O _sendQueue.swap(prevSendQueue); _entitiesInQueue.clear(); // Re-add elements from previous traversal if they still need to be sent - float lodScaleFactor = _traversal.getCurrentLODScaleFactor(); - glm::vec3 viewPosition = _traversal.getCurrentView().getPosition(); while (!prevSendQueue.empty()) { EntityItemPointer entity = prevSendQueue.top().getEntity(); bool forceRemove = prevSendQueue.top().shouldForceRemove(); @@ -127,12 +139,10 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { + if (_traversal.getCurrentView().intersects(cube)) { float priority = _conicalView.computePriority(cube); if (priority != PrioritizedEntity::DO_NOT_SEND) { - float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE; - float angularDiameter = cube.getScale() / distance; - if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) { + if (_traversal.getCurrentView().isBigEnough(cube)) { _sendQueue.push(PrioritizedEntity(entity, priority)); _entitiesInQueue.insert(entity.get()); } @@ -215,10 +225,9 @@ bool EntityTreeSendThread::addDescendantsToExtraFlaggedEntities(const QUuid& fil return hasNewChild || hasNewDescendants; } -void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTreeElementPointer root, int32_t lodLevelOffset, - bool usesViewFrustum) { +void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) { - DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root, lodLevelOffset, usesViewFrustum); + DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root); // there are three types of traversal: // // (1) FirstTime = at login --> find everything in view @@ -236,11 +245,9 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree case DiffTraversal::First: // When we get to a First traversal, clear the _knownState _knownState.clear(); - if (usesViewFrustum) { - float lodScaleFactor = _traversal.getCurrentLODScaleFactor(); - glm::vec3 viewPosition = _traversal.getCurrentView().getPosition(); - _traversal.setScanCallback([=](DiffTraversal::VisibleElement& next) { - next.element->forEachEntity([=](EntityItemPointer entity) { + if (view.usesViewFrustums()) { + _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { + next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; @@ -248,14 +255,12 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { + if (_traversal.getCurrentView().intersects(cube)) { // Check the size of the entity, it's possible that a "too small to see" entity is included in a // larger octree cell because of its position (for example if it crosses the boundary of a cell it // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen // before we consider including it. - float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE; - float angularDiameter = cube.getScale() / distance; - if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) { + if (_traversal.getCurrentView().isBigEnough(cube)) { float priority = _conicalView.computePriority(cube); _sendQueue.push(PrioritizedEntity(entity, priority)); _entitiesInQueue.insert(entity.get()); @@ -269,7 +274,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree }); } else { _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { - next.element->forEachEntity([this](EntityItemPointer entity) { + next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; @@ -281,13 +286,11 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree } break; case DiffTraversal::Repeat: - if (usesViewFrustum) { - float lodScaleFactor = _traversal.getCurrentLODScaleFactor(); - glm::vec3 viewPosition = _traversal.getCurrentView().getPosition(); - _traversal.setScanCallback([=](DiffTraversal::VisibleElement& next) { + if (view.usesViewFrustums()) { + _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal(); if (next.element->getLastChangedContent() > startOfCompletedTraversal) { - next.element->forEachEntity([=](EntityItemPointer entity) { + next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; @@ -297,11 +300,10 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (next.intersection == ViewFrustum::INSIDE || _traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { + if (next.intersection == ViewFrustum::INSIDE || + _traversal.getCurrentView().intersects(cube)) { // See the DiffTraversal::First case for an explanation of the "entity is too small" check - float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE; - float angularDiameter = cube.getScale() / distance; - if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) { + if (_traversal.getCurrentView().isBigEnough(cube)) { float priority = _conicalView.computePriority(cube); _sendQueue.push(PrioritizedEntity(entity, priority)); _entitiesInQueue.insert(entity.get()); @@ -325,7 +327,7 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal(); if (next.element->getLastChangedContent() > startOfCompletedTraversal) { - next.element->forEachEntity([this](EntityItemPointer entity) { + next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; @@ -343,13 +345,9 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree } break; case DiffTraversal::Differential: - assert(usesViewFrustum); - float lodScaleFactor = _traversal.getCurrentLODScaleFactor(); - glm::vec3 viewPosition = _traversal.getCurrentView().getPosition(); - float completedLODScaleFactor = _traversal.getCompletedLODScaleFactor(); - glm::vec3 completedViewPosition = _traversal.getCompletedView().getPosition(); - _traversal.setScanCallback([=] (DiffTraversal::VisibleElement& next) { - next.element->forEachEntity([=](EntityItemPointer entity) { + assert(view.usesViewFrustums()); + _traversal.setScanCallback([this] (DiffTraversal::VisibleElement& next) { + next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; @@ -359,25 +357,19 @@ void EntityTreeSendThread::startNewTraversal(const ViewFrustum& view, EntityTree bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { + if (_traversal.getCurrentView().intersects(cube)) { // See the DiffTraversal::First case for an explanation of the "entity is too small" check - float distance = glm::distance(cube.calcCenter(), viewPosition) + MIN_VISIBLE_DISTANCE; - float angularDiameter = cube.getScale() / distance; - if (angularDiameter > MIN_ENTITY_ANGULAR_DIAMETER * lodScaleFactor) { - if (!_traversal.getCompletedView().cubeIntersectsKeyhole(cube)) { + if (_traversal.getCurrentView().isBigEnough(cube)) { + if (!_traversal.getCompletedView().intersects(cube)) { float priority = _conicalView.computePriority(cube); _sendQueue.push(PrioritizedEntity(entity, priority)); _entitiesInQueue.insert(entity.get()); - } else { + } else if (!_traversal.getCompletedView().isBigEnough(cube)) { // If this entity was skipped last time because it was too small, we still need to send it - distance = glm::distance(cube.calcCenter(), completedViewPosition) + MIN_VISIBLE_DISTANCE; - angularDiameter = cube.getScale() / distance; - if (angularDiameter <= MIN_ENTITY_ANGULAR_DIAMETER * completedLODScaleFactor) { - // this object was skipped in last completed traversal - float priority = _conicalView.computePriority(cube); - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); - } + // this object was skipped in last completed traversal + float priority = _conicalView.computePriority(cube); + _sendQueue.push(PrioritizedEntity(entity, priority)); + _entitiesInQueue.insert(entity.get()); } } } @@ -506,7 +498,7 @@ void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer& entity) AACube cube = entity->getQueryAACube(success); if (success) { // We can force a removal from _knownState if the current view is used and entity is out of view - if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().cubeIntersectsKeyhole(cube)) { + if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().intersects(cube)) { _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::FORCE_REMOVE, true)); _entitiesInQueue.insert(entity.get()); } diff --git a/assignment-client/src/entities/EntityTreeSendThread.h b/assignment-client/src/entities/EntityTreeSendThread.h index 1e2bd15429..5ea723c8b2 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.h +++ b/assignment-client/src/entities/EntityTreeSendThread.h @@ -41,8 +41,7 @@ private: bool addAncestorsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData); bool addDescendantsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData); - void startNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root, int32_t lodLevelOffset, - bool usesViewFrustum); + void startNewTraversal(const DiffTraversal::View& viewFrustum, EntityTreeElementPointer root); bool traverseTreeAndBuildNextPacketPayload(EncodeBitstreamParams& params, const QJsonObject& jsonFilters) override; void preDistributionProcessing() override; diff --git a/assignment-client/src/octree/OctreeHeadlessViewer.cpp b/assignment-client/src/octree/OctreeHeadlessViewer.cpp index d3b20fb623..4f022ae838 100644 --- a/assignment-client/src/octree/OctreeHeadlessViewer.cpp +++ b/assignment-client/src/octree/OctreeHeadlessViewer.cpp @@ -23,14 +23,7 @@ void OctreeHeadlessViewer::queryOctree() { char serverType = getMyNodeType(); PacketType packetType = getMyQueryMessageType(); - _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); - _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); - _octreeQuery.setCameraFov(_viewFrustum.getFieldOfView()); - _octreeQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio()); - _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); - _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); - _octreeQuery.setCameraEyeOffsetPosition(glm::vec3()); - _octreeQuery.setCameraCenterRadius(_viewFrustum.getCenterRadius()); + _octreeQuery.setMainViewFrustum(_viewFrustum); _octreeQuery.setOctreeSizeScale(_voxelSizeScale); _octreeQuery.setBoundaryLevelAdjust(_boundaryLevelAdjust); diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index de49bd461c..40c052659d 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -330,8 +330,9 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode* } else { // we aren't forcing a full scene, check if something else suggests we should isFullScene = nodeData->haveJSONParametersChanged() || - (nodeData->getUsesFrustum() - && ((!viewFrustumChanged && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged())); + (nodeData->hasMainViewFrustum() && + (nodeData->getViewFrustumJustStoppedChanging() || + nodeData->hasLodChanged())); } if (nodeData->isPacketWaiting()) { @@ -445,7 +446,6 @@ void OctreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, Octre params.trackSend = [this](const QUuid& dataID, quint64 dataEdited) { _myServer->trackSend(dataID, dataEdited, _nodeUuid); }; - nodeData->copyCurrentViewFrustum(params.viewFrustum); bool somethingToSend = true; // assume we have something bool hadSomething = hasSomethingToSend(nodeData); diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index d242b393bf..eea8e8b470 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -294,7 +294,6 @@ void EntityScriptServer::run() { queryJSONParameters[EntityJSONQueryProperties::FLAGS_PROPERTY] = queryFlags; // setup the JSON parameters so that OctreeQuery does not use a frustum and uses our JSON filter - _entityViewer.getOctreeQuery().setUsesFrustum(false); _entityViewer.getOctreeQuery().setJSONParameters(queryJSONParameters); entityScriptingInterface->setEntityTree(_entityViewer.getTree()); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cd4562da54..d1d44aa706 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5791,14 +5791,8 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) { ViewFrustum viewFrustum; copyViewFrustum(viewFrustum); - _octreeQuery.setCameraPosition(viewFrustum.getPosition()); - _octreeQuery.setCameraOrientation(viewFrustum.getOrientation()); - _octreeQuery.setCameraFov(viewFrustum.getFieldOfView()); - _octreeQuery.setCameraAspectRatio(viewFrustum.getAspectRatio()); - _octreeQuery.setCameraNearClip(viewFrustum.getNearClip()); - _octreeQuery.setCameraFarClip(viewFrustum.getFarClip()); - _octreeQuery.setCameraEyeOffsetPosition(glm::vec3()); - _octreeQuery.setCameraCenterRadius(viewFrustum.getCenterRadius()); + _octreeQuery.setMainViewFrustum(viewFrustum); + auto lodManager = DependencyManager::get(); _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale()); _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust()); diff --git a/libraries/entities/src/DiffTraversal.cpp b/libraries/entities/src/DiffTraversal.cpp index 764c420197..11f37728df 100644 --- a/libraries/entities/src/DiffTraversal.cpp +++ b/libraries/entities/src/DiffTraversal.cpp @@ -37,15 +37,14 @@ void DiffTraversal::Waypoint::getNextVisibleElementFirstTime(DiffTraversal::Visi EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; if (nextElement) { - if (!view.usesViewFrustum) { + const auto& cube = nextElement->getAACube(); + if (!view.usesViewFrustums()) { // No LOD truncation if we aren't using the view frustum next.element = nextElement; return; - } else if (view.viewFrustum.cubeIntersectsKeyhole(nextElement->getAACube())) { + } else if (view.intersects(cube)) { // check for LOD truncation - float distance = glm::distance(view.viewFrustum.getPosition(), nextElement->getAACube().calcCenter()) + MIN_VISIBLE_DISTANCE; - float angularDiameter = nextElement->getAACube().getScale() / distance; - if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) { + if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { next.element = nextElement; return; } @@ -76,17 +75,16 @@ void DiffTraversal::Waypoint::getNextVisibleElementRepeat( EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; if (nextElement && nextElement->getLastChanged() > lastTime) { - if (!view.usesViewFrustum) { + if (!view.usesViewFrustums()) { // No LOD truncation if we aren't using the view frustum next.element = nextElement; next.intersection = ViewFrustum::INSIDE; return; } else { // check for LOD truncation - float distance = glm::distance(view.viewFrustum.getPosition(), nextElement->getAACube().calcCenter()) + MIN_VISIBLE_DISTANCE; - float angularDiameter = nextElement->getAACube().getScale() / distance; - if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) { - ViewFrustum::intersection intersection = view.viewFrustum.calculateCubeKeyholeIntersection(nextElement->getAACube()); + const auto& cube = nextElement->getAACube(); + if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { + ViewFrustum::intersection intersection = view.calculateIntersection(cube); if (intersection != ViewFrustum::OUTSIDE) { next.element = nextElement; next.intersection = intersection; @@ -118,14 +116,13 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; if (nextElement) { - AACube cube = nextElement->getAACube(); // check for LOD truncation - float distance = glm::distance(view.viewFrustum.getPosition(), cube.calcCenter()) + MIN_VISIBLE_DISTANCE; - float angularDiameter = cube.getScale() / distance; - if (angularDiameter > MIN_ELEMENT_ANGULAR_DIAMETER * view.lodScaleFactor) { - if (view.viewFrustum.calculateCubeKeyholeIntersection(cube) != ViewFrustum::OUTSIDE) { + const auto& cube = nextElement->getAACube(); + if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { + ViewFrustum::intersection intersection = view.calculateIntersection(cube); + if (intersection != ViewFrustum::OUTSIDE) { next.element = nextElement; - next.intersection = ViewFrustum::OUTSIDE; + next.intersection = intersection; return; } } @@ -137,13 +134,83 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V next.intersection = ViewFrustum::OUTSIDE; } +bool DiffTraversal::View::isBigEnough(const AACube& cube, float minDiameter) const { + if (viewFrustums.empty()) { + // Everything is big enough when not using view frustums + return true; + } + + for (const auto& viewFrustum : viewFrustums) { + if (isAngularSizeBigEnough(viewFrustum.getPosition(), cube, lodScaleFactor, minDiameter)) { + return true; + } + } + return false; +} + +bool DiffTraversal::View::intersects(const AACube& cube) const { + if (viewFrustums.empty()) { + // Everything intersects when not using view frustums + return true; + } + + for (const auto& viewFrustum : viewFrustums) { + if (viewFrustum.cubeIntersectsKeyhole(cube)) { + return true; + } + } + return false; +} + +ViewFrustum::intersection DiffTraversal::View::calculateIntersection(const AACube& cube) const { + if (viewFrustums.empty()) { + // Everything is inside when not using view frustums + return ViewFrustum::INSIDE; + } + + ViewFrustum::intersection intersection = ViewFrustum::OUTSIDE; + + for (const auto& viewFrustum : viewFrustums) { + switch (viewFrustum.calculateCubeKeyholeIntersection(cube)) { + case ViewFrustum::INSIDE: + return ViewFrustum::INSIDE; + case ViewFrustum::INTERSECT: + intersection = ViewFrustum::INTERSECT; + break; + default: + // DO NOTHING + break; + } + } + return intersection; +} + +bool DiffTraversal::View::usesViewFrustums() const { + return !viewFrustums.empty(); +} + +bool DiffTraversal::View::isVerySimilar(const View& view) const { + auto size = view.viewFrustums.size(); + + if (view.lodScaleFactor != lodScaleFactor || + viewFrustums.size() != size) { + return false; + } + + for (size_t i = 0; i < size; ++i) { + if (!viewFrustums[i].isVerySimilar(view.viewFrustums[i])) { + return false; + } + } + return true; +} + DiffTraversal::DiffTraversal() { const int32_t MIN_PATH_DEPTH = 16; _path.reserve(MIN_PATH_DEPTH); } -DiffTraversal::Type DiffTraversal::prepareNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root, - int32_t lodLevelOffset, bool usesViewFrustum) { +DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) { assert(root); // there are three types of traversal: // @@ -155,33 +222,29 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const ViewFrustum& viewFr // // _getNextVisibleElementCallback = identifies elements that need to be traversed, // updates VisibleElement ref argument with pointer-to-element and view-intersection - // (INSIDE, INTERSECT, or OUTSIDE) + // (INSIDE, INTERSECtT, or OUTSIDE) // // external code should update the _scanElementCallback after calling prepareNewTraversal // - _currentView.usesViewFrustum = usesViewFrustum; - float lodScaleFactor = powf(2.0f, lodLevelOffset); Type type; // If usesViewFrustum changes, treat it as a First traversal - if (_completedView.startTime == 0 || _currentView.usesViewFrustum != _completedView.usesViewFrustum) { + if (_completedView.startTime == 0 || _currentView.usesViewFrustums() != _completedView.usesViewFrustums()) { type = Type::First; - _currentView.viewFrustum = viewFrustum; - _currentView.lodScaleFactor = lodScaleFactor; + _currentView.viewFrustums = std::move(view.viewFrustums); + _currentView.lodScaleFactor = view.lodScaleFactor; _getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) { _path.back().getNextVisibleElementFirstTime(next, _currentView); }; - } else if (!_currentView.usesViewFrustum || - (_completedView.viewFrustum.isVerySimilar(viewFrustum) && - lodScaleFactor == _completedView.lodScaleFactor)) { + } else if (!_currentView.usesViewFrustums() || _completedView.isVerySimilar(view)) { type = Type::Repeat; _getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) { _path.back().getNextVisibleElementRepeat(next, _completedView, _completedView.startTime); }; } else { type = Type::Differential; - _currentView.viewFrustum = viewFrustum; - _currentView.lodScaleFactor = lodScaleFactor; + _currentView.viewFrustums = std::move(view.viewFrustums); + _currentView.lodScaleFactor = view.lodScaleFactor; _getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) { _path.back().getNextVisibleElementDifferential(next, _currentView, _completedView); }; diff --git a/libraries/entities/src/DiffTraversal.h b/libraries/entities/src/DiffTraversal.h index 69431d8db5..50fe74a75b 100644 --- a/libraries/entities/src/DiffTraversal.h +++ b/libraries/entities/src/DiffTraversal.h @@ -30,10 +30,15 @@ public: // View is a struct with a ViewFrustum and LOD parameters class View { public: - ViewFrustum viewFrustum; + bool isBigEnough(const AACube& cube, float minDiameter = MIN_ENTITY_ANGULAR_DIAMETER) const; + bool intersects(const AACube& cube) const; + bool usesViewFrustums() const; + bool isVerySimilar(const View& view) const; + ViewFrustum::intersection calculateIntersection(const AACube& cube) const; + + std::vector viewFrustums; uint64_t startTime { 0 }; float lodScaleFactor { 1.0f }; - bool usesViewFrustum { true }; }; // Waypoint is an bookmark in a "path" of waypoints during a traversal. @@ -57,15 +62,12 @@ public: DiffTraversal(); - Type prepareNewTraversal(const ViewFrustum& viewFrustum, EntityTreeElementPointer root, int32_t lodLevelOffset, - bool usesViewFrustum); + Type prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root); - const ViewFrustum& getCurrentView() const { return _currentView.viewFrustum; } - const ViewFrustum& getCompletedView() const { return _completedView.viewFrustum; } + const View& getCurrentView() const { return _currentView; } + const View& getCompletedView() const { return _completedView; } - bool doesCurrentUseViewFrustum() const { return _currentView.usesViewFrustum; } - float getCurrentLODScaleFactor() const { return _currentView.lodScaleFactor; } - float getCompletedLODScaleFactor() const { return _completedView.lodScaleFactor; } + bool doesCurrentUseViewFrustum() const { return _currentView.usesViewFrustums(); } uint64_t getStartOfCompletedTraversal() const { return _completedView.startTime; } bool finished() const { return _path.empty(); } diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index a2ad834e18..b827ed7cd0 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -59,7 +59,6 @@ const int LOW_RES_MOVING_ADJUST = 1; class EncodeBitstreamParams { public: - ViewFrustum viewFrustum; bool includeExistsBits; NodeData* nodeData; diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 18766dd7f6..18e907cb8c 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeQuery.h" + #include #include @@ -16,23 +18,11 @@ #include #include -#include "OctreeConstants.h" -#include "OctreeQuery.h" - -const float DEFAULT_FOV = 45.0f; // degrees -const float DEFAULT_ASPECT_RATIO = 1.0f; -const float DEFAULT_NEAR_CLIP = 0.1f; -const float DEFAULT_FAR_CLIP = 3.0f; - -OctreeQuery::OctreeQuery(bool randomizeConnectionID) : - _cameraFov(DEFAULT_FOV), - _cameraAspectRatio(DEFAULT_ASPECT_RATIO), - _cameraNearClip(DEFAULT_NEAR_CLIP), - _cameraFarClip(DEFAULT_FAR_CLIP), - _cameraCenterRadius(DEFAULT_FAR_CLIP) -{ - _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; +using QueryFlags = uint8_t; +const QueryFlags QUERY_HAS_MAIN_FRUSTUM = 1U << 0; +const QueryFlags QUERY_HAS_SECONDARY_FRUSTUM = 1U << 1; +OctreeQuery::OctreeQuery(bool randomizeConnectionID) { if (randomizeConnectionID) { // randomize our initial octree query connection ID using random_device // the connection ID is 16 bits so we take a generated 32 bit value from random device and chop off the top @@ -47,26 +37,28 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { // pack the connection ID so the server can detect when we start a new connection memcpy(destinationBuffer, &_connectionID, sizeof(_connectionID)); destinationBuffer += sizeof(_connectionID); - - // back a boolean (cut to 1 byte) to designate if this query uses the sent view frustum - memcpy(destinationBuffer, &_usesFrustum, sizeof(_usesFrustum)); - destinationBuffer += sizeof(_usesFrustum); - - if (_usesFrustum) { - // TODO: DRY this up to a shared method - // that can pack any type given the number of bytes - // and return the number of bytes to push the pointer - - // camera details - memcpy(destinationBuffer, &_cameraPosition, sizeof(_cameraPosition)); - destinationBuffer += sizeof(_cameraPosition); - destinationBuffer += packOrientationQuatToBytes(destinationBuffer, _cameraOrientation); - destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _cameraFov); - destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _cameraAspectRatio); - destinationBuffer += packClipValueToTwoByte(destinationBuffer, _cameraNearClip); - destinationBuffer += packClipValueToTwoByte(destinationBuffer, _cameraFarClip); - memcpy(destinationBuffer, &_cameraEyeOffsetPosition, sizeof(_cameraEyeOffsetPosition)); - destinationBuffer += sizeof(_cameraEyeOffsetPosition); + + // flags for wether the frustums are present + QueryFlags frustumFlags = 0; + if (_hasMainFrustum) { + frustumFlags |= QUERY_HAS_MAIN_FRUSTUM; + } + if (_hasSecondaryFrustum) { + frustumFlags |= QUERY_HAS_SECONDARY_FRUSTUM; + } + memcpy(destinationBuffer, &frustumFlags, sizeof(frustumFlags)); + destinationBuffer += sizeof(frustumFlags); + + if (_hasMainFrustum) { + auto byteArray = _mainViewFrustum.toByteArray(); + memcpy(destinationBuffer, byteArray.constData(), byteArray.size()); + destinationBuffer += byteArray.size(); + } + + if (_hasSecondaryFrustum) { + auto byteArray = _secondaryViewFrustum.toByteArray(); + memcpy(destinationBuffer, byteArray.constData(), byteArray.size()); + destinationBuffer += byteArray.size(); } // desired Max Octree PPS @@ -80,9 +72,6 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { // desired boundaryLevelAdjust memcpy(destinationBuffer, &_boundaryLevelAdjust, sizeof(_boundaryLevelAdjust)); destinationBuffer += sizeof(_boundaryLevelAdjust); - - memcpy(destinationBuffer, &_cameraCenterRadius, sizeof(_cameraCenterRadius)); - destinationBuffer += sizeof(_cameraCenterRadius); // create a QByteArray that holds the binary representation of the JSON parameters QByteArray binaryParametersDocument; @@ -110,6 +99,7 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { int OctreeQuery::parseData(ReceivedMessage& message) { const unsigned char* startPosition = reinterpret_cast(message.getRawMessage()); + const unsigned char* endPosition = startPosition + message.getSize(); const unsigned char* sourceBuffer = startPosition; // unpack the connection ID @@ -133,20 +123,23 @@ int OctreeQuery::parseData(ReceivedMessage& message) { } // check if this query uses a view frustum - memcpy(&_usesFrustum, sourceBuffer, sizeof(_usesFrustum)); - sourceBuffer += sizeof(_usesFrustum); - - if (_usesFrustum) { - // unpack camera details - memcpy(&_cameraPosition, sourceBuffer, sizeof(_cameraPosition)); - sourceBuffer += sizeof(_cameraPosition); - sourceBuffer += unpackOrientationQuatFromBytes(sourceBuffer, _cameraOrientation); - sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_cameraFov); - sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer,_cameraAspectRatio); - sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer,_cameraNearClip); - sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer,_cameraFarClip); - memcpy(&_cameraEyeOffsetPosition, sourceBuffer, sizeof(_cameraEyeOffsetPosition)); - sourceBuffer += sizeof(_cameraEyeOffsetPosition); + QueryFlags frustumFlags { 0 }; + memcpy(&frustumFlags, sourceBuffer, sizeof(frustumFlags)); + sourceBuffer += sizeof(frustumFlags); + + _hasMainFrustum = frustumFlags & QUERY_HAS_MAIN_FRUSTUM; + _hasSecondaryFrustum = frustumFlags & QUERY_HAS_SECONDARY_FRUSTUM; + + if (_hasMainFrustum) { + auto bytesLeft = endPosition - sourceBuffer; + auto byteArray = QByteArray::fromRawData(reinterpret_cast(sourceBuffer), bytesLeft); + sourceBuffer += _mainViewFrustum.fromByteArray(byteArray); + } + + if (_hasSecondaryFrustum) { + auto bytesLeft = endPosition - sourceBuffer; + auto byteArray = QByteArray::fromRawData(reinterpret_cast(sourceBuffer), bytesLeft); + sourceBuffer += _secondaryViewFrustum.fromByteArray(byteArray); } // desired Max Octree PPS @@ -161,9 +154,6 @@ int OctreeQuery::parseData(ReceivedMessage& message) { memcpy(&_boundaryLevelAdjust, sourceBuffer, sizeof(_boundaryLevelAdjust)); sourceBuffer += sizeof(_boundaryLevelAdjust); - memcpy(&_cameraCenterRadius, sourceBuffer, sizeof(_cameraCenterRadius)); - sourceBuffer += sizeof(_cameraCenterRadius); - // check if we have a packed JSON filter uint16_t binaryParametersBytes; memcpy(&binaryParametersBytes, sourceBuffer, sizeof(binaryParametersBytes)); @@ -184,8 +174,3 @@ int OctreeQuery::parseData(ReceivedMessage& message) { return sourceBuffer - startPosition; } - -glm::vec3 OctreeQuery::calculateCameraDirection() const { - glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FORWARD, 0.0f)); - return direction; -} diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index 21ce2e7fac..ef52e29f51 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -12,16 +12,14 @@ #ifndef hifi_OctreeQuery_h #define hifi_OctreeQuery_h -#include - -#include -#include - #include #include #include +#include + +#include "OctreeConstants.h" class OctreeQuery : public NodeData { Q_OBJECT @@ -30,31 +28,22 @@ public: OctreeQuery(bool randomizeConnectionID = false); virtual ~OctreeQuery() {} + OctreeQuery(const OctreeQuery&) = delete; + OctreeQuery& operator=(const OctreeQuery&) = delete; + int getBroadcastData(unsigned char* destinationBuffer); int parseData(ReceivedMessage& message) override; - // getters for camera details - const glm::vec3& getCameraPosition() const { return _cameraPosition; } - const glm::quat& getCameraOrientation() const { return _cameraOrientation; } - float getCameraFov() const { return _cameraFov; } - float getCameraAspectRatio() const { return _cameraAspectRatio; } - float getCameraNearClip() const { return _cameraNearClip; } - float getCameraFarClip() const { return _cameraFarClip; } - const glm::vec3& getCameraEyeOffsetPosition() const { return _cameraEyeOffsetPosition; } - float getCameraCenterRadius() const { return _cameraCenterRadius; } + bool hasMainViewFrustum() const { return _hasMainFrustum; } + void setMainViewFrustum(const ViewFrustum& viewFrustum) { _hasMainFrustum = true; _mainViewFrustum = viewFrustum; } + void clearMainViewFrustum() { _hasMainFrustum = false; } + const ViewFrustum& getMainViewFrustum() const { return _mainViewFrustum; } - glm::vec3 calculateCameraDirection() const; + bool hasSecondaryViewFrustum() const { return _hasSecondaryFrustum; } + void setSecondaryViewFrustum(const ViewFrustum& viewFrustum) { _hasSecondaryFrustum = true; _secondaryViewFrustum = viewFrustum; } + void clearSecondaryViewFrustum() { _hasSecondaryFrustum = false; } + const ViewFrustum& getSecondaryViewFrustum() const { return _secondaryViewFrustum; } - // setters for camera details - void setCameraPosition(const glm::vec3& position) { _cameraPosition = position; } - void setCameraOrientation(const glm::quat& orientation) { _cameraOrientation = orientation; } - void setCameraFov(float fov) { _cameraFov = fov; } - void setCameraAspectRatio(float aspectRatio) { _cameraAspectRatio = aspectRatio; } - void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; } - void setCameraFarClip(float farClip) { _cameraFarClip = farClip; } - void setCameraEyeOffsetPosition(const glm::vec3& eyeOffsetPosition) { _cameraEyeOffsetPosition = eyeOffsetPosition; } - void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; } - // getters/setters for JSON filter QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; } void setJSONParameters(const QJsonObject& jsonParameters) @@ -64,9 +53,6 @@ public: int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; } float getOctreeSizeScale() const { return _octreeElementSizeScale; } int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; } - - bool getUsesFrustum() { return _usesFrustum; } - void setUsesFrustum(bool usesFrustum) { _usesFrustum = usesFrustum; } void incrementConnectionID() { ++_connectionID; } @@ -81,33 +67,22 @@ public slots: void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } protected: - // camera details for the avatar - glm::vec3 _cameraPosition { glm::vec3(0.0f) }; - glm::quat _cameraOrientation { glm::quat() }; - float _cameraFov; - float _cameraAspectRatio; - float _cameraNearClip; - float _cameraFarClip; - float _cameraCenterRadius; - glm::vec3 _cameraEyeOffsetPosition { glm::vec3(0.0f) }; + bool _hasMainFrustum { false }; + ViewFrustum _mainViewFrustum; + bool _hasSecondaryFrustum { false }; + ViewFrustum _secondaryViewFrustum; // octree server sending items int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; float _octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE; /// used for LOD calculations int _boundaryLevelAdjust = 0; /// used for LOD calculations - - uint8_t _usesFrustum = true; + uint16_t _connectionID; // query connection ID, randomized to start, increments with each new connection to server QJsonObject _jsonParameters; QReadWriteLock _jsonParametersLock; bool _hasReceivedFirstQuery { false }; - -private: - // privatize the copy constructor and assignment operator so they cannot be called - OctreeQuery(const OctreeQuery&); - OctreeQuery& operator= (const OctreeQuery&); }; #endif // hifi_OctreeQuery_h diff --git a/libraries/octree/src/OctreeQueryNode.cpp b/libraries/octree/src/OctreeQueryNode.cpp index 16542b697e..d6e9343896 100644 --- a/libraries/octree/src/OctreeQueryNode.cpp +++ b/libraries/octree/src/OctreeQueryNode.cpp @@ -139,9 +139,14 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int by } } -void OctreeQueryNode::copyCurrentViewFrustum(ViewFrustum& viewOut) const { +void OctreeQueryNode::copyCurrentMainViewFrustum(ViewFrustum& viewOut) const { QMutexLocker viewLocker(&_viewMutex); - viewOut = _currentViewFrustum; + viewOut = _currentMainViewFrustum; +} + +void OctreeQueryNode::copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const { + QMutexLocker viewLocker(&_viewMutex); + viewOut = _currentSecondaryViewFrustum; } bool OctreeQueryNode::updateCurrentViewFrustum() { @@ -150,70 +155,50 @@ bool OctreeQueryNode::updateCurrentViewFrustum() { return false; } - if (!_usesFrustum) { + if (!_hasMainFrustum && !_hasSecondaryFrustum) { // this client does not use a view frustum so the view frustum for this query has not changed return false; - } else { - bool currentViewFrustumChanged = false; - - ViewFrustum newestViewFrustum; - // get position and orientation details from the camera - newestViewFrustum.setPosition(getCameraPosition()); - newestViewFrustum.setOrientation(getCameraOrientation()); - - newestViewFrustum.setCenterRadius(getCameraCenterRadius()); - - // Also make sure it's got the correct lens details from the camera - float originalFOV = getCameraFov(); - float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND; - - if (0.0f != getCameraAspectRatio() && - 0.0f != getCameraNearClip() && - 0.0f != getCameraFarClip() && - getCameraNearClip() != getCameraFarClip()) { - newestViewFrustum.setProjection(glm::perspective( - glm::radians(wideFOV), // hack - getCameraAspectRatio(), - getCameraNearClip(), - getCameraFarClip())); - newestViewFrustum.calculate(); - } - - - { // if there has been a change, then recalculate - QMutexLocker viewLocker(&_viewMutex); - if (!newestViewFrustum.isVerySimilar(_currentViewFrustum)) { - _currentViewFrustum = newestViewFrustum; - currentViewFrustumChanged = true; - } - } - - // Also check for LOD changes from the client - if (_lodInitialized) { - if (_lastClientBoundaryLevelAdjust != getBoundaryLevelAdjust()) { - _lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust(); - _lodChanged = true; - } - if (_lastClientOctreeSizeScale != getOctreeSizeScale()) { - _lastClientOctreeSizeScale = getOctreeSizeScale(); - _lodChanged = true; - } - } else { - _lodInitialized = true; - _lastClientOctreeSizeScale = getOctreeSizeScale(); - _lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust(); - _lodChanged = false; - } - - // When we first detect that the view stopped changing, we record this. - // but we don't change it back to false until we've completely sent this - // scene. - if (_viewFrustumChanging && !currentViewFrustumChanged) { - _viewFrustumJustStoppedChanging = true; - } - _viewFrustumChanging = currentViewFrustumChanged; - return currentViewFrustumChanged; } + + bool currentViewFrustumChanged = false; + + { // if there has been a change, then recalculate + QMutexLocker viewLocker(&_viewMutex); + if (_hasMainFrustum && !_mainViewFrustum.isVerySimilar(_currentMainViewFrustum)) { + _currentMainViewFrustum = _mainViewFrustum; + currentViewFrustumChanged = true; + } + if (_hasSecondaryFrustum && !_secondaryViewFrustum.isVerySimilar(_currentSecondaryViewFrustum)) { + _currentSecondaryViewFrustum = _secondaryViewFrustum; + currentViewFrustumChanged = true; + } + } + + // Also check for LOD changes from the client + if (_lodInitialized) { + if (_lastClientBoundaryLevelAdjust != getBoundaryLevelAdjust()) { + _lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust(); + _lodChanged = true; + } + if (_lastClientOctreeSizeScale != getOctreeSizeScale()) { + _lastClientOctreeSizeScale = getOctreeSizeScale(); + _lodChanged = true; + } + } else { + _lodInitialized = true; + _lastClientOctreeSizeScale = getOctreeSizeScale(); + _lastClientBoundaryLevelAdjust = getBoundaryLevelAdjust(); + _lodChanged = false; + } + + // When we first detect that the view stopped changing, we record this. + // but we don't change it back to false until we've completely sent this + // scene. + if (_viewFrustumChanging && !currentViewFrustumChanged) { + _viewFrustumJustStoppedChanging = true; + } + _viewFrustumChanging = currentViewFrustumChanged; + return currentViewFrustumChanged; } void OctreeQueryNode::setViewSent(bool viewSent) { diff --git a/libraries/octree/src/OctreeQueryNode.h b/libraries/octree/src/OctreeQueryNode.h index 640a7c7ddc..d8f05c4043 100644 --- a/libraries/octree/src/OctreeQueryNode.h +++ b/libraries/octree/src/OctreeQueryNode.h @@ -49,7 +49,8 @@ public: OctreeElementExtraEncodeData extraEncodeData; - void copyCurrentViewFrustum(ViewFrustum& viewOut) const; + void copyCurrentMainViewFrustum(ViewFrustum& viewOut) const; + void copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const; // These are not classic setters because they are calculating and maintaining state // which is set asynchronously through the network receive @@ -87,9 +88,6 @@ public: void setShouldForceFullScene(bool shouldForceFullScene) { _shouldForceFullScene = shouldForceFullScene; } private: - OctreeQueryNode(const OctreeQueryNode &); - OctreeQueryNode& operator= (const OctreeQueryNode&); - bool _viewSent { false }; std::unique_ptr _octreePacket; bool _octreePacketWaiting; @@ -99,7 +97,8 @@ private: quint64 _firstSuppressedPacket { usecTimestampNow() }; mutable QMutex _viewMutex { QMutex::Recursive }; - ViewFrustum _currentViewFrustum; + ViewFrustum _currentMainViewFrustum; + ViewFrustum _currentSecondaryViewFrustum; bool _viewFrustumChanging { false }; bool _viewFrustumJustStoppedChanging { true }; diff --git a/libraries/octree/src/OctreeUtils.cpp b/libraries/octree/src/OctreeUtils.cpp index 8980504431..8eaf22e198 100644 --- a/libraries/octree/src/OctreeUtils.cpp +++ b/libraries/octree/src/OctreeUtils.cpp @@ -16,6 +16,7 @@ #include #include +#include float calculateRenderAccuracy(const glm::vec3& position, const AABox& bounds, @@ -73,4 +74,10 @@ float getOrthographicAccuracySize(float octreeSizeScale, int boundaryLevelAdjust // Smallest visible element is 1cm const float smallestSize = 0.01f; return (smallestSize * MAX_VISIBILITY_DISTANCE_FOR_UNIT_ELEMENT) / boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale); -} \ No newline at end of file +} + +bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter) { + float distance = glm::distance(cube.calcCenter(), position) + MIN_VISIBLE_DISTANCE; + float angularDiameter = cube.getScale() / distance; + return angularDiameter > minDiameter * lodScaleFactor; +} diff --git a/libraries/octree/src/OctreeUtils.h b/libraries/octree/src/OctreeUtils.h index d5008376ea..58ab366d8d 100644 --- a/libraries/octree/src/OctreeUtils.h +++ b/libraries/octree/src/OctreeUtils.h @@ -15,6 +15,7 @@ #include "OctreeConstants.h" class AABox; +class AACube; class QJsonDocument; /// renderAccuracy represents a floating point "visibility" of an object based on it's view from the camera. At a simple @@ -36,4 +37,6 @@ const float SQRT_THREE = 1.73205080f; const float MIN_ENTITY_ANGULAR_DIAMETER = MIN_ELEMENT_ANGULAR_DIAMETER * SQRT_THREE; const float MIN_VISIBLE_DISTANCE = 0.0001f; // helps avoid divide-by-zero check +bool isAngularSizeBigEnough(glm::vec3 position, const AACube& cube, float lodScaleFactor, float minDiameter); + #endif // hifi_OctreeUtils_h diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index 2a2eebc0a7..f65f5407fd 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -134,7 +134,7 @@ const char* ViewFrustum::debugPlaneName (int plane) const { return "Unknown"; } -void ViewFrustum::fromByteArray(const QByteArray& input) { +int ViewFrustum::fromByteArray(const QByteArray& input) { // From the wire! glm::vec3 cameraPosition; @@ -176,6 +176,8 @@ void ViewFrustum::fromByteArray(const QByteArray& input) { calculate(); } + + return sourceBuffer - startPosition; } diff --git a/libraries/shared/src/ViewFrustum.h b/libraries/shared/src/ViewFrustum.h index 981aabe70c..70fcb4cc32 100644 --- a/libraries/shared/src/ViewFrustum.h +++ b/libraries/shared/src/ViewFrustum.h @@ -147,7 +147,7 @@ public: void invalidate(); // causes all reasonable intersection tests to fail QByteArray toByteArray(); - void fromByteArray(const QByteArray& input); + int fromByteArray(const QByteArray& input); private: glm::mat4 _view; From 98cf48694e8718887a2a6c1592d8e1171fe38ff2 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 16 Apr 2018 15:27:43 -0700 Subject: [PATCH 046/192] Expose secondary camera to game logic --- interface/src/Application.cpp | 32 ++++++++++++++++++++++++++++ interface/src/Application.h | 5 +++++ libraries/shared/src/ViewFrustum.cpp | 10 ++++----- libraries/shared/src/ViewFrustum.h | 1 + 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d1d44aa706..a38f4d022d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5532,6 +5532,26 @@ void Application::update(float deltaTime) { { QMutexLocker viewLocker(&_viewMutex); _myCamera.loadViewFrustum(_viewFrustum); + + + auto renderConfig = _renderEngine->getConfiguration(); + assert(renderConfig); + auto secondaryCamera = dynamic_cast(renderConfig->getConfig("SecondaryCamera")); + assert(secondaryCamera); + + if (secondaryCamera->isEnabled()) { + _secondaryViewFrustum.setPosition(secondaryCamera->position); + _secondaryViewFrustum.setOrientation(secondaryCamera->orientation); + _secondaryViewFrustum.setProjection(secondaryCamera->vFoV, + secondaryCamera->textureWidth / secondaryCamera->textureHeight, + secondaryCamera->nearClipPlaneDistance, + secondaryCamera->farClipPlaneDistance); + _secondaryViewFrustum.calculate(); + _hasSecondaryViewFrustum = true; + } else { + _hasSecondaryViewFrustum = false; + } + } quint64 now = usecTimestampNow(); @@ -5793,6 +5813,13 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) { copyViewFrustum(viewFrustum); _octreeQuery.setMainViewFrustum(viewFrustum); + if (hasSecondaryViewFrustum()) { + copySecondaryViewFrustum(viewFrustum); + _octreeQuery.setSecondaryViewFrustum(viewFrustum); + } else { + _octreeQuery.clearSecondaryViewFrustum(); + } + auto lodManager = DependencyManager::get(); _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale()); _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust()); @@ -5876,6 +5903,11 @@ void Application::copyDisplayViewFrustum(ViewFrustum& viewOut) const { viewOut = _displayViewFrustum; } +void Application::copySecondaryViewFrustum(ViewFrustum& viewOut) const { + QMutexLocker viewLocker(&_viewMutex); + viewOut = _secondaryViewFrustum; +} + void Application::resetSensors(bool andReload) { DependencyManager::get()->reset(); DependencyManager::get()->reset(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 6d611bc8e2..043a9b52ab 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -178,6 +178,9 @@ public: // which might be different from the viewFrustum, i.e. shadowmap // passes, mirror window passes, etc void copyDisplayViewFrustum(ViewFrustum& viewOut) const; + void copySecondaryViewFrustum(ViewFrustum& viewOut) const; + bool hasSecondaryViewFrustum() const { return _hasSecondaryViewFrustum; } + const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } QSharedPointer getEntities() const { return DependencyManager::get(); } QUndoStack* getUndoStack() { return &_undoStack; } @@ -554,6 +557,8 @@ private: ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels) ViewFrustum _displayViewFrustum; + ViewFrustum _secondaryViewFrustum; + bool _hasSecondaryViewFrustum; quint64 _lastQueriedTime; OctreeQuery _octreeQuery { true }; // NodeData derived class for querying octee cells from octree servers diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index f65f5407fd..c2b92aac5f 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -75,6 +75,10 @@ void ViewFrustum::setProjection(const glm::mat4& projection) { _width = _corners[TOP_RIGHT_NEAR].x - _corners[TOP_LEFT_NEAR].x; } +void ViewFrustum::setProjection(float cameraFov, float cameraAspectRatio, float cameraNearClip, float cameraFarClip) { + setProjection(glm::perspective(glm::radians(cameraFov), cameraAspectRatio, cameraNearClip, cameraFarClip)); +} + // ViewFrustum::calculate() // // Description: this will calculate the view frustum bounds for a given position and direction @@ -168,12 +172,8 @@ int ViewFrustum::fromByteArray(const QByteArray& input) { 0.0f != cameraNearClip && 0.0f != cameraFarClip && cameraNearClip != cameraFarClip) { - setProjection(glm::perspective( - glm::radians(cameraFov), - cameraAspectRatio, - cameraNearClip, - cameraFarClip)); + setProjection(cameraFov, cameraAspectRatio, cameraNearClip, cameraFarClip); calculate(); } diff --git a/libraries/shared/src/ViewFrustum.h b/libraries/shared/src/ViewFrustum.h index 70fcb4cc32..ba8957bba3 100644 --- a/libraries/shared/src/ViewFrustum.h +++ b/libraries/shared/src/ViewFrustum.h @@ -48,6 +48,7 @@ public: // setters for lens attributes void setProjection(const glm::mat4 & projection); + void setProjection(float cameraFov, float cameraAspectRatio, float cameraNearClip, float cameraFarClip); void setFocalLength(float focalLength) { _focalLength = focalLength; } bool isPerspective() const; From 7f67547faef1068a765f0aaba8b10a4a08060d12 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 16 Apr 2018 17:45:11 -0700 Subject: [PATCH 047/192] Update HeadlessViewer to not always send a frustum --- .../src/octree/OctreeHeadlessViewer.cpp | 13 +++------ .../src/octree/OctreeHeadlessViewer.h | 27 ++++++++----------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/assignment-client/src/octree/OctreeHeadlessViewer.cpp b/assignment-client/src/octree/OctreeHeadlessViewer.cpp index 4f022ae838..6d91a134c2 100644 --- a/assignment-client/src/octree/OctreeHeadlessViewer.cpp +++ b/assignment-client/src/octree/OctreeHeadlessViewer.cpp @@ -14,25 +14,18 @@ #include #include - -OctreeHeadlessViewer::OctreeHeadlessViewer() { - _viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); -} - void OctreeHeadlessViewer::queryOctree() { char serverType = getMyNodeType(); PacketType packetType = getMyQueryMessageType(); - _octreeQuery.setMainViewFrustum(_viewFrustum); - _octreeQuery.setOctreeSizeScale(_voxelSizeScale); - _octreeQuery.setBoundaryLevelAdjust(_boundaryLevelAdjust); + if (_hasViewFrustum) { + _octreeQuery.setMainViewFrustum(_viewFrustum); + } auto nodeList = DependencyManager::get(); auto node = nodeList->soloNodeOfType(serverType); if (node && node->getActiveSocket()) { - _octreeQuery.setMaxQueryPacketsPerSecond(getMaxPacketsPerSecond()); - auto queryPacket = NLPacket::create(packetType); // encode the query data diff --git a/assignment-client/src/octree/OctreeHeadlessViewer.h b/assignment-client/src/octree/OctreeHeadlessViewer.h index feb8211c39..dea91ce66f 100644 --- a/assignment-client/src/octree/OctreeHeadlessViewer.h +++ b/assignment-client/src/octree/OctreeHeadlessViewer.h @@ -20,9 +20,6 @@ class OctreeHeadlessViewer : public OctreeProcessor { Q_OBJECT public: - OctreeHeadlessViewer(); - virtual ~OctreeHeadlessViewer() {}; - OctreeQuery& getOctreeQuery() { return _octreeQuery; } static int parseOctreeStats(QSharedPointer message, SharedNodePointer sourceNode); @@ -32,34 +29,32 @@ public slots: void queryOctree(); // setters for camera attributes - void setPosition(const glm::vec3& position) { _viewFrustum.setPosition(position); } - void setOrientation(const glm::quat& orientation) { _viewFrustum.setOrientation(orientation); } - void setCenterRadius(float radius) { _viewFrustum.setCenterRadius(radius); } - void setKeyholeRadius(float radius) { _viewFrustum.setCenterRadius(radius); } // TODO: remove this legacy support + void setPosition(const glm::vec3& position) { _hasViewFrustum = true; _viewFrustum.setPosition(position); } + void setOrientation(const glm::quat& orientation) { _hasViewFrustum = true; _viewFrustum.setOrientation(orientation); } + void setCenterRadius(float radius) { _hasViewFrustum = true; _viewFrustum.setCenterRadius(radius); } + void setKeyholeRadius(float radius) { _hasViewFrustum = true; _viewFrustum.setCenterRadius(radius); } // TODO: remove this legacy support // setters for LOD and PPS - void setVoxelSizeScale(float sizeScale) { _voxelSizeScale = sizeScale; } - void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } - void setMaxPacketsPerSecond(int maxPacketsPerSecond) { _maxPacketsPerSecond = maxPacketsPerSecond; } + void setVoxelSizeScale(float sizeScale) { _octreeQuery.setOctreeSizeScale(sizeScale) ; } + void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _octreeQuery.setBoundaryLevelAdjust(boundaryLevelAdjust); } + void setMaxPacketsPerSecond(int maxPacketsPerSecond) { _octreeQuery.setMaxQueryPacketsPerSecond(maxPacketsPerSecond); } // getters for camera attributes const glm::vec3& getPosition() const { return _viewFrustum.getPosition(); } const glm::quat& getOrientation() const { return _viewFrustum.getOrientation(); } // getters for LOD and PPS - float getVoxelSizeScale() const { return _voxelSizeScale; } - int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; } - int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; } + float getVoxelSizeScale() const { return _octreeQuery.getOctreeSizeScale(); } + int getBoundaryLevelAdjust() const { return _octreeQuery.getBoundaryLevelAdjust(); } + int getMaxPacketsPerSecond() const { return _octreeQuery.getMaxQueryPacketsPerSecond(); } unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); } private: OctreeQuery _octreeQuery; + bool _hasViewFrustum { false }; ViewFrustum _viewFrustum; - float _voxelSizeScale { DEFAULT_OCTREE_SIZE_SCALE }; - int _boundaryLevelAdjust { 0 }; - int _maxPacketsPerSecond { DEFAULT_MAX_OCTREE_PPS }; }; #endif // hifi_OctreeHeadlessViewer_h From 3862a02ceed3c1779761b039bd9f48dfb6ad11e6 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 16 Apr 2018 18:30:51 -0700 Subject: [PATCH 048/192] DRY traversal scan callbacks --- .../src/entities/EntityPriorityQueue.cpp | 4 + .../src/entities/EntityTreeSendThread.cpp | 218 ++++++++---------- libraries/entities/src/DiffTraversal.cpp | 29 ++- 3 files changed, 115 insertions(+), 136 deletions(-) diff --git a/assignment-client/src/entities/EntityPriorityQueue.cpp b/assignment-client/src/entities/EntityPriorityQueue.cpp index a38d537649..88dee58f9d 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.cpp +++ b/assignment-client/src/entities/EntityPriorityQueue.cpp @@ -62,6 +62,10 @@ void ConicalView::set(const DiffTraversal::View& view) { } float ConicalView::computePriority(const AACube& cube) const { + if (_conicalViewFrustums.empty()) { + return PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + float priority = PrioritizedEntity::DO_NOT_SEND; for (const auto& view : _conicalViewFrustums) { diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index d14d31bd09..a282c4ad4c 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -135,25 +135,27 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O bool forceRemove = prevSendQueue.top().shouldForceRemove(); prevSendQueue.pop(); if (entity) { - if (!forceRemove) { + float priority = PrioritizedEntity::DO_NOT_SEND; + + + if (forceRemove) { + priority = PrioritizedEntity::FORCE_REMOVE; + } else { bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (_traversal.getCurrentView().intersects(cube)) { - float priority = _conicalView.computePriority(cube); - if (priority != PrioritizedEntity::DO_NOT_SEND) { - if (_traversal.getCurrentView().isBigEnough(cube)) { - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); - } - } + const auto& view = _traversal.getCurrentView(); + if (view.intersects(cube) && view.isBigEnough(cube)) { + priority = _conicalView.computePriority(cube); } } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::FORCE_REMOVE, true)); + } + + + if (priority != PrioritizedEntity::DO_NOT_SEND) { + _sendQueue.emplace(entity, priority, forceRemove); _entitiesInQueue.insert(entity.get()); } } @@ -245,104 +247,79 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En case DiffTraversal::First: // When we get to a First traversal, clear the _knownState _knownState.clear(); - if (view.usesViewFrustums()) { - _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { + _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { + next.element->forEachEntity([&](EntityItemPointer entity) { + // Bail early if we've already checked this entity this frame + if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { + return; + } + float priority = PrioritizedEntity::DO_NOT_SEND; + + + bool success = false; + AACube cube = entity->getQueryAACube(success); + if (success) { + const auto& view = _traversal.getCurrentView(); + // Check the size of the entity, it's possible that a "too small to see" entity is included in a + // larger octree cell because of its position (for example if it crosses the boundary of a cell it + // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen + // before we consider including it. + if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && + view.isBigEnough(cube)) { + priority = _conicalView.computePriority(cube); + } + } else { + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + + + if (priority != PrioritizedEntity::DO_NOT_SEND) { + _sendQueue.emplace(entity, priority); + _entitiesInQueue.insert(entity.get()); + } + }); + }); + break; + case DiffTraversal::Repeat: + _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { + uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal(); + if (next.element->getLastChangedContent() > startOfCompletedTraversal) { next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; } - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - if (_traversal.getCurrentView().intersects(cube)) { - // Check the size of the entity, it's possible that a "too small to see" entity is included in a - // larger octree cell because of its position (for example if it crosses the boundary of a cell it - // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen - // before we consider including it. - if (_traversal.getCurrentView().isBigEnough(cube)) { - float priority = _conicalView.computePriority(cube); - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); + float priority = PrioritizedEntity::DO_NOT_SEND; + + + auto knownTimestamp = _knownState.find(entity.get()); + if (knownTimestamp == _knownState.end()) { + bool success = false; + AACube cube = entity->getQueryAACube(success); + if (success) { + const auto& view = _traversal.getCurrentView(); + // See the DiffTraversal::First case for an explanation of the "entity is too small" check + if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && + view.isBigEnough(cube)) { + priority = _conicalView.computePriority(cube); } + } else { + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); + } else if (entity->getLastEdited() > knownTimestamp->second) { + // it is known and it changed --> put it on the queue with any priority + // TODO: sort these correctly + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + + + if (priority != PrioritizedEntity::DO_NOT_SEND) { + _sendQueue.emplace(entity, priority); _entitiesInQueue.insert(entity.get()); } }); - }); - } else { - _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { - next.element->forEachEntity([&](EntityItemPointer entity) { - // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { - return; - } - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); - }); - }); - } - break; - case DiffTraversal::Repeat: - if (view.usesViewFrustums()) { - _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { - uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal(); - if (next.element->getLastChangedContent() > startOfCompletedTraversal) { - next.element->forEachEntity([&](EntityItemPointer entity) { - // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { - return; - } - auto knownTimestamp = _knownState.find(entity.get()); - if (knownTimestamp == _knownState.end()) { - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - if (next.intersection == ViewFrustum::INSIDE || - _traversal.getCurrentView().intersects(cube)) { - // See the DiffTraversal::First case for an explanation of the "entity is too small" check - if (_traversal.getCurrentView().isBigEnough(cube)) { - float priority = _conicalView.computePriority(cube); - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); - } - } - } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); - } - } else if (entity->getLastEdited() > knownTimestamp->second - || entity->getLastChangedOnServer() > knownTimestamp->second) { - // it is known and it changed --> put it on the queue with any priority - // TODO: sort these correctly - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); - } - }); - } - }); - } else { - _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { - uint64_t startOfCompletedTraversal = _traversal.getStartOfCompletedTraversal(); - if (next.element->getLastChangedContent() > startOfCompletedTraversal) { - next.element->forEachEntity([&](EntityItemPointer entity) { - // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { - return; - } - auto knownTimestamp = _knownState.find(entity.get()); - if (knownTimestamp == _knownState.end() - || entity->getLastEdited() > knownTimestamp->second - || entity->getLastChangedOnServer() > knownTimestamp->second) { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); - } - }); - } - }); - } + } + }); break; case DiffTraversal::Differential: assert(view.usesViewFrustums()); @@ -352,36 +329,35 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { return; } + float priority = PrioritizedEntity::DO_NOT_SEND; + + auto knownTimestamp = _knownState.find(entity.get()); if (knownTimestamp == _knownState.end()) { bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { - if (_traversal.getCurrentView().intersects(cube)) { - // See the DiffTraversal::First case for an explanation of the "entity is too small" check - if (_traversal.getCurrentView().isBigEnough(cube)) { - if (!_traversal.getCompletedView().intersects(cube)) { - float priority = _conicalView.computePriority(cube); - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); - } else if (!_traversal.getCompletedView().isBigEnough(cube)) { - // If this entity was skipped last time because it was too small, we still need to send it - // this object was skipped in last completed traversal - float priority = _conicalView.computePriority(cube); - _sendQueue.push(PrioritizedEntity(entity, priority)); - _entitiesInQueue.insert(entity.get()); - } - } + const auto& view = _traversal.getCurrentView(); + // See the DiffTraversal::First case for an explanation of the "entity is too small" check + if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && + view.isBigEnough(cube)) { + // If this entity wasn't in the last view or + // If this entity was skipped last time because it was too small, we still need to send it + priority = _conicalView.computePriority(cube); } } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); - _entitiesInQueue.insert(entity.get()); + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } } else if (entity->getLastEdited() > knownTimestamp->second || entity->getLastChangedOnServer() > knownTimestamp->second) { // it is known and it changed --> put it on the queue with any priority // TODO: sort these correctly - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY)); + priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + + + if (priority != PrioritizedEntity::DO_NOT_SEND) { + _sendQueue.emplace(entity, priority); _entitiesInQueue.insert(entity.get()); } }); @@ -499,11 +475,11 @@ void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer& entity) if (success) { // We can force a removal from _knownState if the current view is used and entity is out of view if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().intersects(cube)) { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::FORCE_REMOVE, true)); + _sendQueue.emplace(entity, PrioritizedEntity::FORCE_REMOVE, true); _entitiesInQueue.insert(entity.get()); } } else { - _sendQueue.push(PrioritizedEntity(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true)); + _sendQueue.emplace(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true); _entitiesInQueue.insert(entity.get()); } } diff --git a/libraries/entities/src/DiffTraversal.cpp b/libraries/entities/src/DiffTraversal.cpp index 11f37728df..d5f2273fd5 100644 --- a/libraries/entities/src/DiffTraversal.cpp +++ b/libraries/entities/src/DiffTraversal.cpp @@ -13,7 +13,6 @@ #include - DiffTraversal::Waypoint::Waypoint(EntityTreeElementPointer& element) : _nextIndex(0) { assert(element); _weakElement = element; @@ -140,12 +139,12 @@ bool DiffTraversal::View::isBigEnough(const AACube& cube, float minDiameter) con return true; } - for (const auto& viewFrustum : viewFrustums) { - if (isAngularSizeBigEnough(viewFrustum.getPosition(), cube, lodScaleFactor, minDiameter)) { - return true; - } - } - return false; + bool isBigEnough = std::any_of(std::begin(viewFrustums), std::end(viewFrustums), + [&](const ViewFrustum& viewFrustum) { + return isAngularSizeBigEnough(viewFrustum.getPosition(), cube, lodScaleFactor, minDiameter); + }); + + return isBigEnough; } bool DiffTraversal::View::intersects(const AACube& cube) const { @@ -154,12 +153,12 @@ bool DiffTraversal::View::intersects(const AACube& cube) const { return true; } - for (const auto& viewFrustum : viewFrustums) { - if (viewFrustum.cubeIntersectsKeyhole(cube)) { - return true; - } - } - return false; + bool intersects = std::any_of(std::begin(viewFrustums), std::end(viewFrustums), + [&](const ViewFrustum& viewFrustum) { + return viewFrustum.cubeIntersectsKeyhole(cube); + }); + + return intersects; } ViewFrustum::intersection DiffTraversal::View::calculateIntersection(const AACube& cube) const { @@ -231,7 +230,7 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View // If usesViewFrustum changes, treat it as a First traversal if (_completedView.startTime == 0 || _currentView.usesViewFrustums() != _completedView.usesViewFrustums()) { type = Type::First; - _currentView.viewFrustums = std::move(view.viewFrustums); + _currentView.viewFrustums = view.viewFrustums; _currentView.lodScaleFactor = view.lodScaleFactor; _getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) { _path.back().getNextVisibleElementFirstTime(next, _currentView); @@ -243,7 +242,7 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View }; } else { type = Type::Differential; - _currentView.viewFrustums = std::move(view.viewFrustums); + _currentView.viewFrustums = view.viewFrustums; _currentView.lodScaleFactor = view.lodScaleFactor; _getNextVisibleElementCallback = [this](DiffTraversal::VisibleElement& next) { _path.back().getNextVisibleElementDifferential(next, _currentView, _completedView); From 7a710093acc4abd982535985cd48ceed311380f0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 17 Apr 2018 16:28:50 -0700 Subject: [PATCH 049/192] Fix build error --- libraries/entities/src/EntityTree.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 3289101967..d95dbf2990 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -27,9 +27,6 @@ using EntityTreePointer = std::shared_ptr; #include "MovingEntitiesOperator.h" class EntityEditFilters; -class Model; -using ModelPointer = std::shared_ptr; -using ModelWeakPointer = std::weak_ptr; class EntitySimulation; From 69a7f2d4aa2852ac43f4f5454beea494553c2925 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 17 Apr 2018 17:41:35 -0700 Subject: [PATCH 050/192] Fix entity server crash --- .../src/entities/EntityPriorityQueue.h | 47 ++++++++++++++++++- .../src/entities/EntityTreeSendThread.cpp | 22 ++++----- .../src/entities/EntityTreeSendThread.h | 1 - 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/assignment-client/src/entities/EntityPriorityQueue.h b/assignment-client/src/entities/EntityPriorityQueue.h index 4068b4dc4b..730e08591e 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.h +++ b/assignment-client/src/entities/EntityPriorityQueue.h @@ -13,6 +13,7 @@ #define hifi_EntityPriorityQueue_h #include +#include #include #include @@ -71,6 +72,50 @@ private: bool _forceRemove; }; -using EntityPriorityQueue = std::priority_queue< PrioritizedEntity, std::vector, PrioritizedEntity::Compare >; +class EntityPriorityQueue { +public: + inline bool empty() const { + assert(_queue.empty() == _entities.empty()); + return _queue.empty(); + } + + inline const PrioritizedEntity& top() const { + assert(!_queue.empty()); + return _queue.top(); + } + + inline bool contains(const EntityItem* entity) const { + return _entities.find(entity) != std::end(_entities); + } + + inline void emplace(const EntityItemPointer& entity, float priority, bool forceRemove = false) { + assert(entity && !contains(entity.get())); + _queue.emplace(entity, priority, forceRemove); + _entities.insert(entity.get()); + assert(_queue.size() == _entities.size()); + } + + inline void pop() { + assert(!empty()); + _entities.erase(_queue.top().getRawEntityPointer()); + _queue.pop(); + assert(_queue.size() == _entities.size()); + } + + inline void swap(EntityPriorityQueue& other) { + std::swap(_queue, other._queue); + std::swap(_entities, other._entities); + } + +private: + using PriorityQueue = std::priority_queue, + PrioritizedEntity::Compare>; + + PriorityQueue _queue; + // Keep dictionary of al the entities in the queue for fast contain checks. + std::unordered_set _entities; + +}; #endif // hifi_EntityPriorityQueue_h diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index a282c4ad4c..ae7de01c3e 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -127,8 +127,9 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O // and also use the opportunity to cull anything no longer in view if (viewFrustumChanged && !_sendQueue.empty()) { EntityPriorityQueue prevSendQueue; - _sendQueue.swap(prevSendQueue); - _entitiesInQueue.clear(); + std::swap(_sendQueue, prevSendQueue); + assert(_sendQueue.empty()); + // Re-add elements from previous traversal if they still need to be sent while (!prevSendQueue.empty()) { EntityItemPointer entity = prevSendQueue.top().getEntity(); @@ -156,7 +157,6 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority, forceRemove); - _entitiesInQueue.insert(entity.get()); } } } @@ -250,7 +250,7 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En _traversal.setScanCallback([this](DiffTraversal::VisibleElement& next) { next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { + if (_sendQueue.contains(entity.get())) { return; } float priority = PrioritizedEntity::DO_NOT_SEND; @@ -275,7 +275,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); - _entitiesInQueue.insert(entity.get()); } }); }); @@ -286,7 +285,7 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (next.element->getLastChangedContent() > startOfCompletedTraversal) { next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { + if (_sendQueue.contains(entity.get())) { return; } float priority = PrioritizedEntity::DO_NOT_SEND; @@ -315,7 +314,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); - _entitiesInQueue.insert(entity.get()); } }); } @@ -326,7 +324,7 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En _traversal.setScanCallback([this] (DiffTraversal::VisibleElement& next) { next.element->forEachEntity([&](EntityItemPointer entity) { // Bail early if we've already checked this entity this frame - if (_entitiesInQueue.find(entity.get()) != _entitiesInQueue.end()) { + if (_sendQueue.contains(entity.get())) { return; } float priority = PrioritizedEntity::DO_NOT_SEND; @@ -358,7 +356,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); - _entitiesInQueue.insert(entity.get()); } }); }); @@ -447,11 +444,10 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream } } _sendQueue.pop(); - _entitiesInQueue.erase(entity.get()); } nodeData->stats.encodeStopped(); if (_sendQueue.empty()) { - assert(_entitiesInQueue.empty()); + assert(_sendQueue.empty()); params.stopReason = EncodeBitstreamParams::FINISHED; _extraEncodeData->entities.clear(); } @@ -469,18 +465,16 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer& entity) { if (entity) { - if (_entitiesInQueue.find(entity.get()) == _entitiesInQueue.end() && _knownState.find(entity.get()) != _knownState.end()) { + if (!_sendQueue.contains(entity.get()) && _knownState.find(entity.get()) != _knownState.end()) { bool success = false; AACube cube = entity->getQueryAACube(success); if (success) { // We can force a removal from _knownState if the current view is used and entity is out of view if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().intersects(cube)) { _sendQueue.emplace(entity, PrioritizedEntity::FORCE_REMOVE, true); - _entitiesInQueue.insert(entity.get()); } } else { _sendQueue.emplace(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true); - _entitiesInQueue.insert(entity.get()); } } } diff --git a/assignment-client/src/entities/EntityTreeSendThread.h b/assignment-client/src/entities/EntityTreeSendThread.h index 5ea723c8b2..9eea98b7fd 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.h +++ b/assignment-client/src/entities/EntityTreeSendThread.h @@ -50,7 +50,6 @@ private: DiffTraversal _traversal; EntityPriorityQueue _sendQueue; - std::unordered_set _entitiesInQueue; std::unordered_map _knownState; ConicalView _conicalView; // cached optimized view for fast priority calculations From fea49744ed3acbc673eb1b160f526b6c9a898718 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 17 Apr 2018 18:15:47 -0700 Subject: [PATCH 051/192] Add comment for future work --- interface/src/Application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a38f4d022d..ae84491097 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5534,6 +5534,9 @@ void Application::update(float deltaTime) { _myCamera.loadViewFrustum(_viewFrustum); + // TODO: Fix this by modeling the way the secondary camera works on how the main camera works + // ie. Use a camera object stored in the game logic and informs the Engine on where the secondary + // camera should be. auto renderConfig = _renderEngine->getConfiguration(); assert(renderConfig); auto secondaryCamera = dynamic_cast(renderConfig->getConfig("SecondaryCamera")); From 4c90763236dcd83d66d7476fed57dfd25e48895c Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Apr 2018 17:52:15 -0700 Subject: [PATCH 052/192] Correctly update secondary camera frustum --- interface/src/Application.cpp | 92 +++++++++++++++++++++++++++-------- interface/src/Application.h | 2 + 2 files changed, 75 insertions(+), 19 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ae84491097..bbdae9218b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5179,6 +5179,78 @@ void Application::updateDialogs(float deltaTime) const { } } +void Application::updateSecondaryCameraViewFrustum() { + // TODO: Fix this by modeling the way the secondary camera works on how the main camera works + // ie. Use a camera object stored in the game logic and informs the Engine on where the secondary + // camera should be. + + // Code based on SecondaryCameraJob + auto renderConfig = _renderEngine->getConfiguration(); + assert(renderConfig); + auto camera = dynamic_cast(renderConfig->getConfig("SecondaryCamera")); + assert(camera); + + if (!camera->isEnabled()) { + _hasSecondaryViewFrustum = false; + return; + } + + if (camera->mirrorProjection && !camera->attachedEntityId.isNull()) { + auto entityScriptingInterface = DependencyManager::get(); + auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId); + glm::vec3 mirrorPropertiesPosition = entityProperties.getPosition(); + glm::quat mirrorPropertiesRotation = entityProperties.getRotation(); + glm::vec3 mirrorPropertiesDimensions = entityProperties.getDimensions(); + glm::vec3 halfMirrorPropertiesDimensions = 0.5f * mirrorPropertiesDimensions; + + // setup mirror from world as inverse of world from mirror transformation using inverted x and z for mirrored image + // TODO: we are assuming here that UP is world y-axis + glm::mat4 worldFromMirrorRotation = glm::mat4_cast(mirrorPropertiesRotation) * glm::scale(vec3(-1.0f, 1.0f, -1.0f)); + glm::mat4 worldFromMirrorTranslation = glm::translate(mirrorPropertiesPosition); + glm::mat4 worldFromMirror = worldFromMirrorTranslation * worldFromMirrorRotation; + glm::mat4 mirrorFromWorld = glm::inverse(worldFromMirror); + + // get mirror camera position by reflecting main camera position's z coordinate in mirror space + glm::vec3 mainCameraPositionWorld = getCamera().getPosition(); + glm::vec3 mainCameraPositionMirror = vec3(mirrorFromWorld * vec4(mainCameraPositionWorld, 1.0f)); + glm::vec3 mirrorCameraPositionMirror = vec3(mainCameraPositionMirror.x, mainCameraPositionMirror.y, + -mainCameraPositionMirror.z); + glm::vec3 mirrorCameraPositionWorld = vec3(worldFromMirror * vec4(mirrorCameraPositionMirror, 1.0f)); + + // set frustum position to be mirrored camera and set orientation to mirror's adjusted rotation + glm::quat mirrorCameraOrientation = glm::quat_cast(worldFromMirrorRotation); + _secondaryViewFrustum.setPosition(mirrorCameraPositionWorld); + _secondaryViewFrustum.setOrientation(mirrorCameraOrientation); + + // build frustum using mirror space translation of mirrored camera + float nearClip = mirrorCameraPositionMirror.z + mirrorPropertiesDimensions.z * 2.0f; + glm::vec3 upperRight = halfMirrorPropertiesDimensions - mirrorCameraPositionMirror; + glm::vec3 bottomLeft = -halfMirrorPropertiesDimensions - mirrorCameraPositionMirror; + glm::mat4 frustum = glm::frustum(bottomLeft.x, upperRight.x, bottomLeft.y, upperRight.y, nearClip, camera->farClipPlaneDistance); + _secondaryViewFrustum.setProjection(frustum); + } else { + if (!camera->attachedEntityId.isNull()) { + auto entityScriptingInterface = DependencyManager::get(); + auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId); + _secondaryViewFrustum.setPosition(entityProperties.getPosition()); + _secondaryViewFrustum.setOrientation(entityProperties.getRotation()); + } else { + _secondaryViewFrustum.setPosition(camera->position); + _secondaryViewFrustum.setOrientation(camera->orientation); + } + + float aspectRatio = (float)camera->textureWidth / (float)camera->textureHeight; + _secondaryViewFrustum.setProjection(camera->vFoV, + aspectRatio, + camera->nearClipPlaneDistance, + camera->farClipPlaneDistance); + } + // Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera, + // which is not what we want here. + _secondaryViewFrustum.calculate(); + _hasSecondaryViewFrustum = true; +} + static bool domainLoadingInProgress = false; void Application::update(float deltaTime) { @@ -5533,28 +5605,10 @@ void Application::update(float deltaTime) { QMutexLocker viewLocker(&_viewMutex); _myCamera.loadViewFrustum(_viewFrustum); - // TODO: Fix this by modeling the way the secondary camera works on how the main camera works // ie. Use a camera object stored in the game logic and informs the Engine on where the secondary // camera should be. - auto renderConfig = _renderEngine->getConfiguration(); - assert(renderConfig); - auto secondaryCamera = dynamic_cast(renderConfig->getConfig("SecondaryCamera")); - assert(secondaryCamera); - - if (secondaryCamera->isEnabled()) { - _secondaryViewFrustum.setPosition(secondaryCamera->position); - _secondaryViewFrustum.setOrientation(secondaryCamera->orientation); - _secondaryViewFrustum.setProjection(secondaryCamera->vFoV, - secondaryCamera->textureWidth / secondaryCamera->textureHeight, - secondaryCamera->nearClipPlaneDistance, - secondaryCamera->farClipPlaneDistance); - _secondaryViewFrustum.calculate(); - _hasSecondaryViewFrustum = true; - } else { - _hasSecondaryViewFrustum = false; - } - + updateSecondaryCameraViewFrustum(); } quint64 now = usecTimestampNow(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 043a9b52ab..f31ca6547e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -149,6 +149,8 @@ public: void initializeRenderEngine(); void initializeUi(); + void updateSecondaryCameraViewFrustum(); + void updateCamera(RenderArgs& renderArgs, float deltaTime); void paintGL(); void resizeGL(); From 0820ef3c9582a89388090e3e929b3cd7a5010d8a Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 18 Apr 2018 20:19:27 -0700 Subject: [PATCH 053/192] Account for secondary view when deciding to query --- interface/src/Application.cpp | 3 +++ interface/src/Application.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bbdae9218b..a5b859628f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5622,6 +5622,8 @@ void Application::update(float deltaTime) { const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; bool viewIsDifferentEnough = !_lastQueriedViewFrustum.isVerySimilar(_viewFrustum); + viewIsDifferentEnough |= _hasSecondaryViewFrustum && !_lastQueriedSecondaryViewFrustum.isVerySimilar(_secondaryViewFrustum); + // if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it if (queryIsDue || viewIsDifferentEnough) { _lastQueriedTime = now; @@ -5630,6 +5632,7 @@ void Application::update(float deltaTime) { } sendAvatarViewFrustum(); _lastQueriedViewFrustum = _viewFrustum; + _lastQueriedSecondaryViewFrustum = _secondaryViewFrustum; } } diff --git a/interface/src/Application.h b/interface/src/Application.h index f31ca6547e..eed6ceeae5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -557,9 +557,10 @@ private: mutable QMutex _viewMutex { QMutex::Recursive }; ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. - ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels) + ViewFrustum _lastQueriedViewFrustum; // last view frustum used to query octree servers ViewFrustum _displayViewFrustum; ViewFrustum _secondaryViewFrustum; + ViewFrustum _lastQueriedSecondaryViewFrustum; // last secondary view frustum used to query octree servers bool _hasSecondaryViewFrustum; quint64 _lastQueriedTime; From 30d14dcd45834c7241b67b3be63430399417f386 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 19 Apr 2018 13:23:24 -0700 Subject: [PATCH 054/192] Push packet version --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 98b0e1d892..b16f9c903e 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -34,7 +34,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::EntityPhysics: return static_cast(EntityVersion::MaterialData); case PacketType::EntityQuery: - return static_cast(EntityQueryPacketVersion::RemovedJurisdictions); + return static_cast(EntityQueryPacketVersion::MultiFrustumQuery); case PacketType::AvatarIdentity: case PacketType::AvatarData: case PacketType::BulkAvatarData: diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index e6b133c158..9b48e3a132 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -244,7 +244,8 @@ enum class EntityQueryPacketVersion: PacketVersion { JSONFilter = 18, JSONFilterWithFamilyTree = 19, ConnectionIdentifier = 20, - RemovedJurisdictions = 21 + RemovedJurisdictions = 21, + MultiFrustumQuery = 22 }; enum class AssetServerPacketVersion: PacketVersion { From d47ddbd6e4f5a9e09425fb9b8c51e215e195672d Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 18:02:15 -0700 Subject: [PATCH 055/192] CR --- assignment-client/src/entities/EntityPriorityQueue.h | 5 +++-- .../src/entities/EntityTreeSendThread.cpp | 11 ++++------- libraries/entities/src/DiffTraversal.cpp | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/assignment-client/src/entities/EntityPriorityQueue.h b/assignment-client/src/entities/EntityPriorityQueue.h index 730e08591e..9210ac549f 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.h +++ b/assignment-client/src/entities/EntityPriorityQueue.h @@ -22,7 +22,7 @@ const float SQRT_TWO_OVER_TWO = 0.7071067811865f; const float DEFAULT_VIEW_RADIUS = 10.0f; -// ConicalView is an approximation of a ViewFrustum for fast calculation of sort priority. +// ConicalViewFrustum is an approximation of a ViewFrustum for fast calculation of sort priority. class ConicalViewFrustum { public: ConicalViewFrustum() {} @@ -37,6 +37,7 @@ private: float _radius { DEFAULT_VIEW_RADIUS }; }; +// Simple wrapper around a set of conical view frustums class ConicalView { public: ConicalView() {} @@ -113,7 +114,7 @@ private: PrioritizedEntity::Compare>; PriorityQueue _queue; - // Keep dictionary of al the entities in the queue for fast contain checks. + // Keep dictionary of all the entities in the queue for fast contain checks. std::unordered_set _entities; }; diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index ae7de01c3e..2e57f2e00f 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -138,7 +138,6 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O if (entity) { float priority = PrioritizedEntity::DO_NOT_SEND; - if (forceRemove) { priority = PrioritizedEntity::FORCE_REMOVE; } else { @@ -154,7 +153,6 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O } } - if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority, forceRemove); } @@ -305,7 +303,8 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En } else { priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - } else if (entity->getLastEdited() > knownTimestamp->second) { + } else if (entity->getLastEdited() > knownTimestamp->second || + entity->getLastChangedOnServer() > knownTimestamp->second) { // it is known and it changed --> put it on the queue with any priority // TODO: sort these correctly priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; @@ -339,15 +338,13 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En // See the DiffTraversal::First case for an explanation of the "entity is too small" check if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && view.isBigEnough(cube)) { - // If this entity wasn't in the last view or - // If this entity was skipped last time because it was too small, we still need to send it priority = _conicalView.computePriority(cube); } } else { priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - } else if (entity->getLastEdited() > knownTimestamp->second - || entity->getLastChangedOnServer() > knownTimestamp->second) { + } else if (entity->getLastEdited() > knownTimestamp->second || + entity->getLastChangedOnServer() > knownTimestamp->second) { // it is known and it changed --> put it on the queue with any priority // TODO: sort these correctly priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; diff --git a/libraries/entities/src/DiffTraversal.cpp b/libraries/entities/src/DiffTraversal.cpp index d5f2273fd5..39328e11ad 100644 --- a/libraries/entities/src/DiffTraversal.cpp +++ b/libraries/entities/src/DiffTraversal.cpp @@ -221,7 +221,7 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View // // _getNextVisibleElementCallback = identifies elements that need to be traversed, // updates VisibleElement ref argument with pointer-to-element and view-intersection - // (INSIDE, INTERSECtT, or OUTSIDE) + // (INSIDE, INTERSECT, or OUTSIDE) // // external code should update the _scanElementCallback after calling prepareNewTraversal // From 21213e81f4bda569b8cca9db2088ec3375fe1d71 Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 18 Apr 2018 16:21:03 -0700 Subject: [PATCH 056/192] Multiview support for priority queue --- .../src/avatars/AvatarMixerSlave.cpp | 2 +- interface/src/Application.h | 6 ++-- interface/src/avatar/AvatarManager.cpp | 16 +++++++-- .../src/EntityTreeRenderer.cpp | 20 ++++++++--- .../src/EntityTreeRenderer.h | 3 +- .../src/AbstractViewStateInterface.h | 4 +++ libraries/shared/src/PrioritySortUtil.h | 33 ++++++++++++------- tests/render-perf/src/main.cpp | 10 ++++++ 8 files changed, 71 insertions(+), 23 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixerSlave.cpp b/assignment-client/src/avatars/AvatarMixerSlave.cpp index 6f19b73cc5..da9b7934ad 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlave.cpp @@ -223,7 +223,7 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node) // prepare to sort ViewFrustum cameraView = nodeData->getViewFrustum(); - PrioritySortUtil::PriorityQueue sortedAvatars(cameraView, + PrioritySortUtil::PriorityQueue sortedAvatars({cameraView}, AvatarData::_avatarSortCoefficientSize, AvatarData::_avatarSortCoefficientCenter, AvatarData::_avatarSortCoefficientAge); diff --git a/interface/src/Application.h b/interface/src/Application.h index eed6ceeae5..256f428d12 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -175,13 +175,13 @@ public: Camera& getCamera() { return _myCamera; } const Camera& getCamera() const { return _myCamera; } // Represents the current view frustum of the avatar. - void copyViewFrustum(ViewFrustum& viewOut) const; + void copyViewFrustum(ViewFrustum& viewOut) const override; + void copySecondaryViewFrustum(ViewFrustum& viewOut) const override; + bool hasSecondaryViewFrustum() const override { return _hasSecondaryViewFrustum; } // Represents the view frustum of the current rendering pass, // which might be different from the viewFrustum, i.e. shadowmap // passes, mirror window passes, etc void copyDisplayViewFrustum(ViewFrustum& viewOut) const; - void copySecondaryViewFrustum(ViewFrustum& viewOut) const; - bool hasSecondaryViewFrustum() const { return _hasSecondaryViewFrustum; } const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } QSharedPointer getEntities() const { return DependencyManager::get(); } diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index b71c060465..cd20fd9350 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -155,9 +155,19 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { AvatarSharedPointer _avatar; }; - ViewFrustum cameraView; - qApp->copyDisplayViewFrustum(cameraView); - PrioritySortUtil::PriorityQueue sortedAvatars(cameraView, + + std::vector views; + + ViewFrustum view; + qApp->copyCurrentViewFrustum(view); + views.push_back(view); + + if (qApp->hasSecondaryViewFrustum()) { + qApp->copySecondaryViewFrustum(view); + views.push_back(view); + } + + PrioritySortUtil::PriorityQueue sortedAvatars(views, AvatarData::_avatarSortCoefficientSize, AvatarData::_avatarSortCoefficientCenter, AvatarData::_avatarSortCoefficientAge); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index ba81922979..511fa33591 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -296,7 +296,8 @@ void EntityTreeRenderer::addPendingEntities(const render::ScenePointer& scene, r } } -void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const ViewFrustum& view, render::Transaction& transaction) { +void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const std::vector& views, + render::Transaction& transaction) { PROFILE_RANGE_EX(simulation_physics, "ChangeInScene", 0xffff00ff, (uint64_t)_changedEntities.size()); PerformanceTimer pt("change"); std::unordered_set changedEntities; @@ -357,7 +358,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene // prioritize and sort the renderables uint64_t sortStart = usecTimestampNow(); - PrioritySortUtil::PriorityQueue sortedRenderables(view); + PrioritySortUtil::PriorityQueue sortedRenderables(views); { PROFILE_RANGE_EX(simulation_physics, "SortRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); std::unordered_map::iterator itr = _renderablesToUpdate.begin(); @@ -415,9 +416,20 @@ void EntityTreeRenderer::update(bool simulate) { if (scene) { render::Transaction transaction; addPendingEntities(scene, transaction); + + std::vector views; + ViewFrustum view; - _viewState->copyCurrentViewFrustum(view); - updateChangedEntities(scene, view, transaction); + _viewState->copyViewFrustum(view); + views.push_back(view); + + if (_viewState->hasSecondaryViewFrustum()) { + _viewState->copySecondaryViewFrustum(view); + views.push_back(view); + } + + + updateChangedEntities(scene, views, transaction); scene->enqueueTransaction(transaction); } } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index f5cedfdd01..7a7920d5b2 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -148,7 +148,8 @@ protected: private: void addPendingEntities(const render::ScenePointer& scene, render::Transaction& transaction); - void updateChangedEntities(const render::ScenePointer& scene, const ViewFrustum& view, render::Transaction& transaction); + void updateChangedEntities(const render::ScenePointer& scene, const std::vector& views, + render::Transaction& transaction); EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); } render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); } diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index 54fdc903ca..9d781b7d18 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -31,6 +31,10 @@ public: /// copies the current view frustum for rendering the view state virtual void copyCurrentViewFrustum(ViewFrustum& viewOut) const = 0; + virtual void copyViewFrustum(ViewFrustum& viewOut) const = 0; + virtual void copySecondaryViewFrustum(ViewFrustum& viewOut) const = 0; + virtual bool hasSecondaryViewFrustum() const = 0; + virtual QThread* getMainThread() = 0; virtual PickRay computePickRay(float x, float y) const = 0; diff --git a/libraries/shared/src/PrioritySortUtil.h b/libraries/shared/src/PrioritySortUtil.h index 279fa42ea4..7c0f30ec75 100644 --- a/libraries/shared/src/PrioritySortUtil.h +++ b/libraries/shared/src/PrioritySortUtil.h @@ -83,15 +83,15 @@ namespace PrioritySortUtil { template class PriorityQueue { public: + using Views = std::vector; + PriorityQueue() = delete; - - PriorityQueue(const ViewFrustum& view) : _view(view) { } - - PriorityQueue(const ViewFrustum& view, float angularWeight, float centerWeight, float ageWeight) - : _view(view), _angularWeight(angularWeight), _centerWeight(centerWeight), _ageWeight(ageWeight) + PriorityQueue(const Views& views) : _views(views) { } + PriorityQueue(const Views& views, float angularWeight, float centerWeight, float ageWeight) + : _views(views), _angularWeight(angularWeight), _centerWeight(centerWeight), _ageWeight(ageWeight) { } - void setView(const ViewFrustum& view) { _view = view; } + void setViews(const Views& views) { _views = views; } void setWeights(float angularWeight, float centerWeight, float ageWeight) { _angularWeight = angularWeight; @@ -109,7 +109,18 @@ namespace PrioritySortUtil { bool empty() const { return _queue.empty(); } private: + float computePriority(const T& thing) const { + float priority = std::numeric_limits::min(); + + for (const auto& view : _views) { + priority = std::max(priority, computePriority(view, thing)); + } + + return priority; + } + + float computePriority(const ViewFrustum& view, const T& thing) const { // priority = weighted linear combination of multiple values: // (a) angular size // (b) proximity to center of view @@ -117,11 +128,11 @@ namespace PrioritySortUtil { // where the relative "weights" are tuned to scale the contributing values into units of "priority". glm::vec3 position = thing.getPosition(); - glm::vec3 offset = position - _view.getPosition(); + glm::vec3 offset = position - view.getPosition(); float distance = glm::length(offset) + 0.001f; // add 1mm to avoid divide by zero const float MIN_RADIUS = 0.1f; // WORKAROUND for zero size objects (we still want them to sort by distance) float radius = glm::min(thing.getRadius(), MIN_RADIUS); - float cosineAngle = (glm::dot(offset, _view.getDirection()) / distance); + float cosineAngle = (glm::dot(offset, view.getDirection()) / distance); float age = (float)(usecTimestampNow() - thing.getTimestamp()); // we modulatate "age" drift rate by the cosineAngle term to make periphrial objects sort forward @@ -134,8 +145,8 @@ namespace PrioritySortUtil { + _ageWeight * cosineAngleFactor * age; // decrement priority of things outside keyhole - if (distance - radius > _view.getCenterRadius()) { - if (!_view.sphereIntersectsFrustum(position, radius)) { + if (distance - radius > view.getCenterRadius()) { + if (!view.sphereIntersectsFrustum(position, radius)) { constexpr float OUT_OF_VIEW_PENALTY = -10.0f; priority += OUT_OF_VIEW_PENALTY; } @@ -143,7 +154,7 @@ namespace PrioritySortUtil { return priority; } - ViewFrustum _view; + Views _views; std::priority_queue _queue; float _angularWeight { DEFAULT_ANGULAR_COEF }; float _centerWeight { DEFAULT_CENTER_COEF }; diff --git a/tests/render-perf/src/main.cpp b/tests/render-perf/src/main.cpp index 9249b3d957..8c17d7c5c2 100644 --- a/tests/render-perf/src/main.cpp +++ b/tests/render-perf/src/main.cpp @@ -441,6 +441,16 @@ protected: viewOut = _viewFrustum; } + void copyViewFrustum(ViewFrustum& viewOut) const override { + viewOut = _viewFrustum; + } + + void copySecondaryViewFrustum(ViewFrustum& viewOut) const override {} + + bool hasSecondaryViewFrustum() const override { + return false; + } + QThread* getMainThread() override { return QThread::currentThread(); } From 1b2b70b7691b65cfa96881cddd005a6f2d664147 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 23 Apr 2018 15:47:05 -0700 Subject: [PATCH 057/192] Send both frustums to Avatar Mixer --- assignment-client/src/avatars/AvatarMixer.cpp | 8 +++----- .../src/avatars/AvatarMixerClientData.cpp | 16 ++++++++++++---- .../src/avatars/AvatarMixerClientData.h | 4 ++-- .../src/avatars/AvatarMixerSlave.cpp | 4 ++-- interface/src/Application.cpp | 4 ++++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 29340f6474..6353a1664f 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -521,11 +521,9 @@ void AvatarMixer::handleViewFrustumPacket(QSharedPointer messag auto start = usecTimestampNow(); getOrCreateClientData(senderNode); - if (senderNode->getLinkedData()) { - AvatarMixerClientData* nodeData = dynamic_cast(senderNode->getLinkedData()); - if (nodeData != nullptr) { - nodeData->readViewFrustumPacket(message->getMessage()); - } + AvatarMixerClientData* nodeData = dynamic_cast(senderNode->getLinkedData()); + if (nodeData) { + nodeData->readViewFrustumPacket(message->getMessage()); } auto end = usecTimestampNow(); diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index 268aba62d6..8c159cf744 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -19,8 +19,6 @@ AvatarMixerClientData::AvatarMixerClientData(const QUuid& nodeID) : NodeData(nodeID) { - _currentViewFrustum.invalidate(); - // in case somebody calls getSessionUUID on the AvatarData instance, make sure it has the right ID _avatar->setID(nodeID); } @@ -129,11 +127,21 @@ void AvatarMixerClientData::removeFromRadiusIgnoringSet(SharedNodePointer self, } void AvatarMixerClientData::readViewFrustumPacket(const QByteArray& message) { - _currentViewFrustum.fromByteArray(message); + _currentViewFrustums.clear(); + + auto offset = 0; + while (offset < message.size()) { + ViewFrustum frustum; + offset += frustum.fromByteArray(message); + _currentViewFrustums.push_back(frustum); + } } bool AvatarMixerClientData::otherAvatarInView(const AABox& otherAvatarBox) { - return _currentViewFrustum.boxIntersectsKeyhole(otherAvatarBox); + return std::any_of(std::begin(_currentViewFrustums), std::end(_currentViewFrustums), + [&](const ViewFrustum& viewFrustum) { + return viewFrustum.boxIntersectsKeyhole(otherAvatarBox); + }); } void AvatarMixerClientData::loadJSONStats(QJsonObject& jsonObject) const { diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 6963f4df0d..4b06617175 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -110,7 +110,7 @@ public: bool getRequestsDomainListData() { return _requestsDomainListData; } void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; } - ViewFrustum getViewFrustum() const { return _currentViewFrustum; } + const std::vector& getViewFrustums() const { return _currentViewFrustums; } uint64_t getLastOtherAvatarEncodeTime(QUuid otherAvatar) const; void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, uint64_t time); @@ -150,7 +150,7 @@ private: SimpleMovingAverage _avgOtherAvatarDataRate; std::unordered_set _radiusIgnoredOthers; - ViewFrustum _currentViewFrustum; + std::vector _currentViewFrustums; int _recentOtherAvatarsInView { 0 }; int _recentOtherAvatarsOutOfView { 0 }; diff --git a/assignment-client/src/avatars/AvatarMixerSlave.cpp b/assignment-client/src/avatars/AvatarMixerSlave.cpp index da9b7934ad..30d94ed772 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlave.cpp @@ -222,8 +222,8 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node) }; // prepare to sort - ViewFrustum cameraView = nodeData->getViewFrustum(); - PrioritySortUtil::PriorityQueue sortedAvatars({cameraView}, + const auto& cameraViews = nodeData->getViewFrustums(); + PrioritySortUtil::PriorityQueue sortedAvatars(cameraViews, AvatarData::_avatarSortCoefficientSize, AvatarData::_avatarSortCoefficientCenter, AvatarData::_avatarSortCoefficientAge); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a5b859628f..33c334b493 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5806,6 +5806,10 @@ void Application::update(float deltaTime) { void Application::sendAvatarViewFrustum() { QByteArray viewFrustumByteArray = _viewFrustum.toByteArray(); + if (hasSecondaryViewFrustum()) { + viewFrustumByteArray += _viewFrustum.toByteArray(); + } + auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size()); avatarPacket->write(viewFrustumByteArray); From 538f24162f3ecc2892ca361a0339eced1087113f Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 23 Apr 2018 15:57:21 -0700 Subject: [PATCH 058/192] Define ViewFrustums type alias --- assignment-client/src/avatars/AvatarMixerClientData.h | 4 ++-- interface/src/avatar/AvatarManager.cpp | 2 +- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 4 ++-- libraries/entities-renderer/src/EntityTreeRenderer.h | 2 +- libraries/entities/src/DiffTraversal.h | 2 +- libraries/shared/src/PrioritySortUtil.h | 10 ++++------ libraries/shared/src/ViewFrustum.h | 1 + 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 4b06617175..13415d6a66 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -110,7 +110,7 @@ public: bool getRequestsDomainListData() { return _requestsDomainListData; } void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; } - const std::vector& getViewFrustums() const { return _currentViewFrustums; } + const ViewFrustums& getViewFrustums() const { return _currentViewFrustums; } uint64_t getLastOtherAvatarEncodeTime(QUuid otherAvatar) const; void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, uint64_t time); @@ -150,7 +150,7 @@ private: SimpleMovingAverage _avgOtherAvatarDataRate; std::unordered_set _radiusIgnoredOthers; - std::vector _currentViewFrustums; + ViewFrustums _currentViewFrustums; int _recentOtherAvatarsInView { 0 }; int _recentOtherAvatarsOutOfView { 0 }; diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index cd20fd9350..087e23a933 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -156,7 +156,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { }; - std::vector views; + ViewFrustums views; ViewFrustum view; qApp->copyCurrentViewFrustum(view); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 511fa33591..6dd13c7332 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -296,7 +296,7 @@ void EntityTreeRenderer::addPendingEntities(const render::ScenePointer& scene, r } } -void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const std::vector& views, +void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views, render::Transaction& transaction) { PROFILE_RANGE_EX(simulation_physics, "ChangeInScene", 0xffff00ff, (uint64_t)_changedEntities.size()); PerformanceTimer pt("change"); @@ -417,7 +417,7 @@ void EntityTreeRenderer::update(bool simulate) { render::Transaction transaction; addPendingEntities(scene, transaction); - std::vector views; + ViewFrustums views; ViewFrustum view; _viewState->copyViewFrustum(view); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 7a7920d5b2..9ed4f9d21d 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -148,7 +148,7 @@ protected: private: void addPendingEntities(const render::ScenePointer& scene, render::Transaction& transaction); - void updateChangedEntities(const render::ScenePointer& scene, const std::vector& views, + void updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views, render::Transaction& transaction); EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); } render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); } diff --git a/libraries/entities/src/DiffTraversal.h b/libraries/entities/src/DiffTraversal.h index 50fe74a75b..0fd014ac23 100644 --- a/libraries/entities/src/DiffTraversal.h +++ b/libraries/entities/src/DiffTraversal.h @@ -36,7 +36,7 @@ public: bool isVerySimilar(const View& view) const; ViewFrustum::intersection calculateIntersection(const AACube& cube) const; - std::vector viewFrustums; + ViewFrustums viewFrustums; uint64_t startTime { 0 }; float lodScaleFactor { 1.0f }; }; diff --git a/libraries/shared/src/PrioritySortUtil.h b/libraries/shared/src/PrioritySortUtil.h index 7c0f30ec75..ba15222611 100644 --- a/libraries/shared/src/PrioritySortUtil.h +++ b/libraries/shared/src/PrioritySortUtil.h @@ -83,15 +83,13 @@ namespace PrioritySortUtil { template class PriorityQueue { public: - using Views = std::vector; - PriorityQueue() = delete; - PriorityQueue(const Views& views) : _views(views) { } - PriorityQueue(const Views& views, float angularWeight, float centerWeight, float ageWeight) + PriorityQueue(const ViewFrustums& views) : _views(views) { } + PriorityQueue(const ViewFrustums& views, float angularWeight, float centerWeight, float ageWeight) : _views(views), _angularWeight(angularWeight), _centerWeight(centerWeight), _ageWeight(ageWeight) { } - void setViews(const Views& views) { _views = views; } + void setViews(const ViewFrustums& views) { _views = views; } void setWeights(float angularWeight, float centerWeight, float ageWeight) { _angularWeight = angularWeight; @@ -154,7 +152,7 @@ namespace PrioritySortUtil { return priority; } - Views _views; + ViewFrustums _views; std::priority_queue _queue; float _angularWeight { DEFAULT_ANGULAR_COEF }; float _centerWeight { DEFAULT_CENTER_COEF }; diff --git a/libraries/shared/src/ViewFrustum.h b/libraries/shared/src/ViewFrustum.h index ba8957bba3..128a717df8 100644 --- a/libraries/shared/src/ViewFrustum.h +++ b/libraries/shared/src/ViewFrustum.h @@ -189,5 +189,6 @@ private: }; using ViewFrustumPointer = std::shared_ptr; +using ViewFrustums = std::vector; #endif // hifi_ViewFrustum_h From ddde0228ba3b1fd6b8a3006101594ff6ead9e2a8 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 23 Apr 2018 16:10:44 -0700 Subject: [PATCH 059/192] Fix AC not sending Avatar Mixer a frustum --- assignment-client/src/Agent.cpp | 15 +++++++++++++++ assignment-client/src/Agent.h | 1 + interface/src/Application.cpp | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 1df901dd98..26bfb586a6 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -594,9 +594,24 @@ void Agent::sendAvatarIdentityPacket() { auto scriptedAvatar = DependencyManager::get(); scriptedAvatar->markIdentityDataChanged(); scriptedAvatar->sendIdentityPacket(); + sendAvatarViewFrustum(); } } +void Agent::sendAvatarViewFrustum() { + auto scriptedAvatar = DependencyManager::get(); + ViewFrustum view; + view.setPosition(scriptedAvatar->getWorldPosition()); + view.setOrientation(scriptedAvatar->getHeadOrientation()); + auto viewFrustumByteArray = view.toByteArray(); + + auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size()); + avatarPacket->write(viewFrustumByteArray); + + DependencyManager::get()->broadcastToNodes(std::move(avatarPacket), + { NodeType::AvatarMixer }); +} + void Agent::processAgentAvatar() { if (!_scriptEngine->isFinished() && _isAvatar) { auto scriptedAvatar = DependencyManager::get(); diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index 1229f06276..e4ce0f95eb 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -97,6 +97,7 @@ private: void setAvatarSound(SharedSoundPointer avatarSound) { _avatarSound = avatarSound; } void sendAvatarIdentityPacket(); + void sendAvatarViewFrustum(); QString _scriptContents; QTimer* _scriptRequestTimeout { nullptr }; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 33c334b493..cdb535fad1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5806,8 +5806,8 @@ void Application::update(float deltaTime) { void Application::sendAvatarViewFrustum() { QByteArray viewFrustumByteArray = _viewFrustum.toByteArray(); - if (hasSecondaryViewFrustum()) { - viewFrustumByteArray += _viewFrustum.toByteArray(); + if (_hasSecondaryViewFrustum) { + viewFrustumByteArray += _secondaryViewFrustum.toByteArray(); } auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size()); From a283d28686fcdb9aa138dad0d66e4d4ab5ccb2b4 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 24 Apr 2018 19:09:16 -0700 Subject: [PATCH 060/192] Send number of frustums in packet --- assignment-client/src/Agent.cpp | 7 ++++++- .../src/avatars/AvatarMixerClientData.cpp | 13 +++++++++---- .../src/avatars/AvatarMixerClientData.h | 2 +- interface/src/Application.cpp | 6 +++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 26bfb586a6..8816ed9629 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -600,12 +600,17 @@ void Agent::sendAvatarIdentityPacket() { void Agent::sendAvatarViewFrustum() { auto scriptedAvatar = DependencyManager::get(); + ViewFrustum view; view.setPosition(scriptedAvatar->getWorldPosition()); view.setOrientation(scriptedAvatar->getHeadOrientation()); + view.calculate(); + + uint8_t numFrustums = 1; auto viewFrustumByteArray = view.toByteArray(); - auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size()); + auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums)); + avatarPacket->writePrimitive(numFrustums); avatarPacket->write(viewFrustumByteArray); DependencyManager::get()->broadcastToNodes(std::move(avatarPacket), diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index 8c159cf744..a8e5a7c541 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -126,13 +126,18 @@ void AvatarMixerClientData::removeFromRadiusIgnoringSet(SharedNodePointer self, } } -void AvatarMixerClientData::readViewFrustumPacket(const QByteArray& message) { +void AvatarMixerClientData::readViewFrustumPacket(QByteArray message) { _currentViewFrustums.clear(); + + uint8_t numFrustums = 0; + memcpy(&numFrustums, message.constData(), sizeof(numFrustums)); + message.remove(0, sizeof(numFrustums)); - auto offset = 0; - while (offset < message.size()) { + for (uint8_t i = 0; i < numFrustums; ++i) { ViewFrustum frustum; - offset += frustum.fromByteArray(message); + auto bytesRead = frustum.fromByteArray(message); + message.remove(0, bytesRead); + _currentViewFrustums.push_back(frustum); } } diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 13415d6a66..f17404b79f 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -98,7 +98,7 @@ public: void removeFromRadiusIgnoringSet(SharedNodePointer self, const QUuid& other); void ignoreOther(SharedNodePointer self, SharedNodePointer other); - void readViewFrustumPacket(const QByteArray& message); + void readViewFrustumPacket(QByteArray message); bool otherAvatarInView(const AABox& otherAvatarBox); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cdb535fad1..c88b5981b4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5805,12 +5805,16 @@ void Application::update(float deltaTime) { } void Application::sendAvatarViewFrustum() { + uint8_t numFrustums = 1; QByteArray viewFrustumByteArray = _viewFrustum.toByteArray(); + if (_hasSecondaryViewFrustum) { + ++numFrustums; viewFrustumByteArray += _secondaryViewFrustum.toByteArray(); } - auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size()); + auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums)); + avatarPacket->writePrimitive(numFrustums); avatarPacket->write(viewFrustumByteArray); DependencyManager::get()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer); From 2ad948c46219e75bbfab174aea2aeb4674adadb7 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 24 Apr 2018 19:12:42 -0700 Subject: [PATCH 061/192] Bump ViewFrustum packet version --- libraries/networking/src/udt/PacketHeaders.cpp | 2 ++ libraries/networking/src/udt/PacketHeaders.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index b16f9c903e..17b0d90cfe 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -90,6 +90,8 @@ PacketVersion versionForPacketType(PacketType packetType) { return 18; // replace min_avatar_scale and max_avatar_scale with min_avatar_height and max_avatar_height case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); + case PacketType::ViewFrustum: + return static_cast(ViewFrustumVersion::SendMultipleFrustums); default: return 20; } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 9b48e3a132..c72bbb0129 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -328,4 +328,8 @@ enum class PingVersion : PacketVersion { IncludeConnectionID = 18 }; +enum class ViewFrustumVersion : PacketVersion { + SendMultipleFrustums = 21 +}; + #endif // hifi_PacketHeaders_h From 83a438eb22c02ea6a86301433588c119d023a1f3 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 18:10:55 -0700 Subject: [PATCH 062/192] Set avatar view packets on their own timer --- assignment-client/src/Agent.cpp | 10 ++++++++-- assignment-client/src/Agent.h | 1 + libraries/avatars/src/AvatarData.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 8816ed9629..f560ea72bd 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -548,16 +548,18 @@ void Agent::setIsAvatar(bool isAvatar) { if (_isAvatar && !_avatarIdentityTimer) { // set up the avatar timers _avatarIdentityTimer = new QTimer(this); + _avatarViewTimer = new QTimer(this); // connect our slot connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket); + connect(_avatarViewTimer, &QTimer::timeout, this, &Agent::sendAvatarViewFrustum); // start the timers _avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets + _avatarViewTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS); // tell the avatarAudioTimer to start ticking QMetaObject::invokeMethod(&_avatarAudioTimer, "start"); - } if (!_isAvatar) { @@ -567,6 +569,10 @@ void Agent::setIsAvatar(bool isAvatar) { delete _avatarIdentityTimer; _avatarIdentityTimer = nullptr; + _avatarViewTimer->stop(); + delete _avatarViewTimer; + _avatarViewTimer = nullptr; + // The avatar mixer never times out a connection (e.g., based on identity or data packets) // but rather keeps avatars in its list as long as "connected". As a result, clients timeout // when we stop sending identity, but then get woken up again by the mixer itself, which sends @@ -585,6 +591,7 @@ void Agent::setIsAvatar(bool isAvatar) { nodeList->sendPacket(std::move(packet), *node); }); } + QMetaObject::invokeMethod(&_avatarAudioTimer, "stop"); } } @@ -594,7 +601,6 @@ void Agent::sendAvatarIdentityPacket() { auto scriptedAvatar = DependencyManager::get(); scriptedAvatar->markIdentityDataChanged(); scriptedAvatar->sendIdentityPacket(); - sendAvatarViewFrustum(); } } diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index e4ce0f95eb..d144f0bc01 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -107,6 +107,7 @@ private: int _numAvatarSoundSentBytes = 0; bool _isAvatar = false; QTimer* _avatarIdentityTimer = nullptr; + QTimer* _avatarViewTimer = nullptr; QHash _outgoingScriptAudioSequenceNumbers; AudioGate _audioGate; diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 888c3bfb24..3db94f6691 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -278,6 +278,7 @@ namespace AvatarDataPacket { const float MAX_AUDIO_LOUDNESS = 1000.0f; // close enough for mouth animation const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000; +const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 100; // See also static AvatarData::defaultFullAvatarModelUrl(). const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default"); From 5a064d3499681c6b1376007e550fb7cea8526010 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 14:13:15 +1200 Subject: [PATCH 063/192] Remove selection handles and list highlight when entity deletes --- scripts/system/edit.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index c99c8d401a..9b6b70b954 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -471,6 +471,10 @@ var toolBar = (function () { } } + function checkDeletedEntityAndUpdate(entityID) { + selectionManager.removeEntity(entityID); + } + function initialize() { Script.scriptEnding.connect(cleanup); Window.domainChanged.connect(function () { @@ -493,8 +497,10 @@ var toolBar = (function () { Entities.canRezTmpChanged.connect(checkEditPermissionsAndUpdate); Entities.canRezCertifiedChanged.connect(checkEditPermissionsAndUpdate); Entities.canRezTmpCertifiedChanged.connect(checkEditPermissionsAndUpdate); - var hasRezPermissions = (Entities.canRez() || Entities.canRezTmp() || Entities.canRezCertified() || Entities.canRezTmpCertified()); + + Entities.deletingEntity.connect(checkDeletedEntityAndUpdate); + var createButtonIconRsrc = (hasRezPermissions ? CREATE_ENABLED_ICON : CREATE_DISABLED_ICON); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); activeButton = tablet.addButton({ From f27e363b6879d6a3e064ee45e91fafcb770ad465 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 15:23:13 +1200 Subject: [PATCH 064/192] Remove entity from list when it deletes; handle multiple deletions --- scripts/system/edit.js | 17 ++++++++++++++++- scripts/system/libraries/entitySelectionTool.js | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 9b6b70b954..6bb815a597 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -471,8 +471,23 @@ var toolBar = (function () { } } + var entitiesToDelete = []; + var deletedEntityTimer = null; + var DELETE_ENTITY_TIMER_TIMEOUT = 100; + function checkDeletedEntityAndUpdate(entityID) { - selectionManager.removeEntity(entityID); + // Allow for multiple entity deletes before updating the entity list. + entitiesToDelete.push(entityID); + if (deletedEntityTimer !== null) { + Script.clearTimeout(deletedEntityTimer); + } + deletedEntityTimer = Script.setTimeout(function () { + selectionManager.removeEntities(entitiesToDelete); + entityListTool.clearEntityList(); + entityListTool.sendUpdate(); + entitiesToDelete = []; + deletedEntityTimer = null; + }, DELETE_ENTITY_TIMER_TIMEOUT); } function initialize() { diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 2322210522..4996579799 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -149,6 +149,17 @@ SelectionManager = (function() { that._update(true); }; + that.removeEntities = function (entityIDs) { + for (var i = 0, length = entityIDs.length; i < length; i++) { + var idx = that.selections.indexOf(entityIDs[i]); + if (idx >= 0) { + that.selections.splice(idx, 1); + Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityIDs[i]); + } + } + that._update(true); + }; + that.clearSelections = function() { that.selections = []; that._update(true); From 48632be3c2760725d6376f03e227045a1d7220b4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 16:12:48 +1200 Subject: [PATCH 065/192] Fix up cache APIs' JSDoc --- libraries/animation/src/AnimationCache.h | 30 +++---- libraries/audio/src/SoundCache.h | 20 ++--- .../src/model-networking/ModelCache.h | 18 ++--- .../src/model-networking/TextureCache.h | 81 +++++++++---------- libraries/networking/src/ResourceCache.h | 18 ++--- 5 files changed, 70 insertions(+), 97 deletions(-) diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h index 03b37aef2f..103b620254 100644 --- a/libraries/animation/src/AnimationCache.h +++ b/libraries/animation/src/AnimationCache.h @@ -43,45 +43,39 @@ public: * @property {number} sizeCached - Size in bytes of all cached resources. Read-only. */ - // Functions are copied over from ResourceCache (see ResourceCache.h for reason). + // Functions are copied over from ResourceCache (see ResourceCache.h for reason). - /**jsdoc + /**jsdoc * Get the list of all resource URLs. * @function AnimationCache.getResourceList - * @return {string[]} + * @returns {string[]} */ - /**jsdoc + /**jsdoc * @function AnimationCache.dirty * @returns {Signal} */ - /**jsdoc + /**jsdoc * @function AnimationCache.updateTotalSize * @param {number} deltaSize */ - /**jsdoc + /**jsdoc + * Prefetches a resource. * @function AnimationCache.prefetch - * @param {string} url - * @param {object} extra - * @returns {object} + * @param {string} url - URL of the resource to prefetch. + * @param {object} [extra=null] + * @returns {Resource} */ - /**jsdoc + /**jsdoc * Asynchronously loads a resource from the specified URL and returns it. * @function AnimationCache.getResource * @param {string} url - URL of the resource to load. * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. * @param {} [extra=null] - * @return {Resource} - */ - - /**jsdoc - * Prefetches a resource. - * @function AnimationCache.prefetch - * @param {string} url - URL of the resource to prefetch. - * @return {Resource} + * @returns {Resource} */ diff --git a/libraries/audio/src/SoundCache.h b/libraries/audio/src/SoundCache.h index d8c52635e0..039e815ff3 100644 --- a/libraries/audio/src/SoundCache.h +++ b/libraries/audio/src/SoundCache.h @@ -36,12 +36,12 @@ public: */ - // Functions are copied over from ResourceCache (see ResourceCache.h for reason). + // Functions are copied over from ResourceCache (see ResourceCache.h for reason). /**jsdoc * Get the list of all resource URLs. * @function SoundCache.getResourceList - * @return {string[]} + * @returns {string[]} */ /**jsdoc @@ -55,10 +55,11 @@ public: */ /**jsdoc + * Prefetches a resource. * @function SoundCache.prefetch - * @param {string} url - * @param {object} extra - * @returns {object} + * @param {string} url - URL of the resource to prefetch. + * @param {object} [extra=null] + * @returns {Resource} */ /**jsdoc @@ -67,14 +68,7 @@ public: * @param {string} url - URL of the resource to load. * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. * @param {} [extra=null] - * @return {Resource} - */ - - /**jsdoc - * Prefetches a resource. - * @function SoundCache.prefetch - * @param {string} url - URL of the resource to prefetch. - * @return {Resource} + * @returns {Resource} */ diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 9532f39ce0..438c5e0d65 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -156,7 +156,7 @@ public: /**jsdoc * Get the list of all resource URLs. * @function ModelCache.getResourceList - * @return {string[]} + * @returns {string[]} */ /**jsdoc @@ -170,10 +170,11 @@ public: */ /**jsdoc + * Prefetches a resource. * @function ModelCache.prefetch - * @param {string} url - * @param {object} extra - * @returns {object} + * @param {string} url - URL of the resource to prefetch. + * @param {object} [extra=null] + * @returns {Resource} */ /**jsdoc @@ -182,14 +183,7 @@ public: * @param {string} url - URL of the resource to load. * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. * @param {} [extra=null] - * @return {Resource} - */ - - /**jsdoc - * Prefetches a resource. - * @function ModelCache.prefetch - * @param {string} url - URL of the resource to prefetch. - * @return {Resource} + * @returns {Resource} */ diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 3f46dc3074..0c0dbeefa4 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -148,56 +148,50 @@ public: // Properties are copied over from ResourceCache (see ResourceCache.h for reason). /**jsdoc - * API to manage texture cache resources. - * @namespace TextureCache - * - * @property {number} numTotal - Total number of total resources. Read-only. - * @property {number} numCached - Total number of cached resource. Read-only. - * @property {number} sizeTotal - Size in bytes of all resources. Read-only. - * @property {number} sizeCached - Size in bytes of all cached resources. Read-only. - */ + * API to manage texture cache resources. + * @namespace TextureCache + * + * @property {number} numTotal - Total number of total resources. Read-only. + * @property {number} numCached - Total number of cached resource. Read-only. + * @property {number} sizeTotal - Size in bytes of all resources. Read-only. + * @property {number} sizeCached - Size in bytes of all cached resources. Read-only. + */ // Functions are copied over from ResourceCache (see ResourceCache.h for reason). - /**jsdoc - * Get the list of all resource URLs. - * @function TextureCache.getResourceList - * @return {string[]} - */ + /**jsdoc + * Get the list of all resource URLs. + * @function TextureCache.getResourceList + * @returns {string[]} + */ - /**jsdoc - * @function TextureCache.dirty - * @returns {Signal} - */ + /**jsdoc + * @function TextureCache.dirty + * @returns {Signal} + */ - /**jsdoc - * @function TextureCache.updateTotalSize - * @param {number} deltaSize - */ + /**jsdoc + * @function TextureCache.updateTotalSize + * @param {number} deltaSize + */ - /**jsdoc - * @function TextureCache.prefetch - * @param {string} url - * @param {object} extra - * @returns {object} - */ + /**jsdoc + * Prefetches a resource. + * @function TextureCache.prefetch + * @param {string} url - URL of the resource to prefetch. + * @param {object} [extra=null] + * @returns {Resource} + */ - /**jsdoc - * Asynchronously loads a resource from the specified URL and returns it. - * @function TextureCache.getResource - * @param {string} url - URL of the resource to load. - * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. - * @param {} [extra=null] - * @return {Resource} - */ - - /**jsdoc - * Prefetches a resource. - * @function TextureCache.prefetch - * @param {string} url - URL of the resource to prefetch. - * @return {Resource} - */ + /**jsdoc + * Asynchronously loads a resource from the specified URL and returns it. + * @function TextureCache.getResource + * @param {string} url - URL of the resource to load. + * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. + * @param {} [extra=null] + * @returns {Resource} + */ /// Returns the ID of the permutation/normal texture used for Perlin noise shader programs. This texture @@ -246,10 +240,11 @@ signals: protected: /**jsdoc - * @function TextureCache.prefect + * @function TextureCache.prefetch * @param {string} url * @param {number} type * @param {number} [maxNumPixels=67108864] + * @returns {Resource} */ // Overload ResourceCache::prefetch to allow specifying texture type for loads Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url, int type, int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS); diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 609483bc56..8a77beefd4 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -209,7 +209,7 @@ public: /**jsdoc * Get the list of all resource URLs. * @function ResourceCache.getResourceList - * @return {string[]} + * @returns {string[]} */ Q_INVOKABLE QVariantList getResourceList(); @@ -251,10 +251,11 @@ protected slots: void updateTotalSize(const qint64& deltaSize); /**jsdoc + * Prefetches a resource. * @function ResourceCache.prefetch - * @param {string} url - * @param {object} extra - * @returns {object} + * @param {string} url - URL of the resource to prefetch. + * @param {object} [extra=null] + * @returns {Resource} */ // Prefetches a resource to be held by the QScriptEngine. // Left as a protected member so subclasses can overload prefetch @@ -267,7 +268,7 @@ protected slots: * @param {string} url - URL of the resource to load. * @param {string} [fallback=""] - Fallback URL if load of the desired URL fails. * @param {} [extra=null] - * @return {Resource} + * @returns {Resource} */ /// Loads a resource from the specified URL and returns it. /// If the caller is on a different thread than the ResourceCache, @@ -285,12 +286,7 @@ protected: // Pointers created through this method should be owned by the caller, // which should be a QScriptEngine with ScriptableResource registered, so that // the QScriptEngine will delete the pointer when it is garbage collected. - /**jsdoc - * Prefetches a resource. - * @function ResourceCache.prefetch - * @param {string} url - URL of the resource to prefetch. - * @return {Resource} - */ + // JSDoc is provided on more general function signature. Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url) { return prefetch(url, nullptr); } /// Creates a new resource. From 3febdcb141d540075c09739efae715d7543a1e14 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 16:15:35 +1200 Subject: [PATCH 066/192] Miscellaneous JSDoc tidying --- interface/src/scripting/SelectionScriptingInterface.h | 6 +++--- .../src/graphics-scripting/GraphicsScriptingInterface.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 71ff41248a..86ececcbca 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -131,7 +131,7 @@ public: /**jsdoc * Get the names of all the selection lists. * @function Selection.getListNames - * @return {list[]} An array of names of all the selection lists. + * @returns {list[]} An array of names of all the selection lists. */ Q_INVOKABLE QStringList getListNames() const; @@ -181,7 +181,7 @@ public: * Get the list of avatars, entities, and overlays stored in a selection list. * @function Selection.getList * @param {string} listName - The name of the selection list. - * @return {Selection.SelectedItemsList} The content of a selection list. If the list name doesn't exist, the function + * @returns {Selection.SelectedItemsList} The content of a selection list. If the list name doesn't exist, the function * returns an empty object with no properties. */ Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const; @@ -189,7 +189,7 @@ public: /**jsdoc * Get the names of the highlighted selection lists. * @function Selection.getHighlightedListNames - * @return {string[]} An array of names of the selection list currently highlight enabled. + * @returns {string[]} An array of names of the selection list currently highlight enabled. */ Q_INVOKABLE QStringList getHighlightedListNames() const; diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h index 526352804b..e0bb39c855 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h @@ -39,7 +39,7 @@ public slots: * * @function Graphics.getModel * @param {UUID} entityID - The objectID of the model whose meshes are to be retrieved. - * @return {Graphics.Model} the resulting Model object + * @returns {Graphics.Model} the resulting Model object */ scriptable::ScriptableModelPointer getModel(QUuid uuid); @@ -54,7 +54,7 @@ public slots: * * @function Graphics.newMesh * @param {Graphics.IFSData} ifsMeshData Index-Faced Set (IFS) arrays used to create the new mesh. - * @return {Graphics.Mesh} the resulting Mesh / Mesh Part object + * @returns {Graphics.Mesh} the resulting Mesh / Mesh Part object */ /**jsdoc * @typedef {object} Graphics.IFSData From 05c534991eb182b9e2786548cd32dda8f73f771b Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Wed, 2 May 2018 09:39:42 -0700 Subject: [PATCH 067/192] Fix ASAN warnings --- libraries/audio/src/AudioDynamics.h | 31 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libraries/audio/src/AudioDynamics.h b/libraries/audio/src/AudioDynamics.h index a43833610a..03506fa8a1 100644 --- a/libraries/audio/src/AudioDynamics.h +++ b/libraries/audio/src/AudioDynamics.h @@ -10,9 +10,9 @@ // Inline functions to implement audio dynamics processing // -#include #include #include +#include #ifndef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -147,13 +147,13 @@ static const int IEEE754_EXPN_BIAS = 127; static inline int32_t peaklog2(float* input) { // float as integer bits - int32_t u = *(int32_t*)input; + uint32_t u = *(uint32_t*)input; // absolute value - int32_t peak = u & IEEE754_FABS_MASK; + uint32_t peak = u & IEEE754_FABS_MASK; // split into e and x - 1.0 - int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; + int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff; // saturate @@ -183,16 +183,16 @@ static inline int32_t peaklog2(float* input) { static inline int32_t peaklog2(float* input0, float* input1) { // float as integer bits - int32_t u0 = *(int32_t*)input0; - int32_t u1 = *(int32_t*)input1; + uint32_t u0 = *(uint32_t*)input0; + uint32_t u1 = *(uint32_t*)input1; // max absolute value u0 &= IEEE754_FABS_MASK; u1 &= IEEE754_FABS_MASK; - int32_t peak = MAX(u0, u1); + uint32_t peak = MAX(u0, u1); // split into e and x - 1.0 - int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; + int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff; // saturate @@ -222,20 +222,20 @@ static inline int32_t peaklog2(float* input0, float* input1) { static inline int32_t peaklog2(float* input0, float* input1, float* input2, float* input3) { // float as integer bits - int32_t u0 = *(int32_t*)input0; - int32_t u1 = *(int32_t*)input1; - int32_t u2 = *(int32_t*)input2; - int32_t u3 = *(int32_t*)input3; + uint32_t u0 = *(uint32_t*)input0; + uint32_t u1 = *(uint32_t*)input1; + uint32_t u2 = *(uint32_t*)input2; + uint32_t u3 = *(uint32_t*)input3; // max absolute value u0 &= IEEE754_FABS_MASK; u1 &= IEEE754_FABS_MASK; u2 &= IEEE754_FABS_MASK; u3 &= IEEE754_FABS_MASK; - int32_t peak = MAX(MAX(u0, u1), MAX(u2, u3)); + uint32_t peak = MAX(MAX(u0, u1), MAX(u2, u3)); // split into e and x - 1.0 - int32_t e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; + int e = IEEE754_EXPN_BIAS - (peak >> IEEE754_MANT_BITS) + LOG2_HEADROOM; int32_t x = (peak << IEEE754_EXPN_BITS) & 0x7fffffff; // saturate @@ -303,8 +303,7 @@ static inline int32_t fixlog2(int32_t x) { // split into e and x - 1.0 uint32_t u = (uint32_t)x; int e = CLZ(u); - u <<= e; // normalize to [0x80000000, 0xffffffff] - x = u & 0x7fffffff; // x - 1.0 + x = (u << e) & 0x7fffffff; int k = x >> (31 - LOG2_TABBITS); From b29984ab2c8f7efec889c001db5efe58bfeed161 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 1 May 2018 16:52:47 -0700 Subject: [PATCH 068/192] Remove max log age for rolling interface log --- libraries/shared/src/shared/FileLogger.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 1e17ee9e7c..6a10629ee5 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -36,7 +36,6 @@ protected: private: const FileLogger& _logger; QMutex _fileMutex; - std::chrono::system_clock::time_point _lastRollTime; }; static const QString FILENAME_FORMAT = "hifi-log_%1%2.txt"; @@ -52,7 +51,6 @@ static QUuid SESSION_ID; static const qint64 MAX_LOG_SIZE = 512 * 1024; // Max log files found in the log directory is 100. static const qint64 MAX_LOG_DIR_SIZE = 512 * 1024 * 100; -static const std::chrono::minutes MAX_LOG_AGE { 60 }; static FilePersistThread* _persistThreadInstance; @@ -83,12 +81,10 @@ FilePersistThread::FilePersistThread(const FileLogger& logger) : _logger(logger) if (file.exists()) { rollFileIfNecessary(file, false); } - _lastRollTime = std::chrono::system_clock::now(); } void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfRolled) { - auto now = std::chrono::system_clock::now(); - if ((file.size() > MAX_LOG_SIZE) || (now - _lastRollTime) > MAX_LOG_AGE) { + if (file.size() > MAX_LOG_SIZE) { QString newFileName = getLogRollerFilename(); if (file.copy(newFileName)) { file.open(QIODevice::WriteOnly | QIODevice::Truncate); @@ -97,8 +93,6 @@ void FilePersistThread::rollFileIfNecessary(QFile& file, bool notifyListenersIfR if (notifyListenersIfRolled) { emit rollingLogFile(newFileName); } - - _lastRollTime = std::chrono::system_clock::now(); } QDir logDir(FileUtils::standardPath(LOGS_DIRECTORY)); From 7bad849e67e4ff2ccefb90f3d1c149b06eedacfb Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 15:29:22 -0700 Subject: [PATCH 069/192] Make resource swapchains immutable, fix for 14638 --- .../src/gpu/gl/GLBackendOutput.cpp | 4 ++-- .../src/gpu/gl/GLBackendPipeline.cpp | 7 +++---- libraries/gpu/src/gpu/ResourceSwapChain.h | 19 +++++++---------- .../render-utils/src/AntialiasingEffect.cpp | 21 +++++++++---------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp index 2285b0e486..d1ab34da90 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp @@ -46,10 +46,10 @@ void GLBackend::do_setFramebuffer(const Batch& batch, size_t paramOffset) { } void GLBackend::do_setFramebufferSwapChain(const Batch& batch, size_t paramOffset) { - auto swapChain = batch._swapChains.get(batch._params[paramOffset]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset]._uint)); if (swapChain) { auto index = batch._params[paramOffset + 1]._uint; - FramebufferPointer framebuffer = static_cast(swapChain.get())->get(index); + const auto& framebuffer = swapChain->get(index); setFramebuffer(framebuffer); } } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp index 58fcc51605..91f1d8bb8c 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp @@ -268,7 +268,7 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si return; } - SwapChainPointer swapChain = batch._swapChains.get(batch._params[paramOffset + 0]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset + 0]._uint)); if (!swapChain) { releaseResourceTexture(slot); @@ -276,9 +276,8 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si } auto index = batch._params[paramOffset + 2]._uint; auto renderBufferSlot = batch._params[paramOffset + 3]._uint; - FramebufferPointer resourceFramebuffer = static_cast(swapChain.get())->get(index); - TexturePointer resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); - + auto resourceFramebuffer = swapChain->get(index); + auto resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); setResourceTexture(slot, resourceTexture); } diff --git a/libraries/gpu/src/gpu/ResourceSwapChain.h b/libraries/gpu/src/gpu/ResourceSwapChain.h index 7b46b35521..84e8ec7c74 100644 --- a/libraries/gpu/src/gpu/ResourceSwapChain.h +++ b/libraries/gpu/src/gpu/ResourceSwapChain.h @@ -15,18 +15,18 @@ namespace gpu { class SwapChain { public: - SwapChain(unsigned int size = 2U) : _size{ size } {} + SwapChain(size_t size = 2U) : _size{ size } {} virtual ~SwapChain() {} void advance() { _frontIndex = (_frontIndex + 1) % _size; } - unsigned int getSize() const { return _size; } + size_t getSize() const { return _size; } protected: - unsigned int _size; - unsigned int _frontIndex{ 0U }; + const size_t _size; + size_t _frontIndex{ 0U }; }; typedef std::shared_ptr SwapChainPointer; @@ -41,16 +41,13 @@ namespace gpu { using Type = R; using TypePointer = std::shared_ptr; + using TypeConstPointer = std::shared_ptr; - ResourceSwapChain(unsigned int size = 2U) : SwapChain{ size } {} - - void reset() { - for (auto& ptr : _resources) { - ptr.reset(); + ResourceSwapChain(const std::vector& v) : SwapChain{ std::min(v.size(), MAX_SIZE) } { + for (size_t i = 0; i < _size; ++i) { + _resources[i] = v[i]; } } - - TypePointer& edit(unsigned int index) { return _resources[(index + _frontIndex) % _size]; } const TypePointer& get(unsigned int index) const { return _resources[(index + _frontIndex) % _size]; } private: diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index e620fc2d61..f77b4fc68b 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -189,7 +189,6 @@ const int AntialiasingPass_NextMapSlot = 4; Antialiasing::Antialiasing(bool isSharpenEnabled) : _isSharpenEnabled{ isSharpenEnabled } { - _antialiasingBuffers = std::make_shared(2U); } Antialiasing::~Antialiasing() { @@ -321,25 +320,25 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const int width = sourceBuffer->getWidth(); int height = sourceBuffer->getHeight(); - if (_antialiasingBuffers->get(0)) { - if (_antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) {// || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) { - _antialiasingBuffers->edit(0).reset(); - _antialiasingBuffers->edit(1).reset(); - _antialiasingTextures[0].reset(); - _antialiasingTextures[1].reset(); - } + if (_antialiasingBuffers && _antialiasingBuffers->get(0) && _antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) { + _antialiasingBuffers.reset(); + _antialiasingTextures[0].reset(); + _antialiasingTextures[1].reset(); } - if (!_antialiasingBuffers->get(0)) { + + if (!_antialiasingBuffers) { + std::vector antiAliasingBuffers; // Link the antialiasing FBO to texture auto format = sourceBuffer->getRenderBuffer(0)->getTexelFormat(); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP); for (int i = 0; i < 2; i++) { - auto& antiAliasingBuffer = _antialiasingBuffers->edit(i); - antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing")); + antiAliasingBuffers.emplace_back(gpu::Framebuffer::create("antialiasing")); + const auto& antiAliasingBuffer = antiAliasingBuffers.back(); _antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler); antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]); } + _antialiasingBuffers = std::make_shared(antiAliasingBuffers); } gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) { From 233c60a5063573cb55770b382013deeefadfba6f Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 16:54:26 -0700 Subject: [PATCH 070/192] Change type used for swap chain count --- libraries/gpu/src/gpu/ResourceSwapChain.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/gpu/src/gpu/ResourceSwapChain.h b/libraries/gpu/src/gpu/ResourceSwapChain.h index 84e8ec7c74..28c5ff2ed3 100644 --- a/libraries/gpu/src/gpu/ResourceSwapChain.h +++ b/libraries/gpu/src/gpu/ResourceSwapChain.h @@ -15,18 +15,18 @@ namespace gpu { class SwapChain { public: - SwapChain(size_t size = 2U) : _size{ size } {} + SwapChain(uint8_t size = 2U) : _size{ size } {} virtual ~SwapChain() {} void advance() { _frontIndex = (_frontIndex + 1) % _size; } - size_t getSize() const { return _size; } + uint8_t getSize() const { return _size; } protected: - const size_t _size; - size_t _frontIndex{ 0U }; + const uint8_t _size; + uint8_t _frontIndex{ 0U }; }; typedef std::shared_ptr SwapChainPointer; @@ -43,7 +43,7 @@ namespace gpu { using TypePointer = std::shared_ptr; using TypeConstPointer = std::shared_ptr; - ResourceSwapChain(const std::vector& v) : SwapChain{ std::min(v.size(), MAX_SIZE) } { + ResourceSwapChain(const std::vector& v) : SwapChain{ std::min((uint8_t)v.size(), MAX_SIZE) } { for (size_t i = 0; i < _size; ++i) { _resources[i] = v[i]; } From 697fde4a1a247437ea730cdb642f470e395b0ecd Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 2 May 2018 13:31:32 -0700 Subject: [PATCH 071/192] Cleanup meta texture related changes --- libraries/baking/src/FBXBaker.cpp | 56 ------------------- libraries/baking/src/ModelBaker.cpp | 4 -- libraries/baking/src/TextureBaker.cpp | 11 ++-- libraries/fbx/src/FBXReader.cpp | 1 - libraries/fbx/src/FBXReader_Material.cpp | 4 -- .../src/model-networking/TextureCache.cpp | 10 +--- libraries/networking/src/ResourceCache.cpp | 2 - 7 files changed, 6 insertions(+), 82 deletions(-) diff --git a/libraries/baking/src/FBXBaker.cpp b/libraries/baking/src/FBXBaker.cpp index 175698eeea..c8ba98f0b1 100644 --- a/libraries/baking/src/FBXBaker.cpp +++ b/libraries/baking/src/FBXBaker.cpp @@ -74,62 +74,6 @@ void FBXBaker::bakeSourceCopy() { checkIfTexturesFinished(); } -void FBXBaker::embedTextureMetaData() { - std::vector embeddedTextureNodes; - - for (FBXNode& rootChild : _rootNode.children) { - if (rootChild.name == "Objects") { - qlonglong maxId = 0; - for (auto &child : rootChild.children) { - if (child.properties.length() == 3) { - maxId = std::max(maxId, child.properties[0].toLongLong()); - } - } - - for (auto& object : rootChild.children) { - if (object.name == "Texture") { - QVariant relativeFilename; - for (auto& child : object.children) { - if (child.name == "RelativeFilename") { - relativeFilename = child.properties[0]; - break; - } - } - - if (relativeFilename.isNull() || !relativeFilename.toString().endsWith(BAKED_META_TEXTURE_SUFFIX)) { - continue; - } - - FBXNode videoNode; - videoNode.name = "Video"; - videoNode.properties.append(++maxId); - videoNode.properties.append(object.properties[1]); - videoNode.properties.append("Clip"); - - QString bakedTextureFilePath { - _bakedOutputDir + "/" + relativeFilename.toString() - }; - qDebug() << "Location of texture: " << bakedTextureFilePath; - - QFile textureFile { bakedTextureFilePath }; - if (!textureFile.open(QIODevice::ReadOnly)) { - qWarning() << "Failed to open: " << bakedTextureFilePath; - continue; - } - - videoNode.children.append({ "RelativeFilename", { relativeFilename }, { } }); - videoNode.children.append({ "Content", { textureFile.readAll() }, { } }); - - rootChild.children.append(videoNode); - - textureFile.close(); - } - } - } - } - -} - void FBXBaker::setupOutputFolder() { // make sure there isn't already an output directory using the same name if (QDir(_bakedOutputDir).exists()) { diff --git a/libraries/baking/src/ModelBaker.cpp b/libraries/baking/src/ModelBaker.cpp index 020a0dbfc2..ee26b94b81 100644 --- a/libraries/baking/src/ModelBaker.cpp +++ b/libraries/baking/src/ModelBaker.cpp @@ -537,8 +537,6 @@ void ModelBaker::embedTextureMetaData() { } } - qDebug() << "Max id found was: " << maxId; - for (auto& object : rootChild.children) { if (object.name == "Texture") { QVariant relativeFilename; @@ -567,7 +565,6 @@ void ModelBaker::embedTextureMetaData() { QString bakedTextureFilePath { _bakedOutputDir + "/" + relativeFilename.toString() }; - qDebug() << "Location of texture: " << bakedTextureFilePath; QFile textureFile { bakedTextureFilePath }; if (!textureFile.open(QIODevice::ReadOnly)) { @@ -585,7 +582,6 @@ void ModelBaker::embedTextureMetaData() { } } } - } void ModelBaker::exportScene() { diff --git a/libraries/baking/src/TextureBaker.cpp b/libraries/baking/src/TextureBaker.cpp index 7a5dc85a61..45895494a0 100644 --- a/libraries/baking/src/TextureBaker.cpp +++ b/libraries/baking/src/TextureBaker.cpp @@ -128,11 +128,11 @@ void TextureBaker::processTexture() { auto filePath = _outputDirectory.absoluteFilePath(_textureURL.fileName()); QFile file { filePath }; if (!file.open(QIODevice::WriteOnly) || file.write(_originalTexture) == -1) { - handleError("Could not write meta texture for " + _textureURL.toString()); + handleError("Could not write original texture for " + _textureURL.toString()); return; } _outputFiles.push_back(filePath); - meta.original =_metaTexturePathPrefix +_textureURL.fileName(); + meta.original = _metaTexturePathPrefix +_textureURL.fileName(); } // IMPORTANT: _originalTexture is empty past this point @@ -157,18 +157,17 @@ void TextureBaker::processTexture() { return; } - const char* data = reinterpret_cast(memKTX->_storage->data()); - const size_t length = memKTX->_storage->size(); const char* name = khronos::gl::texture::toString(memKTX->_header.getGLInternaFormat()); if (name == nullptr) { handleError("Could not determine internal format for compressed KTX: " + _textureURL.toString()); return; } - qDebug() << "Found type: " << name; - // attempt to write the baked texture to the destination file path { + const char* data = reinterpret_cast(memKTX->_storage->data()); + const size_t length = memKTX->_storage->size(); + auto fileName = _baseFilename + BAKED_TEXTURE_BCN_SUFFIX; auto filePath = _outputDirectory.absoluteFilePath(fileName); QFile bakedTextureFile { filePath }; diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 1f237edfb0..1e59646795 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1101,7 +1101,6 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS } if (!content.isEmpty()) { _textureContent.insert(filepath, content); - qDebug() << "Adding content: " << filepath << content.length(); } } else if (object.name == "Material") { FBXMaterial material; diff --git a/libraries/fbx/src/FBXReader_Material.cpp b/libraries/fbx/src/FBXReader_Material.cpp index 88dc7f599d..4aa3044934 100644 --- a/libraries/fbx/src/FBXReader_Material.cpp +++ b/libraries/fbx/src/FBXReader_Material.cpp @@ -85,16 +85,12 @@ FBXTexture FBXReader::getTexture(const QString& textureID) { FBXTexture texture; const QByteArray& filepath = _textureFilepaths.value(textureID); texture.content = _textureContent.value(filepath); - qDebug() << "Getting texture: " << textureID << filepath << texture.content.length(); if (texture.content.isEmpty()) { // the content is not inlined - qDebug() << "Texture is not inlined"; texture.filename = _textureFilenames.value(textureID); } else { // use supplied filepath for inlined content - qDebug() << "Texture is inlined"; texture.filename = filepath; } - qDebug() << "Path: " << texture.filename; texture.id = textureID; texture.name = _textureNames.value(textureID); diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 54b654c56b..241c4eef3b 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -315,7 +315,6 @@ NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type, _textureSource = std::make_shared(url, (int)type); _lowestRequestedMipLevel = 0; - qDebug() << "Creating networktexture: " << url; if (url.fileName().endsWith(TEXTURE_META_EXTENSION)) { _currentlyLoadingResourceType = ResourceType::META; } else if (url.fileName().endsWith(".ktx")) { @@ -402,7 +401,6 @@ NetworkTexture::~NetworkTexture() { const uint16_t NetworkTexture::NULL_MIP_LEVEL = std::numeric_limits::max(); void NetworkTexture::makeRequest() { - qDebug() << "In makeRequest for " << _activeUrl << (int)_currentlyLoadingResourceType; if (_currentlyLoadingResourceType != ResourceType::KTX) { Resource::makeRequest(); return; @@ -454,7 +452,6 @@ void NetworkTexture::makeRequest() { _ktxHeaderRequest->send(); - qDebug() << "Starting mip range request"; startMipRangeRequest(NULL_MIP_LEVEL, NULL_MIP_LEVEL); } else if (_ktxResourceState == PENDING_MIP_REQUEST) { if (_lowestKnownPopulatedMip > 0) { @@ -594,7 +591,6 @@ void NetworkTexture::startMipRangeRequest(uint16_t low, uint16_t high) { bool isHighMipRequest = low == NULL_MIP_LEVEL && high == NULL_MIP_LEVEL; - qDebug() << "Making ktx mip request to: " << _activeUrl; _ktxMipRequest = DependencyManager::get()->createResourceRequest(this, _activeUrl); if (!_ktxMipRequest) { @@ -944,9 +940,7 @@ void NetworkTexture::handleFinishedInitialLoad() { } void NetworkTexture::downloadFinished(const QByteArray& data) { - qDebug() << "Loading content: " << _activeUrl; if (_currentlyLoadingResourceType == ResourceType::META) { - qDebug() << "Loading meta content: " << _activeUrl; loadMetaContent(data); } else if (_currentlyLoadingResourceType == ResourceType::ORIGINAL) { loadTextureContent(data); @@ -984,7 +978,6 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) { _currentlyLoadingResourceType = ResourceType::KTX; _activeUrl = _activeUrl.resolved(url); - qDebug() << "Active url is now: " << _activeUrl; auto textureCache = DependencyManager::get(); auto self = _self.lock(); if (!self) { @@ -1010,13 +1003,12 @@ void NetworkTexture::loadMetaContent(const QByteArray& content) { } qWarning() << "Failed to find supported texture type in " << _activeUrl; - //TextureCache::requestCompleted(_self); Resource::handleFailedRequest(ResourceRequest::NotFound); } void NetworkTexture::loadTextureContent(const QByteArray& content) { if (_currentlyLoadingResourceType != ResourceType::ORIGINAL) { - qWarning() << "Trying to load texture content when currentl resource type is not ORIGINAL"; + qWarning() << "Trying to load texture content when current resource type is not ORIGINAL"; assert(false); return; } diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 4d3ba9da25..4d1bfdea66 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -619,7 +619,6 @@ void Resource::init(bool resetLoaded) { _loaded = false; } _attempts = 0; - qDebug() << "Initting resource: " << _url; if (_url.isEmpty()) { _startedLoading = _loaded = true; @@ -672,7 +671,6 @@ void Resource::makeRequest() { PROFILE_ASYNC_BEGIN(resource, "Resource:" + getType(), QString::number(_requestID), { { "url", _url.toString() }, { "activeURL", _activeUrl.toString() } }); - qDebug() << "Making request to " << _activeUrl; _request = DependencyManager::get()->createResourceRequest(this, _activeUrl); if (!_request) { From 529869e80c79bd281d60e526d0a3fce219132c55 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 2 May 2018 13:41:52 -0700 Subject: [PATCH 072/192] Make NetworkTexture extension comparisons case-insensitive --- .../model-networking/src/model-networking/TextureCache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 241c4eef3b..ed21fd35bc 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -315,9 +315,10 @@ NetworkTexture::NetworkTexture(const QUrl& url, image::TextureUsage::Type type, _textureSource = std::make_shared(url, (int)type); _lowestRequestedMipLevel = 0; - if (url.fileName().endsWith(TEXTURE_META_EXTENSION)) { + auto fileNameLowercase = url.fileName().toLower(); + if (fileNameLowercase.endsWith(TEXTURE_META_EXTENSION)) { _currentlyLoadingResourceType = ResourceType::META; - } else if (url.fileName().endsWith(".ktx")) { + } else if (fileNameLowercase.endsWith(".ktx")) { _currentlyLoadingResourceType = ResourceType::KTX; } else { _currentlyLoadingResourceType = ResourceType::ORIGINAL; From 4a96dc2fdc4b4c722d8f342d1c33876273b08fc5 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 3 May 2018 08:48:17 +1200 Subject: [PATCH 073/192] Refactor --- scripts/system/libraries/entitySelectionTool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4996579799..36cc98a80b 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -140,22 +140,22 @@ SelectionManager = (function() { that._update(true); }; - that.removeEntity = function(entityID) { + function removeEntityByID(entityID) { var idx = that.selections.indexOf(entityID); if (idx >= 0) { that.selections.splice(idx, 1); Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityID); } + } + + that.removeEntity = function (entityID) { + removeEntityByID(entityID); that._update(true); }; that.removeEntities = function (entityIDs) { for (var i = 0, length = entityIDs.length; i < length; i++) { - var idx = that.selections.indexOf(entityIDs[i]); - if (idx >= 0) { - that.selections.splice(idx, 1); - Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityIDs[i]); - } + removeEntityByID(entityIDs[i]); } that._update(true); }; From 5312c81a6fe7be0ca5b5c90bbab24d91e2d14963 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 3 May 2018 08:49:18 +1200 Subject: [PATCH 074/192] Match style of surrounding code --- scripts/system/libraries/entitySelectionTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 36cc98a80b..e84600a64a 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -153,7 +153,7 @@ SelectionManager = (function() { that._update(true); }; - that.removeEntities = function (entityIDs) { + that.removeEntities = function(entityIDs) { for (var i = 0, length = entityIDs.length; i < length; i++) { removeEntityByID(entityIDs[i]); } From e0b16dfe03493caf8f8aae8cbe02393b21d66df5 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 May 2018 14:17:01 -0700 Subject: [PATCH 075/192] Allow use of `--url` command line argument in test mode. --- interface/src/Application.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eb59576cc0..3c9e244da6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2143,6 +2143,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto scriptEngines = DependencyManager::get(); const auto testScript = property(hifi::properties::TEST).toUrl(); scriptEngines->loadScript(testScript, false); + + // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. + if (arguments().contains("--url")) { + auto reply = SandboxUtils::getStatus(); + connect(reply, &QNetworkReply::finished, this, [=] { + handleSandboxStatus(reply); + }); + } } else { PROFILE_RANGE(render, "GetSandboxStatus"); auto reply = SandboxUtils::getStatus(); From 5cbb8674ec2c001302cdcc43085b2ea7cf62157c Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 May 2018 14:45:28 -0700 Subject: [PATCH 076/192] Use default parameter for saveSnapshot(). --- interface/src/Application.cpp | 2 +- interface/src/Application.h | 2 +- interface/src/ui/Snapshot.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 22a77b9bf1..bd306948bb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7387,7 +7387,7 @@ void Application::loadAvatarBrowser() const { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { // Get a screenshot and save it - QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, QString()); + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename); // If we're not doing an animated snapshot as well... if (!includeAnimated) { // Tell the dependency manager that the capture of the still snapshot has taken place. diff --git a/interface/src/Application.h b/interface/src/Application.h index f1276bca34..fe31f55dcb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -732,6 +732,6 @@ private: std::atomic _pendingIdleEvent { true }; std::atomic _pendingRenderEvent { true }; - QString testSnapshotLocation { QString() }; + QString testSnapshotLocation; }; #endif // hifi_Application_h diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 86c860cfcb..a3454bcba5 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -37,7 +37,7 @@ class Snapshot : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: - static QString saveSnapshot(QImage image, const QString& filename, const QString& pathname); + static QString saveSnapshot(QImage image, const QString& filename, const QString& pathname = QString()); static QTemporaryFile* saveTempSnapshot(QImage image); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); From e549f7b0859a69a6e48a915a9cf2537e9cf34991 Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Wed, 2 May 2018 14:48:08 -0700 Subject: [PATCH 077/192] Fix VS2017 performance loss --- libraries/audio/src/AudioDynamics.h | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/libraries/audio/src/AudioDynamics.h b/libraries/audio/src/AudioDynamics.h index 03506fa8a1..542f6f1a05 100644 --- a/libraries/audio/src/AudioDynamics.h +++ b/libraries/audio/src/AudioDynamics.h @@ -21,7 +21,15 @@ #define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) +#define FORCEINLINE __forceinline +#elif defined(__GNUC__) +#define FORCEINLINE inline __attribute__((always_inline)) +#else +#define FORCEINLINE inline +#endif + +#if defined(_MSC_VER) #include #define MUL64(a,b) __emul((a), (b)) #else @@ -42,14 +50,14 @@ #include // convert float to int using round-to-nearest -static inline int32_t floatToInt(float x) { +FORCEINLINE static int32_t floatToInt(float x) { return _mm_cvt_ss2si(_mm_load_ss(&x)); } #else // convert float to int using round-to-nearest -static inline int32_t floatToInt(float x) { +FORCEINLINE static int32_t floatToInt(float x) { x += (x < 0.0f ? -0.5f : 0.5f); // round return (int32_t)x; } @@ -60,12 +68,12 @@ static const double FIXQ31 = 2147483648.0; // convert float to Q31 static const double DB_TO_LOG2 = 0.16609640474436813; // convert dB to log2 // convert dB to amplitude -static inline double dBToGain(double dB) { +static double dBToGain(double dB) { return pow(10.0, dB / 20.0); } // convert milliseconds to first-order time constant -static inline int32_t msToTc(double ms, double sampleRate) { +static int32_t msToTc(double ms, double sampleRate) { double tc = exp(-1000.0 / (ms * sampleRate)); return (int32_t)(FIXQ31 * tc); // Q31 } @@ -144,7 +152,7 @@ static const int IEEE754_EXPN_BIAS = 127; // x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff // x > 2^LOG2_HEADROOM undefined // -static inline int32_t peaklog2(float* input) { +FORCEINLINE static int32_t peaklog2(float* input) { // float as integer bits uint32_t u = *(uint32_t*)input; @@ -180,7 +188,7 @@ static inline int32_t peaklog2(float* input) { // x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff // x > 2^LOG2_HEADROOM undefined // -static inline int32_t peaklog2(float* input0, float* input1) { +FORCEINLINE static int32_t peaklog2(float* input0, float* input1) { // float as integer bits uint32_t u0 = *(uint32_t*)input0; @@ -219,7 +227,7 @@ static inline int32_t peaklog2(float* input0, float* input1) { // x < 2^(31-LOG2_HEADROOM) returns 0x7fffffff // x > 2^LOG2_HEADROOM undefined // -static inline int32_t peaklog2(float* input0, float* input1, float* input2, float* input3) { +FORCEINLINE static int32_t peaklog2(float* input0, float* input1, float* input2, float* input3) { // float as integer bits uint32_t u0 = *(uint32_t*)input0; @@ -261,7 +269,7 @@ static inline int32_t peaklog2(float* input0, float* input1, float* input2, floa // Count Leading Zeros // Emulates the CLZ (ARM) and LZCNT (x86) instruction // -static inline int CLZ(uint32_t u) { +FORCEINLINE static int CLZ(uint32_t u) { if (u == 0) { return 32; @@ -294,7 +302,7 @@ static inline int CLZ(uint32_t u) { // Compute -log2(x) for x=[0,1] in Q31, result in Q26 // x <= 0 returns 0x7fffffff // -static inline int32_t fixlog2(int32_t x) { +FORCEINLINE static int32_t fixlog2(int32_t x) { if (x <= 0) { return 0x7fffffff; @@ -323,7 +331,7 @@ static inline int32_t fixlog2(int32_t x) { // Compute exp2(-x) for x=[0,32] in Q26, result in Q31 // x <= 0 returns 0x7fffffff // -static inline int32_t fixexp2(int32_t x) { +FORCEINLINE static int32_t fixexp2(int32_t x) { if (x <= 0) { return 0x7fffffff; @@ -349,7 +357,7 @@ static inline int32_t fixexp2(int32_t x) { } // fast TPDF dither in [-1.0f, 1.0f] -static inline float dither() { +FORCEINLINE static float dither() { static uint32_t rz = 0; rz = rz * 69069 + 1; int32_t r0 = rz & 0xffff; From 56e5b0e7b434c6375207c0f4cf14fbaea03666cb Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 May 2018 15:25:31 -0700 Subject: [PATCH 078/192] Added `autoTester.enableAuto();` to the recursive tests. --- tools/auto-tester/src/Test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 7139f0a43c..18d1350402 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -371,7 +371,8 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact textStream << "var autoTester = Script.require(\"https://github.com/" + githubUser + "/hifi_tests/blob/" + gitHubBranch + "/tests/utils/autoTester.js?raw=true\");" << endl; - textStream << "autoTester.enableRecursive();" << endl << endl; + textStream << "autoTester.enableRecursive();" << endl; + textStream << "autoTester.enableAuto();" << endl << endl; QVector testPathnames; From b9cdaf31a07b0346aa5e3a1005c106687097e1ef Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 2 May 2018 15:26:03 -0700 Subject: [PATCH 079/192] Corrected name of create all recursive tests call. --- tools/auto-tester/src/ui/AutoTester.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index c5115d69b2..8c534eb7c7 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -95,7 +95,7 @@ 24 - + 360 From 5f394fb25442c51cf2bbbf8e39be2c26ddd0d588 Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Wed, 2 May 2018 15:31:40 -0700 Subject: [PATCH 080/192] Remove workaround for VS2013 bug --- libraries/audio/src/AudioDynamics.h | 2 +- libraries/audio/src/AudioReverb.cpp | 2 +- libraries/audio/src/AudioSRC.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/audio/src/AudioDynamics.h b/libraries/audio/src/AudioDynamics.h index 542f6f1a05..dac59dbce1 100644 --- a/libraries/audio/src/AudioDynamics.h +++ b/libraries/audio/src/AudioDynamics.h @@ -362,7 +362,7 @@ FORCEINLINE static float dither() { rz = rz * 69069 + 1; int32_t r0 = rz & 0xffff; int32_t r1 = rz >> 16; - return (int32_t)(r0 - r1) * (1/65536.0f); + return (r0 - r1) * (1/65536.0f); } // diff --git a/libraries/audio/src/AudioReverb.cpp b/libraries/audio/src/AudioReverb.cpp index c561231376..0901e76251 100644 --- a/libraries/audio/src/AudioReverb.cpp +++ b/libraries/audio/src/AudioReverb.cpp @@ -1954,7 +1954,7 @@ static inline float dither() { rz = rz * 69069 + 1; int32_t r0 = rz & 0xffff; int32_t r1 = rz >> 16; - return (int32_t)(r0 - r1) * (1/65536.0f); + return (r0 - r1) * (1/65536.0f); } // convert float to int16_t with dither, interleave stereo diff --git a/libraries/audio/src/AudioSRC.cpp b/libraries/audio/src/AudioSRC.cpp index 80cb756d04..fbdf890246 100644 --- a/libraries/audio/src/AudioSRC.cpp +++ b/libraries/audio/src/AudioSRC.cpp @@ -1200,7 +1200,7 @@ static inline float dither() { rz = rz * 69069 + 1; int32_t r0 = rz & 0xffff; int32_t r1 = rz >> 16; - return (int32_t)(r0 - r1) * (1/65536.0f); + return (r0 - r1) * (1/65536.0f); } // convert float to int16_t with dither, interleave stereo From 3071b410bff9d1370077ecad1acb2cc6e38c58a6 Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Wed, 2 May 2018 15:42:53 -0700 Subject: [PATCH 081/192] Remove obsolete 32-bit optimizations --- libraries/audio/src/AudioReverb.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libraries/audio/src/AudioReverb.cpp b/libraries/audio/src/AudioReverb.cpp index 0901e76251..d457ce7a96 100644 --- a/libraries/audio/src/AudioReverb.cpp +++ b/libraries/audio/src/AudioReverb.cpp @@ -13,18 +13,11 @@ #include "AudioReverb.h" #ifdef _MSC_VER - #include -inline static int MULHI(int a, int b) { - long long c = __emul(a, b); - return ((int*)&c)[1]; -} - +#define MULHI(a,b) ((int32_t)(__emul(a, b) >> 32)) #else - -#define MULHI(a,b) (int)(((long long)(a) * (b)) >> 32) - -#endif // _MSC_VER +#define MULHI(a,b) ((int32_t)(((int64_t)(a) * (int64_t)(b)) >> 32)) +#endif #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) From 56ba59681a95450a151b6e9bad59a35e731c3380 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 2 May 2018 16:12:55 -0700 Subject: [PATCH 082/192] Fix MS14741, allowing uninstall of apps whose scripts are no longer running --- interface/src/commerce/QmlCommerce.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index 568556cb22..722f29ba2f 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -301,7 +301,7 @@ bool QmlCommerce::uninstallApp(const QString& itemHref) { // Read from the file to know what .js script to stop QFile appFile(_appsPath + "/" + appHref.fileName()); if (!appFile.open(QIODevice::ReadOnly)) { - qCDebug(commerce) << "Couldn't open local .app.json file for deletion."; + qCDebug(commerce) << "Couldn't open local .app.json file for deletion. Cannot continue with app uninstallation. App filename is:" << appHref.fileName(); return false; } QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll()); @@ -309,15 +309,13 @@ bool QmlCommerce::uninstallApp(const QString& itemHref) { QString scriptUrl = appFileJsonObject["scriptURL"].toString(); if (!DependencyManager::get()->stopScript(scriptUrl.trimmed(), false)) { - qCDebug(commerce) << "Couldn't stop script."; - return false; + qCWarning(commerce) << "Couldn't stop script during app uninstall. Continuing anyway. ScriptURL is:" << scriptUrl.trimmed(); } // Delete the .app.json from the filesystem // remove() closes the file first. if (!appFile.remove()) { - qCDebug(commerce) << "Couldn't delete local .app.json file."; - return false; + qCWarning(commerce) << "Couldn't delete local .app.json file during app uninstall. Continuing anyway. App filename is:" << appHref.fileName(); } emit appUninstalled(itemHref); From e1c5eb9bda063367ab0af270d14505ab925af9ab Mon Sep 17 00:00:00 2001 From: Clement Date: Wed, 2 May 2018 17:17:19 -0700 Subject: [PATCH 083/192] Fix wizard wording --- domain-server/resources/web/wizard/index.shtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/domain-server/resources/web/wizard/index.shtml b/domain-server/resources/web/wizard/index.shtml index 5a3286296d..3bc7503b44 100644 --- a/domain-server/resources/web/wizard/index.shtml +++ b/domain-server/resources/web/wizard/index.shtml @@ -26,7 +26,7 @@ Place names are similar to web addresses. Users who want to visit your domain can enter its Place Name in High Fidelity's Interface. You can choose a Place Name for your domain.
    - People can also use your domain's IP address (shown below) to visit your High Fidelity domain. + Your domain may also be reachable by IP address.
    @@ -35,10 +35,10 @@ From 3e77d946ea49e82fd1b22c3fbe0713aef57ac67b Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Wed, 2 May 2018 17:48:04 -0700 Subject: [PATCH 084/192] Silence warnings of unused functions --- libraries/audio/src/AudioDynamics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/audio/src/AudioDynamics.h b/libraries/audio/src/AudioDynamics.h index dac59dbce1..8dbc7a75cc 100644 --- a/libraries/audio/src/AudioDynamics.h +++ b/libraries/audio/src/AudioDynamics.h @@ -68,12 +68,12 @@ static const double FIXQ31 = 2147483648.0; // convert float to Q31 static const double DB_TO_LOG2 = 0.16609640474436813; // convert dB to log2 // convert dB to amplitude -static double dBToGain(double dB) { +FORCEINLINE static double dBToGain(double dB) { return pow(10.0, dB / 20.0); } // convert milliseconds to first-order time constant -static int32_t msToTc(double ms, double sampleRate) { +FORCEINLINE static int32_t msToTc(double ms, double sampleRate) { double tc = exp(-1000.0 / (ms * sampleRate)); return (int32_t)(FIXQ31 * tc); // Q31 } From 9776e1d15d42313d845ac532a4c77d807c1ae9fa Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 2 May 2018 23:38:30 -0700 Subject: [PATCH 085/192] Exposing larger number of ubo because we can and moving the ubo slot using 11 to 12 to avoid collision --- .../src/RenderableParticleEffectEntityItem.cpp | 4 ++-- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 4 ++-- libraries/gpu-gl-common/src/gpu/gl/GLBackend.h | 2 +- libraries/gpu/src/gpu/Batch.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index b3a4a1a1ab..ee77646920 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,8 +23,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static int32_t PARTICLE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static int32_t PARTICLE_UNIFORM_SLOT { 12 }; static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { auto texturedPipeline = _texturedPipeline.lock(); diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 394ab08dfb..d571eac35c 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -34,8 +34,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER { 0 }; static const int32_t PAINTSTROKE_TEXTURE_SLOT { 0 }; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static const int32_t PAINTSTROKE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static const int32_t PAINTSTROKE_UNIFORM_SLOT { 12 }; static gpu::Stream::FormatPointer polylineFormat; static gpu::PipelinePointer polylinePipeline; #ifdef POLYLINE_ENTITY_USE_FADE_EFFECT diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index f2e2271552..53a147fb27 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -92,7 +92,7 @@ public: // this is the maximum per shader stage on the low end apple // TODO make it platform dependant at init time - static const int MAX_NUM_UNIFORM_BUFFERS = 12; + static const int MAX_NUM_UNIFORM_BUFFERS = 15; size_t getMaxNumUniformBuffers() const { return MAX_NUM_UNIFORM_BUFFERS; } // this is the maximum per shader stage on the low end apple diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 31bbfdd708..7725ee7bce 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -34,7 +34,7 @@ ProfileRangeBatch::~ProfileRangeBatch() { using namespace gpu; // FIXME make these backend / pipeline dependent. -static const int MAX_NUM_UNIFORM_BUFFERS = 12; +static const int MAX_NUM_UNIFORM_BUFFERS = 15; static const int MAX_NUM_RESOURCE_BUFFERS = 16; static const int MAX_NUM_RESOURCE_TEXTURES = 16; From 2a7e8c6f89944962370edbbd310c4660f5738b3b Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Thu, 3 May 2018 07:15:18 -0700 Subject: [PATCH 086/192] Default audio meter overlay to "on" --- interface/src/ui/AvatarInputs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 3053cb8855..0aa352de23 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -18,7 +18,7 @@ static AvatarInputs* INSTANCE{ nullptr }; -Setting::Handle showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, false }; +Setting::Handle showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, true }; AvatarInputs* AvatarInputs::getInstance() { if (!INSTANCE) { From 6579e3c3d23a9117e7f64bcc4a320bebf3498c7b Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 3 May 2018 09:09:58 -0700 Subject: [PATCH 087/192] Adjusting the number to 14 max UBO per shader stage after checking on opengl.glinfo.org --- libraries/gpu-gl-common/src/gpu/gl/GLBackend.h | 2 +- libraries/gpu/src/gpu/Batch.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 53a147fb27..f0b79fb23e 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -92,7 +92,7 @@ public: // this is the maximum per shader stage on the low end apple // TODO make it platform dependant at init time - static const int MAX_NUM_UNIFORM_BUFFERS = 15; + static const int MAX_NUM_UNIFORM_BUFFERS = 14; size_t getMaxNumUniformBuffers() const { return MAX_NUM_UNIFORM_BUFFERS; } // this is the maximum per shader stage on the low end apple diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 7725ee7bce..4b965af7bc 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -34,7 +34,7 @@ ProfileRangeBatch::~ProfileRangeBatch() { using namespace gpu; // FIXME make these backend / pipeline dependent. -static const int MAX_NUM_UNIFORM_BUFFERS = 15; +static const int MAX_NUM_UNIFORM_BUFFERS = 14; static const int MAX_NUM_RESOURCE_BUFFERS = 16; static const int MAX_NUM_RESOURCE_TEXTURES = 16; From 60a49c3f7c630f03666e04cc67f3c4558c7816cf Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 3 May 2018 10:37:29 -0700 Subject: [PATCH 088/192] applying the local lights on translucent fix --- .../src/RenderableParticleEffectEntityItem.cpp | 4 ++-- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 4 ++-- libraries/gpu-gl-common/src/gpu/gl/GLBackend.h | 2 +- libraries/gpu/src/gpu/Batch.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index b3a4a1a1ab..ee77646920 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,8 +23,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static int32_t PARTICLE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static int32_t PARTICLE_UNIFORM_SLOT { 12 }; static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { auto texturedPipeline = _texturedPipeline.lock(); diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 394ab08dfb..d571eac35c 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -34,8 +34,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER { 0 }; static const int32_t PAINTSTROKE_TEXTURE_SLOT { 0 }; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static const int32_t PAINTSTROKE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static const int32_t PAINTSTROKE_UNIFORM_SLOT { 12 }; static gpu::Stream::FormatPointer polylineFormat; static gpu::PipelinePointer polylinePipeline; #ifdef POLYLINE_ENTITY_USE_FADE_EFFECT diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 5bbb44f9e1..314bbee387 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -91,7 +91,7 @@ public: // this is the maximum per shader stage on the low end apple // TODO make it platform dependant at init time - static const int MAX_NUM_UNIFORM_BUFFERS = 12; + static const int MAX_NUM_UNIFORM_BUFFERS = 14; size_t getMaxNumUniformBuffers() const { return MAX_NUM_UNIFORM_BUFFERS; } // this is the maximum per shader stage on the low end apple diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 84a7c275f0..90115806b4 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -34,7 +34,7 @@ ProfileRangeBatch::~ProfileRangeBatch() { using namespace gpu; // FIXME make these backend / pipeline dependent. -static const int MAX_NUM_UNIFORM_BUFFERS = 12; +static const int MAX_NUM_UNIFORM_BUFFERS = 14; static const int MAX_NUM_RESOURCE_BUFFERS = 16; static const int MAX_NUM_RESOURCE_TEXTURES = 16; From cefb8457eacb47af31b32f44088bd98e9b2c0edc Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 3 May 2018 11:17:31 -0700 Subject: [PATCH 089/192] Fix uninitialized boolean --- libraries/networking/src/NodeList.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 9595c5da84..c5cf5e9524 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -167,7 +167,7 @@ private: HifiSockAddr _assignmentServerSocket; bool _isShuttingDown { false }; QTimer _keepAlivePingTimer; - bool _requestsDomainListData; + bool _requestsDomainListData { false }; mutable QReadWriteLock _ignoredSetLock; tbb::concurrent_unordered_set _ignoredNodeIDs; From 46f461dcdbdcf40095ef4e152fc082ae27d952e3 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 11:20:37 -0700 Subject: [PATCH 090/192] Don't display crash message if running from command line with a test script. --- interface/src/Application.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2abac520fb..45a1a34f1a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -743,6 +743,9 @@ extern DisplayPluginList getDisplayPlugins(); extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); +const QString TEST_SCRIPT { "--testScript" }; +const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" }; + bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); @@ -777,7 +780,22 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; bool suppressPrompt = cmdOptionExists(argc, const_cast(argv), SUPPRESS_SETTINGS_RESET); - bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); + + // Ignore any previous crashes if running from command line with a test script. + bool inTestMode { false }; + for (int i = 0; i < argc; ++i) { + QString parameter(argv[i]); + if (parameter == TEST_SCRIPT) { + inTestMode = true; + break; + } + } + + bool previousSessionCrashed { false }; + if (!inTestMode) { + previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); + } + // get dir to use for cache static const auto CACHE_SWITCH = "--cache"; QString cacheDir = getCmdOption(argc, const_cast(argv), CACHE_SWITCH); @@ -997,10 +1015,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); setProperty(hifi::properties::CRASHED, _previousSessionCrashed); { - const QString TEST_SCRIPT { "--testScript" }; - const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" }; - const QStringList args = arguments(); + for (int i = 0; i < args.size() - 1; ++i) { if (args.at(i) == TEST_SCRIPT) { QString testScriptPath = args.at(i + 1); From 4793cddde6a4e1eb12281df57b0cb722e9e66f68 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 3 May 2018 11:27:07 -0700 Subject: [PATCH 091/192] fix highlighting issues --- .../highlightNearbyEntities.js | 4 ++- .../mouseHighlightEntities.js | 31 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index a66f7bd144..32e1b4300d 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -89,7 +89,9 @@ } if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) { dispatcherUtils.highlightTargetEntity(props.id); - newHighlightedEntities.push(props.id); + if (newHighlightedEntities.indexOf(props.id) < 0) { + newHighlightedEntities.push(props.id); + } } } diff --git a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js index 6af1055a69..86c96fcf6b 100644 --- a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js +++ b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js @@ -12,7 +12,7 @@ /* jslint bitwise: true */ -/* global Script, print, Entities, Picks, HMD */ +/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/ (function() { @@ -20,6 +20,7 @@ function MouseHighlightEntities() { this.highlightedEntity = null; + this.grabbedEntity = null; this.parameters = dispatcherUtils.makeDispatcherModuleParameters( 5, @@ -27,13 +28,18 @@ [], 100); + this.setGrabbedEntity = function(entity) { + this.grabbedEntity = entity; + this.highlightedEntity = null; + }; + this.isReady = function(controllerData) { if (HMD.active) { if (this.highlightedEntity) { dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity); this.highlightedEntity = null; } - } else { + } else if (!this.grabbedEntity) { var pickResult = controllerData.mouseRayPick; if (pickResult.type === Picks.INTERSECTED_ENTITY) { var targetEntityID = pickResult.objectID; @@ -70,8 +76,29 @@ var mouseHighlightEntities = new MouseHighlightEntities(); dispatcherUtils.enableDispatcherModule("MouseHighlightEntities", mouseHighlightEntities); + var handleMessage = function(channel, message, sender) { + var data; + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Object-Manipulation') { + try { + data = JSON.parse(message); + if (data.action === 'grab') { + var grabbedEntity = data.grabbedEntity; + mouseHighlightEntities.setGrabbedEntity(grabbedEntity); + } else if (data.action === 'release') { + mouseHighlightEntities.setGrabbedEntity(null); + } + } catch (e) { + print("Warning: mouseHighlightEntities -- error parsing Hifi-Object-Manipulation: " + message); + } + } + } + }; + function cleanup() { dispatcherUtils.disableDispatcherModule("MouseHighlightEntities"); } + Messages.subscribe('Hifi-Object-Manipulation'); + Messages.messageReceived.connect(handleMessage); Script.scriptEnding.connect(cleanup); })(); From c258e8c2488b69f5b88846d9a09bb1a6bb3666dc Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 3 May 2018 11:27:07 -0700 Subject: [PATCH 092/192] fix highlighting issues --- .../highlightNearbyEntities.js | 4 ++- .../mouseHighlightEntities.js | 31 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index a66f7bd144..32e1b4300d 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -89,7 +89,9 @@ } if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) { dispatcherUtils.highlightTargetEntity(props.id); - newHighlightedEntities.push(props.id); + if (newHighlightedEntities.indexOf(props.id) < 0) { + newHighlightedEntities.push(props.id); + } } } diff --git a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js index 6af1055a69..86c96fcf6b 100644 --- a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js +++ b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js @@ -12,7 +12,7 @@ /* jslint bitwise: true */ -/* global Script, print, Entities, Picks, HMD */ +/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/ (function() { @@ -20,6 +20,7 @@ function MouseHighlightEntities() { this.highlightedEntity = null; + this.grabbedEntity = null; this.parameters = dispatcherUtils.makeDispatcherModuleParameters( 5, @@ -27,13 +28,18 @@ [], 100); + this.setGrabbedEntity = function(entity) { + this.grabbedEntity = entity; + this.highlightedEntity = null; + }; + this.isReady = function(controllerData) { if (HMD.active) { if (this.highlightedEntity) { dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity); this.highlightedEntity = null; } - } else { + } else if (!this.grabbedEntity) { var pickResult = controllerData.mouseRayPick; if (pickResult.type === Picks.INTERSECTED_ENTITY) { var targetEntityID = pickResult.objectID; @@ -70,8 +76,29 @@ var mouseHighlightEntities = new MouseHighlightEntities(); dispatcherUtils.enableDispatcherModule("MouseHighlightEntities", mouseHighlightEntities); + var handleMessage = function(channel, message, sender) { + var data; + if (sender === MyAvatar.sessionUUID) { + if (channel === 'Hifi-Object-Manipulation') { + try { + data = JSON.parse(message); + if (data.action === 'grab') { + var grabbedEntity = data.grabbedEntity; + mouseHighlightEntities.setGrabbedEntity(grabbedEntity); + } else if (data.action === 'release') { + mouseHighlightEntities.setGrabbedEntity(null); + } + } catch (e) { + print("Warning: mouseHighlightEntities -- error parsing Hifi-Object-Manipulation: " + message); + } + } + } + }; + function cleanup() { dispatcherUtils.disableDispatcherModule("MouseHighlightEntities"); } + Messages.subscribe('Hifi-Object-Manipulation'); + Messages.messageReceived.connect(handleMessage); Script.scriptEnding.connect(cleanup); })(); From 767e6b15f34e9827d41f2e351933dba566eb0c2f Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 3 May 2018 11:42:06 -0700 Subject: [PATCH 093/192] Fixing the local lighting on translucents bug --- .../src/RenderableParticleEffectEntityItem.cpp | 4 ++-- .../entities-renderer/src/RenderablePolyLineEntityItem.cpp | 4 ++-- libraries/gpu-gl-common/src/gpu/gl/GLBackend.h | 2 +- libraries/gpu/src/gpu/Batch.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index b3a4a1a1ab..ee77646920 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,8 +23,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static int32_t PARTICLE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static int32_t PARTICLE_UNIFORM_SLOT { 12 }; static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { auto texturedPipeline = _texturedPipeline.lock(); diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 394ab08dfb..d571eac35c 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -34,8 +34,8 @@ using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER { 0 }; static const int32_t PAINTSTROKE_TEXTURE_SLOT { 0 }; -// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 11 to avoid collisions -static const int32_t PAINTSTROKE_UNIFORM_SLOT { 11 }; +// FIXME: This is interfering with the uniform buffers in DeferredLightingEffect.cpp, so use 12 to avoid collisions +static const int32_t PAINTSTROKE_UNIFORM_SLOT { 12 }; static gpu::Stream::FormatPointer polylineFormat; static gpu::PipelinePointer polylinePipeline; #ifdef POLYLINE_ENTITY_USE_FADE_EFFECT diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 5bbb44f9e1..314bbee387 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -91,7 +91,7 @@ public: // this is the maximum per shader stage on the low end apple // TODO make it platform dependant at init time - static const int MAX_NUM_UNIFORM_BUFFERS = 12; + static const int MAX_NUM_UNIFORM_BUFFERS = 14; size_t getMaxNumUniformBuffers() const { return MAX_NUM_UNIFORM_BUFFERS; } // this is the maximum per shader stage on the low end apple diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 84a7c275f0..90115806b4 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -34,7 +34,7 @@ ProfileRangeBatch::~ProfileRangeBatch() { using namespace gpu; // FIXME make these backend / pipeline dependent. -static const int MAX_NUM_UNIFORM_BUFFERS = 12; +static const int MAX_NUM_UNIFORM_BUFFERS = 14; static const int MAX_NUM_RESOURCE_BUFFERS = 16; static const int MAX_NUM_RESOURCE_TEXTURES = 16; From cffb008c3113b3871533d0e4b4aa1448dd99b604 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 3 May 2018 13:07:32 -0700 Subject: [PATCH 094/192] fixing edge case --- scripts/system/controllers/grab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 8ae94a4caa..a835373e4d 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -409,7 +409,7 @@ Grabber.prototype.pressEvent = function(event) { var args = "mouse"; Entities.callEntityMethod(this.entityID, "startDistanceGrab", args); - Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'grab', grabbedEntity: this.entityID })); @@ -450,7 +450,7 @@ Grabber.prototype.releaseEvent = function(event) { var args = "mouse"; Entities.callEntityMethod(this.entityID, "releaseGrab", args); - Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'release', grabbedEntity: this.entityID, joint: "mouse" From a6eab29b14fb952853462b5f37716cf4c9e6ee0a Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 3 May 2018 13:07:32 -0700 Subject: [PATCH 095/192] fixing edge case --- scripts/system/controllers/grab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 8ae94a4caa..a835373e4d 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -409,7 +409,7 @@ Grabber.prototype.pressEvent = function(event) { var args = "mouse"; Entities.callEntityMethod(this.entityID, "startDistanceGrab", args); - Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'grab', grabbedEntity: this.entityID })); @@ -450,7 +450,7 @@ Grabber.prototype.releaseEvent = function(event) { var args = "mouse"; Entities.callEntityMethod(this.entityID, "releaseGrab", args); - Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ + Messages.sendLocalMessage('Hifi-Object-Manipulation', JSON.stringify({ action: 'release', grabbedEntity: this.entityID, joint: "mouse" From fc9bd7f905d2f0c6dd92ac539e2dbbb4afb75f17 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 3 May 2018 13:51:50 -0700 Subject: [PATCH 096/192] Fix for crash deep in QML after useFullAvatarURL Here we avoid calling FSTReader::downloadMapping() from within MyAvatar::useFullAvatarURL(). This prevents the error case where a QEventLoop is entered during QML execution. --- interface/src/avatar/MyAvatar.cpp | 18 +++++++++++------- .../src/model-networking/ModelCache.cpp | 19 +++++++++++-------- .../src/model-networking/ModelCache.h | 2 ++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index e116b3830e..15b220c63b 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1486,6 +1486,15 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { std::shared_ptr skeletonConnection = std::make_shared(); *skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() { if (skeletonModelChangeCount == _skeletonModelChangeCount) { + + if (_fullAvatarModelName.isEmpty()) { + // Store the FST file name into preferences + const auto& mapping = _skeletonModel->getGeometry()->getMapping(); + if (mapping.value("name").isValid()) { + _fullAvatarModelName = mapping.value("name").toString(); + } + } + initHeadBones(); _skeletonModel->setCauterizeBoneSet(_headBoneSet); _fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl(); @@ -1548,12 +1557,7 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN if (_fullAvatarURLFromPreferences != fullAvatarURL) { _fullAvatarURLFromPreferences = fullAvatarURL; - if (modelName.isEmpty()) { - QVariantHash fullAvatarFST = FSTReader::downloadMapping(_fullAvatarURLFromPreferences.toString()); - _fullAvatarModelName = fullAvatarFST["name"].toString(); - } else { - _fullAvatarModelName = modelName; - } + _fullAvatarModelName = modelName; } const QString& urlString = fullAvatarURL.toString(); @@ -1561,8 +1565,8 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN setSkeletonModelURL(fullAvatarURL); UserActivityLogger::getInstance().changedModel("skeleton", urlString); } + markIdentityDataChanged(); - } void MyAvatar::setAttachmentData(const QVector& attachmentData) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 416920d43f..45f2462f57 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -63,9 +63,10 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryMappingResource::downloadFinished", _url.toString(), { { "url", _url.toString() } }); - auto mapping = FSTReader::readMapping(data); + // store parsed contents of FST file + _mapping = FSTReader::readMapping(data); - QString filename = mapping.value("filename").toString(); + QString filename = _mapping.value("filename").toString(); if (filename.isNull()) { qCDebug(modelnetworking) << "Mapping file" << _url << "has no \"filename\" field"; @@ -73,7 +74,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { } else { QUrl url = _url.resolved(filename); - QString texdir = mapping.value(TEXDIR_FIELD).toString(); + QString texdir = _mapping.value(TEXDIR_FIELD).toString(); if (!texdir.isNull()) { if (!texdir.endsWith('/')) { texdir += '/'; @@ -83,15 +84,16 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { _textureBaseUrl = url.resolved(QUrl(".")); } - auto scripts = FSTReader::getScripts(_url, mapping); + auto scripts = FSTReader::getScripts(_url, _mapping); if (scripts.size() > 0) { - mapping.remove(SCRIPT_FIELD); + _mapping.remove(SCRIPT_FIELD); for (auto &scriptPath : scripts) { - mapping.insertMulti(SCRIPT_FIELD, scriptPath); + _mapping.insertMulti(SCRIPT_FIELD, scriptPath); } } - auto animGraphVariant = mapping.value("animGraphUrl"); + auto animGraphVariant = _mapping.value("animGraphUrl"); + if (animGraphVariant.isValid()) { QUrl fstUrl(animGraphVariant.toString()); if (fstUrl.isValid()) { @@ -104,7 +106,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { } auto modelCache = DependencyManager::get(); - GeometryExtra extra{ mapping, _textureBaseUrl, false }; + GeometryExtra extra{ _mapping, _textureBaseUrl, false }; // Get the raw GeometryResource _geometryResource = modelCache->getResource(url, QUrl(), &extra).staticCast(); @@ -379,6 +381,7 @@ Geometry::Geometry(const Geometry& geometry) { } _animGraphOverrideUrl = geometry._animGraphOverrideUrl; + _mapping = geometry._mapping; } void Geometry::setTextures(const QVariantMap& textureMap) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index cda825e5fb..7cb11587c9 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -55,6 +55,7 @@ public: virtual bool areTexturesLoaded() const; const QUrl& getAnimGraphOverrideUrl() const { return _animGraphOverrideUrl; } + const QVariantHash& getMapping() const { return _mapping; } protected: friend class GeometryMappingResource; @@ -68,6 +69,7 @@ protected: NetworkMaterials _materials; QUrl _animGraphOverrideUrl; + QVariantHash _mapping; // parsed contents of FST file. private: mutable bool _areTexturesLoaded { false }; From 3a5425122bcba2a91525c457ef92ca752a4dd782 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 14:31:01 -0700 Subject: [PATCH 097/192] Shutdown interface when test script finishes. --- interface/src/Application.cpp | 4 +++- libraries/script-engine/src/ScriptEngines.cpp | 11 ++++++++++- libraries/script-engine/src/ScriptEngines.h | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 45a1a34f1a..d8c162a79c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2160,7 +2160,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo if (testProperty.isValid()) { auto scriptEngines = DependencyManager::get(); const auto testScript = property(hifi::properties::TEST).toUrl(); - scriptEngines->loadScript(testScript, false); + + // Set last parameter to exit interface when the test script finishes + scriptEngines->loadScript(testScript, false, false, false, false, true); // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. if (arguments().contains("--url")) { diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index f2ed296b63..ef4eddbf39 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -456,7 +456,7 @@ void ScriptEngines::reloadAllScripts() { } ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, - bool activateMainWindow, bool reload) { + bool activateMainWindow, bool reload, bool exitWhenFinished) { if (thread() != QThread::currentThread()) { ScriptEnginePointer result { nullptr }; BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), @@ -496,6 +496,11 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); + // Shutdown interface when script finishes, if requested + if (exitWhenFinished) { + connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished); + } + // get the script engine object to load the script at the designated script URL scriptEngine->loadURL(scriptUrl, reload); } @@ -536,6 +541,10 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { emit scriptCountChanged(); } +void ScriptEngines::exitWhenFinished() { + qApp->quit(); +} + int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { int ii=0; for (auto initializer : _scriptInitializers) { diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 376bae4827..6f88e8978d 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -91,7 +91,7 @@ public: * @returns {boolean} */ Q_INVOKABLE ScriptEnginePointer loadScript(const QUrl& scriptFilename = QString(), - bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false); + bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false, bool exitWhenFinished = false); /**jsdoc * @function ScriptDiscoveryService.stopScript @@ -266,6 +266,7 @@ protected: ScriptEnginePointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); } void removeScriptEngine(ScriptEnginePointer); void onScriptEngineLoaded(const QString& scriptFilename); + void exitWhenFinished(); void onScriptEngineError(const QString& scriptFilename); void launchScriptEngine(ScriptEnginePointer); From 3b566332c6d6fe3413b0bf6b3293dd75b46a8e01 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 14:34:12 -0700 Subject: [PATCH 098/192] Shutdown interface when test script finishes. --- libraries/script-engine/src/ScriptEngines.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index ef4eddbf39..d2834e8c4a 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -456,7 +456,7 @@ void ScriptEngines::reloadAllScripts() { } ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, - bool activateMainWindow, bool reload, bool exitWhenFinished) { + bool activateMainWindow, bool reload, bool exitWhenFinished) { if (thread() != QThread::currentThread()) { ScriptEnginePointer result { nullptr }; BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), @@ -496,7 +496,7 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); - // Shutdown interface when script finishes, if requested + // Shutdown Interface when script finishes, if requested if (exitWhenFinished) { connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished); } From beb19c53faa18ff57bb0f12b147b2ca5292354e6 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 15:00:14 -0700 Subject: [PATCH 099/192] Added date and time to auto-generated scripts. --- tools/auto-tester/src/Test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 18d1350402..e9dcad6c72 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -366,10 +366,10 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact } QTextStream textStream(&allTestsFilename); - textStream << "// This is an automatically generated file, created by auto-tester" << endl << endl; + textStream << "// This is an automatically generated file, created by auto-tester on " << __DATE__ << ", " << __TIME__ << endl << endl; textStream << "var autoTester = Script.require(\"https://github.com/" + githubUser + "/hifi_tests/blob/" - + gitHubBranch + "/tests/utils/autoTester.js?raw=true\");" << endl; + + gitHubBranch + "/tests/utils/autoTester.js?raw=true\");" << endl << endl; textStream << "autoTester.enableRecursive();" << endl; textStream << "autoTester.enableAuto();" << endl << endl; From fe9c6052f73a55aa1873485fa6ae6a7c1d6bf580 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 15:02:11 -0700 Subject: [PATCH 100/192] Added `quitWhenFinished` parameter to the command line. --- interface/src/Application.cpp | 15 +++++++++++---- interface/src/Application.h | 1 + interface/src/ui/Snapshot.cpp | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d8c162a79c..fed6caab89 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -743,7 +743,9 @@ extern DisplayPluginList getDisplayPlugins(); extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); +// Parameters used for running tests from teh command line const QString TEST_SCRIPT { "--testScript" }; +const QString TEST_QUIT_WHEN_FINISHED { "--quitWhenFinished" }; const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" }; bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { @@ -1018,11 +1020,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo const QStringList args = arguments(); for (int i = 0; i < args.size() - 1; ++i) { - if (args.at(i) == TEST_SCRIPT) { + if (args.at(i) == TEST_SCRIPT && (i + 1) < args.size()) { QString testScriptPath = args.at(i + 1); if (QFileInfo(testScriptPath).exists()) { setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); - } + } + + // quite when finished parameter must directly follow the test script + if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED) { + quitWhenFinished = true; + } } else if (args.at(i) == TEST_SNAPSHOT_LOCATION) { // Set test snapshot location only if it is a writeable directory QString pathname(args.at(i + 1)); @@ -2161,8 +2168,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto scriptEngines = DependencyManager::get(); const auto testScript = property(hifi::properties::TEST).toUrl(); - // Set last parameter to exit interface when the test script finishes - scriptEngines->loadScript(testScript, false, false, false, false, true); + // Set last parameter to exit interface when the test script finishes, if so requested + scriptEngines->loadScript(testScript, false, false, false, false, quitWhenFinished); // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. if (arguments().contains("--url")) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 088b74aa9b..cc366c74fe 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -740,5 +740,6 @@ private: std::atomic _pendingRenderEvent { true }; QString testSnapshotLocation; + bool quitWhenFinished { false }; }; #endif // hifi_Application_h diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index d52f01223c..5616b35ac0 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -73,6 +73,7 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { return data; } +#pragma optimize("", off) QString Snapshot::saveSnapshot(QImage image, const QString& filename, const QString& pathname) { QFile* snapshotFile = savedFileForSnapshot(image, false, filename, pathname); @@ -92,6 +93,7 @@ QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { return static_cast(savedFileForSnapshot(image, true, QString(), QString())); } +#pragma optimize("", off) QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname) { // adding URL to snapshot From 2c6c0a25fcc95b0ba37a356ae460d3da8b796036 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 15:15:30 -0700 Subject: [PATCH 101/192] Add testSnapshotLocation parameter to `takeSnapshot`. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fed6caab89..54f1ba2606 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7412,7 +7412,7 @@ void Application::loadAvatarBrowser() const { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { // Get a screenshot and save it - QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename); + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testSnapshotLocation); // If we're not doing an animated snapshot as well... if (!includeAnimated) { // Tell the dependency manager that the capture of the still snapshot has taken place. From 887b8285cdc03dce6c9ab369e6f8200ed16668bf Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 16:44:04 -0700 Subject: [PATCH 102/192] Removed unneeded pragma. --- interface/src/ui/Snapshot.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 5616b35ac0..a84e19154b 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -73,7 +73,6 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { return data; } -#pragma optimize("", off) QString Snapshot::saveSnapshot(QImage image, const QString& filename, const QString& pathname) { QFile* snapshotFile = savedFileForSnapshot(image, false, filename, pathname); From da621d99d35c55fae647d2f4510b985f21b218d1 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 16:52:03 -0700 Subject: [PATCH 103/192] Removed unneeded pragma. --- interface/src/ui/Snapshot.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index a84e19154b..d52f01223c 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -92,7 +92,6 @@ QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { return static_cast(savedFileForSnapshot(image, true, QString(), QString())); } -#pragma optimize("", off) QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname) { // adding URL to snapshot From 1f691edf0d7a731a692757844748c62a9e62a088 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 3 May 2018 17:04:17 -0700 Subject: [PATCH 104/192] Removed platform code (was used for MD files). --- tools/auto-tester/src/Test.cpp | 72 ---------------------------------- tools/auto-tester/src/Test.h | 6 --- 2 files changed, 78 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index e9dcad6c72..e00bc920e5 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -530,26 +530,6 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { QStringList tokens = line.split('"'); relevantTextFromTest.title = tokens[1]; - } else if (lineAssertPlatform.match(line).hasMatch()) { - QStringList platforms = line.split('"'); - relevantTextFromTest.platform = platforms[1]; - - } else if (lineAssertDisplay.match(line).hasMatch()) { - QStringList displays = line.split('"'); - relevantTextFromTest.display = displays[1]; - - } else if (lineAssertCPU.match(line).hasMatch()) { - QStringList cpus = line.split('"'); - relevantTextFromTest.cpu = cpus[1]; - - } else if (lineAssertGPU.match(line).hasMatch()) { - QStringList gpus = line.split('"'); - relevantTextFromTest.gpu = gpus[1]; - - } else if (lineAssertPhysicalMemoryGB.match(line).hasMatch()) { - QStringList physicalMemoryGB = line.split('"'); - relevantTextFromTest.physicalMemoryGB = physicalMemoryGB[1]; - } else if (lineStepSnapshot.match(line).hasMatch()) { QStringList tokens = line.split('"'); QString nameOfStep = tokens[1]; @@ -653,58 +633,6 @@ void Test::createMDFile(const QString& testDirectory) { stream << "## Preconditions" << "\n"; stream << "- In an empty region of a domain with editing rights." << "\n\n"; - // Platform - QStringList platforms = testScriptLines.platform.split(" ");; - if (platforms.size() > 0) { - stream << "## Platforms\n"; - stream << "Run the test on each of the following platforms\n"; - for (int i = 0; i < platforms.size(); ++i) { - // Note that the platforms parameter may include extra spaces, these appear as empty strings in the list - if (platforms[i] != QString()) { - stream << " - " << platforms[i] << "\n"; - } - } - } - - // Display - QStringList displays = testScriptLines.display.split(" "); - if (displays.size()) { - stream << "## Displays\n"; - stream << "Run the test on each of the following displays\n"; - for (int i = 0; i < displays.size(); ++i) { - // Note that the displays parameter may include extra spaces, these appear as empty strings in the list - if (displays[i] != QString()) { - stream << " - " << displays[i] << "\n"; - } - } - } - - // CPU - QStringList cpus = testScriptLines.cpu.split(" "); - if (cpus.size() > 0) { - stream << "## Processors\n"; - stream << "Run the test on each of the following processors\n"; - for (int i = 0; i < cpus.size(); ++i) { - // Note that the cpus parameter may include extra spaces, these appear as empty strings in the list - if (cpus[i] != QString()) { - stream << " - " << cpus[i] << "\n"; - } - } - } - - // GPU - QStringList gpus = testScriptLines.gpu.split(" "); - if (gpus.size() > 0) { - stream << "## Graphics Cards\n"; - stream << "Run the test on graphics cards from each of the following vendors\n"; - for (int i = 0; i < gpus.size(); ++i) { - // Note that the gpus parameter may include extra spaces, these appear as empty strings in the list - if (gpus[i] != QString()) { - stream << " - " << gpus[i] << "\n"; - } - } - } - stream << "## Steps\n"; stream << "Press space bar to advance step by step\n\n"; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 02cab53381..b341c1d00f 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -30,12 +30,6 @@ using StepList = std::vector; class ExtractedText { public: QString title; - QString platform; - QString display; - QString cpu; - QString gpu; - QString physicalMemoryGB; - StepList stepList; }; From 7fe16f82fbdaed268b03ce8caa935b196019c929 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 3 May 2018 17:08:17 -0700 Subject: [PATCH 105/192] Move variables to Agent.cpp --- assignment-client/src/Agent.cpp | 3 +++ libraries/avatars/src/AvatarData.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index f560ea72bd..0b373e511b 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -554,6 +554,9 @@ void Agent::setIsAvatar(bool isAvatar) { connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket); connect(_avatarViewTimer, &QTimer::timeout, this, &Agent::sendAvatarViewFrustum); + static const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000; + static const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 1000; + // start the timers _avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets _avatarViewTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 3db94f6691..bbcdd3693d 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -277,9 +277,6 @@ namespace AvatarDataPacket { const float MAX_AUDIO_LOUDNESS = 1000.0f; // close enough for mouth animation -const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000; -const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 100; - // See also static AvatarData::defaultFullAvatarModelUrl(). const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default"); From 79576e0f48f9dd7b080d333d9d4b5113853e89e7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 3 May 2018 17:16:35 -0700 Subject: [PATCH 106/192] update request and dependency hoek for CVE --- server-console/package-lock.json | 355 +++++++++++++------------------ server-console/package.json | 2 +- 2 files changed, 147 insertions(+), 210 deletions(-) diff --git a/server-console/package-lock.json b/server-console/package-lock.json index 4311fde51a..4f12f2fa00 100644 --- a/server-console/package-lock.json +++ b/server-console/package-lock.json @@ -20,7 +20,6 @@ "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "dev": true, "requires": { "co": "4.6.0", "fast-deep-equal": "1.0.0", @@ -41,11 +40,6 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=" }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" - }, "array-find-index": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.1.tgz", @@ -118,16 +112,10 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" }, - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "author-regex": { "version": "1.0.0", @@ -136,17 +124,14 @@ "dev": true }, "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.3.2.tgz", - "integrity": "sha1-054L7kEs7Q6O2Uoj4xTzE6lbn9E=", - "requires": { - "lru-cache": "4.0.1" - } + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", + "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, "base64-js": { "version": "1.2.0", @@ -204,11 +189,11 @@ "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", + "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", "requires": { - "hoek": "2.16.3" + "hoek": "4.2.1" } }, "buffers": { @@ -239,9 +224,9 @@ } }, "caseless": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=" + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, "chainsaw": { "version": "0.1.0", @@ -252,18 +237,6 @@ "traverse": "0.3.9" } }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, "cheerio": { "version": "0.19.0", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.19.0.tgz", @@ -295,8 +268,7 @@ "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, "code-point-at": { "version": "1.0.0", @@ -318,6 +290,7 @@ "version": "2.9.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, "requires": { "graceful-readlink": "1.0.1" } @@ -373,11 +346,21 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", + "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", "requires": { - "boom": "2.10.1" + "boom": "5.2.0" + }, + "dependencies": { + "boom": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", + "requires": { + "hoek": "4.2.1" + } + } } }, "css-select": { @@ -728,7 +711,7 @@ "minimist": "1.2.0", "pretty-bytes": "1.0.4", "progress-stream": "1.2.0", - "request": "2.71.0", + "request": "2.85.0", "single-line-log": "1.1.2", "throttleit": "0.0.2" }, @@ -828,11 +811,6 @@ "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" - }, "extend": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", @@ -875,14 +853,12 @@ "fast-deep-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", - "dev": true + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "fd-slicer": { "version": "1.0.1", @@ -976,13 +952,23 @@ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "1.0.0-rc4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.0-rc4.tgz", - "integrity": "sha1-BaxrwiIntD5EYfSIFhVUaZ1Pi14=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "async": "1.5.2", - "combined-stream": "1.0.5", - "mime-types": "2.1.10" + "asynckit": "0.4.0", + "combined-stream": "1.0.6", + "mime-types": "2.1.18" + }, + "dependencies": { + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "1.0.0" + } + } } }, "fs-extra": { @@ -1058,19 +1044,6 @@ } } }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=" - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "requires": { - "is-property": "1.0.2" - } - }, "get-package-info": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/get-package-info/-/get-package-info-1.0.0.tgz", @@ -1212,7 +1185,8 @@ "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true }, "growly": { "version": "1.3.0", @@ -1222,43 +1196,32 @@ "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" }, "har-validator": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "chalk": "1.1.3", - "commander": "2.9.0", - "is-my-json-valid": "2.13.1", - "pinkie-promise": "2.0.1" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "requires": { - "ansi-regex": "2.0.0" + "ajv": "5.5.2", + "har-schema": "2.0.0" } }, "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" + "boom": "4.3.1", + "cryptiles": "3.1.2", + "hoek": "4.2.1", + "sntp": "2.1.0" } }, "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" }, "home-path": { "version": "1.0.5", @@ -1301,13 +1264,20 @@ } }, "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "0.2.0", + "assert-plus": "1.0.0", "jsprim": "1.2.2", "sshpk": "1.7.4" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } } }, "indent-string": { @@ -1388,28 +1358,12 @@ "number-is-nan": "1.0.0" } }, - "is-my-json-valid": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.13.1.tgz", - "integrity": "sha1-1Vd4qC/rawlj/0vhEdXRaE6JBwc=", - "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "jsonpointer": "2.0.0", - "xtend": "4.0.1" - } - }, "is-promise": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz", "integrity": "sha1-MVc3YcBX4zwukaq56W2gjO++duU=", "dev": true }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=" - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1465,8 +1419,7 @@ "json-schema-traverse": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" }, "json-stringify-safe": { "version": "5.0.1", @@ -1478,11 +1431,6 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.2.3.tgz", "integrity": "sha1-4lK5mmr5AdPsQfMyWJyQUJp7xgU=" }, - "jsonpointer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz", - "integrity": "sha1-OvHdIP6FRjkQ1GmjheMwF9KgMNk=" - }, "jsprim": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.2.2.tgz", @@ -1569,15 +1517,6 @@ "signal-exit": "2.1.2" } }, - "lru-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.1.tgz", - "integrity": "sha1-E0OVXtry432bnn7nJB4nxLn7cr4=", - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.0.0" - } - }, "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", @@ -1603,16 +1542,16 @@ } }, "mime-db": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.22.0.tgz", - "integrity": "sha1-qyOmNy3J2G09yRIb0OvTgQWhkEo=" + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" }, "mime-types": { - "version": "2.1.10", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.10.tgz", - "integrity": "sha1-uTx8tDYuFtQQcqflRTj7TUMHCDc=", + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.22.0" + "mime-db": "1.33.0" } }, "minimist": { @@ -1891,11 +1830,6 @@ } } }, - "node-uuid": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", - "integrity": "sha1-baWhdmjEs91ZYjvaEc9/pMH2Cm8=" - }, "nodeify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz", @@ -1945,7 +1879,7 @@ "minimist": "1.2.0", "pretty-bytes": "1.0.4", "progress-stream": "1.2.0", - "request": "2.71.0", + "request": "2.85.0", "single-line-log": "1.1.2", "throttleit": "0.0.2" }, @@ -1973,9 +1907,9 @@ "integrity": "sha1-wCD1KcUoKt/dIz2R1LGBw9aG3Es=" }, "oauth-sign": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.1.tgz", - "integrity": "sha1-GCQ5vbkTeL90YOdcZOpD5kSN7wY=" + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" }, "object-assign": { "version": "4.0.1", @@ -2099,8 +2033,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, "pify": { "version": "2.3.0", @@ -2111,12 +2044,14 @@ "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "requires": { "pinkie": "2.0.4" } @@ -2166,11 +2101,6 @@ "is-promise": "1.0.1" } }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, "pump": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.1.tgz", @@ -2183,8 +2113,7 @@ "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, "q": { "version": "1.5.1", @@ -2193,9 +2122,9 @@ "dev": true }, "qs": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.1.0.tgz", - "integrity": "sha1-7B0WJrJCeNmfD99FSeUk4k7O6yY=" + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" }, "rc": { "version": "1.1.6", @@ -2252,31 +2181,39 @@ } }, "request": { - "version": "2.71.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.71.0.tgz", - "integrity": "sha1-bxRkPJxaZ8ruapXPjvBHfVYDvZE=", + "version": "2.85.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", + "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.3.2", - "bl": "1.1.2", - "caseless": "0.11.0", + "aws-sign2": "0.7.0", + "aws4": "1.7.0", + "caseless": "0.12.0", "combined-stream": "1.0.5", - "extend": "3.0.0", + "extend": "3.0.1", "forever-agent": "0.6.1", - "form-data": "1.0.0-rc4", - "har-validator": "2.0.6", - "hawk": "3.1.3", - "http-signature": "1.1.1", + "form-data": "2.3.2", + "har-validator": "5.0.3", + "hawk": "6.0.2", + "http-signature": "1.2.0", "is-typedarray": "1.0.0", "isstream": "0.1.2", "json-stringify-safe": "5.0.1", - "mime-types": "2.1.10", - "node-uuid": "1.4.7", - "oauth-sign": "0.8.1", - "qs": "6.1.0", + "mime-types": "2.1.18", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.1", + "safe-buffer": "5.1.1", "stringstream": "0.0.5", - "tough-cookie": "2.2.2", - "tunnel-agent": "0.4.2" + "tough-cookie": "2.3.4", + "tunnel-agent": "0.6.0", + "uuid": "3.2.1" + }, + "dependencies": { + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + } } }, "request-progress": { @@ -2308,8 +2245,7 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, "sanitize-filename": { "version": "1.6.1", @@ -2347,11 +2283,11 @@ } }, "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "requires": { - "hoek": "2.16.3" + "hoek": "4.2.1" } }, "spdx-correct": { @@ -2483,11 +2419,6 @@ } } }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" - }, "tar-fs": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.12.0.tgz", @@ -2585,9 +2516,12 @@ } }, "tough-cookie": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", - "integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=" + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "requires": { + "punycode": "1.4.1" + } }, "traverse": { "version": "0.3.9", @@ -2611,9 +2545,12 @@ } }, "tunnel-agent": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.2.tgz", - "integrity": "sha1-EQTj82rIcSXChycAZ9WC0YEzv+4=" + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "5.1.1" + } }, "tweetnacl": { "version": "0.14.3", @@ -2644,6 +2581,11 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "uuid": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" + }, "validate-npm-package-license": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", @@ -2710,11 +2652,6 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" }, - "yallist": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.0.0.tgz", - "integrity": "sha1-MGxUODXwnuGkyyO3vOmrNByRzdQ=" - }, "yargs": { "version": "3.32.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", diff --git a/server-console/package.json b/server-console/package.json index 2428d2574e..6dd39ea6f8 100644 --- a/server-console/package.json +++ b/server-console/package.json @@ -30,7 +30,7 @@ "fs-extra": "^1.0.0", "node-notifier": "^5.2.1", "os-homedir": "^1.0.1", - "request": "^2.67.0", + "request": "^2.85.0", "request-progress": "1.0.2", "tar-fs": "^1.12.0", "yargs": "^3.30.0" From d774dc2060e546612526cf7df7877ee39ad87812 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 26 Apr 2018 18:34:38 -0700 Subject: [PATCH 107/192] WIP Only use conical frustums on the server --- .../src/entities/EntityPriorityQueue.cpp | 76 -------- .../src/entities/EntityTreeSendThread.cpp | 87 ++------- .../src/entities/EntityTreeSendThread.h | 4 +- libraries/entities/src/DiffTraversal.cpp | 179 ++++++++---------- libraries/entities/src/DiffTraversal.h | 14 +- .../entities/src}/EntityPriorityQueue.h | 38 +--- libraries/shared/src/GLMHelpers.cpp | 6 + libraries/shared/src/GLMHelpers.h | 2 + libraries/shared/src/ViewFrustum.cpp | 7 - .../shared/src/shared/ConicalViewFrustum.cpp | 125 ++++++++++++ .../shared/src/shared/ConicalViewFrustum.h | 64 +++++++ 11 files changed, 306 insertions(+), 296 deletions(-) delete mode 100644 assignment-client/src/entities/EntityPriorityQueue.cpp rename {assignment-client/src/entities => libraries/entities/src}/EntityPriorityQueue.h (70%) create mode 100644 libraries/shared/src/shared/ConicalViewFrustum.cpp create mode 100644 libraries/shared/src/shared/ConicalViewFrustum.h diff --git a/assignment-client/src/entities/EntityPriorityQueue.cpp b/assignment-client/src/entities/EntityPriorityQueue.cpp deleted file mode 100644 index 88dee58f9d..0000000000 --- a/assignment-client/src/entities/EntityPriorityQueue.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -// EntityPriorityQueue.cpp -// assignment-client/src/entities -// -// Created by Andrew Meadows 2017.08.08 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "EntityPriorityQueue.h" - -const float PrioritizedEntity::DO_NOT_SEND = -1.0e-6f; -const float PrioritizedEntity::FORCE_REMOVE = -1.0e-5f; -const float PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY = 1.0f; - -void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) { - // The ConicalView has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part. - // Why? Because approximate intersection tests are much faster to compute for a cone than for a frustum. - _position = viewFrustum.getPosition(); - _direction = viewFrustum.getDirection(); - - // We cache the sin and cos of the half angle of the cone that bounds the frustum. - // (the math here is left as an exercise for the reader) - float A = viewFrustum.getAspectRatio(); - float t = tanf(0.5f * viewFrustum.getFieldOfView()); - _cosAngle = 1.0f / sqrtf(1.0f + (A * A + 1.0f) * (t * t)); - _sinAngle = sqrtf(1.0f - _cosAngle * _cosAngle); - - _radius = viewFrustum.getCenterRadius(); -} - -float ConicalViewFrustum::computePriority(const AACube& cube) const { - glm::vec3 p = cube.calcCenter() - _position; // position of bounding sphere in view-frame - float d = glm::length(p); // distance to center of bounding sphere - float r = 0.5f * cube.getScale(); // radius of bounding sphere - if (d < _radius + r) { - return r; - } - // We check the angle between the center of the cube and the _direction of the view. - // If it is less than the sum of the half-angle from center of cone to outer edge plus - // the half apparent angle of the bounding sphere then it is in view. - // - // The math here is left as an exercise for the reader with the following hints: - // (1) We actually check the dot product of the cube's local position rather than the angle and - // (2) we take advantage of this trig identity: cos(A+B) = cos(A)*cos(B) - sin(A)*sin(B) - if (glm::dot(p, _direction) > sqrtf(d * d - r * r) * _cosAngle - r * _sinAngle) { - const float AVOID_DIVIDE_BY_ZERO = 0.001f; - return r / (d + AVOID_DIVIDE_BY_ZERO); - } - return PrioritizedEntity::DO_NOT_SEND; -} - - -void ConicalView::set(const DiffTraversal::View& view) { - auto size = view.viewFrustums.size(); - _conicalViewFrustums.resize(size); - for (size_t i = 0; i < size; ++i) { - _conicalViewFrustums[i].set(view.viewFrustums[i]); - } -} - -float ConicalView::computePriority(const AACube& cube) const { - if (_conicalViewFrustums.empty()) { - return PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; - } - - float priority = PrioritizedEntity::DO_NOT_SEND; - - for (const auto& view : _conicalViewFrustums) { - priority = std::max(priority, view.computePriority(cube)); - } - - return priority; -} diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index 2e57f2e00f..0d943055f4 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -141,16 +141,8 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O if (forceRemove) { priority = PrioritizedEntity::FORCE_REMOVE; } else { - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - const auto& view = _traversal.getCurrentView(); - if (view.intersects(cube) && view.isBigEnough(cube)) { - priority = _conicalView.computePriority(cube); - } - } else { - priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; - } + const auto& view = _traversal.getCurrentView(); + priority = view.computePriority(entity); } if (priority != PrioritizedEntity::DO_NOT_SEND) { @@ -235,11 +227,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En // (3) Differential = view has changed --> find what has changed or in new view but not old // // The "scanCallback" we provide to the traversal depends on the type: - // - // The _conicalView is updated here as a cached view approximation used by the lambdas for efficient - // computation of entity sorting priorities. - // - _conicalView.set(_traversal.getCurrentView()); switch (type) { case DiffTraversal::First: @@ -251,25 +238,8 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En if (_sendQueue.contains(entity.get())) { return; } - float priority = PrioritizedEntity::DO_NOT_SEND; - - - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - const auto& view = _traversal.getCurrentView(); - // Check the size of the entity, it's possible that a "too small to see" entity is included in a - // larger octree cell because of its position (for example if it crosses the boundary of a cell it - // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen - // before we consider including it. - if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && - view.isBigEnough(cube)) { - priority = _conicalView.computePriority(cube); - } - } else { - priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; - } - + const auto& view = _traversal.getCurrentView(); + float priority = view.computePriority(entity); if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); @@ -288,21 +258,11 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En } float priority = PrioritizedEntity::DO_NOT_SEND; - auto knownTimestamp = _knownState.find(entity.get()); if (knownTimestamp == _knownState.end()) { - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - const auto& view = _traversal.getCurrentView(); - // See the DiffTraversal::First case for an explanation of the "entity is too small" check - if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && - view.isBigEnough(cube)) { - priority = _conicalView.computePriority(cube); - } - } else { - priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; - } + const auto& view = _traversal.getCurrentView(); + priority = view.computePriority(entity); + } else if (entity->getLastEdited() > knownTimestamp->second || entity->getLastChangedOnServer() > knownTimestamp->second) { // it is known and it changed --> put it on the queue with any priority @@ -310,7 +270,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); } @@ -328,21 +287,11 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En } float priority = PrioritizedEntity::DO_NOT_SEND; - auto knownTimestamp = _knownState.find(entity.get()); if (knownTimestamp == _knownState.end()) { - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - const auto& view = _traversal.getCurrentView(); - // See the DiffTraversal::First case for an explanation of the "entity is too small" check - if ((next.intersection == ViewFrustum::INSIDE || view.intersects(cube)) && - view.isBigEnough(cube)) { - priority = _conicalView.computePriority(cube); - } - } else { - priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; - } + const auto& view = _traversal.getCurrentView(); + priority = view.computePriority(entity); + } else if (entity->getLastEdited() > knownTimestamp->second || entity->getLastChangedOnServer() > knownTimestamp->second) { // it is known and it changed --> put it on the queue with any priority @@ -350,7 +299,6 @@ void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, En priority = PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; } - if (priority != PrioritizedEntity::DO_NOT_SEND) { _sendQueue.emplace(entity, priority); } @@ -463,14 +411,13 @@ bool EntityTreeSendThread::traverseTreeAndBuildNextPacketPayload(EncodeBitstream void EntityTreeSendThread::editingEntityPointer(const EntityItemPointer& entity) { if (entity) { if (!_sendQueue.contains(entity.get()) && _knownState.find(entity.get()) != _knownState.end()) { - bool success = false; - AACube cube = entity->getQueryAACube(success); - if (success) { - // We can force a removal from _knownState if the current view is used and entity is out of view - if (_traversal.doesCurrentUseViewFrustum() && !_traversal.getCurrentView().intersects(cube)) { - _sendQueue.emplace(entity, PrioritizedEntity::FORCE_REMOVE, true); - } - } else { + const auto& view = _traversal.getCurrentView(); + float priority = view.computePriority(entity); + + // We can force a removal from _knownState if the current view is used and entity is out of view + if (priority == PrioritizedEntity::DO_NOT_SEND) { + _sendQueue.emplace(entity, PrioritizedEntity::FORCE_REMOVE, true); + } else if (priority == PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY) { _sendQueue.emplace(entity, PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY, true); } } diff --git a/assignment-client/src/entities/EntityTreeSendThread.h b/assignment-client/src/entities/EntityTreeSendThread.h index 9eea98b7fd..1305d7bfc7 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.h +++ b/assignment-client/src/entities/EntityTreeSendThread.h @@ -17,8 +17,9 @@ #include "../octree/OctreeSendThread.h" #include +#include +#include -#include "EntityPriorityQueue.h" class EntityNodeData; class EntityItem; @@ -51,7 +52,6 @@ private: DiffTraversal _traversal; EntityPriorityQueue _sendQueue; std::unordered_map _knownState; - ConicalView _conicalView; // cached optimized view for fast priority calculations // packet construction stuff EntityTreeElementExtraEncodeDataPointer _extraEncodeData { new EntityTreeElementExtraEncodeData() }; diff --git a/libraries/entities/src/DiffTraversal.cpp b/libraries/entities/src/DiffTraversal.cpp index 39328e11ad..36d1f41267 100644 --- a/libraries/entities/src/DiffTraversal.cpp +++ b/libraries/entities/src/DiffTraversal.cpp @@ -13,6 +13,8 @@ #include +#include "EntityPriorityQueue.h" + DiffTraversal::Waypoint::Waypoint(EntityTreeElementPointer& element) : _nextIndex(0) { assert(element); _weakElement = element; @@ -35,19 +37,9 @@ void DiffTraversal::Waypoint::getNextVisibleElementFirstTime(DiffTraversal::Visi while (_nextIndex < NUMBER_OF_CHILDREN) { EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; - if (nextElement) { - const auto& cube = nextElement->getAACube(); - if (!view.usesViewFrustums()) { - // No LOD truncation if we aren't using the view frustum - next.element = nextElement; - return; - } else if (view.intersects(cube)) { - // check for LOD truncation - if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { - next.element = nextElement; - return; - } - } + if (nextElement && view.shouldTraverseElement(*nextElement)) { + next.element = nextElement; + return; } } } @@ -63,7 +55,6 @@ void DiffTraversal::Waypoint::getNextVisibleElementRepeat( EntityTreeElementPointer element = _weakElement.lock(); if (element->getLastChangedContent() > lastTime) { next.element = element; - next.intersection = ViewFrustum::INTERSECT; return; } } @@ -73,30 +64,17 @@ void DiffTraversal::Waypoint::getNextVisibleElementRepeat( while (_nextIndex < NUMBER_OF_CHILDREN) { EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; - if (nextElement && nextElement->getLastChanged() > lastTime) { - if (!view.usesViewFrustums()) { - // No LOD truncation if we aren't using the view frustum - next.element = nextElement; - next.intersection = ViewFrustum::INSIDE; - return; - } else { - // check for LOD truncation - const auto& cube = nextElement->getAACube(); - if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { - ViewFrustum::intersection intersection = view.calculateIntersection(cube); - if (intersection != ViewFrustum::OUTSIDE) { - next.element = nextElement; - next.intersection = intersection; - return; - } - } - } + if (nextElement && + nextElement->getLastChanged() > lastTime && + view.shouldTraverseElement(*nextElement)) { + + next.element = nextElement; + return; } } } } next.element.reset(); - next.intersection = ViewFrustum::OUTSIDE; } void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::VisibleElement& next, @@ -106,7 +84,6 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V ++_nextIndex; EntityTreeElementPointer element = _weakElement.lock(); next.element = element; - next.intersection = ViewFrustum::INTERSECT; return; } else if (_nextIndex < NUMBER_OF_CHILDREN) { EntityTreeElementPointer element = _weakElement.lock(); @@ -114,74 +91,14 @@ void DiffTraversal::Waypoint::getNextVisibleElementDifferential(DiffTraversal::V while (_nextIndex < NUMBER_OF_CHILDREN) { EntityTreeElementPointer nextElement = element->getChildAtIndex(_nextIndex); ++_nextIndex; - if (nextElement) { - // check for LOD truncation - const auto& cube = nextElement->getAACube(); - if (view.isBigEnough(cube, MIN_ELEMENT_ANGULAR_DIAMETER)) { - ViewFrustum::intersection intersection = view.calculateIntersection(cube); - if (intersection != ViewFrustum::OUTSIDE) { - next.element = nextElement; - next.intersection = intersection; - return; - } - } + if (nextElement && view.shouldTraverseElement(*nextElement)) { + next.element = nextElement; + return; } } } } next.element.reset(); - next.intersection = ViewFrustum::OUTSIDE; -} - -bool DiffTraversal::View::isBigEnough(const AACube& cube, float minDiameter) const { - if (viewFrustums.empty()) { - // Everything is big enough when not using view frustums - return true; - } - - bool isBigEnough = std::any_of(std::begin(viewFrustums), std::end(viewFrustums), - [&](const ViewFrustum& viewFrustum) { - return isAngularSizeBigEnough(viewFrustum.getPosition(), cube, lodScaleFactor, minDiameter); - }); - - return isBigEnough; -} - -bool DiffTraversal::View::intersects(const AACube& cube) const { - if (viewFrustums.empty()) { - // Everything intersects when not using view frustums - return true; - } - - bool intersects = std::any_of(std::begin(viewFrustums), std::end(viewFrustums), - [&](const ViewFrustum& viewFrustum) { - return viewFrustum.cubeIntersectsKeyhole(cube); - }); - - return intersects; -} - -ViewFrustum::intersection DiffTraversal::View::calculateIntersection(const AACube& cube) const { - if (viewFrustums.empty()) { - // Everything is inside when not using view frustums - return ViewFrustum::INSIDE; - } - - ViewFrustum::intersection intersection = ViewFrustum::OUTSIDE; - - for (const auto& viewFrustum : viewFrustums) { - switch (viewFrustum.calculateCubeKeyholeIntersection(cube)) { - case ViewFrustum::INSIDE: - return ViewFrustum::INSIDE; - case ViewFrustum::INTERSECT: - intersection = ViewFrustum::INTERSECT; - break; - default: - // DO NOTHING - break; - } - } - return intersection; } bool DiffTraversal::View::usesViewFrustums() const { @@ -204,6 +121,73 @@ bool DiffTraversal::View::isVerySimilar(const View& view) const { return true; } +float DiffTraversal::View::computePriority(const EntityItemPointer& entity) const { + if (!entity) { + return PrioritizedEntity::DO_NOT_SEND; + } + + if (!usesViewFrustums()) { + return PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + + bool success = false; + auto cube = entity->getQueryAACube(success); + if (!success) { + return PrioritizedEntity::WHEN_IN_DOUBT_PRIORITY; + } + + auto center = cube.calcCenter(); // center of bounding sphere + auto radius = 0.5f * SQRT_THREE * cube.getScale(); // radius of bounding sphere + + auto priority = PrioritizedEntity::DO_NOT_SEND; + + for (const auto& frustum : viewFrustums) { + auto position = center - frustum.getPosition(); // position of bounding sphere in view-frame + float distance = glm::length(position); // distance to center of bounding sphere + + // Check the size of the entity, it's possible that a "too small to see" entity is included in a + // larger octree cell because of its position (for example if it crosses the boundary of a cell it + // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen + // before we consider including it. + float angularSize = frustum.getAngularSize(distance, radius); + if (angularSize > lodScaleFactor * MIN_ENTITY_ANGULAR_DIAMETER && + frustum.intersects(position, distance, radius)) { + + // use the angular size as priority + // we compute the max priority for all frustums + priority = std::max(priority, angularSize); + } + } + + return priority; +} + +bool DiffTraversal::View::shouldTraverseElement(const EntityTreeElement& element) const { + if (!usesViewFrustums()) { + return true; + } + + const auto& cube = element.getAACube(); + + auto center = cube.calcCenter(); // center of bounding sphere + auto radius = 0.5f * SQRT_THREE * cube.getScale(); // radius of bounding sphere + + + return any_of(begin(viewFrustums), end(viewFrustums), [&](const ConicalViewFrustum& frustum) { + auto position = center - frustum.getPosition(); // position of bounding sphere in view-frame + float distance = glm::length(position); // distance to center of bounding sphere + + // Check the size of the entity, it's possible that a "too small to see" entity is included in a + // larger octree cell because of its position (for example if it crosses the boundary of a cell it + // pops to the next higher cell. So we want to check to see that the entity is large enough to be seen + // before we consider including it. + float angularSize = frustum.getAngularSize(distance, radius); + + return angularSize > lodScaleFactor * MIN_ELEMENT_ANGULAR_DIAMETER && + frustum.intersects(position, distance, radius); + }); +} + DiffTraversal::DiffTraversal() { const int32_t MIN_PATH_DEPTH = 16; _path.reserve(MIN_PATH_DEPTH); @@ -262,7 +246,6 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View void DiffTraversal::getNextVisibleElement(DiffTraversal::VisibleElement& next) { if (_path.empty()) { next.element.reset(); - next.intersection = ViewFrustum::OUTSIDE; return; } _getNextVisibleElementCallback(next); diff --git a/libraries/entities/src/DiffTraversal.h b/libraries/entities/src/DiffTraversal.h index 0fd014ac23..d62c7b8ee1 100644 --- a/libraries/entities/src/DiffTraversal.h +++ b/libraries/entities/src/DiffTraversal.h @@ -12,7 +12,7 @@ #ifndef hifi_DiffTraversal_h #define hifi_DiffTraversal_h -#include +#include #include "EntityTreeElement.h" @@ -24,19 +24,18 @@ public: class VisibleElement { public: EntityTreeElementPointer element; - ViewFrustum::intersection intersection { ViewFrustum::OUTSIDE }; }; // View is a struct with a ViewFrustum and LOD parameters class View { public: - bool isBigEnough(const AACube& cube, float minDiameter = MIN_ENTITY_ANGULAR_DIAMETER) const; - bool intersects(const AACube& cube) const; bool usesViewFrustums() const; bool isVerySimilar(const View& view) const; - ViewFrustum::intersection calculateIntersection(const AACube& cube) const; - ViewFrustums viewFrustums; + bool shouldTraverseElement(const EntityTreeElement& element) const; + float computePriority(const EntityItemPointer& entity) const; + + ConicalViewFrustums viewFrustums; uint64_t startTime { 0 }; float lodScaleFactor { 1.0f }; }; @@ -65,9 +64,6 @@ public: Type prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root); const View& getCurrentView() const { return _currentView; } - const View& getCompletedView() const { return _completedView; } - - bool doesCurrentUseViewFrustum() const { return _currentView.usesViewFrustums(); } uint64_t getStartOfCompletedTraversal() const { return _completedView.startTime; } bool finished() const { return _path.empty(); } diff --git a/assignment-client/src/entities/EntityPriorityQueue.h b/libraries/entities/src/EntityPriorityQueue.h similarity index 70% rename from assignment-client/src/entities/EntityPriorityQueue.h rename to libraries/entities/src/EntityPriorityQueue.h index 9210ac549f..354cd70af3 100644 --- a/assignment-client/src/entities/EntityPriorityQueue.h +++ b/libraries/entities/src/EntityPriorityQueue.h @@ -15,44 +15,14 @@ #include #include -#include -#include -#include - -const float SQRT_TWO_OVER_TWO = 0.7071067811865f; -const float DEFAULT_VIEW_RADIUS = 10.0f; - -// ConicalViewFrustum is an approximation of a ViewFrustum for fast calculation of sort priority. -class ConicalViewFrustum { -public: - ConicalViewFrustum() {} - ConicalViewFrustum(const ViewFrustum& viewFrustum) { set(viewFrustum); } - void set(const ViewFrustum& viewFrustum); - float computePriority(const AACube& cube) const; -private: - glm::vec3 _position { 0.0f, 0.0f, 0.0f }; - glm::vec3 _direction { 0.0f, 0.0f, 1.0f }; - float _sinAngle { SQRT_TWO_OVER_TWO }; - float _cosAngle { SQRT_TWO_OVER_TWO }; - float _radius { DEFAULT_VIEW_RADIUS }; -}; - -// Simple wrapper around a set of conical view frustums -class ConicalView { -public: - ConicalView() {} - void set(const DiffTraversal::View& view); - float computePriority(const AACube& cube) const; -private: - std::vector _conicalViewFrustums; -}; +#include "EntityItem.h" // PrioritizedEntity is a placeholder in a sorted queue. class PrioritizedEntity { public: - static const float DO_NOT_SEND; - static const float FORCE_REMOVE; - static const float WHEN_IN_DOUBT_PRIORITY; + static constexpr float DO_NOT_SEND { -1.0e-6f }; + static constexpr float FORCE_REMOVE { -1.0e-5f }; + static constexpr float WHEN_IN_DOUBT_PRIORITY { 1.0f }; PrioritizedEntity(EntityItemPointer entity, float priority, bool forceRemove = false) : _weakEntity(entity), _rawEntityPointer(entity.get()), _priority(priority), _forceRemove(forceRemove) {} EntityItemPointer getEntity() const { return _weakEntity.lock(); } diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp index 72710a6a7d..1776d63173 100644 --- a/libraries/shared/src/GLMHelpers.cpp +++ b/libraries/shared/src/GLMHelpers.cpp @@ -222,6 +222,12 @@ int unpackOrientationQuatFromSixBytes(const unsigned char* buffer, glm::quat& qu return 6; } +bool closeEnough(float a, float b, float relativeError) { + assert(relativeError >= 0.0f); + // NOTE: we add EPSILON to the denominator so we can avoid checking for division by zero. + // This method works fine when: fabsf(a + b) >> EPSILON + return fabsf(a - b) / (0.5f * fabsf(a + b) + EPSILON) < relativeError; +} // Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's // http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde, diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h index 5c9a8b5ca1..0e1af27cd2 100644 --- a/libraries/shared/src/GLMHelpers.h +++ b/libraries/shared/src/GLMHelpers.h @@ -137,6 +137,8 @@ int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, flo int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix); int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix); +bool closeEnough(float a, float b, float relativeError); + /// \return vec3 with euler angles in radians glm::vec3 safeEulerAngles(const glm::quat& q); diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index c2b92aac5f..c89a9fbd60 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -338,13 +338,6 @@ bool ViewFrustum::boxIntersectsKeyhole(const AABox& box) const { return true; } -bool closeEnough(float a, float b, float relativeError) { - assert(relativeError >= 0.0f); - // NOTE: we add EPSILON to the denominator so we can avoid checking for division by zero. - // This method works fine when: fabsf(a + b) >> EPSILON - return fabsf(a - b) / (0.5f * fabsf(a + b) + EPSILON) < relativeError; -} - // TODO: the slop and relative error should be passed in by argument rather than hard-coded. bool ViewFrustum::isVerySimilar(const ViewFrustum& other) const { const float MIN_POSITION_SLOP_SQUARED = 25.0f; // 5 meters squared diff --git a/libraries/shared/src/shared/ConicalViewFrustum.cpp b/libraries/shared/src/shared/ConicalViewFrustum.cpp new file mode 100644 index 0000000000..906bbc48a3 --- /dev/null +++ b/libraries/shared/src/shared/ConicalViewFrustum.cpp @@ -0,0 +1,125 @@ +// +// ConicalViewFrustum.cpp +// libraries/shared/src/shared +// +// Created by Clement Brisset 4/26/18 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "ConicalViewFrustum.h" + +#include "../ViewFrustum.h" + +void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) { + // The ConicalViewFrustum has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part. + // Why? Because approximate intersection tests are much faster to compute for a cone than for a frustum. + _position = viewFrustum.getPosition(); + _direction = viewFrustum.getDirection(); + _radius = viewFrustum.getCenterRadius(); + _farClip = viewFrustum.getFarClip(); + + // Considering the rectangle intersection the frustum and the perpendicular plane 1 unit + // away from the frustum's origin + // We are looking for the angle between the ray that goes through the center of the rectangle + // and the ray that goes through one of the corners of the rectangle + // (Both rays coming from the frustum's origin) + // This angle will let us construct a cone in which the frustum is inscribed + // Let's define: + // A = aspect ratio = width / height + // fov = vertical field of view + // y = half height of the rectangle + // x = half width of the rectangle + // r = half diagonal of the rectangle + // then, we have: + // y / 1 = tan(fov / 2) + // x = A * y = A * tan(fov / 2) + // r^2 = x^2 + y^2 = (A^2 + 1) * tan^2(fov / 2) + // r / 1 = tan(angle) = sqrt((A^2 + 1) * tan^2(fov / 2)) + // angle = atan(sqrt((A^2 + 1) * tan^2(fov / 2))) + float A = viewFrustum.getAspectRatio(); + float t = tanf(0.5f * viewFrustum.getFieldOfView()); + + auto tan2Angle = (A * A + 1.0f) * (t * t); + _angle = atanf(sqrt(tan2Angle)); + + calculate(); +} + +void ConicalViewFrustum::calculate() { + _cosAngle = cosf(_angle); + _sinAngle = sqrtf(1.0f - _cosAngle * _cosAngle); +} + +bool ConicalViewFrustum::isVerySimilar(const ConicalViewFrustum& other) const { + const float MIN_POSITION_SLOP_SQUARED = 25.0f; // 5 meters squared + const float MIN_ANGLE_BETWEEN = 0.174533f; // radian angle between 2 vectors 10 degrees apart + const float MIN_RELATIVE_ERROR = 0.01f; // 1% + + return glm::distance2(_position, other._position) < MIN_POSITION_SLOP_SQUARED && + angleBetween(_direction, other._direction) > MIN_ANGLE_BETWEEN && + closeEnough(_angle, other._angle, MIN_RELATIVE_ERROR) && + closeEnough(_farClip, other._farClip, MIN_RELATIVE_ERROR) && + closeEnough(_radius, other._radius, MIN_RELATIVE_ERROR); +} + +bool ConicalViewFrustum::intersects(const glm::vec3& position, float distance, float radius) const { + if (distance < _radius + radius) { + // Inside keyhole radius + return true; + } + if (distance > _farClip + radius) { + // Past far clip + return false; + } + + // We check the angle between the center of the cube and the _direction of the view. + // If it is less than the sum of the half-angle from center of cone to outer edge plus + // the half apparent angle of the bounding sphere then it is in view. + // + // The math here is left as an exercise for the reader with the following hints: + // (1) We actually check the dot product of the cube's local position rather than the angle and + // (2) we take advantage of this trig identity: cos(A+B) = cos(A)*cos(B) - sin(A)*sin(B) + return glm::dot(position, _direction) > + sqrtf(distance * distance - radius * radius) * _cosAngle - radius * _sinAngle; +} + +bool ConicalViewFrustum::getAngularSize(float distance, float radius) const { + const float AVOID_DIVIDE_BY_ZERO = 0.001f; + float angularSize = radius / (distance + AVOID_DIVIDE_BY_ZERO); + return angularSize; +} + +int ConicalViewFrustum::serialize(unsigned char* destinationBuffer) const { + const unsigned char* startPosition = destinationBuffer; + + memcpy(destinationBuffer, &_position, sizeof(_position)); + destinationBuffer += sizeof(_position); + memcpy(destinationBuffer, &_direction, sizeof(_direction)); + destinationBuffer += sizeof(_direction); + destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _angle); + destinationBuffer += packClipValueToTwoByte(destinationBuffer, _farClip); + memcpy(destinationBuffer, &_radius, sizeof(_radius)); + destinationBuffer += sizeof(_radius); + + return destinationBuffer - startPosition; +} + +int ConicalViewFrustum::deserialize(const unsigned char* sourceBuffer) { + const unsigned char* startPosition = sourceBuffer; + + memcpy(&_position, sourceBuffer, sizeof(_position)); + sourceBuffer += sizeof(_position); + memcpy(&_direction, sourceBuffer, sizeof(_direction)); + sourceBuffer += sizeof(_direction); + sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*)sourceBuffer, &_angle); + sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer, _farClip); + memcpy(&_radius, sourceBuffer, sizeof(_radius)); + sourceBuffer += sizeof(_radius); + + calculate(); + + return sourceBuffer - startPosition; +} diff --git a/libraries/shared/src/shared/ConicalViewFrustum.h b/libraries/shared/src/shared/ConicalViewFrustum.h new file mode 100644 index 0000000000..3cadedda9d --- /dev/null +++ b/libraries/shared/src/shared/ConicalViewFrustum.h @@ -0,0 +1,64 @@ +// +// ConicalViewFrustum.h +// libraries/shared/src/shared +// +// Created by Clement Brisset 4/26/18 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ConicalViewFrustum_h +#define hifi_ConicalViewFrustum_h + +#include + +#include + +class AACube; +class ViewFrustum; +using ViewFrustums = std::vector; + +const float SQRT_TWO_OVER_TWO = 0.7071067811865f; +const float DEFAULT_VIEW_ANGLE = 1.0f; +const float DEFAULT_VIEW_RADIUS = 10.0f; +const float DEFAULT_VIEW_FAR_CLIP = 100.0f; + +// ConicalViewFrustum is an approximation of a ViewFrustum for fast calculation of sort priority. +class ConicalViewFrustum { +public: + ConicalViewFrustum() = default; + ConicalViewFrustum(const ViewFrustum& viewFrustum) { set(viewFrustum); } + + void set(const ViewFrustum& viewFrustum); + void calculate(); + + const glm::vec3& getPosition() const { return _position; } + const glm::vec3& getDirection() const { return _direction; } + float getAngle() const { return _angle; } + float getRadius() const { return _radius; } + float getFarClip() const { return _farClip; } + + bool isVerySimilar(const ConicalViewFrustum& other) const; + + bool intersects(const glm::vec3& position, float distance, float radius) const; + bool getAngularSize(float distance, float radius) const; + + int serialize(unsigned char* destinationBuffer) const; + int deserialize(const unsigned char* sourceBuffer); + +private: + glm::vec3 _position { 0.0f, 0.0f, 0.0f }; + glm::vec3 _direction { 0.0f, 0.0f, 1.0f }; + float _angle { DEFAULT_VIEW_ANGLE }; + float _radius { DEFAULT_VIEW_RADIUS }; + float _farClip { DEFAULT_VIEW_FAR_CLIP }; + + float _sinAngle { SQRT_TWO_OVER_TWO }; + float _cosAngle { SQRT_TWO_OVER_TWO }; +}; +using ConicalViewFrustums = std::vector; + + +#endif /* hifi_ConicalViewFrustum_h */ From e400eb4ed2c86f6132896404849b70193c63c4ae Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 30 Apr 2018 19:50:00 -0700 Subject: [PATCH 108/192] Rename ViewFrustum packets to AvatarQuery --- assignment-client/src/Agent.cpp | 2 +- assignment-client/src/avatars/AvatarMixer.cpp | 6 +++--- assignment-client/src/avatars/AvatarMixer.h | 2 +- interface/src/Application.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.cpp | 6 +++--- libraries/networking/src/udt/PacketHeaders.h | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 0b373e511b..0183248648 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -618,7 +618,7 @@ void Agent::sendAvatarViewFrustum() { uint8_t numFrustums = 1; auto viewFrustumByteArray = view.toByteArray(); - auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums)); + auto avatarPacket = NLPacket::create(PacketType::AvatarQuery, viewFrustumByteArray.size() + sizeof(numFrustums)); avatarPacket->writePrimitive(numFrustums); avatarPacket->write(viewFrustumByteArray); diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 6353a1664f..d74c76032d 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -47,7 +47,7 @@ AvatarMixer::AvatarMixer(ReceivedMessage& message) : auto& packetReceiver = DependencyManager::get()->getPacketReceiver(); packetReceiver.registerListener(PacketType::AvatarData, this, "queueIncomingPacket"); packetReceiver.registerListener(PacketType::AdjustAvatarSorting, this, "handleAdjustAvatarSorting"); - packetReceiver.registerListener(PacketType::ViewFrustum, this, "handleViewFrustumPacket"); + packetReceiver.registerListener(PacketType::AvatarQuery, this, "handleAvatarQueryPacket"); packetReceiver.registerListener(PacketType::AvatarIdentity, this, "handleAvatarIdentityPacket"); packetReceiver.registerListener(PacketType::KillAvatar, this, "handleKillAvatarPacket"); packetReceiver.registerListener(PacketType::NodeIgnoreRequest, this, "handleNodeIgnoreRequestPacket"); @@ -517,7 +517,7 @@ void AvatarMixer::handleAdjustAvatarSorting(QSharedPointer mess } -void AvatarMixer::handleViewFrustumPacket(QSharedPointer message, SharedNodePointer senderNode) { +void AvatarMixer::handleAvatarQueryPacket(QSharedPointer message, SharedNodePointer senderNode) { auto start = usecTimestampNow(); getOrCreateClientData(senderNode); @@ -683,7 +683,7 @@ void AvatarMixer::sendStatsPacket() { incomingPacketStats["handleNodeIgnoreRequestPacket"] = TIGHT_LOOP_STAT_UINT64(_handleNodeIgnoreRequestPacketElapsedTime); incomingPacketStats["handleRadiusIgnoreRequestPacket"] = TIGHT_LOOP_STAT_UINT64(_handleRadiusIgnoreRequestPacketElapsedTime); incomingPacketStats["handleRequestsDomainListDataPacket"] = TIGHT_LOOP_STAT_UINT64(_handleRequestsDomainListDataPacketElapsedTime); - incomingPacketStats["handleViewFrustumPacket"] = TIGHT_LOOP_STAT_UINT64(_handleViewFrustumPacketElapsedTime); + incomingPacketStats["handleAvatarQueryPacket"] = TIGHT_LOOP_STAT_UINT64(_handleViewFrustumPacketElapsedTime); singleCoreTasks["incoming_packets"] = incomingPacketStats; singleCoreTasks["sendStats"] = (float)_sendStatsElapsedTime; diff --git a/assignment-client/src/avatars/AvatarMixer.h b/assignment-client/src/avatars/AvatarMixer.h index 1fbfd7338b..9ef5903eec 100644 --- a/assignment-client/src/avatars/AvatarMixer.h +++ b/assignment-client/src/avatars/AvatarMixer.h @@ -46,7 +46,7 @@ public slots: private slots: void queueIncomingPacket(QSharedPointer message, SharedNodePointer node); void handleAdjustAvatarSorting(QSharedPointer message, SharedNodePointer senderNode); - void handleViewFrustumPacket(QSharedPointer message, SharedNodePointer senderNode); + void handleAvatarQueryPacket(QSharedPointer message, SharedNodePointer senderNode); void handleAvatarIdentityPacket(QSharedPointer message, SharedNodePointer senderNode); void handleKillAvatarPacket(QSharedPointer message, SharedNodePointer senderNode); void handleNodeIgnoreRequestPacket(QSharedPointer message, SharedNodePointer senderNode); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5e10d29505..a1301ff43e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5852,7 +5852,7 @@ void Application::sendAvatarViewFrustum() { viewFrustumByteArray += _secondaryViewFrustum.toByteArray(); } - auto avatarPacket = NLPacket::create(PacketType::ViewFrustum, viewFrustumByteArray.size() + sizeof(numFrustums)); + auto avatarPacket = NLPacket::create(PacketType::AvatarQuery, viewFrustumByteArray.size() + sizeof(numFrustums)); avatarPacket->writePrimitive(numFrustums); avatarPacket->write(viewFrustumByteArray); diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 17b0d90cfe..123e11b7c5 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -34,7 +34,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::EntityPhysics: return static_cast(EntityVersion::MaterialData); case PacketType::EntityQuery: - return static_cast(EntityQueryPacketVersion::MultiFrustumQuery); + return static_cast(EntityQueryPacketVersion::ConicalFrustums); case PacketType::AvatarIdentity: case PacketType::AvatarData: case PacketType::BulkAvatarData: @@ -90,8 +90,8 @@ PacketVersion versionForPacketType(PacketType packetType) { return 18; // replace min_avatar_scale and max_avatar_scale with min_avatar_height and max_avatar_height case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); - case PacketType::ViewFrustum: - return static_cast(ViewFrustumVersion::SendMultipleFrustums); + case PacketType::AvatarQuery: + return static_cast(AvatarQueryVersion::SendMultipleFrustums); default: return 20; } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index c72bbb0129..20fe23a19a 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -103,7 +103,7 @@ public: RadiusIgnoreRequest, UsernameFromIDRequest, UsernameFromIDReply, - ViewFrustum, + AvatarQuery, RequestsDomainListData, PerAvatarGainSet, EntityScriptGetStatus, @@ -328,7 +328,7 @@ enum class PingVersion : PacketVersion { IncludeConnectionID = 18 }; -enum class ViewFrustumVersion : PacketVersion { +enum class AvatarQueryVersion : PacketVersion { SendMultipleFrustums = 21 }; From 67c119cd2ef39c44e970bb9cedbb2e76a41bdfc5 Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 30 Apr 2018 19:50:51 -0700 Subject: [PATCH 109/192] Send Entity Query via conical frustums --- .../src/entities/EntityTreeSendThread.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 ++- libraries/octree/src/OctreeQuery.cpp | 16 ++++------------ libraries/octree/src/OctreeQuery.h | 9 +++------ libraries/octree/src/OctreeQueryNode.cpp | 4 ++-- libraries/octree/src/OctreeQueryNode.h | 12 ++++++------ 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index 0d943055f4..1851714f0d 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -108,7 +108,7 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O DiffTraversal::View newView; - ViewFrustum viewFrustum; + ConicalViewFrustum viewFrustum; if (nodeData->hasMainViewFrustum()) { nodeData->copyCurrentMainViewFrustum(viewFrustum); newView.viewFrustums.push_back(viewFrustum); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 20fe23a19a..1bedfdf3e6 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -245,7 +245,8 @@ enum class EntityQueryPacketVersion: PacketVersion { JSONFilterWithFamilyTree = 19, ConnectionIdentifier = 20, RemovedJurisdictions = 21, - MultiFrustumQuery = 22 + MultiFrustumQuery = 22, + ConicalFrustums = 23 }; enum class AssetServerPacketVersion: PacketVersion { diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 18e907cb8c..6b3f7b8e05 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -50,15 +50,11 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { destinationBuffer += sizeof(frustumFlags); if (_hasMainFrustum) { - auto byteArray = _mainViewFrustum.toByteArray(); - memcpy(destinationBuffer, byteArray.constData(), byteArray.size()); - destinationBuffer += byteArray.size(); + destinationBuffer += _mainViewFrustum.serialize(destinationBuffer); } if (_hasSecondaryFrustum) { - auto byteArray = _secondaryViewFrustum.toByteArray(); - memcpy(destinationBuffer, byteArray.constData(), byteArray.size()); - destinationBuffer += byteArray.size(); + destinationBuffer += _secondaryViewFrustum.serialize(destinationBuffer); } // desired Max Octree PPS @@ -131,15 +127,11 @@ int OctreeQuery::parseData(ReceivedMessage& message) { _hasSecondaryFrustum = frustumFlags & QUERY_HAS_SECONDARY_FRUSTUM; if (_hasMainFrustum) { - auto bytesLeft = endPosition - sourceBuffer; - auto byteArray = QByteArray::fromRawData(reinterpret_cast(sourceBuffer), bytesLeft); - sourceBuffer += _mainViewFrustum.fromByteArray(byteArray); + sourceBuffer += _mainViewFrustum.deserialize(sourceBuffer); } if (_hasSecondaryFrustum) { - auto bytesLeft = endPosition - sourceBuffer; - auto byteArray = QByteArray::fromRawData(reinterpret_cast(sourceBuffer), bytesLeft); - sourceBuffer += _secondaryViewFrustum.fromByteArray(byteArray); + sourceBuffer += _secondaryViewFrustum.deserialize(sourceBuffer); } // desired Max Octree PPS diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index ef52e29f51..f28d4c317e 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -16,8 +16,7 @@ #include #include - -#include +#include #include "OctreeConstants.h" @@ -37,12 +36,10 @@ public: bool hasMainViewFrustum() const { return _hasMainFrustum; } void setMainViewFrustum(const ViewFrustum& viewFrustum) { _hasMainFrustum = true; _mainViewFrustum = viewFrustum; } void clearMainViewFrustum() { _hasMainFrustum = false; } - const ViewFrustum& getMainViewFrustum() const { return _mainViewFrustum; } bool hasSecondaryViewFrustum() const { return _hasSecondaryFrustum; } void setSecondaryViewFrustum(const ViewFrustum& viewFrustum) { _hasSecondaryFrustum = true; _secondaryViewFrustum = viewFrustum; } void clearSecondaryViewFrustum() { _hasSecondaryFrustum = false; } - const ViewFrustum& getSecondaryViewFrustum() const { return _secondaryViewFrustum; } // getters/setters for JSON filter QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; } @@ -68,9 +65,9 @@ public slots: protected: bool _hasMainFrustum { false }; - ViewFrustum _mainViewFrustum; + ConicalViewFrustum _mainViewFrustum; bool _hasSecondaryFrustum { false }; - ViewFrustum _secondaryViewFrustum; + ConicalViewFrustum _secondaryViewFrustum; // octree server sending items int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; diff --git a/libraries/octree/src/OctreeQueryNode.cpp b/libraries/octree/src/OctreeQueryNode.cpp index d6e9343896..568504a344 100644 --- a/libraries/octree/src/OctreeQueryNode.cpp +++ b/libraries/octree/src/OctreeQueryNode.cpp @@ -139,12 +139,12 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int by } } -void OctreeQueryNode::copyCurrentMainViewFrustum(ViewFrustum& viewOut) const { +void OctreeQueryNode::copyCurrentMainViewFrustum(ConicalViewFrustum& viewOut) const { QMutexLocker viewLocker(&_viewMutex); viewOut = _currentMainViewFrustum; } -void OctreeQueryNode::copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const { +void OctreeQueryNode::copyCurrentSecondaryViewFrustum(ConicalViewFrustum& viewOut) const { QMutexLocker viewLocker(&_viewMutex); viewOut = _currentSecondaryViewFrustum; } diff --git a/libraries/octree/src/OctreeQueryNode.h b/libraries/octree/src/OctreeQueryNode.h index d8f05c4043..13337c2c69 100644 --- a/libraries/octree/src/OctreeQueryNode.h +++ b/libraries/octree/src/OctreeQueryNode.h @@ -14,14 +14,14 @@ #include -#include +#include + #include "OctreeConstants.h" #include "OctreeElementBag.h" #include "OctreePacketData.h" #include "OctreeQuery.h" #include "OctreeSceneStats.h" #include "SentPacketHistory.h" -#include class OctreeSendThread; class OctreeServer; @@ -49,8 +49,8 @@ public: OctreeElementExtraEncodeData extraEncodeData; - void copyCurrentMainViewFrustum(ViewFrustum& viewOut) const; - void copyCurrentSecondaryViewFrustum(ViewFrustum& viewOut) const; + void copyCurrentMainViewFrustum(ConicalViewFrustum& viewOut) const; + void copyCurrentSecondaryViewFrustum(ConicalViewFrustum& viewOut) const; // These are not classic setters because they are calculating and maintaining state // which is set asynchronously through the network receive @@ -97,8 +97,8 @@ private: quint64 _firstSuppressedPacket { usecTimestampNow() }; mutable QMutex _viewMutex { QMutex::Recursive }; - ViewFrustum _currentMainViewFrustum; - ViewFrustum _currentSecondaryViewFrustum; + ConicalViewFrustum _currentMainViewFrustum; + ConicalViewFrustum _currentSecondaryViewFrustum; bool _viewFrustumChanging { false }; bool _viewFrustumJustStoppedChanging { true }; From b4ea32bbb6fb7884dbbe8dd0450ae98ac0b0cdfa Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 30 Apr 2018 19:51:18 -0700 Subject: [PATCH 110/192] Correctly compute conical frustum for irregular ones --- .../shared/src/shared/ConicalViewFrustum.cpp | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/libraries/shared/src/shared/ConicalViewFrustum.cpp b/libraries/shared/src/shared/ConicalViewFrustum.cpp index 906bbc48a3..c73a722f0e 100644 --- a/libraries/shared/src/shared/ConicalViewFrustum.cpp +++ b/libraries/shared/src/shared/ConicalViewFrustum.cpp @@ -17,38 +17,24 @@ void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) { // The ConicalViewFrustum has two parts: a central sphere (same as ViewFrustum) and a circular cone that bounds the frustum part. // Why? Because approximate intersection tests are much faster to compute for a cone than for a frustum. _position = viewFrustum.getPosition(); - _direction = viewFrustum.getDirection(); _radius = viewFrustum.getCenterRadius(); _farClip = viewFrustum.getFarClip(); - // Considering the rectangle intersection the frustum and the perpendicular plane 1 unit - // away from the frustum's origin - // We are looking for the angle between the ray that goes through the center of the rectangle - // and the ray that goes through one of the corners of the rectangle - // (Both rays coming from the frustum's origin) - // This angle will let us construct a cone in which the frustum is inscribed - // Let's define: - // A = aspect ratio = width / height - // fov = vertical field of view - // y = half height of the rectangle - // x = half width of the rectangle - // r = half diagonal of the rectangle - // then, we have: - // y / 1 = tan(fov / 2) - // x = A * y = A * tan(fov / 2) - // r^2 = x^2 + y^2 = (A^2 + 1) * tan^2(fov / 2) - // r / 1 = tan(angle) = sqrt((A^2 + 1) * tan^2(fov / 2)) - // angle = atan(sqrt((A^2 + 1) * tan^2(fov / 2))) - float A = viewFrustum.getAspectRatio(); - float t = tanf(0.5f * viewFrustum.getFieldOfView()); + auto topLeft = viewFrustum.getNearTopLeft() - _position; + auto topRight = viewFrustum.getNearTopRight() - _position; + auto bottomLeft = viewFrustum.getNearBottomLeft() - _position; + auto bottomRight = viewFrustum.getNearBottomRight() - _position; + auto centerAxis = 0.25f * (topLeft + topRight + bottomLeft + bottomRight); // Take the average - auto tan2Angle = (A * A + 1.0f) * (t * t); - _angle = atanf(sqrt(tan2Angle)); - - calculate(); + _direction = glm::normalize(centerAxis); + _angle = std::max(std::max(angleBetween(_direction, topLeft), + angleBetween(_direction, topRight)), + std::max(angleBetween(_direction, bottomLeft), + angleBetween(_direction, bottomRight))); } void ConicalViewFrustum::calculate() { + // Pre-compute cos and sin for faster checks _cosAngle = cosf(_angle); _sinAngle = sqrtf(1.0f - _cosAngle * _cosAngle); } From 3283c5eaeca6bb13ddd70add0f93e88b91804916 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 12:37:51 -0700 Subject: [PATCH 111/192] Fix inverted comparaison --- libraries/octree/src/OctreeQuery.cpp | 1 - libraries/shared/src/shared/ConicalViewFrustum.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 6b3f7b8e05..7aa702138f 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -95,7 +95,6 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { int OctreeQuery::parseData(ReceivedMessage& message) { const unsigned char* startPosition = reinterpret_cast(message.getRawMessage()); - const unsigned char* endPosition = startPosition + message.getSize(); const unsigned char* sourceBuffer = startPosition; // unpack the connection ID diff --git a/libraries/shared/src/shared/ConicalViewFrustum.cpp b/libraries/shared/src/shared/ConicalViewFrustum.cpp index c73a722f0e..8538543da6 100644 --- a/libraries/shared/src/shared/ConicalViewFrustum.cpp +++ b/libraries/shared/src/shared/ConicalViewFrustum.cpp @@ -45,7 +45,7 @@ bool ConicalViewFrustum::isVerySimilar(const ConicalViewFrustum& other) const { const float MIN_RELATIVE_ERROR = 0.01f; // 1% return glm::distance2(_position, other._position) < MIN_POSITION_SLOP_SQUARED && - angleBetween(_direction, other._direction) > MIN_ANGLE_BETWEEN && + angleBetween(_direction, other._direction) < MIN_ANGLE_BETWEEN && closeEnough(_angle, other._angle, MIN_RELATIVE_ERROR) && closeEnough(_farClip, other._farClip, MIN_RELATIVE_ERROR) && closeEnough(_radius, other._radius, MIN_RELATIVE_ERROR); From 27c471ee9774f2fd98c0584402ad7a7242c5ad18 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 15:57:26 -0700 Subject: [PATCH 112/192] Move all wire frustums to conical frustums --- assignment-client/src/Agent.cpp | 14 +++- .../src/avatars/AvatarMixerClientData.cpp | 15 ++-- .../src/avatars/AvatarMixerClientData.h | 6 +- .../src/entities/EntityTreeSendThread.cpp | 11 +-- .../src/octree/OctreeHeadlessViewer.cpp | 5 +- .../src/octree/OctreeSendThread.cpp | 2 +- interface/src/Application.cpp | 80 ++++++++++--------- interface/src/Application.h | 14 ++-- interface/src/avatar/AvatarManager.cpp | 13 +-- .../src/EntityTreeRenderer.cpp | 19 +---- .../src/EntityTreeRenderer.h | 3 +- libraries/octree/src/OctreeQuery.cpp | 46 ++++------- libraries/octree/src/OctreeQuery.h | 15 +--- libraries/octree/src/OctreeQueryNode.cpp | 29 +++---- libraries/octree/src/OctreeQueryNode.h | 6 +- libraries/octree/src/OctreeUtils.h | 3 +- .../src/AbstractViewStateInterface.h | 6 +- libraries/shared/src/NumericalConstants.h | 2 + libraries/shared/src/PrioritySortUtil.h | 16 ++-- libraries/shared/src/ViewFrustum.cpp | 63 --------------- libraries/shared/src/ViewFrustum.h | 3 - .../shared/src/shared/ConicalViewFrustum.cpp | 47 +++++++++-- .../shared/src/shared/ConicalViewFrustum.h | 8 +- tests/render-perf/src/main.cpp | 12 +-- 24 files changed, 181 insertions(+), 257 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 0183248648..da811b8af5 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -614,13 +614,19 @@ void Agent::sendAvatarViewFrustum() { view.setPosition(scriptedAvatar->getWorldPosition()); view.setOrientation(scriptedAvatar->getHeadOrientation()); view.calculate(); + ConicalViewFrustum conicalView { view }; + + auto avatarPacket = NLPacket::create(PacketType::AvatarQuery); + auto destinationBuffer = reinterpret_cast(avatarPacket->getPayload()); + auto bufferStart = destinationBuffer; uint8_t numFrustums = 1; - auto viewFrustumByteArray = view.toByteArray(); + memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums)); + destinationBuffer += sizeof(numFrustums); - auto avatarPacket = NLPacket::create(PacketType::AvatarQuery, viewFrustumByteArray.size() + sizeof(numFrustums)); - avatarPacket->writePrimitive(numFrustums); - avatarPacket->write(viewFrustumByteArray); + destinationBuffer += conicalView.serialize(destinationBuffer); + + avatarPacket->setPayloadSize(destinationBuffer - bufferStart); DependencyManager::get()->broadcastToNodes(std::move(avatarPacket), { NodeType::AvatarMixer }); diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index a8e5a7c541..aa93fc9e08 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -128,15 +128,16 @@ void AvatarMixerClientData::removeFromRadiusIgnoringSet(SharedNodePointer self, void AvatarMixerClientData::readViewFrustumPacket(QByteArray message) { _currentViewFrustums.clear(); + + auto sourceBuffer = reinterpret_cast(message.constData()); uint8_t numFrustums = 0; - memcpy(&numFrustums, message.constData(), sizeof(numFrustums)); - message.remove(0, sizeof(numFrustums)); + memcpy(&numFrustums, sourceBuffer, sizeof(numFrustums)); + sourceBuffer += sizeof(numFrustums); for (uint8_t i = 0; i < numFrustums; ++i) { - ViewFrustum frustum; - auto bytesRead = frustum.fromByteArray(message); - message.remove(0, bytesRead); + ConicalViewFrustum frustum; + sourceBuffer += frustum.deserialize(sourceBuffer); _currentViewFrustums.push_back(frustum); } @@ -144,8 +145,8 @@ void AvatarMixerClientData::readViewFrustumPacket(QByteArray message) { bool AvatarMixerClientData::otherAvatarInView(const AABox& otherAvatarBox) { return std::any_of(std::begin(_currentViewFrustums), std::end(_currentViewFrustums), - [&](const ViewFrustum& viewFrustum) { - return viewFrustum.boxIntersectsKeyhole(otherAvatarBox); + [&](const ConicalViewFrustum& viewFrustum) { + return viewFrustum.intersects(otherAvatarBox); }); } diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index f17404b79f..f3b2b587ee 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include const QString OUTBOUND_AVATAR_DATA_STATS_KEY = "outbound_av_data_kbps"; const QString INBOUND_AVATAR_DATA_STATS_KEY = "inbound_av_data_kbps"; @@ -110,7 +110,7 @@ public: bool getRequestsDomainListData() { return _requestsDomainListData; } void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; } - const ViewFrustums& getViewFrustums() const { return _currentViewFrustums; } + const ConicalViewFrustums& getViewFrustums() const { return _currentViewFrustums; } uint64_t getLastOtherAvatarEncodeTime(QUuid otherAvatar) const; void setLastOtherAvatarEncodeTime(const QUuid& otherAvatar, uint64_t time); @@ -150,7 +150,7 @@ private: SimpleMovingAverage _avgOtherAvatarDataRate; std::unordered_set _radiusIgnoredOthers; - ViewFrustums _currentViewFrustums; + ConicalViewFrustums _currentViewFrustums; int _recentOtherAvatarsInView { 0 }; int _recentOtherAvatarsOutOfView { 0 }; diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index 1851714f0d..f008ef9925 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -107,16 +107,7 @@ void EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O DiffTraversal::View newView; - - ConicalViewFrustum viewFrustum; - if (nodeData->hasMainViewFrustum()) { - nodeData->copyCurrentMainViewFrustum(viewFrustum); - newView.viewFrustums.push_back(viewFrustum); - } - if (nodeData->hasSecondaryViewFrustum()) { - nodeData->copyCurrentSecondaryViewFrustum(viewFrustum); - newView.viewFrustums.push_back(viewFrustum); - } + newView.viewFrustums = nodeData->getCurrentViews(); int32_t lodLevelOffset = nodeData->getBoundaryLevelAdjust() + (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST); newView.lodScaleFactor = powf(2.0f, lodLevelOffset); diff --git a/assignment-client/src/octree/OctreeHeadlessViewer.cpp b/assignment-client/src/octree/OctreeHeadlessViewer.cpp index 6d91a134c2..039dbdab78 100644 --- a/assignment-client/src/octree/OctreeHeadlessViewer.cpp +++ b/assignment-client/src/octree/OctreeHeadlessViewer.cpp @@ -19,7 +19,10 @@ void OctreeHeadlessViewer::queryOctree() { PacketType packetType = getMyQueryMessageType(); if (_hasViewFrustum) { - _octreeQuery.setMainViewFrustum(_viewFrustum); + ConicalViewFrustums views { _viewFrustum }; + _octreeQuery.setConicalViews(views); + } else { + _octreeQuery.clearConicalViews(); } auto nodeList = DependencyManager::get(); diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 40c052659d..482b20272a 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -330,7 +330,7 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode* } else { // we aren't forcing a full scene, check if something else suggests we should isFullScene = nodeData->haveJSONParametersChanged() || - (nodeData->hasMainViewFrustum() && + (nodeData->hasConicalViews() && (nodeData->getViewFrustumJustStoppedChanging() || nodeData->hasLodChanged())); } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a1301ff43e..d14af685f0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5230,10 +5230,10 @@ void Application::updateSecondaryCameraViewFrustum() { assert(camera); if (!camera->isEnabled()) { - _hasSecondaryViewFrustum = false; return; } + ViewFrustum secondaryViewFrustum; if (camera->mirrorProjection && !camera->attachedEntityId.isNull()) { auto entityScriptingInterface = DependencyManager::get(); auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId); @@ -5258,36 +5258,37 @@ void Application::updateSecondaryCameraViewFrustum() { // set frustum position to be mirrored camera and set orientation to mirror's adjusted rotation glm::quat mirrorCameraOrientation = glm::quat_cast(worldFromMirrorRotation); - _secondaryViewFrustum.setPosition(mirrorCameraPositionWorld); - _secondaryViewFrustum.setOrientation(mirrorCameraOrientation); + secondaryViewFrustum.setPosition(mirrorCameraPositionWorld); + secondaryViewFrustum.setOrientation(mirrorCameraOrientation); // build frustum using mirror space translation of mirrored camera float nearClip = mirrorCameraPositionMirror.z + mirrorPropertiesDimensions.z * 2.0f; glm::vec3 upperRight = halfMirrorPropertiesDimensions - mirrorCameraPositionMirror; glm::vec3 bottomLeft = -halfMirrorPropertiesDimensions - mirrorCameraPositionMirror; glm::mat4 frustum = glm::frustum(bottomLeft.x, upperRight.x, bottomLeft.y, upperRight.y, nearClip, camera->farClipPlaneDistance); - _secondaryViewFrustum.setProjection(frustum); + secondaryViewFrustum.setProjection(frustum); } else { if (!camera->attachedEntityId.isNull()) { auto entityScriptingInterface = DependencyManager::get(); auto entityProperties = entityScriptingInterface->getEntityProperties(camera->attachedEntityId); - _secondaryViewFrustum.setPosition(entityProperties.getPosition()); - _secondaryViewFrustum.setOrientation(entityProperties.getRotation()); + secondaryViewFrustum.setPosition(entityProperties.getPosition()); + secondaryViewFrustum.setOrientation(entityProperties.getRotation()); } else { - _secondaryViewFrustum.setPosition(camera->position); - _secondaryViewFrustum.setOrientation(camera->orientation); + secondaryViewFrustum.setPosition(camera->position); + secondaryViewFrustum.setOrientation(camera->orientation); } float aspectRatio = (float)camera->textureWidth / (float)camera->textureHeight; - _secondaryViewFrustum.setProjection(camera->vFoV, + secondaryViewFrustum.setProjection(camera->vFoV, aspectRatio, camera->nearClipPlaneDistance, camera->farClipPlaneDistance); } // Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera, // which is not what we want here. - _secondaryViewFrustum.calculate(); - _hasSecondaryViewFrustum = true; + secondaryViewFrustum.calculate(); + + _conicalViews.push_back(secondaryViewFrustum); } static bool domainLoadingInProgress = false; @@ -5644,6 +5645,8 @@ void Application::update(float deltaTime) { QMutexLocker viewLocker(&_viewMutex); _myCamera.loadViewFrustum(_viewFrustum); + _conicalViews.clear(); + _conicalViews.push_back(_viewFrustum); // TODO: Fix this by modeling the way the secondary camera works on how the main camera works // ie. Use a camera object stored in the game logic and informs the Engine on where the secondary // camera should be. @@ -5660,18 +5663,29 @@ void Application::update(float deltaTime) { quint64 sinceLastQuery = now - _lastQueriedTime; const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; - bool viewIsDifferentEnough = !_lastQueriedViewFrustum.isVerySimilar(_viewFrustum); - viewIsDifferentEnough |= _hasSecondaryViewFrustum && !_lastQueriedSecondaryViewFrustum.isVerySimilar(_secondaryViewFrustum); + + bool viewIsDifferentEnough = false; + if (_conicalViews.size() == _lastQueriedViews.size()) { + for (size_t i = 0; i < _conicalViews.size(); ++i) { + if (!_conicalViews[i].isVerySimilar(_lastQueriedViews[i])) { + viewIsDifferentEnough = true; + break; + } + } + } else { + viewIsDifferentEnough = true; + } + // if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it if (queryIsDue || viewIsDifferentEnough) { - _lastQueriedTime = now; if (DependencyManager::get()->shouldRenderEntities()) { queryOctree(NodeType::EntityServer, PacketType::EntityQuery); } sendAvatarViewFrustum(); - _lastQueriedViewFrustum = _viewFrustum; - _lastQueriedSecondaryViewFrustum = _secondaryViewFrustum; + + _lastQueriedViews = _conicalViews; + _lastQueriedTime = now; } } @@ -5844,17 +5858,19 @@ void Application::update(float deltaTime) { } void Application::sendAvatarViewFrustum() { - uint8_t numFrustums = 1; - QByteArray viewFrustumByteArray = _viewFrustum.toByteArray(); + auto avatarPacket = NLPacket::create(PacketType::AvatarQuery); + auto destinationBuffer = reinterpret_cast(avatarPacket->getPayload()); + unsigned char* bufferStart = destinationBuffer; - if (_hasSecondaryViewFrustum) { - ++numFrustums; - viewFrustumByteArray += _secondaryViewFrustum.toByteArray(); + uint8_t numFrustums = _conicalViews.size(); + memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums)); + destinationBuffer += sizeof(numFrustums); + + for (const auto& view : _conicalViews) { + destinationBuffer += view.serialize(destinationBuffer); } - auto avatarPacket = NLPacket::create(PacketType::AvatarQuery, viewFrustumByteArray.size() + sizeof(numFrustums)); - avatarPacket->writePrimitive(numFrustums); - avatarPacket->write(viewFrustumByteArray); + avatarPacket->setPayloadSize(destinationBuffer - bufferStart); DependencyManager::get()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer); } @@ -5916,16 +5932,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType) { return; // bail early if settings are not loaded } - ViewFrustum viewFrustum; - copyViewFrustum(viewFrustum); - _octreeQuery.setMainViewFrustum(viewFrustum); - - if (hasSecondaryViewFrustum()) { - copySecondaryViewFrustum(viewFrustum); - _octreeQuery.setSecondaryViewFrustum(viewFrustum); - } else { - _octreeQuery.clearSecondaryViewFrustum(); - } + _octreeQuery.setConicalViews(_conicalViews); auto lodManager = DependencyManager::get(); _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale()); @@ -6010,11 +6017,6 @@ void Application::copyDisplayViewFrustum(ViewFrustum& viewOut) const { viewOut = _displayViewFrustum; } -void Application::copySecondaryViewFrustum(ViewFrustum& viewOut) const { - QMutexLocker viewLocker(&_viewMutex); - viewOut = _secondaryViewFrustum; -} - void Application::resetSensors(bool andReload) { DependencyManager::get()->reset(); DependencyManager::get()->reset(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 83e719333d..6d749f9458 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -175,14 +176,14 @@ public: Camera& getCamera() { return _myCamera; } const Camera& getCamera() const { return _myCamera; } // Represents the current view frustum of the avatar. - void copyViewFrustum(ViewFrustum& viewOut) const override; - void copySecondaryViewFrustum(ViewFrustum& viewOut) const override; - bool hasSecondaryViewFrustum() const override { return _hasSecondaryViewFrustum; } + void copyViewFrustum(ViewFrustum& viewOut) const; // Represents the view frustum of the current rendering pass, // which might be different from the viewFrustum, i.e. shadowmap // passes, mirror window passes, etc void copyDisplayViewFrustum(ViewFrustum& viewOut) const; + const ConicalViewFrustums& getConicalViews() const override { return _conicalViews; } + const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } QSharedPointer getEntities() const { return DependencyManager::get(); } QUndoStack* getUndoStack() { return &_undoStack; } @@ -574,11 +575,10 @@ private: mutable QMutex _viewMutex { QMutex::Recursive }; ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. - ViewFrustum _lastQueriedViewFrustum; // last view frustum used to query octree servers ViewFrustum _displayViewFrustum; - ViewFrustum _secondaryViewFrustum; - ViewFrustum _lastQueriedSecondaryViewFrustum; // last secondary view frustum used to query octree servers - bool _hasSecondaryViewFrustum; + + ConicalViewFrustums _conicalViews; + ConicalViewFrustums _lastQueriedViews; // last views used to query servers quint64 _lastQueriedTime; OctreeQuery _octreeQuery { true }; // NodeData derived class for querying octee cells from octree servers diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 087e23a933..d24618fada 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "Application.h" #include "AvatarManager.h" @@ -156,17 +157,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { }; - ViewFrustums views; - - ViewFrustum view; - qApp->copyCurrentViewFrustum(view); - views.push_back(view); - - if (qApp->hasSecondaryViewFrustum()) { - qApp->copySecondaryViewFrustum(view); - views.push_back(view); - } - + const auto& views = qApp->getConicalViews(); PrioritySortUtil::PriorityQueue sortedAvatars(views, AvatarData::_avatarSortCoefficientSize, AvatarData::_avatarSortCoefficientCenter, diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 6dd13c7332..600d1c32a8 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -296,8 +296,7 @@ void EntityTreeRenderer::addPendingEntities(const render::ScenePointer& scene, r } } -void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views, - render::Transaction& transaction) { +void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene, render::Transaction& transaction) { PROFILE_RANGE_EX(simulation_physics, "ChangeInScene", 0xffff00ff, (uint64_t)_changedEntities.size()); PerformanceTimer pt("change"); std::unordered_set changedEntities; @@ -358,6 +357,8 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene // prioritize and sort the renderables uint64_t sortStart = usecTimestampNow(); + + const auto& views = _viewState->getConicalViews(); PrioritySortUtil::PriorityQueue sortedRenderables(views); { PROFILE_RANGE_EX(simulation_physics, "SortRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); @@ -417,19 +418,7 @@ void EntityTreeRenderer::update(bool simulate) { render::Transaction transaction; addPendingEntities(scene, transaction); - ViewFrustums views; - - ViewFrustum view; - _viewState->copyViewFrustum(view); - views.push_back(view); - - if (_viewState->hasSecondaryViewFrustum()) { - _viewState->copySecondaryViewFrustum(view); - views.push_back(view); - } - - - updateChangedEntities(scene, views, transaction); + updateChangedEntities(scene, transaction); scene->enqueueTransaction(transaction); } } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 9ed4f9d21d..882ec2fd5b 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -148,8 +148,7 @@ protected: private: void addPendingEntities(const render::ScenePointer& scene, render::Transaction& transaction); - void updateChangedEntities(const render::ScenePointer& scene, const ViewFrustums& views, - render::Transaction& transaction); + void updateChangedEntities(const render::ScenePointer& scene, render::Transaction& transaction); EntityRendererPointer renderableForEntity(const EntityItemPointer& entity) const { return renderableForEntityId(entity->getID()); } render::ItemID renderableIdForEntity(const EntityItemPointer& entity) const { return renderableIdForEntityId(entity->getID()); } diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 7aa702138f..072774f0f5 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -18,10 +18,6 @@ #include #include -using QueryFlags = uint8_t; -const QueryFlags QUERY_HAS_MAIN_FRUSTUM = 1U << 0; -const QueryFlags QUERY_HAS_SECONDARY_FRUSTUM = 1U << 1; - OctreeQuery::OctreeQuery(bool randomizeConnectionID) { if (randomizeConnectionID) { // randomize our initial octree query connection ID using random_device @@ -38,23 +34,13 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { memcpy(destinationBuffer, &_connectionID, sizeof(_connectionID)); destinationBuffer += sizeof(_connectionID); - // flags for wether the frustums are present - QueryFlags frustumFlags = 0; - if (_hasMainFrustum) { - frustumFlags |= QUERY_HAS_MAIN_FRUSTUM; - } - if (_hasSecondaryFrustum) { - frustumFlags |= QUERY_HAS_SECONDARY_FRUSTUM; - } - memcpy(destinationBuffer, &frustumFlags, sizeof(frustumFlags)); - destinationBuffer += sizeof(frustumFlags); + // Number of frustums + uint8_t numFrustums = _conicalViews.size(); + memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums)); + destinationBuffer += sizeof(numFrustums); - if (_hasMainFrustum) { - destinationBuffer += _mainViewFrustum.serialize(destinationBuffer); - } - - if (_hasSecondaryFrustum) { - destinationBuffer += _secondaryViewFrustum.serialize(destinationBuffer); + for (const auto& view : _conicalViews) { + destinationBuffer += view.serialize(destinationBuffer); } // desired Max Octree PPS @@ -118,19 +104,15 @@ int OctreeQuery::parseData(ReceivedMessage& message) { } // check if this query uses a view frustum - QueryFlags frustumFlags { 0 }; - memcpy(&frustumFlags, sourceBuffer, sizeof(frustumFlags)); - sourceBuffer += sizeof(frustumFlags); + uint8_t numFrustums = 0; + memcpy(&numFrustums, sourceBuffer, sizeof(numFrustums)); + sourceBuffer += sizeof(numFrustums); - _hasMainFrustum = frustumFlags & QUERY_HAS_MAIN_FRUSTUM; - _hasSecondaryFrustum = frustumFlags & QUERY_HAS_SECONDARY_FRUSTUM; - - if (_hasMainFrustum) { - sourceBuffer += _mainViewFrustum.deserialize(sourceBuffer); - } - - if (_hasSecondaryFrustum) { - sourceBuffer += _secondaryViewFrustum.deserialize(sourceBuffer); + _conicalViews.clear(); + for (int i = 0; i < numFrustums; ++i) { + ConicalViewFrustum view; + sourceBuffer += view.deserialize(sourceBuffer); + _conicalViews.push_back(view); } // desired Max Octree PPS diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index f28d4c317e..7dfc1cfaaf 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -33,13 +33,9 @@ public: int getBroadcastData(unsigned char* destinationBuffer); int parseData(ReceivedMessage& message) override; - bool hasMainViewFrustum() const { return _hasMainFrustum; } - void setMainViewFrustum(const ViewFrustum& viewFrustum) { _hasMainFrustum = true; _mainViewFrustum = viewFrustum; } - void clearMainViewFrustum() { _hasMainFrustum = false; } - - bool hasSecondaryViewFrustum() const { return _hasSecondaryFrustum; } - void setSecondaryViewFrustum(const ViewFrustum& viewFrustum) { _hasSecondaryFrustum = true; _secondaryViewFrustum = viewFrustum; } - void clearSecondaryViewFrustum() { _hasSecondaryFrustum = false; } + bool hasConicalViews() const { return !_conicalViews.empty(); } + void setConicalViews(ConicalViewFrustums views) { _conicalViews = views; } + void clearConicalViews() { _conicalViews.clear(); } // getters/setters for JSON filter QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; } @@ -64,10 +60,7 @@ public slots: void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } protected: - bool _hasMainFrustum { false }; - ConicalViewFrustum _mainViewFrustum; - bool _hasSecondaryFrustum { false }; - ConicalViewFrustum _secondaryViewFrustum; + ConicalViewFrustums _conicalViews; // octree server sending items int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; diff --git a/libraries/octree/src/OctreeQueryNode.cpp b/libraries/octree/src/OctreeQueryNode.cpp index 568504a344..2d1d89a11c 100644 --- a/libraries/octree/src/OctreeQueryNode.cpp +++ b/libraries/octree/src/OctreeQueryNode.cpp @@ -139,23 +139,13 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int by } } -void OctreeQueryNode::copyCurrentMainViewFrustum(ConicalViewFrustum& viewOut) const { - QMutexLocker viewLocker(&_viewMutex); - viewOut = _currentMainViewFrustum; -} - -void OctreeQueryNode::copyCurrentSecondaryViewFrustum(ConicalViewFrustum& viewOut) const { - QMutexLocker viewLocker(&_viewMutex); - viewOut = _currentSecondaryViewFrustum; -} - bool OctreeQueryNode::updateCurrentViewFrustum() { // if shutting down, return immediately if (_isShuttingDown) { return false; } - if (!_hasMainFrustum && !_hasSecondaryFrustum) { + if (!hasConicalViews()) { // this client does not use a view frustum so the view frustum for this query has not changed return false; } @@ -164,12 +154,17 @@ bool OctreeQueryNode::updateCurrentViewFrustum() { { // if there has been a change, then recalculate QMutexLocker viewLocker(&_viewMutex); - if (_hasMainFrustum && !_mainViewFrustum.isVerySimilar(_currentMainViewFrustum)) { - _currentMainViewFrustum = _mainViewFrustum; - currentViewFrustumChanged = true; - } - if (_hasSecondaryFrustum && !_secondaryViewFrustum.isVerySimilar(_currentSecondaryViewFrustum)) { - _currentSecondaryViewFrustum = _secondaryViewFrustum; + + if (_conicalViews.size() == _currentConicalViews.size()) { + for (size_t i = 0; i < _conicalViews.size(); ++i) { + if (!_conicalViews[i].isVerySimilar(_currentConicalViews[i])) { + _currentConicalViews = _conicalViews; + currentViewFrustumChanged = true; + break; + } + } + } else { + _currentConicalViews = _conicalViews; currentViewFrustumChanged = true; } } diff --git a/libraries/octree/src/OctreeQueryNode.h b/libraries/octree/src/OctreeQueryNode.h index 13337c2c69..d984e048c1 100644 --- a/libraries/octree/src/OctreeQueryNode.h +++ b/libraries/octree/src/OctreeQueryNode.h @@ -49,8 +49,7 @@ public: OctreeElementExtraEncodeData extraEncodeData; - void copyCurrentMainViewFrustum(ConicalViewFrustum& viewOut) const; - void copyCurrentSecondaryViewFrustum(ConicalViewFrustum& viewOut) const; + const ConicalViewFrustums& getCurrentViews() const { return _currentConicalViews; } // These are not classic setters because they are calculating and maintaining state // which is set asynchronously through the network receive @@ -97,8 +96,7 @@ private: quint64 _firstSuppressedPacket { usecTimestampNow() }; mutable QMutex _viewMutex { QMutex::Recursive }; - ConicalViewFrustum _currentMainViewFrustum; - ConicalViewFrustum _currentSecondaryViewFrustum; + ConicalViewFrustums _currentConicalViews; bool _viewFrustumChanging { false }; bool _viewFrustumJustStoppedChanging { true }; diff --git a/libraries/octree/src/OctreeUtils.h b/libraries/octree/src/OctreeUtils.h index 58ab366d8d..dff56cad64 100644 --- a/libraries/octree/src/OctreeUtils.h +++ b/libraries/octree/src/OctreeUtils.h @@ -12,6 +12,8 @@ #ifndef hifi_OctreeUtils_h #define hifi_OctreeUtils_h +#include + #include "OctreeConstants.h" class AABox; @@ -33,7 +35,6 @@ float getOrthographicAccuracySize(float octreeSizeScale, int boundaryLevelAdjust // MIN_ELEMENT_ANGULAR_DIAMETER = angular diameter of 1x1x1m cube at 400m = sqrt(3) / 400 = 0.0043301 radians ~= 0.25 degrees const float MIN_ELEMENT_ANGULAR_DIAMETER = 0.0043301f; // radians // NOTE: the entity bounding cube is larger than the smallest possible containing octree element by sqrt(3) -const float SQRT_THREE = 1.73205080f; const float MIN_ENTITY_ANGULAR_DIAMETER = MIN_ELEMENT_ANGULAR_DIAMETER * SQRT_THREE; const float MIN_VISIBLE_DISTANCE = 0.0001f; // helps avoid divide-by-zero check diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index 9d781b7d18..b90e291da5 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -24,6 +24,8 @@ class Transform; class QThread; class ViewFrustum; class PickRay; +class ConicalViewFrustum; +using ConicalViewFrustums = std::vector; /// Interface provided by Application to other objects that need access to the current view state details class AbstractViewStateInterface { @@ -31,9 +33,7 @@ public: /// copies the current view frustum for rendering the view state virtual void copyCurrentViewFrustum(ViewFrustum& viewOut) const = 0; - virtual void copyViewFrustum(ViewFrustum& viewOut) const = 0; - virtual void copySecondaryViewFrustum(ViewFrustum& viewOut) const = 0; - virtual bool hasSecondaryViewFrustum() const = 0; + virtual const ConicalViewFrustums& getConicalViews() const = 0; virtual QThread* getMainThread() = 0; diff --git a/libraries/shared/src/NumericalConstants.h b/libraries/shared/src/NumericalConstants.h index e2d2409d56..4c24a73226 100644 --- a/libraries/shared/src/NumericalConstants.h +++ b/libraries/shared/src/NumericalConstants.h @@ -48,6 +48,8 @@ const int BYTES_PER_KILOBYTE = 1000; const int BYTES_PER_KILOBIT = BYTES_PER_KILOBYTE / BITS_IN_BYTE; const int KILO_PER_MEGA = 1000; +const float SQRT_THREE = 1.73205080f; + #define KB_TO_BYTES_SHIFT 10 #define MB_TO_BYTES_SHIFT 20 #define GB_TO_BYTES_SHIFT 30 diff --git a/libraries/shared/src/PrioritySortUtil.h b/libraries/shared/src/PrioritySortUtil.h index ba15222611..34ec074d45 100644 --- a/libraries/shared/src/PrioritySortUtil.h +++ b/libraries/shared/src/PrioritySortUtil.h @@ -15,7 +15,7 @@ #include #include "NumericalConstants.h" -#include "ViewFrustum.h" +#include "shared/ConicalViewFrustum.h" /* PrioritySortUtil is a helper for sorting 3D things relative to a ViewFrustum. To use: @@ -84,12 +84,12 @@ namespace PrioritySortUtil { class PriorityQueue { public: PriorityQueue() = delete; - PriorityQueue(const ViewFrustums& views) : _views(views) { } - PriorityQueue(const ViewFrustums& views, float angularWeight, float centerWeight, float ageWeight) + PriorityQueue(const ConicalViewFrustums& views) : _views(views) { } + PriorityQueue(const ConicalViewFrustums& views, float angularWeight, float centerWeight, float ageWeight) : _views(views), _angularWeight(angularWeight), _centerWeight(centerWeight), _ageWeight(ageWeight) { } - void setViews(const ViewFrustums& views) { _views = views; } + void setViews(const ConicalViewFrustums& views) { _views = views; } void setWeights(float angularWeight, float centerWeight, float ageWeight) { _angularWeight = angularWeight; @@ -118,7 +118,7 @@ namespace PrioritySortUtil { return priority; } - float computePriority(const ViewFrustum& view, const T& thing) const { + float computePriority(const ConicalViewFrustum& view, const T& thing) const { // priority = weighted linear combination of multiple values: // (a) angular size // (b) proximity to center of view @@ -143,8 +143,8 @@ namespace PrioritySortUtil { + _ageWeight * cosineAngleFactor * age; // decrement priority of things outside keyhole - if (distance - radius > view.getCenterRadius()) { - if (!view.sphereIntersectsFrustum(position, radius)) { + if (distance - radius > view.getRadius()) { + if (!view.intersects(offset, distance, radius)) { constexpr float OUT_OF_VIEW_PENALTY = -10.0f; priority += OUT_OF_VIEW_PENALTY; } @@ -152,7 +152,7 @@ namespace PrioritySortUtil { return priority; } - ViewFrustums _views; + ConicalViewFrustums _views; std::priority_queue _queue; float _angularWeight { DEFAULT_ANGULAR_COEF }; float _centerWeight { DEFAULT_CENTER_COEF }; diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index c89a9fbd60..3aa70b0897 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -138,69 +138,6 @@ const char* ViewFrustum::debugPlaneName (int plane) const { return "Unknown"; } -int ViewFrustum::fromByteArray(const QByteArray& input) { - - // From the wire! - glm::vec3 cameraPosition; - glm::quat cameraOrientation; - float cameraCenterRadius; - float cameraFov; - float cameraAspectRatio; - float cameraNearClip; - float cameraFarClip; - - const unsigned char* startPosition = reinterpret_cast(input.constData()); - const unsigned char* sourceBuffer = startPosition; - - // camera details - memcpy(&cameraPosition, sourceBuffer, sizeof(cameraPosition)); - sourceBuffer += sizeof(cameraPosition); - sourceBuffer += unpackOrientationQuatFromBytes(sourceBuffer, cameraOrientation); - sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*)sourceBuffer, &cameraFov); - sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer, cameraAspectRatio); - sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer, cameraNearClip); - sourceBuffer += unpackClipValueFromTwoByte(sourceBuffer, cameraFarClip); - memcpy(&cameraCenterRadius, sourceBuffer, sizeof(cameraCenterRadius)); - sourceBuffer += sizeof(cameraCenterRadius); - - setPosition(cameraPosition); - setOrientation(cameraOrientation); - setCenterRadius(cameraCenterRadius); - - // Also make sure it's got the correct lens details from the camera - if (0.0f != cameraAspectRatio && - 0.0f != cameraNearClip && - 0.0f != cameraFarClip && - cameraNearClip != cameraFarClip) { - - setProjection(cameraFov, cameraAspectRatio, cameraNearClip, cameraFarClip); - calculate(); - } - - return sourceBuffer - startPosition; -} - - -QByteArray ViewFrustum::toByteArray() { - static const int LARGE_ENOUGH = 1024; - QByteArray viewFrustumDataByteArray(LARGE_ENOUGH, 0); - unsigned char* destinationBuffer = reinterpret_cast(viewFrustumDataByteArray.data()); - unsigned char* startPosition = destinationBuffer; - - // camera details - memcpy(destinationBuffer, &_position, sizeof(_position)); - destinationBuffer += sizeof(_position); - destinationBuffer += packOrientationQuatToBytes(destinationBuffer, _orientation); - destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _fieldOfView); - destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _aspectRatio); - destinationBuffer += packClipValueToTwoByte(destinationBuffer, _nearClip); - destinationBuffer += packClipValueToTwoByte(destinationBuffer, _farClip); - memcpy(destinationBuffer, &_centerSphereRadius, sizeof(_centerSphereRadius)); - destinationBuffer += sizeof(_centerSphereRadius); - - return viewFrustumDataByteArray.left(destinationBuffer - startPosition); -} - ViewFrustum::intersection ViewFrustum::calculateCubeFrustumIntersection(const AACube& cube) const { // only check against frustum ViewFrustum::intersection result = INSIDE; diff --git a/libraries/shared/src/ViewFrustum.h b/libraries/shared/src/ViewFrustum.h index 128a717df8..eada65468d 100644 --- a/libraries/shared/src/ViewFrustum.h +++ b/libraries/shared/src/ViewFrustum.h @@ -147,9 +147,6 @@ public: void invalidate(); // causes all reasonable intersection tests to fail - QByteArray toByteArray(); - int fromByteArray(const QByteArray& input); - private: glm::mat4 _view; glm::mat4 _projection; diff --git a/libraries/shared/src/shared/ConicalViewFrustum.cpp b/libraries/shared/src/shared/ConicalViewFrustum.cpp index 8538543da6..2ef096e3a8 100644 --- a/libraries/shared/src/shared/ConicalViewFrustum.cpp +++ b/libraries/shared/src/shared/ConicalViewFrustum.cpp @@ -11,6 +11,8 @@ #include "ConicalViewFrustum.h" + +#include "../NumericalConstants.h" #include "../ViewFrustum.h" void ConicalViewFrustum::set(const ViewFrustum& viewFrustum) { @@ -45,13 +47,46 @@ bool ConicalViewFrustum::isVerySimilar(const ConicalViewFrustum& other) const { const float MIN_RELATIVE_ERROR = 0.01f; // 1% return glm::distance2(_position, other._position) < MIN_POSITION_SLOP_SQUARED && - angleBetween(_direction, other._direction) < MIN_ANGLE_BETWEEN && - closeEnough(_angle, other._angle, MIN_RELATIVE_ERROR) && - closeEnough(_farClip, other._farClip, MIN_RELATIVE_ERROR) && - closeEnough(_radius, other._radius, MIN_RELATIVE_ERROR); + angleBetween(_direction, other._direction) < MIN_ANGLE_BETWEEN && + closeEnough(_angle, other._angle, MIN_RELATIVE_ERROR) && + closeEnough(_farClip, other._farClip, MIN_RELATIVE_ERROR) && + closeEnough(_radius, other._radius, MIN_RELATIVE_ERROR); } -bool ConicalViewFrustum::intersects(const glm::vec3& position, float distance, float radius) const { +bool ConicalViewFrustum::intersects(const AACube& cube) const { + auto radius = 0.5f * SQRT_THREE * cube.getScale(); // radius of bounding sphere + auto position = cube.calcCenter() - _position; // position of bounding sphere in view-frame + float distance = glm::length(position); + + return intersects(position, distance, radius); +} + +bool ConicalViewFrustum::intersects(const AABox& box) const { + auto radius = 0.5f * glm::length(box.getScale()); // radius of bounding sphere + auto position = box.calcCenter() - _position; // position of bounding sphere in view-frame + float distance = glm::length(position); + + return intersects(position, distance, radius); +} + +bool ConicalViewFrustum::getAngularSize(const AACube& cube) const { + auto radius = 0.5f * SQRT_THREE * cube.getScale(); // radius of bounding sphere + auto position = cube.calcCenter() - _position; // position of bounding sphere in view-frame + float distance = glm::length(position); + + return getAngularSize(distance, radius); +} + +bool ConicalViewFrustum::getAngularSize(const AABox& box) const { + auto radius = 0.5f * glm::length(box.getScale()); // radius of bounding sphere + auto position = box.calcCenter() - _position; // position of bounding sphere in view-frame + float distance = glm::length(position); + + return getAngularSize(distance, radius); +} + + +bool ConicalViewFrustum::intersects(const glm::vec3& relativePosition, float distance, float radius) const { if (distance < _radius + radius) { // Inside keyhole radius return true; @@ -68,7 +103,7 @@ bool ConicalViewFrustum::intersects(const glm::vec3& position, float distance, f // The math here is left as an exercise for the reader with the following hints: // (1) We actually check the dot product of the cube's local position rather than the angle and // (2) we take advantage of this trig identity: cos(A+B) = cos(A)*cos(B) - sin(A)*sin(B) - return glm::dot(position, _direction) > + return glm::dot(relativePosition, _direction) > sqrtf(distance * distance - radius * radius) * _cosAngle - radius * _sinAngle; } diff --git a/libraries/shared/src/shared/ConicalViewFrustum.h b/libraries/shared/src/shared/ConicalViewFrustum.h index 3cadedda9d..dc372d560e 100644 --- a/libraries/shared/src/shared/ConicalViewFrustum.h +++ b/libraries/shared/src/shared/ConicalViewFrustum.h @@ -17,6 +17,7 @@ #include class AACube; +class AABox; class ViewFrustum; using ViewFrustums = std::vector; @@ -42,7 +43,12 @@ public: bool isVerySimilar(const ConicalViewFrustum& other) const; - bool intersects(const glm::vec3& position, float distance, float radius) const; + bool intersects(const AACube& cube) const; + bool intersects(const AABox& box) const; + bool getAngularSize(const AACube& cube) const; + bool getAngularSize(const AABox& box) const; + + bool intersects(const glm::vec3& relativePosition, float distance, float radius) const; bool getAngularSize(float distance, float radius) const; int serialize(unsigned char* destinationBuffer) const; diff --git a/tests/render-perf/src/main.cpp b/tests/render-perf/src/main.cpp index 8c17d7c5c2..2e72d9cead 100644 --- a/tests/render-perf/src/main.cpp +++ b/tests/render-perf/src/main.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -441,14 +442,9 @@ protected: viewOut = _viewFrustum; } - void copyViewFrustum(ViewFrustum& viewOut) const override { - viewOut = _viewFrustum; - } - - void copySecondaryViewFrustum(ViewFrustum& viewOut) const override {} - - bool hasSecondaryViewFrustum() const override { - return false; + const ConicalViewFrustums& getConicalViews() const override { + assert(false); + return ConicalViewFrustums(); } QThread* getMainThread() override { From d7e9fdc6a42b0c2940399a6103d80e5d52f5d1e6 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 18:19:25 -0700 Subject: [PATCH 113/192] Bump Avatar Query packet version --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 123e11b7c5..d6ab7d0f9c 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -91,7 +91,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); case PacketType::AvatarQuery: - return static_cast(AvatarQueryVersion::SendMultipleFrustums); + return static_cast(AvatarQueryVersion::ConicalFrustums); default: return 20; } diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 1bedfdf3e6..2252b09ae5 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -330,7 +330,8 @@ enum class PingVersion : PacketVersion { }; enum class AvatarQueryVersion : PacketVersion { - SendMultipleFrustums = 21 + SendMultipleFrustums = 21, + ConicalFrustums = 22 }; #endif // hifi_PacketHeaders_h From d87cd2af6e979f3010bb21a6ac4992a921233238 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 18:23:00 -0700 Subject: [PATCH 114/192] Update avatar query names --- assignment-client/src/Agent.cpp | 14 +++++++------- assignment-client/src/Agent.h | 4 ++-- interface/src/Application.cpp | 4 ++-- interface/src/Application.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index da811b8af5..42924a8487 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -548,18 +548,18 @@ void Agent::setIsAvatar(bool isAvatar) { if (_isAvatar && !_avatarIdentityTimer) { // set up the avatar timers _avatarIdentityTimer = new QTimer(this); - _avatarViewTimer = new QTimer(this); + _avatarQueryTimer = new QTimer(this); // connect our slot connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket); - connect(_avatarViewTimer, &QTimer::timeout, this, &Agent::sendAvatarViewFrustum); + connect(_avatarQueryTimer, &QTimer::timeout, this, &Agent::queryAvatars); static const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000; static const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 1000; // start the timers _avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets - _avatarViewTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS); + _avatarQueryTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS); // tell the avatarAudioTimer to start ticking QMetaObject::invokeMethod(&_avatarAudioTimer, "start"); @@ -572,9 +572,9 @@ void Agent::setIsAvatar(bool isAvatar) { delete _avatarIdentityTimer; _avatarIdentityTimer = nullptr; - _avatarViewTimer->stop(); - delete _avatarViewTimer; - _avatarViewTimer = nullptr; + _avatarQueryTimer->stop(); + delete _avatarQueryTimer; + _avatarQueryTimer = nullptr; // The avatar mixer never times out a connection (e.g., based on identity or data packets) // but rather keeps avatars in its list as long as "connected". As a result, clients timeout @@ -607,7 +607,7 @@ void Agent::sendAvatarIdentityPacket() { } } -void Agent::sendAvatarViewFrustum() { +void Agent::queryAvatars() { auto scriptedAvatar = DependencyManager::get(); ViewFrustum view; diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index d144f0bc01..0cdc9e0029 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -97,7 +97,7 @@ private: void setAvatarSound(SharedSoundPointer avatarSound) { _avatarSound = avatarSound; } void sendAvatarIdentityPacket(); - void sendAvatarViewFrustum(); + void queryAvatars(); QString _scriptContents; QTimer* _scriptRequestTimeout { nullptr }; @@ -107,7 +107,7 @@ private: int _numAvatarSoundSentBytes = 0; bool _isAvatar = false; QTimer* _avatarIdentityTimer = nullptr; - QTimer* _avatarViewTimer = nullptr; + QTimer* _avatarQueryTimer = nullptr; QHash _outgoingScriptAudioSequenceNumbers; AudioGate _audioGate; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d14af685f0..f9d048b6ac 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5682,7 +5682,7 @@ void Application::update(float deltaTime) { if (DependencyManager::get()->shouldRenderEntities()) { queryOctree(NodeType::EntityServer, PacketType::EntityQuery); } - sendAvatarViewFrustum(); + queryAvatars(); _lastQueriedViews = _conicalViews; _lastQueriedTime = now; @@ -5857,7 +5857,7 @@ void Application::update(float deltaTime) { } } -void Application::sendAvatarViewFrustum() { +void Application::queryAvatars() { auto avatarPacket = NLPacket::create(PacketType::AvatarQuery); auto destinationBuffer = reinterpret_cast(avatarPacket->getPayload()); unsigned char* bufferStart = destinationBuffer; diff --git a/interface/src/Application.h b/interface/src/Application.h index 6d749f9458..4a9c293237 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -492,9 +492,9 @@ private: void updateDialogs(float deltaTime) const; void queryOctree(NodeType_t serverType, PacketType packetType); + void queryAvatars(); int sendNackPackets(); - void sendAvatarViewFrustum(); std::shared_ptr getMyAvatar() const; From 487a63025f0681d52f032e85fd4530468392d6e0 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 1 May 2018 19:11:00 -0700 Subject: [PATCH 115/192] Fix warning --- assignment-client/src/avatars/AvatarMixerClientData.cpp | 2 +- assignment-client/src/avatars/AvatarMixerClientData.h | 2 +- interface/src/Application.cpp | 2 +- libraries/octree/src/OctreeQuery.cpp | 2 +- tests/render-perf/src/main.cpp | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index aa93fc9e08..d5a8b37742 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -126,7 +126,7 @@ void AvatarMixerClientData::removeFromRadiusIgnoringSet(SharedNodePointer self, } } -void AvatarMixerClientData::readViewFrustumPacket(QByteArray message) { +void AvatarMixerClientData::readViewFrustumPacket(const QByteArray& message) { _currentViewFrustums.clear(); auto sourceBuffer = reinterpret_cast(message.constData()); diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index f3b2b587ee..e038e81505 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -98,7 +98,7 @@ public: void removeFromRadiusIgnoringSet(SharedNodePointer self, const QUuid& other); void ignoreOther(SharedNodePointer self, SharedNodePointer other); - void readViewFrustumPacket(QByteArray message); + void readViewFrustumPacket(const QByteArray& message); bool otherAvatarInView(const AABox& otherAvatarBox); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f9d048b6ac..d3c75219c5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5862,7 +5862,7 @@ void Application::queryAvatars() { auto destinationBuffer = reinterpret_cast(avatarPacket->getPayload()); unsigned char* bufferStart = destinationBuffer; - uint8_t numFrustums = _conicalViews.size(); + uint8_t numFrustums = (uint8_t)_conicalViews.size(); memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums)); destinationBuffer += sizeof(numFrustums); diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 072774f0f5..3f730d4458 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -35,7 +35,7 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { destinationBuffer += sizeof(_connectionID); // Number of frustums - uint8_t numFrustums = _conicalViews.size(); + uint8_t numFrustums = (uint8_t)_conicalViews.size(); memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums)); destinationBuffer += sizeof(numFrustums); diff --git a/tests/render-perf/src/main.cpp b/tests/render-perf/src/main.cpp index 2e72d9cead..33aea6dcc9 100644 --- a/tests/render-perf/src/main.cpp +++ b/tests/render-perf/src/main.cpp @@ -443,8 +443,7 @@ protected: } const ConicalViewFrustums& getConicalViews() const override { - assert(false); - return ConicalViewFrustums(); + return _view; } QThread* getMainThread() override { @@ -1122,6 +1121,7 @@ private: graphics::LightPointer _globalLight { std::make_shared() }; bool _ready { false }; EntitySimulationPointer _entitySimulation; + ConicalViewFrustums _view; QStringList _commands; QString _commandPath; From 73ce02ce75098cae634664151b11c6f28b8508d6 Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Fri, 4 May 2018 07:56:44 -0700 Subject: [PATCH 116/192] Fix asan warnings in byte-unpacking functions --- libraries/shared/src/GLMHelpers.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp index 72710a6a7d..e963345ecd 100644 --- a/libraries/shared/src/GLMHelpers.cpp +++ b/libraries/shared/src/GLMHelpers.cpp @@ -76,13 +76,15 @@ glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) { // Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) { - int16_t outVal = (int16_t)(scalar * (float)(1 << radix)); - memcpy(buffer, &outVal, sizeof(uint16_t)); - return sizeof(uint16_t); + int16_t twoByteFixed = (int16_t)(scalar * (float)(1 << radix)); + memcpy(buffer, &twoByteFixed, sizeof(int16_t)); + return sizeof(int16_t); } int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) { - *destinationPointer = *byteFixedPointer / (float)(1 << radix); + int16_t twoByteFixed; + memcpy(&twoByteFixed, byteFixedPointer, sizeof(int16_t)); + *destinationPointer = twoByteFixed / (float)(1 << radix); return sizeof(int16_t); } @@ -102,18 +104,19 @@ int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm return sourceBuffer - startPosition; } - int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) { const float ANGLE_CONVERSION_RATIO = (std::numeric_limits::max() / 360.0f); - uint16_t angleHolder = floorf((degrees + 180.0f) * ANGLE_CONVERSION_RATIO); - memcpy(buffer, &angleHolder, sizeof(uint16_t)); + uint16_t twoByteAngle = floorf((degrees + 180.0f) * ANGLE_CONVERSION_RATIO); + memcpy(buffer, &twoByteAngle, sizeof(uint16_t)); return sizeof(uint16_t); } int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) { - *destinationPointer = (*byteAnglePointer / (float) std::numeric_limits::max()) * 360.0f - 180.0f; + uint16_t twoByteAngle; + memcpy(&twoByteAngle, byteAnglePointer, sizeof(uint16_t)); + *destinationPointer = (twoByteAngle / (float) std::numeric_limits::max()) * 360.0f - 180.0f; return sizeof(uint16_t); } From a57c72df6e4754e497f38827bfa888f954325212 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 4 May 2018 08:53:49 -0700 Subject: [PATCH 117/192] fix entity highlighting during edit mode --- .../controllers/controllerModules/mouseHighlightEntities.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js index 86c96fcf6b..3180e58e2c 100644 --- a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js +++ b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js @@ -12,10 +12,11 @@ /* jslint bitwise: true */ -/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/ +/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar, isInEditMode*/ (function() { + Script.include("/~/system/libraries/utils.js"); var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js"); function MouseHighlightEntities() { @@ -39,7 +40,7 @@ dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity); this.highlightedEntity = null; } - } else if (!this.grabbedEntity) { + } else if (!this.grabbedEntity && !isInEditMode()) { var pickResult = controllerData.mouseRayPick; if (pickResult.type === Picks.INTERSECTED_ENTITY) { var targetEntityID = pickResult.objectID; From d44882e6dc94a1bc96256b01bfd6915d64fb1b0e Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 4 May 2018 08:53:49 -0700 Subject: [PATCH 118/192] fix entity highlighting during edit mode --- .../controllers/controllerModules/mouseHighlightEntities.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js index 86c96fcf6b..3180e58e2c 100644 --- a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js +++ b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js @@ -12,10 +12,11 @@ /* jslint bitwise: true */ -/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar*/ +/* global Script, print, Entities, Picks, HMD, Controller, MyAvatar, isInEditMode*/ (function() { + Script.include("/~/system/libraries/utils.js"); var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js"); function MouseHighlightEntities() { @@ -39,7 +40,7 @@ dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity); this.highlightedEntity = null; } - } else if (!this.grabbedEntity) { + } else if (!this.grabbedEntity && !isInEditMode()) { var pickResult = controllerData.mouseRayPick; if (pickResult.type === Picks.INTERSECTED_ENTITY) { var targetEntityID = pickResult.objectID; From e48d39ec38c3012b019e928bf05718dc23d9ba1d Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 4 May 2018 10:10:48 -0700 Subject: [PATCH 119/192] MS14758: Fix avatar reset when gifting worn avatar --- interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 6b48f8d51d..d79b8d09fa 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -729,7 +729,7 @@ Rectangle { } lightboxPopup.button2text = "CONFIRM"; lightboxPopup.button2method = function() { - MyAvatar.skeletonModelURL = ''; + MyAvatar.useFullAvatarURL(''); root.activeView = "giftAsset"; lightboxPopup.visible = false; }; From ac0fe620869535d3f49d2cc7d443432db174a409 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 4 May 2018 10:41:52 -0700 Subject: [PATCH 120/192] Make ModelBaker ktx extension check case-insensitive --- libraries/baking/src/ModelBaker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/baking/src/ModelBaker.cpp b/libraries/baking/src/ModelBaker.cpp index ee26b94b81..ac332f4ceb 100644 --- a/libraries/baking/src/ModelBaker.cpp +++ b/libraries/baking/src/ModelBaker.cpp @@ -246,9 +246,9 @@ bool ModelBaker::compressMesh(FBXMesh& mesh, bool hasDeformers, FBXNode& dracoMe QString ModelBaker::compressTexture(QString modelTextureFileName, image::TextureUsage::Type textureType) { - QFileInfo modelTextureFileInfo{ modelTextureFileName.replace("\\", "/") }; + QFileInfo modelTextureFileInfo { modelTextureFileName.replace("\\", "/") }; - if (modelTextureFileInfo.suffix() == BAKED_TEXTURE_KTX_EXT.mid(1)) { + if (modelTextureFileInfo.suffix().toLower() == BAKED_TEXTURE_KTX_EXT.mid(1)) { // re-baking a model that already references baked textures // this is an error - return from here handleError("Cannot re-bake a file that already references compressed textures"); From fc3fd75100fdf0d6a147492b911e1b937e73e1e6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 4 May 2018 10:42:19 -0700 Subject: [PATCH 121/192] Fix TextureMeta::deserialize not handling json parse errors --- libraries/ktx/src/TextureMeta.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/ktx/src/TextureMeta.cpp b/libraries/ktx/src/TextureMeta.cpp index 88235d8a4b..3a2abf24c4 100644 --- a/libraries/ktx/src/TextureMeta.cpp +++ b/libraries/ktx/src/TextureMeta.cpp @@ -11,6 +11,7 @@ #include "TextureMeta.h" +#include #include #include @@ -19,7 +20,12 @@ const QString TEXTURE_META_EXTENSION = ".texmeta.json"; bool TextureMeta::deserialize(const QByteArray& data, TextureMeta* meta) { QJsonParseError error; auto doc = QJsonDocument::fromJson(data, &error); + if (error.error != QJsonParseError::NoError) { + qDebug() << "Failed to parse TextureMeta:" << error.errorString(); + return false; + } if (!doc.isObject()) { + qDebug() << "Unable to process TextureMeta: top-level value is not an Object"; return false; } From e1d218bb57d11ed2b83003ab005dbc6fcb30f6b9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 4 May 2018 11:25:11 -0700 Subject: [PATCH 122/192] Bump asset packet version for texture meta --- libraries/networking/src/udt/PacketHeaders.cpp | 3 +-- libraries/networking/src/udt/PacketHeaders.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 98b0e1d892..9eae01cefa 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -59,11 +59,10 @@ PacketVersion versionForPacketType(PacketType packetType) { return 17; case PacketType::AssetMappingOperation: case PacketType::AssetMappingOperationReply: - return static_cast(AssetServerPacketVersion::RedirectedMappings); case PacketType::AssetGetInfo: case PacketType::AssetGet: case PacketType::AssetUpload: - return static_cast(AssetServerPacketVersion::RangeRequestSupport); + return static_cast(AssetServerPacketVersion::BakingTextureMeta); case PacketType::NodeIgnoreRequest: return 18; // Introduction of node ignore request (which replaced an unused packet tpye) diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index e6b133c158..20d98ca2d1 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -250,7 +250,8 @@ enum class EntityQueryPacketVersion: PacketVersion { enum class AssetServerPacketVersion: PacketVersion { VegasCongestionControl = 19, RangeRequestSupport, - RedirectedMappings + RedirectedMappings, + BakingTextureMeta }; enum class AvatarMixerPacketVersion : PacketVersion { From a35517d9851aad3ea1c324840912670a3c54bcd0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 5 May 2018 07:05:10 +1200 Subject: [PATCH 123/192] Fix JSDoc for Users.requestUsernameFromID --- .../script-engine/src/UsersScriptingInterface.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index f214c3f11c..e80d38239f 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -106,10 +106,11 @@ public slots: void mute(const QUuid& nodeID); /**jsdoc - * Get the user name and machine fingerprint associated with the given UUID. This will only do anything if you're an admin - * of the domain you're in. - * @function Users.getUsernameFromID - * @param {Uuid} nodeID The node or session ID of the user whose username you want. + * Request the user name and machine fingerprint associated with the given UUID. The user name will be returned in a + * {@link Users.usernameFromIDReply|usernameFromIDReply} signal. This will only do anything if you're an admin of the domain + * you're in. + * @function Users.requestUsernameFromID + * @param {Uuid} nodeID The node or session ID of the user whose user name you want. */ void requestUsernameFromID(const QUuid& nodeID); @@ -170,7 +171,8 @@ signals: void enteredIgnoreRadius(); /**jsdoc - * Notifies scripts of the user name and machine fingerprint associated with a UUID. + * Triggered in response to a {@link Users.requestUsernameFromID|requestUsernameFromID} call. Provides the user name and + * machine fingerprint associated with a UUID. * Username and machineFingerprint will be their default constructor output if the requesting user isn't an admin. * @function Users.usernameFromIDReply * @param {Uuid} nodeID From aef5ea093604bc2685f319a9e835ba915323f6be Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 4 May 2018 12:30:13 -0700 Subject: [PATCH 124/192] Correct usage of the test script URL. --- interface/src/Application.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 54f1ba2606..fc1602e2e3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1022,7 +1022,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo for (int i = 0; i < args.size() - 1; ++i) { if (args.at(i) == TEST_SCRIPT && (i + 1) < args.size()) { QString testScriptPath = args.at(i + 1); - if (QFileInfo(testScriptPath).exists()) { + + // If the URL scheme is "http(s)" then use as is, else - treat it as a local file + // This is done so as not break previous command line scripts + if (testScriptPath.left(4) == "http") { + setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath)); + } else if (QFileInfo(testScriptPath).exists()) { setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); } From 81df7a1293516de182f2b86ae289f00aa97d9091 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Fri, 4 May 2018 12:41:39 -0700 Subject: [PATCH 125/192] Fix texture leak in QML surface test --- tests/qml/src/main.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/qml/src/main.cpp b/tests/qml/src/main.cpp index 349ac55d88..d983353893 100644 --- a/tests/qml/src/main.cpp +++ b/tests/qml/src/main.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ private: OffscreenGLCanvas _sharedContext; std::array, DIVISIONS_X> _surfaces; - QOpenGLFunctions_4_5_Core _glf; + QOpenGLFunctions_4_1_Core _glf; std::function _discardLamdba; QSize _size; size_t _surfaceCount{ 0 }; @@ -145,7 +145,7 @@ void TestWindow::initGl() { gl::initModuleGl(); _glf.initializeOpenGLFunctions(); - _glf.glCreateFramebuffers(1, &_fbo); + _glf.glGenFramebuffers(1, &_fbo); if (!_sharedContext.create(&_glContext) || !_sharedContext.makeCurrent()) { qFatal("Unable to intialize Shared GL context"); @@ -196,6 +196,12 @@ void TestWindow::buildSurface(QmlInfo& qmlInfo, bool video) { void TestWindow::destroySurface(QmlInfo& qmlInfo) { auto& surface = qmlInfo.surface; + auto& currentTexture = qmlInfo.texture; + if (currentTexture) { + auto readFence = _glf.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + _discardLamdba(currentTexture, readFence); + } auto webView = surface->getRootItem(); if (webView) { // stop loading @@ -274,16 +280,19 @@ void TestWindow::draw() { if (!qmlInfo.surface || !qmlInfo.texture) { continue; } - _glf.glNamedFramebufferTexture(_fbo, GL_COLOR_ATTACHMENT0, qmlInfo.texture, 0); - _glf.glBlitNamedFramebuffer(_fbo, 0, - // src coordinates - 0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1, - // dst coordinates - incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1), - // blit mask and filter - GL_COLOR_BUFFER_BIT, GL_NEAREST); + _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo); + _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, qmlInfo.texture, 0); + _glf.glBlitFramebuffer( + // src coordinates + 0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1, + // dst coordinates + incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1), + // blit mask and filter + GL_COLOR_BUFFER_BIT, GL_NEAREST); } } + _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); + _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); _glContext.swapBuffers(this); } From 53fe0bc616c36ebece838e0e00cf84575addfcf7 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 4 May 2018 14:08:21 -0700 Subject: [PATCH 126/192] MS14699: Prevent Wallet passcode from being sticky in certain cases --- .../qml/hifi/commerce/wallet/PassphraseModal.qml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml index 1cada9789b..c4abd40d2a 100644 --- a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml +++ b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml @@ -47,6 +47,13 @@ Item { onWalletAuthenticatedStatusResult: { submitPassphraseInputButton.enabled = true; + + // It's not possible to auth with a blank passphrase, + // so bail early if we get this signal without anything in the passphrase field + if (passphraseField.text === "") { + return; + } + if (!isAuthenticated) { errorText.text = "Authentication failed - please try again."; passphraseField.error = true; @@ -211,6 +218,10 @@ Item { error = false; focus = true; forceActiveFocus(); + } else { + showPassphrase.checked = false; + passphraseField.text = ""; + error = false; } } From 2c2b74f4c8a965ee7f0171f9d9685d09b9c75a4e Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 4 May 2018 14:13:14 -0700 Subject: [PATCH 127/192] Removed unused variable. --- tools/auto-tester/src/ui/AutoTester.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index e0f92664ef..59fe5d9de2 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -94,7 +94,6 @@ void AutoTester::saveImage(int index) { QPixmap pixmap; pixmap.loadFromData(downloaders[index]->downloadedData()); - int sdf = pixmap.width(); QImage image = pixmap.toImage(); image = image.convertToFormat(QImage::Format_ARGB32); From 6414fcaae568b31e43c89b72bbc7405d4eb5e88a Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 4 May 2018 14:20:17 -0700 Subject: [PATCH 128/192] fix-another-highlighting-issue --- .../controllerModules/highlightNearbyEntities.js | 11 ++++++++++- .../controllers/controllerModules/inEditMode.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index 32e1b4300d..bc09ebee7a 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -56,6 +56,12 @@ return canGrabEntity; }; + this.clearAll = function() { + this.highlightedEntities.forEach(function(entity) { + dispatcherUtils.unhighlightTargetEntity(entity); + }); + }; + this.hasHyperLink = function(props) { return (props.href !== "" && props.href !== undefined); }; @@ -121,7 +127,6 @@ if (channel === 'Hifi-unhighlight-entity') { try { data = JSON.parse(message); - var hand = data.hand; if (hand === dispatcherUtils.LEFT_HAND) { leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID); @@ -131,6 +136,9 @@ } catch (e) { print("Failed to parse message"); } + } else if (channel === 'Hifi-unhighlight-all') { + leftHighlightNearbyEntities.clearAll(); + rightHighlightNearbyEntities.clearAll(); } } }; @@ -145,6 +153,7 @@ dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities"); } Messages.subscribe('Hifi-unhighlight-entity'); + Messages.subscribe('Hifi-unhighlight-all'); Messages.messageReceived.connect(handleMessage); Script.scriptEnding.connect(cleanup); }()); diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index f7e86f9042..3ad7902d71 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -78,6 +78,7 @@ Script.include("/~/system/libraries/utils.js"); if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) { this.triggerClicked = false; } + Messages.sendLocalMessage('Hifi-unhighlight-all', ''); return makeRunningValues(true, [], []); } this.triggerClicked = false; From 176d69444f461cdb16d3d26b9ae0f06e17db0476 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 4 May 2018 14:20:17 -0700 Subject: [PATCH 129/192] fix-another-highlighting-issue --- .../controllerModules/highlightNearbyEntities.js | 11 ++++++++++- .../controllers/controllerModules/inEditMode.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index 32e1b4300d..bc09ebee7a 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -56,6 +56,12 @@ return canGrabEntity; }; + this.clearAll = function() { + this.highlightedEntities.forEach(function(entity) { + dispatcherUtils.unhighlightTargetEntity(entity); + }); + }; + this.hasHyperLink = function(props) { return (props.href !== "" && props.href !== undefined); }; @@ -121,7 +127,6 @@ if (channel === 'Hifi-unhighlight-entity') { try { data = JSON.parse(message); - var hand = data.hand; if (hand === dispatcherUtils.LEFT_HAND) { leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID); @@ -131,6 +136,9 @@ } catch (e) { print("Failed to parse message"); } + } else if (channel === 'Hifi-unhighlight-all') { + leftHighlightNearbyEntities.clearAll(); + rightHighlightNearbyEntities.clearAll(); } } }; @@ -145,6 +153,7 @@ dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities"); } Messages.subscribe('Hifi-unhighlight-entity'); + Messages.subscribe('Hifi-unhighlight-all'); Messages.messageReceived.connect(handleMessage); Script.scriptEnding.connect(cleanup); }()); diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index f7e86f9042..3ad7902d71 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -78,6 +78,7 @@ Script.include("/~/system/libraries/utils.js"); if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) { this.triggerClicked = false; } + Messages.sendLocalMessage('Hifi-unhighlight-all', ''); return makeRunningValues(true, [], []); } this.triggerClicked = false; From 0e92bb41bfcfeb9fe4c9f114706a8d721fb2a7fd Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 4 May 2018 14:20:17 -0700 Subject: [PATCH 130/192] fix-another-highlighting-issue --- .../controllerModules/highlightNearbyEntities.js | 11 ++++++++++- .../controllers/controllerModules/inEditMode.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index 32e1b4300d..bc09ebee7a 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -56,6 +56,12 @@ return canGrabEntity; }; + this.clearAll = function() { + this.highlightedEntities.forEach(function(entity) { + dispatcherUtils.unhighlightTargetEntity(entity); + }); + }; + this.hasHyperLink = function(props) { return (props.href !== "" && props.href !== undefined); }; @@ -121,7 +127,6 @@ if (channel === 'Hifi-unhighlight-entity') { try { data = JSON.parse(message); - var hand = data.hand; if (hand === dispatcherUtils.LEFT_HAND) { leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID); @@ -131,6 +136,9 @@ } catch (e) { print("Failed to parse message"); } + } else if (channel === 'Hifi-unhighlight-all') { + leftHighlightNearbyEntities.clearAll(); + rightHighlightNearbyEntities.clearAll(); } } }; @@ -145,6 +153,7 @@ dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities"); } Messages.subscribe('Hifi-unhighlight-entity'); + Messages.subscribe('Hifi-unhighlight-all'); Messages.messageReceived.connect(handleMessage); Script.scriptEnding.connect(cleanup); }()); diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index f7e86f9042..3ad7902d71 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -78,6 +78,7 @@ Script.include("/~/system/libraries/utils.js"); if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) { this.triggerClicked = false; } + Messages.sendLocalMessage('Hifi-unhighlight-all', ''); return makeRunningValues(true, [], []); } this.triggerClicked = false; From b04c5bd0db04688dfa965fe3aa90d79ab2bbf1fa Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 4 May 2018 14:43:16 -0700 Subject: [PATCH 131/192] CR --- interface/src/Application.cpp | 16 ++++++++-------- interface/src/Application.h | 8 ++++++-- libraries/entities/src/EntityPriorityQueue.h | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d3c75219c5..0d8ab13a9f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -967,7 +967,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _entitySimulation(new PhysicalEntitySimulation()), _physicsEngine(new PhysicsEngine(Vectors::ZERO)), _entityClipboard(new EntityTree()), - _lastQueriedTime(usecTimestampNow()), _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), _hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT), @@ -5084,7 +5083,7 @@ void Application::reloadResourceCaches() { resetPhysicsReadyInformation(); // Query the octree to refresh everything in view - _lastQueriedTime = 0; + _queryExpiry = SteadyClock::now(); _octreeQuery.incrementConnectionID(); queryOctree(NodeType::EntityServer, PacketType::EntityQuery); @@ -5660,9 +5659,6 @@ void Application::update(float deltaTime) { PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PerformanceTimer perfTimer("queryOctree"); QMutexLocker viewLocker(&_viewMutex); - quint64 sinceLastQuery = now - _lastQueriedTime; - const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; - bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; bool viewIsDifferentEnough = false; if (_conicalViews.size() == _lastQueriedViews.size()) { @@ -5678,14 +5674,16 @@ void Application::update(float deltaTime) { // if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it - if (queryIsDue || viewIsDifferentEnough) { + static const std::chrono::seconds MIN_PERIOD_BETWEEN_QUERIES { 3 }; + auto now = SteadyClock::now(); + if (now > _queryExpiry || viewIsDifferentEnough) { if (DependencyManager::get()->shouldRenderEntities()) { queryOctree(NodeType::EntityServer, PacketType::EntityQuery); } queryAvatars(); _lastQueriedViews = _conicalViews; - _lastQueriedTime = now; + _queryExpiry = now + MIN_PERIOD_BETWEEN_QUERIES; } } @@ -6142,7 +6140,7 @@ void Application::nodeActivated(SharedNodePointer node) { // If we get a new EntityServer activated, reset lastQueried time // so we will do a proper query during update if (node->getType() == NodeType::EntityServer) { - _lastQueriedTime = 0; + _queryExpiry = SteadyClock::now(); _octreeQuery.incrementConnectionID(); } @@ -6151,6 +6149,8 @@ void Application::nodeActivated(SharedNodePointer node) { } if (node->getType() == NodeType::AvatarMixer) { + _queryExpiry = SteadyClock::now(); + // new avatar mixer, send off our identity packet on next update loop // Reset skeletonModelUrl if the last server modified our choice. // Override the avatar url (but not model name) here too. diff --git a/interface/src/Application.h b/interface/src/Application.h index 4a9c293237..654b5c797b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -111,7 +111,8 @@ class Application : public QApplication, public AbstractViewStateInterface, public AbstractScriptingServicesInterface, public AbstractUriHandler, - public PluginContainer { + public PluginContainer +{ Q_OBJECT // TODO? Get rid of those @@ -579,7 +580,10 @@ private: ConicalViewFrustums _conicalViews; ConicalViewFrustums _lastQueriedViews; // last views used to query servers - quint64 _lastQueriedTime; + + using SteadyClock = std::chrono::steady_clock; + using TimePoint = SteadyClock::time_point; + TimePoint _queryExpiry; OctreeQuery _octreeQuery { true }; // NodeData derived class for querying octee cells from octree servers diff --git a/libraries/entities/src/EntityPriorityQueue.h b/libraries/entities/src/EntityPriorityQueue.h index 354cd70af3..339676d237 100644 --- a/libraries/entities/src/EntityPriorityQueue.h +++ b/libraries/entities/src/EntityPriorityQueue.h @@ -20,8 +20,8 @@ // PrioritizedEntity is a placeholder in a sorted queue. class PrioritizedEntity { public: - static constexpr float DO_NOT_SEND { -1.0e-6f }; - static constexpr float FORCE_REMOVE { -1.0e-5f }; + static constexpr float DO_NOT_SEND { -1.0e6f }; + static constexpr float FORCE_REMOVE { -1.0e5f }; static constexpr float WHEN_IN_DOUBT_PRIORITY { 1.0f }; PrioritizedEntity(EntityItemPointer entity, float priority, bool forceRemove = false) : _weakEntity(entity), _rawEntityPointer(entity.get()), _priority(priority), _forceRemove(forceRemove) {} From ad60a791803c41ddfac08aef31d7f0ed3c144d46 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 4 May 2018 14:43:28 -0700 Subject: [PATCH 132/192] Fix for android builds --- interface/src/Application.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0d8ab13a9f..0a76c8f475 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5226,9 +5226,8 @@ void Application::updateSecondaryCameraViewFrustum() { auto renderConfig = _renderEngine->getConfiguration(); assert(renderConfig); auto camera = dynamic_cast(renderConfig->getConfig("SecondaryCamera")); - assert(camera); - if (!camera->isEnabled()) { + if (!camera || !camera->isEnabled()) { return; } From cc4d04aaef8d7e1aae0950c4187e26211d7842f1 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 4 May 2018 14:45:57 -0700 Subject: [PATCH 133/192] experimenting --- tests/qml/src/main.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/qml/src/main.cpp b/tests/qml/src/main.cpp index d983353893..d70bb52dde 100644 --- a/tests/qml/src/main.cpp +++ b/tests/qml/src/main.cpp @@ -109,14 +109,6 @@ TestWindow::TestWindow() { Setting::init(); setSurfaceType(QSurface::OpenGLSurface); - QSurfaceFormat format; - format.setDepthBufferSize(24); - format.setStencilBufferSize(8); - format.setVersion(4, 5); - format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); - format.setOption(QSurfaceFormat::DebugContext); - QSurfaceFormat::setDefaultFormat(format); - setFormat(format); qmlRegisterType("Hifi", 1, 0, "TestItem"); @@ -301,6 +293,16 @@ void TestWindow::resizeEvent(QResizeEvent* ev) { } int main(int argc, char** argv) { + + QSurfaceFormat format; + format.setDepthBufferSize(24); + format.setStencilBufferSize(8); + format.setVersion(4, 1); + format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + format.setOption(QSurfaceFormat::DebugContext); + QSurfaceFormat::setDefaultFormat(format); + // setFormat(format); + QGuiApplication app(argc, argv); TestWindow window; return app.exec(); From 00d2f9494bbc493a8efad13ea2cbe29a1983339c Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Fri, 4 May 2018 15:07:20 -0700 Subject: [PATCH 134/192] Change HMACAuth::calculateHash to just call existing methods --- libraries/networking/src/HMACAuth.cpp | 17 ++++------------- libraries/networking/src/HMACAuth.h | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/libraries/networking/src/HMACAuth.cpp b/libraries/networking/src/HMACAuth.cpp index 8e57978b5a..515af9a070 100644 --- a/libraries/networking/src/HMACAuth.cpp +++ b/libraries/networking/src/HMACAuth.cpp @@ -106,21 +106,12 @@ HMACAuth::HMACHash HMACAuth::result() { bool HMACAuth::calculateHash(HMACHash& hashResult, const char* data, int dataLen) { QMutexLocker lock(&_lock); - if (!HMAC_Update(_hmacContext, reinterpret_cast(data), dataLen)) { - qCWarning(networking) << "Error occured calling HMAC_Update"; + if (!addData(data, dataLen)) { + qCWarning(networking) << "Error occured calling HMACAuth::addData()"; assert(false); return false; } - hashResult.resize(EVP_MAX_MD_SIZE); - unsigned int hashLen; - if (HMAC_Final(_hmacContext, &hashResult[0], &hashLen)) { - hashResult.resize((size_t)hashLen); - // Clear state for possible reuse. - HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr); - return true; - } - qCWarning(networking) << "Error occured calling HMAC_Final"; - assert(false); - return false; + hashResult = result(); + return true; } diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h index ec06bfbda2..59870bb7b6 100644 --- a/libraries/networking/src/HMACAuth.h +++ b/libraries/networking/src/HMACAuth.h @@ -35,7 +35,7 @@ public: HMACHash result(); private: - QMutex _lock; + QMutex _lock { QMutex::Recursive }; struct hmac_ctx_st* _hmacContext; AuthMethod _authMethod; }; From 4ebed7605c979eed603a1d7738730537708e3359 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 4 May 2018 10:10:48 -0700 Subject: [PATCH 135/192] MS14758: Fix avatar reset when gifting worn avatar --- interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 08e3e7a552..b54a931c51 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -582,7 +582,7 @@ Rectangle { } lightboxPopup.button2text = "CONFIRM"; lightboxPopup.button2method = function() { - MyAvatar.skeletonModelURL = ''; + MyAvatar.useFullAvatarURL(''); root.activeView = "giftAsset"; lightboxPopup.visible = false; }; From 8480bb962b99bdcf2a5b3e457d9cd36106889b68 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 3 May 2018 13:51:50 -0700 Subject: [PATCH 136/192] Fix for crash deep in QML after useFullAvatarURL Here we avoid calling FSTReader::downloadMapping() from within MyAvatar::useFullAvatarURL(). This prevents the error case where a QEventLoop is entered during QML execution. --- interface/src/avatar/MyAvatar.cpp | 18 +++++++++++------- .../src/model-networking/ModelCache.cpp | 14 +++++++++----- .../src/model-networking/ModelCache.h | 2 ++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 249a765d92..3eef1dac3c 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1473,6 +1473,15 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { std::shared_ptr skeletonConnection = std::make_shared(); *skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() { if (skeletonModelChangeCount == _skeletonModelChangeCount) { + + if (_fullAvatarModelName.isEmpty()) { + // Store the FST file name into preferences + const auto& mapping = _skeletonModel->getGeometry()->getMapping(); + if (mapping.value("name").isValid()) { + _fullAvatarModelName = mapping.value("name").toString(); + } + } + initHeadBones(); _skeletonModel->setCauterizeBoneSet(_headBoneSet); _fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl(); @@ -1535,12 +1544,7 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN if (_fullAvatarURLFromPreferences != fullAvatarURL) { _fullAvatarURLFromPreferences = fullAvatarURL; - if (modelName.isEmpty()) { - QVariantHash fullAvatarFST = FSTReader::downloadMapping(_fullAvatarURLFromPreferences.toString()); - _fullAvatarModelName = fullAvatarFST["name"].toString(); - } else { - _fullAvatarModelName = modelName; - } + _fullAvatarModelName = modelName; } const QString& urlString = fullAvatarURL.toString(); @@ -1548,8 +1552,8 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN setSkeletonModelURL(fullAvatarURL); UserActivityLogger::getInstance().changedModel("skeleton", urlString); } + markIdentityDataChanged(); - } void MyAvatar::setAttachmentData(const QVector& attachmentData) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index f17cdbb7e8..939168f1b1 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -63,16 +63,18 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryMappingResource::downloadFinished", _url.toString(), { { "url", _url.toString() } }); - auto mapping = FSTReader::readMapping(data); + // store parsed contents of FST file + _mapping = FSTReader::readMapping(data); + + QString filename = _mapping.value("filename").toString(); - QString filename = mapping.value("filename").toString(); if (filename.isNull()) { qCDebug(modelnetworking) << "Mapping file" << _url << "has no \"filename\" field"; finishedLoading(false); } else { QUrl url = _url.resolved(filename); - QString texdir = mapping.value(TEXDIR_FIELD).toString(); + QString texdir = _mapping.value(TEXDIR_FIELD).toString(); if (!texdir.isNull()) { if (!texdir.endsWith('/')) { texdir += '/'; @@ -82,7 +84,8 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { _textureBaseUrl = url.resolved(QUrl(".")); } - auto animGraphVariant = mapping.value("animGraphUrl"); + auto animGraphVariant = _mapping.value("animGraphUrl"); + if (animGraphVariant.isValid()) { QUrl fstUrl(animGraphVariant.toString()); if (fstUrl.isValid()) { @@ -95,7 +98,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { } auto modelCache = DependencyManager::get(); - GeometryExtra extra{ mapping, _textureBaseUrl, false }; + GeometryExtra extra{ _mapping, _textureBaseUrl, false }; // Get the raw GeometryResource _geometryResource = modelCache->getResource(url, QUrl(), &extra).staticCast(); @@ -362,6 +365,7 @@ Geometry::Geometry(const Geometry& geometry) { } _animGraphOverrideUrl = geometry._animGraphOverrideUrl; + _mapping = geometry._mapping; } void Geometry::setTextures(const QVariantMap& textureMap) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 9532f39ce0..6978e0077e 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -55,6 +55,7 @@ public: virtual bool areTexturesLoaded() const; const QUrl& getAnimGraphOverrideUrl() const { return _animGraphOverrideUrl; } + const QVariantHash& getMapping() const { return _mapping; } protected: friend class GeometryMappingResource; @@ -68,6 +69,7 @@ protected: NetworkMaterials _materials; QUrl _animGraphOverrideUrl; + QVariantHash _mapping; // parsed contents of FST file. private: mutable bool _areTexturesLoaded { false }; From da9fb9c751a20b8d915ed657c5056cb4fe030d37 Mon Sep 17 00:00:00 2001 From: Clement Date: Thu, 26 Apr 2018 14:27:45 -0700 Subject: [PATCH 137/192] Fix non self-sufficient headers --- assignment-client/src/AssignmentClient.cpp | 14 ++++---- .../src/AssignmentClientMonitor.cpp | 3 +- assignment-client/src/AssignmentDynamic.cpp | 4 +-- assignment-client/src/AssignmentFactory.cpp | 3 +- .../src/audio/AudioMixerSlavePool.cpp | 4 +-- .../src/audio/AvatarAudioStream.cpp | 3 +- assignment-client/src/avatars/AvatarMixer.cpp | 4 +-- .../src/avatars/AvatarMixerClientData.cpp | 4 +-- .../src/avatars/AvatarMixerSlave.cpp | 4 +-- .../src/avatars/AvatarMixerSlave.h | 2 ++ .../src/avatars/AvatarMixerSlavePool.cpp | 4 +-- .../src/avatars/ScriptableAvatar.cpp | 3 +- .../src/entities/EntityServer.cpp | 8 +++-- .../src/messages/MessagesMixer.cpp | 3 +- .../octree/OctreeInboundPacketProcessor.cpp | 3 +- .../src/octree/OctreeSendThread.cpp | 3 +- domain-server/src/DomainServerNodeData.cpp | 4 +-- domain-server/src/DomainServerNodeData.h | 1 + .../src/DomainServerWebSessionData.cpp | 4 +-- gvr-interface/src/Client.cpp | 6 ++-- gvr-interface/src/GVRInterface.cpp | 4 +-- gvr-interface/src/GVRMainWindow.cpp | 4 +-- gvr-interface/src/LoginDialog.cpp | 6 ++-- gvr-interface/src/RenderingClient.cpp | 4 +-- interface/src/AvatarBookmarks.cpp | 3 +- interface/src/Bookmarks.cpp | 4 +-- interface/src/DiscoverabilityManager.cpp | 6 ++-- interface/src/DiscoverabilityManager.h | 4 +++ interface/src/GLCanvas.cpp | 4 +-- interface/src/InterfaceDynamicFactory.cpp | 5 +-- interface/src/InterfaceParentFinder.cpp | 8 ++--- interface/src/LODManager.cpp | 4 +-- interface/src/LocationBookmarks.cpp | 6 ++-- interface/src/Menu.cpp | 4 +-- interface/src/ModelPackager.cpp | 4 +-- interface/src/ModelPackager.h | 2 ++ interface/src/ModelPropertiesDialog.cpp | 4 +-- interface/src/ModelSelector.cpp | 6 ++-- interface/src/SecondaryCamera.cpp | 13 +++++--- interface/src/SecondaryCamera.h | 2 ++ interface/src/SpeechRecognizer.cpp | 3 +- interface/src/SpeechRecognizer.mm | 4 +-- interface/src/UIUtil.cpp | 4 +-- interface/src/audio/AudioScope.cpp | 4 +-- interface/src/avatar/AvatarManager.cpp | 3 +- interface/src/commerce/Ledger.cpp | 9 ++++-- interface/src/commerce/Wallet.cpp | 32 +++++++++---------- interface/src/networking/CloseEventSender.cpp | 4 +-- .../src/octree/OctreePacketProcessor.cpp | 3 +- .../AccountServicesScriptingInterface.cpp | 4 +-- .../AccountServicesScriptingInterface.h | 2 ++ interface/src/scripting/AudioDevices.cpp | 5 ++- .../GooglePolyScriptingInterface.cpp | 4 +-- ...lessVoiceRecognitionScriptingInterface.cpp | 7 ++-- interface/src/ui/DomainConnectionDialog.cpp | 4 +-- interface/src/ui/HMDToolsDialog.cpp | 5 +-- interface/src/ui/LodToolsDialog.cpp | 3 +- interface/src/ui/ModelsBrowser.cpp | 4 +-- interface/src/ui/OctreeStatsDialog.cpp | 5 ++- interface/src/ui/OctreeStatsDialog.h | 3 +- interface/src/ui/OctreeStatsProvider.cpp | 6 ++-- interface/src/ui/OverlayConductor.cpp | 3 +- interface/src/ui/OverlayConductor.h | 6 ++-- interface/src/ui/Snapshot.cpp | 3 +- interface/src/ui/Snapshot.h | 1 + interface/src/ui/SnapshotAnimated.cpp | 3 +- interface/src/ui/SnapshotUploader.cpp | 5 ++- interface/src/ui/StandAloneJSConsole.cpp | 4 +-- interface/src/ui/TestingDialog.cpp | 4 +-- interface/src/ui/overlays/ModelOverlay.cpp | 3 +- libraries/animation/src/AnimClip.cpp | 3 +- libraries/animation/src/AnimExpression.cpp | 6 ++-- libraries/animation/src/AnimNode.cpp | 3 +- libraries/animation/src/AnimNodeLoader.cpp | 3 +- libraries/animation/src/AnimVariant.cpp | 5 +-- libraries/animation/src/AnimationObject.cpp | 3 +- libraries/audio-client/src/AudioClient.cpp | 4 +-- libraries/audio-client/src/AudioIOStats.cpp | 4 +-- libraries/audio/src/AudioFOA.cpp | 3 +- libraries/audio/src/AudioGate.cpp | 3 +- libraries/audio/src/AudioHRTF.cpp | 3 +- libraries/audio/src/AudioLimiter.cpp | 3 +- libraries/audio/src/AudioReverb.cpp | 4 +-- libraries/audio/src/AudioRingBuffer.cpp | 4 +-- libraries/audio/src/AudioSRC.cpp | 3 +- libraries/audio/src/InboundAudioStream.cpp | 3 +- libraries/audio/src/InjectedAudioStream.cpp | 3 +- libraries/audio/src/Sound.cpp | 4 +-- libraries/avatars/src/AvatarHashMap.cpp | 3 +- libraries/baking/src/Baker.cpp | 4 +-- libraries/baking/src/FBXBaker.cpp | 4 +-- libraries/baking/src/JSBaker.cpp | 3 +- libraries/baking/src/JSBaker.h | 2 ++ libraries/baking/src/OBJBaker.cpp | 3 +- libraries/baking/src/TextureBaker.cpp | 4 +-- libraries/baking/src/TextureBaker.h | 1 + .../src/controllers/DeviceProxy.cpp | 17 ---------- .../controllers/src/controllers/Pose.cpp | 4 +-- .../src/controllers/impl/Mapping.cpp | 15 --------- .../src/controllers/impl/Route.cpp | 15 --------- .../impl/conditionals/EndpointConditional.cpp | 15 --------- .../impl/endpoints/ArrayEndpoint.cpp | 15 --------- .../impl/endpoints/StandardEndpoint.cpp | 15 --------- .../impl/filters/ConstrainToIntegerFilter.cpp | 15 --------- .../ConstrainToPositiveIntegerFilter.cpp | 15 --------- .../controllers/impl/filters/InvertFilter.cpp | 15 --------- .../embedded-webserver/src/HTTPConnection.cpp | 4 +-- .../embedded-webserver/src/HTTPManager.cpp | 3 +- .../src/HTTPSConnection.cpp | 3 +- .../embedded-webserver/src/HTTPSManager.cpp | 4 +-- .../entities/src/DeleteEntityOperator.cpp | 4 +-- libraries/entities/src/DeleteEntityOperator.h | 6 ++++ .../entities/src/EntityDynamicInterface.cpp | 3 +- .../entities/src/EntityDynamicInterface.h | 5 ++- libraries/entities/src/EntityEditFilters.cpp | 2 +- .../entities/src/EntityEditPacketSender.cpp | 8 +++-- .../entities/src/EntityItemProperties.cpp | 16 ++++++---- libraries/entities/src/EntityItemProperties.h | 1 + libraries/entities/src/EntityTree.h | 6 ++-- libraries/entities/src/EntityTypes.cpp | 3 +- libraries/entities/src/HazePropertyGroup.cpp | 3 +- libraries/entities/src/LightEntityItem.cpp | 2 +- libraries/entities/src/ModelEntityItem.cpp | 6 ++-- .../entities/src/MovingEntitiesOperator.cpp | 4 +-- .../entities/src/MovingEntitiesOperator.h | 3 +- .../entities/src/ParticleEffectEntityItem.cpp | 3 +- libraries/entities/src/PolyLineEntityItem.cpp | 2 +- libraries/entities/src/ShapeEntityItem.cpp | 2 +- .../entities/src/SkyboxPropertyGroup.cpp | 3 +- libraries/entities/src/SkyboxPropertyGroup.h | 2 ++ libraries/entities/src/TextEntityItem.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 3 +- libraries/fbx/src/FSTReader.cpp | 4 +-- libraries/fbx/src/GLTFReader.cpp | 5 +-- .../src/graphics-scripting/ScriptableMesh.cpp | 16 ++++++---- .../graphics-scripting/ScriptableMeshPart.cpp | 15 +++++---- .../graphics-scripting/ScriptableModel.cpp | 5 ++- libraries/graphics/src/graphics/Haze.cpp | 3 +- libraries/networking/src/AddressManager.cpp | 3 +- libraries/networking/src/Assignment.cpp | 9 +++--- libraries/networking/src/AtpReply.cpp | 3 +- .../networking/src/BandwidthRecorder.cpp | 2 +- .../networking/src/DataServerAccountInfo.cpp | 3 +- libraries/networking/src/HifiSockAddr.cpp | 3 +- .../src/LocationScriptingInterface.cpp | 4 +-- .../networking/src/NetworkAccessManager.cpp | 3 +- libraries/networking/src/Node.cpp | 4 +-- libraries/networking/src/OAuthAccessToken.cpp | 4 +-- .../src/OAuthNetworkAccessManager.cpp | 4 +-- libraries/networking/src/PacketSender.cpp | 3 +- .../networking/src/RSAKeypairGenerator.cpp | 4 +-- .../src/ReceivedPacketProcessor.cpp | 3 +- .../networking/src/ReceivedPacketProcessor.h | 4 +++ .../networking/src/ThreadedAssignment.cpp | 4 +-- .../networking/src/UserActivityLogger.cpp | 7 ++-- .../networking/src/WalletTransaction.cpp | 5 ++- .../networking/src/udt/ConnectionStats.cpp | 3 +- libraries/octree/src/Octree.cpp | 3 +- .../octree/src/OctreeEditPacketSender.cpp | 3 +- libraries/octree/src/OctreeElement.cpp | 5 +-- libraries/octree/src/OctreePacketData.cpp | 3 +- libraries/octree/src/OctreePersistThread.cpp | 3 +- libraries/octree/src/OctreeProcessor.cpp | 5 +-- libraries/octree/src/OctreeSceneStats.cpp | 4 +-- .../octree/src/OctreeScriptingInterface.cpp | 4 +-- libraries/physics/src/EntityMotionState.cpp | 3 +- libraries/physics/src/MeshMassProperties.cpp | 4 +-- libraries/physics/src/ObjectAction.cpp | 4 +-- libraries/physics/src/ObjectActionOffset.cpp | 4 +-- libraries/physics/src/ObjectActionTractor.cpp | 4 +-- .../src/ObjectActionTravelOriented.cpp | 3 +- libraries/physics/src/ObjectConstraint.cpp | 4 +-- .../src/ObjectConstraintBallSocket.cpp | 3 +- .../physics/src/ObjectConstraintConeTwist.cpp | 3 +- .../physics/src/ObjectConstraintHinge.cpp | 3 +- .../physics/src/ObjectConstraintSlider.cpp | 3 +- libraries/physics/src/ObjectDynamic.cpp | 4 +-- libraries/physics/src/ObjectMotionState.cpp | 3 +- libraries/physics/src/PhysicsEngine.cpp | 4 +-- libraries/physics/src/ShapeFactory.cpp | 3 +- libraries/physics/src/ShapeManager.cpp | 5 +-- .../physics/src/ThreadSafeDynamicsWorld.cpp | 3 +- .../recording/src/recording/ClipCache.cpp | 3 +- .../src/AmbientOcclusionEffect.cpp | 7 ++-- .../render-utils/src/AntialiasingEffect.cpp | 2 +- libraries/render-utils/src/LightStage.cpp | 4 +-- .../render-utils/src/RenderPipelines.cpp | 6 ++-- libraries/render/src/render/DrawTask.cpp | 6 ++-- libraries/render/src/render/ShapePipeline.cpp | 7 ++-- .../script-engine/src/ArrayBufferClass.cpp | 4 +-- .../src/ArrayBufferPrototype.cpp | 3 +- libraries/script-engine/src/BatchLoader.cpp | 8 +++-- .../src/ConsoleScriptingInterface.cpp | 4 ++- libraries/script-engine/src/DataViewClass.cpp | 6 ++-- .../script-engine/src/DataViewPrototype.cpp | 5 +-- libraries/script-engine/src/EventTypes.cpp | 4 +-- libraries/script-engine/src/KeyEvent.cpp | 4 +-- libraries/script-engine/src/Mat4.cpp | 9 ++++-- .../script-engine/src/MenuItemProperties.cpp | 4 +-- libraries/script-engine/src/MouseEvent.cpp | 6 ++-- libraries/script-engine/src/MouseEvent.h | 5 ++- libraries/script-engine/src/Quat.cpp | 7 ++-- libraries/script-engine/src/Quat.h | 2 ++ .../script-engine/src/ScriptAudioInjector.cpp | 3 +- libraries/script-engine/src/ScriptEngine.cpp | 3 +- libraries/script-engine/src/ScriptUUID.cpp | 3 +- libraries/script-engine/src/ScriptUUID.h | 1 + libraries/script-engine/src/SpatialEvent.cpp | 6 ++-- libraries/script-engine/src/TouchEvent.cpp | 5 ++- libraries/script-engine/src/TouchEvent.h | 7 +++- .../script-engine/src/TypedArrayPrototype.cpp | 4 +-- libraries/script-engine/src/TypedArrays.cpp | 4 +-- .../src/UndoStackScriptingInterface.cpp | 4 +-- libraries/script-engine/src/Vec3.cpp | 7 ++-- .../script-engine/src/WebSocketClass.cpp | 3 +- .../src/WebSocketServerClass.cpp | 3 +- libraries/script-engine/src/WheelEvent.cpp | 8 ++--- libraries/script-engine/src/WheelEvent.h | 6 +++- .../script-engine/src/XMLHttpRequestClass.cpp | 3 +- libraries/shared/src/AACube.cpp | 3 +- libraries/shared/src/CubeProjectedPolygon.cpp | 4 +-- libraries/shared/src/GPUIdent.cpp | 6 ++-- libraries/shared/src/GPUIdent.h | 2 ++ libraries/shared/src/GenericThread.cpp | 5 ++- libraries/shared/src/Gzip.cpp | 3 +- libraries/shared/src/LogUtils.cpp | 4 +-- libraries/shared/src/OctalCode.cpp | 3 +- libraries/shared/src/PIDController.cpp | 9 ++++-- libraries/shared/src/PerfStat.cpp | 4 +-- libraries/shared/src/SimpleMovingAverage.cpp | 3 +- libraries/shared/src/StDev.cpp | 4 +-- libraries/shared/src/StreamUtils.cpp | 4 +-- libraries/shared/src/TriangleSet.cpp | 2 +- .../shared/src/VariantMapToScriptValue.cpp | 5 +-- libraries/shared/src/ViewFrustum.cpp | 6 ++-- libraries/shared/src/shared/StringHelpers.cpp | 4 +-- plugins/pcmCodec/src/PCMCodecManager.cpp | 4 +-- tests/jitter/src/JitterTests.cpp | 4 +-- tests/networking/src/ResourceTests.cpp | 4 +-- .../src/SequenceNumberStatsTests.cpp | 4 +-- tests/octree/src/AABoxCubeTests.cpp | 4 +-- tests/octree/src/ModelTests.cpp | 6 ++-- tests/octree/src/OctreeTests.cpp | 4 +-- tests/physics/src/ShapeInfoTests.cpp | 4 +-- tests/physics/src/ShapeManagerTests.cpp | 5 +-- tests/shared/src/AABoxTests.cpp | 4 +-- tests/shared/src/AACubeTests.cpp | 4 +-- tests/shared/src/DualQuaternionTests.cpp | 4 +-- tests/shared/src/GeometryUtilTests.cpp | 4 +-- tools/ac-client/src/ACClientApp.cpp | 5 +-- tools/atp-client/src/ATPClientApp.cpp | 4 +-- tools/ice-client/src/ICEClientApp.cpp | 5 +-- tools/oven/src/BakerCLI.cpp | 3 +- tools/oven/src/OvenCLIApplication.cpp | 4 +-- tools/oven/src/ui/BakeWidget.cpp | 4 +-- tools/oven/src/ui/DomainBakeWidget.cpp | 4 +-- tools/oven/src/ui/ModelBakeWidget.cpp | 3 +- tools/oven/src/ui/ModesWidget.cpp | 4 +-- tools/oven/src/ui/OvenMainWindow.cpp | 4 +-- tools/oven/src/ui/ResultsWindow.cpp | 4 +-- tools/oven/src/ui/SkyboxBakeWidget.cpp | 6 ++-- tools/vhacd-util/src/VHACDUtilApp.cpp | 5 ++- 263 files changed, 632 insertions(+), 603 deletions(-) delete mode 100644 libraries/controllers/src/controllers/DeviceProxy.cpp delete mode 100644 libraries/controllers/src/controllers/impl/Mapping.cpp delete mode 100644 libraries/controllers/src/controllers/impl/Route.cpp delete mode 100644 libraries/controllers/src/controllers/impl/conditionals/EndpointConditional.cpp delete mode 100644 libraries/controllers/src/controllers/impl/endpoints/ArrayEndpoint.cpp delete mode 100644 libraries/controllers/src/controllers/impl/endpoints/StandardEndpoint.cpp delete mode 100644 libraries/controllers/src/controllers/impl/filters/ConstrainToIntegerFilter.cpp delete mode 100644 libraries/controllers/src/controllers/impl/filters/ConstrainToPositiveIntegerFilter.cpp delete mode 100644 libraries/controllers/src/controllers/impl/filters/InvertFilter.cpp diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index efced972a0..41e42aa0a1 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AssignmentClient.h" + #include #include @@ -32,16 +34,14 @@ #include #include #include - -#include "AssignmentFactory.h" -#include "AssignmentDynamicFactory.h" - -#include "AssignmentClient.h" -#include "AssignmentClientLogging.h" -#include "avatars/ScriptableAvatar.h" #include #include +#include "AssignmentClientLogging.h" +#include "AssignmentDynamicFactory.h" +#include "AssignmentFactory.h" +#include "avatars/ScriptableAvatar.h" + const QString ASSIGNMENT_CLIENT_TARGET_NAME = "assignment-client"; const long long ASSIGNMENT_REQUEST_INTERVAL_MSECS = 1 * 1000; diff --git a/assignment-client/src/AssignmentClientMonitor.cpp b/assignment-client/src/AssignmentClientMonitor.cpp index 1868ccfafe..2847d4ebf1 100644 --- a/assignment-client/src/AssignmentClientMonitor.cpp +++ b/assignment-client/src/AssignmentClientMonitor.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AssignmentClientMonitor.h" + #include #include @@ -19,7 +21,6 @@ #include #include -#include "AssignmentClientMonitor.h" #include "AssignmentClientApp.h" #include "AssignmentClientChildData.h" #include "SharedUtil.h" diff --git a/assignment-client/src/AssignmentDynamic.cpp b/assignment-client/src/AssignmentDynamic.cpp index 7adbd55c39..447097ac74 100644 --- a/assignment-client/src/AssignmentDynamic.cpp +++ b/assignment-client/src/AssignmentDynamic.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "EntitySimulation.h" - #include "AssignmentDynamic.h" +#include "EntitySimulation.h" + AssignmentDynamic::AssignmentDynamic(EntityDynamicType type, const QUuid& id, EntityItemPointer ownerEntity) : EntityDynamicInterface(type, id), _data(QByteArray()), diff --git a/assignment-client/src/AssignmentFactory.cpp b/assignment-client/src/AssignmentFactory.cpp index 38eb72649f..405039d833 100644 --- a/assignment-client/src/AssignmentFactory.cpp +++ b/assignment-client/src/AssignmentFactory.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AssignmentFactory.h" + #include #include "Agent.h" #include "assets/AssetServer.h" -#include "AssignmentFactory.h" #include "audio/AudioMixer.h" #include "avatars/AvatarMixer.h" #include "entities/EntityServer.h" diff --git a/assignment-client/src/audio/AudioMixerSlavePool.cpp b/assignment-client/src/audio/AudioMixerSlavePool.cpp index e28c96e259..dfe7ef56aa 100644 --- a/assignment-client/src/audio/AudioMixerSlavePool.cpp +++ b/assignment-client/src/audio/AudioMixerSlavePool.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioMixerSlavePool.h" + #include #include -#include "AudioMixerSlavePool.h" - void AudioMixerSlaveThread::run() { while (true) { wait(); diff --git a/assignment-client/src/audio/AvatarAudioStream.cpp b/assignment-client/src/audio/AvatarAudioStream.cpp index 42495b4dd0..22ea8c0617 100644 --- a/assignment-client/src/audio/AvatarAudioStream.cpp +++ b/assignment-client/src/audio/AvatarAudioStream.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarAudioStream.h" + #include #include "AudioLogging.h" -#include "AvatarAudioStream.h" AvatarAudioStream::AvatarAudioStream(bool isStereo, int numStaticJitterFrames) : PositionalAudioStream(PositionalAudioStream::Microphone, isStereo, numStaticJitterFrames) {} diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index d74c76032d..9b5c4d4f30 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarMixer.h" + #include #include #include @@ -31,8 +33,6 @@ #include #include -#include "AvatarMixer.h" - const QString AVATAR_MIXER_LOGGING_NAME = "avatar-mixer"; // FIXME - what we'd actually like to do is send to users at ~50% of their present rate down to 30hz. Assume 90 for now. diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index d5a8b37742..e185fe9167 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarMixerClientData.h" + #include #include #include -#include "AvatarMixerClientData.h" - AvatarMixerClientData::AvatarMixerClientData(const QUuid& nodeID) : NodeData(nodeID) { diff --git a/assignment-client/src/avatars/AvatarMixerSlave.cpp b/assignment-client/src/avatars/AvatarMixerSlave.cpp index 30d94ed772..984884adb2 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlave.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarMixerSlave.h" + #include #include @@ -28,10 +30,8 @@ #include #include - #include "AvatarMixer.h" #include "AvatarMixerClientData.h" -#include "AvatarMixerSlave.h" void AvatarMixerSlave::configure(ConstIter begin, ConstIter end) { _begin = begin; diff --git a/assignment-client/src/avatars/AvatarMixerSlave.h b/assignment-client/src/avatars/AvatarMixerSlave.h index bdddd5ceab..7be119c4b2 100644 --- a/assignment-client/src/avatars/AvatarMixerSlave.h +++ b/assignment-client/src/avatars/AvatarMixerSlave.h @@ -12,6 +12,8 @@ #ifndef hifi_AvatarMixerSlave_h #define hifi_AvatarMixerSlave_h +#include + class AvatarMixerClientData; class AvatarMixerSlaveStats { diff --git a/assignment-client/src/avatars/AvatarMixerSlavePool.cpp b/assignment-client/src/avatars/AvatarMixerSlavePool.cpp index 25b88686b7..962bba21d2 100644 --- a/assignment-client/src/avatars/AvatarMixerSlavePool.cpp +++ b/assignment-client/src/avatars/AvatarMixerSlavePool.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarMixerSlavePool.h" + #include #include -#include "AvatarMixerSlavePool.h" - void AvatarMixerSlaveThread::run() { while (true) { wait(); diff --git a/assignment-client/src/avatars/ScriptableAvatar.cpp b/assignment-client/src/avatars/ScriptableAvatar.cpp index 1f3f770867..e7210db83a 100644 --- a/assignment-client/src/avatars/ScriptableAvatar.cpp +++ b/assignment-client/src/avatars/ScriptableAvatar.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ScriptableAvatar.h" + #include #include #include @@ -16,7 +18,6 @@ #include #include #include -#include "ScriptableAvatar.h" QByteArray ScriptableAvatar::toByteArrayStateful(AvatarDataDetail dataDetail, bool dropFaceTracking) { diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index 70fad03d67..c108dad6cf 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -9,21 +9,23 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EntityServer.h" + #include #include +#include +#include + #include #include #include #include #include #include -#include -#include #include #include "AssignmentParentFinder.h" #include "EntityNodeData.h" -#include "EntityServer.h" #include "EntityServerConsts.h" #include "EntityTreeSendThread.h" diff --git a/assignment-client/src/messages/MessagesMixer.cpp b/assignment-client/src/messages/MessagesMixer.cpp index 4bf708cf34..c11c8f40a0 100644 --- a/assignment-client/src/messages/MessagesMixer.cpp +++ b/assignment-client/src/messages/MessagesMixer.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "MessagesMixer.h" + #include #include #include @@ -16,7 +18,6 @@ #include #include #include -#include "MessagesMixer.h" const QString MESSAGES_MIXER_LOGGING_NAME = "messages-mixer"; diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp index bce6e7fe44..ef532bb33f 100644 --- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp +++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeInboundPacketProcessor.h" + #include #include @@ -17,7 +19,6 @@ #include "OctreeServer.h" #include "OctreeServerConsts.h" -#include "OctreeInboundPacketProcessor.h" static QUuid DEFAULT_NODE_ID_REF; const quint64 TOO_LONG_SINCE_LAST_NACK = 1 * USECS_PER_SECOND; diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 482b20272a..e9aa44b970 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeSendThread.h" + #include #include @@ -17,7 +19,6 @@ #include #include -#include "OctreeSendThread.h" #include "OctreeServer.h" #include "OctreeServerConsts.h" #include "OctreeLogging.h" diff --git a/domain-server/src/DomainServerNodeData.cpp b/domain-server/src/DomainServerNodeData.cpp index 974d4a59c3..486b51f9eb 100644 --- a/domain-server/src/DomainServerNodeData.cpp +++ b/domain-server/src/DomainServerNodeData.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DomainServerNodeData.h" + #include #include #include @@ -17,8 +19,6 @@ #include -#include "DomainServerNodeData.h" - DomainServerNodeData::StringPairHash DomainServerNodeData::_overrideHash; DomainServerNodeData::DomainServerNodeData() { diff --git a/domain-server/src/DomainServerNodeData.h b/domain-server/src/DomainServerNodeData.h index db41c77cf2..6b8e9a1718 100644 --- a/domain-server/src/DomainServerNodeData.h +++ b/domain-server/src/DomainServerNodeData.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/domain-server/src/DomainServerWebSessionData.cpp b/domain-server/src/DomainServerWebSessionData.cpp index 3744af77f3..90eea17bec 100644 --- a/domain-server/src/DomainServerWebSessionData.cpp +++ b/domain-server/src/DomainServerWebSessionData.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DomainServerWebSessionData.h" + #include #include #include #include -#include "DomainServerWebSessionData.h" - DomainServerWebSessionData::DomainServerWebSessionData() : _username(), _roles() diff --git a/gvr-interface/src/Client.cpp b/gvr-interface/src/Client.cpp index 65238ad784..8f064c7fd5 100644 --- a/gvr-interface/src/Client.cpp +++ b/gvr-interface/src/Client.cpp @@ -9,14 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Client.h" + #include #include #include #include #include -#include "Client.h" - Client::Client(QObject* parent) : QObject(parent) { @@ -70,4 +70,4 @@ void Client::processDatagrams() { processVerifiedPacket(senderSockAddr, incomingPacket); } } -} \ No newline at end of file +} diff --git a/gvr-interface/src/GVRInterface.cpp b/gvr-interface/src/GVRInterface.cpp index 3d58396322..f9a29d4ac4 100644 --- a/gvr-interface/src/GVRInterface.cpp +++ b/gvr-interface/src/GVRInterface.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "GVRInterface.h" + #ifdef ANDROID #include @@ -32,8 +34,6 @@ #include "GVRMainWindow.h" #include "RenderingClient.h" -#include "GVRInterface.h" - static QString launchURLString = QString(); #ifdef ANDROID diff --git a/gvr-interface/src/GVRMainWindow.cpp b/gvr-interface/src/GVRMainWindow.cpp index 7a36aba66e..5495354233 100644 --- a/gvr-interface/src/GVRMainWindow.cpp +++ b/gvr-interface/src/GVRMainWindow.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "GVRMainWindow.h" + #include #include #include @@ -37,8 +39,6 @@ const float LIBOVR_LONG_PRESS_DURATION = 0.75f; #include "LoginDialog.h" #include "RenderingClient.h" -#include "GVRMainWindow.h" - GVRMainWindow::GVRMainWindow(QWidget* parent) : diff --git a/gvr-interface/src/LoginDialog.cpp b/gvr-interface/src/LoginDialog.cpp index 95b7451bcb..d4efd425bd 100644 --- a/gvr-interface/src/LoginDialog.cpp +++ b/gvr-interface/src/LoginDialog.cpp @@ -9,14 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LoginDialog.h" + #include #include #include #include #include -#include "LoginDialog.h" - LoginDialog::LoginDialog(QWidget* parent) : QDialog(parent) { @@ -66,4 +66,4 @@ void LoginDialog::setupGUI() { void LoginDialog::loginButtonClicked() { emit credentialsEntered(_usernameLineEdit->text(), _passwordLineEdit->text()); close(); -} \ No newline at end of file +} diff --git a/gvr-interface/src/RenderingClient.cpp b/gvr-interface/src/RenderingClient.cpp index f04be5cb7f..4c691a48e6 100644 --- a/gvr-interface/src/RenderingClient.cpp +++ b/gvr-interface/src/RenderingClient.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "RenderingClient.h" + #include #include @@ -17,8 +19,6 @@ #include #include -#include "RenderingClient.h" - RenderingClient* RenderingClient::_instance = NULL; RenderingClient::RenderingClient(QObject *parent, const QString& launchURLString) : diff --git a/interface/src/AvatarBookmarks.cpp b/interface/src/AvatarBookmarks.cpp index 7845158a80..8e15de673f 100644 --- a/interface/src/AvatarBookmarks.cpp +++ b/interface/src/AvatarBookmarks.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarBookmarks.h" + #include #include #include @@ -27,7 +29,6 @@ #include "MainWindow.h" #include "Menu.h" -#include "AvatarBookmarks.h" #include "InterfaceLogging.h" #include "QVariantGLM.h" diff --git a/interface/src/Bookmarks.cpp b/interface/src/Bookmarks.cpp index f48b5e1f5b..6e99b81e50 100644 --- a/interface/src/Bookmarks.cpp +++ b/interface/src/Bookmarks.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Bookmarks.h" + #include #include #include @@ -22,8 +24,6 @@ #include "Menu.h" #include "InterfaceLogging.h" -#include "Bookmarks.h" - Bookmarks::Bookmarks() : _isMenuSorted(false) { diff --git a/interface/src/DiscoverabilityManager.cpp b/interface/src/DiscoverabilityManager.cpp index b3c059de7f..684539145e 100644 --- a/interface/src/DiscoverabilityManager.cpp +++ b/interface/src/DiscoverabilityManager.cpp @@ -9,7 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DiscoverabilityManager.h" + #include +#include #include #include @@ -21,11 +24,8 @@ #include #include "Crashpad.h" -#include "DiscoverabilityManager.h" #include "Menu.h" -#include - const Discoverability::Mode DEFAULT_DISCOVERABILITY_MODE = Discoverability::Connections; DiscoverabilityManager::DiscoverabilityManager() : diff --git a/interface/src/DiscoverabilityManager.h b/interface/src/DiscoverabilityManager.h index 96190b25d9..0c62ad5663 100644 --- a/interface/src/DiscoverabilityManager.h +++ b/interface/src/DiscoverabilityManager.h @@ -12,9 +12,13 @@ #ifndef hifi_DiscoverabilityManager_h #define hifi_DiscoverabilityManager_h +#include + #include #include +class QNetworkReply; + namespace Discoverability { enum Mode { None, diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index ec96f7c5d4..0d087c9b48 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// FIXME ordering of headers -#include "Application.h" #include "GLCanvas.h" +#include "Application.h" + bool GLCanvas::event(QEvent* event) { if (QEvent::Paint == event->type() && qApp->isAboutToQuit()) { return true; diff --git a/interface/src/InterfaceDynamicFactory.cpp b/interface/src/InterfaceDynamicFactory.cpp index b7861b56c8..e0d912b252 100644 --- a/interface/src/InterfaceDynamicFactory.cpp +++ b/interface/src/InterfaceDynamicFactory.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - +#include "InterfaceDynamicFactory.h" #include #include @@ -22,9 +22,6 @@ #include #include -#include "InterfaceDynamicFactory.h" - - EntityDynamicPointer interfaceDynamicFactory(EntityDynamicType type, const QUuid& id, EntityItemPointer ownerEntity) { switch (type) { case DYNAMIC_TYPE_NONE: diff --git a/interface/src/InterfaceParentFinder.cpp b/interface/src/InterfaceParentFinder.cpp index 14088bc716..b9be58f04b 100644 --- a/interface/src/InterfaceParentFinder.cpp +++ b/interface/src/InterfaceParentFinder.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "InterfaceParentFinder.h" + #include +#include +#include #include #include -#include -#include - -#include "InterfaceParentFinder.h" SpatiallyNestableWeakPointer InterfaceParentFinder::find(QUuid parentID, bool& success, SpatialParentTree* entityTree) const { SpatiallyNestableWeakPointer parent; diff --git a/interface/src/LODManager.cpp b/interface/src/LODManager.cpp index d7d73e962a..d06ba14bcf 100644 --- a/interface/src/LODManager.cpp +++ b/interface/src/LODManager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LODManager.h" + #include #include #include @@ -17,8 +19,6 @@ #include "ui/DialogsManager.h" #include "InterfaceLogging.h" -#include "LODManager.h" - Setting::Handle desktopLODDecreaseFPS("desktopLODDecreaseFPS", DEFAULT_DESKTOP_LOD_DOWN_FPS); Setting::Handle hmdLODDecreaseFPS("hmdLODDecreaseFPS", DEFAULT_HMD_LOD_DOWN_FPS); diff --git a/interface/src/LocationBookmarks.cpp b/interface/src/LocationBookmarks.cpp index 285f533a7f..f29a8f18f9 100644 --- a/interface/src/LocationBookmarks.cpp +++ b/interface/src/LocationBookmarks.cpp @@ -9,10 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LocationBookmarks.h" + #include #include #include #include +#include #include #include @@ -21,9 +24,6 @@ #include "MainWindow.h" #include "Menu.h" -#include "LocationBookmarks.h" -#include - const QString LocationBookmarks::HOME_BOOKMARK = "Home"; LocationBookmarks::LocationBookmarks() { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 60d5abf260..bf0fc05350 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Menu.h" + #include #include #include @@ -52,8 +54,6 @@ #include "SpeechRecognizer.h" #endif -#include "Menu.h" - extern bool DEV_DECIMATE_TEXTURES; Menu* Menu::getInstance() { diff --git a/interface/src/ModelPackager.cpp b/interface/src/ModelPackager.cpp index 0e34eebc80..3a5d92eb8c 100644 --- a/interface/src/ModelPackager.cpp +++ b/interface/src/ModelPackager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelPackager.h" + #include #include #include @@ -21,8 +23,6 @@ #include "ModelPropertiesDialog.h" #include "InterfaceLogging.h" -#include "ModelPackager.h" - static const int MAX_TEXTURE_SIZE = 1024; void copyDirectoryContent(QDir& from, QDir& to) { diff --git a/interface/src/ModelPackager.h b/interface/src/ModelPackager.h index 60b3825c4d..acd4d85f68 100644 --- a/interface/src/ModelPackager.h +++ b/interface/src/ModelPackager.h @@ -17,6 +17,8 @@ #include "ui/ModelsBrowser.h" +class FBXGeometry; + class ModelPackager : public QObject { public: static bool package(); diff --git a/interface/src/ModelPropertiesDialog.cpp b/interface/src/ModelPropertiesDialog.cpp index 35b07aa2b2..8984f89d07 100644 --- a/interface/src/ModelPropertiesDialog.cpp +++ b/interface/src/ModelPropertiesDialog.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelPropertiesDialog.h" + #include #include #include @@ -23,8 +25,6 @@ #include #include -#include "ModelPropertiesDialog.h" - ModelPropertiesDialog::ModelPropertiesDialog(FSTReader::ModelType modelType, const QVariantHash& originalMapping, const QString& basePath, const FBXGeometry& geometry) : diff --git a/interface/src/ModelSelector.cpp b/interface/src/ModelSelector.cpp index 2f85849fbe..7d91359a11 100644 --- a/interface/src/ModelSelector.cpp +++ b/interface/src/ModelSelector.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelSelector.h" + #include #include #include @@ -16,8 +18,6 @@ #include #include -#include "ModelSelector.h" - static const QString AVATAR_HEAD_AND_BODY_STRING = "Avatar Body with Head"; static const QString AVATAR_ATTACHEMENT_STRING = "Avatar Attachment"; static const QString ENTITY_MODEL_STRING = "Entity Model"; @@ -82,4 +82,4 @@ void ModelSelector::browse() { _browseButton->setText(fileInfo.fileName()); lastModelBrowseLocation.set(fileInfo.path()); } -} \ No newline at end of file +} diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index a4bf0bcefe..acde535d2b 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -9,13 +9,16 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Application.h" #include "SecondaryCamera.h" -#include -#include -#include + #include +#include +#include +#include + +#include "Application.h" + using RenderArgsPointer = std::shared_ptr; void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { @@ -213,4 +216,4 @@ void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inp task.addJob("RenderDeferredTask", items); } task.addJob("EndSecondaryCamera", cachedArg); -} \ No newline at end of file +} diff --git a/interface/src/SecondaryCamera.h b/interface/src/SecondaryCamera.h index 026b72d865..3d9e52617c 100644 --- a/interface/src/SecondaryCamera.h +++ b/interface/src/SecondaryCamera.h @@ -17,6 +17,8 @@ #include #include #include +#include +#include class MainRenderTask { public: diff --git a/interface/src/SpeechRecognizer.cpp b/interface/src/SpeechRecognizer.cpp index f5d0cb9e24..4815d20a83 100644 --- a/interface/src/SpeechRecognizer.cpp +++ b/interface/src/SpeechRecognizer.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SpeechRecognizer.h" + #include #include #include "InterfaceLogging.h" -#include "SpeechRecognizer.h" #if defined(Q_OS_WIN) diff --git a/interface/src/SpeechRecognizer.mm b/interface/src/SpeechRecognizer.mm index 038bcce3e4..6b9da6f3e8 100644 --- a/interface/src/SpeechRecognizer.mm +++ b/interface/src/SpeechRecognizer.mm @@ -16,10 +16,10 @@ #import #import -#include - #include "SpeechRecognizer.h" +#include + @interface SpeechRecognizerDelegate : NSObject { SpeechRecognizer* _listener; } diff --git a/interface/src/UIUtil.cpp b/interface/src/UIUtil.cpp index 7b50975c92..a27bd6c5db 100644 --- a/interface/src/UIUtil.cpp +++ b/interface/src/UIUtil.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "UIUtil.h" + #include #include -#include "UIUtil.h" - int UIUtil::getWindowTitleBarHeight(const QWidget* window) { QStyleOptionTitleBar options; options.titleBarState = 1; diff --git a/interface/src/audio/AudioScope.cpp b/interface/src/audio/AudioScope.cpp index 1a2e867d51..1750c00d37 100644 --- a/interface/src/audio/AudioScope.cpp +++ b/interface/src/audio/AudioScope.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioScope.h" + #include #include @@ -19,8 +21,6 @@ #include #include -#include "AudioScope.h" - static const unsigned int DEFAULT_FRAMES_PER_SCOPE = 5; static const unsigned int MULTIPLIER_SCOPE_HEIGHT = 20; static const unsigned int SCOPE_HEIGHT = 2 * 15 * MULTIPLIER_SCOPE_HEIGHT; diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index d24618fada..094b3bb67b 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarManager.h" + #include #include @@ -38,7 +40,6 @@ #include #include "Application.h" -#include "AvatarManager.h" #include "InterfaceLogging.h" #include "Menu.h" #include "MyAvatar.h" diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index fde8c49933..f791ea25bc 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -9,16 +9,19 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Ledger.h" + #include #include #include #include -#include "Wallet.h" -#include "Ledger.h" -#include "CommerceLogging.h" + #include #include +#include "Wallet.h" +#include "CommerceLogging.h" + // inventory answers {status: 'success', data: {assets: [{id: "guid", title: "name", preview: "url"}....]}} // balance answers {status: 'success', data: {balance: integer}} // buy and receive_at answer {status: 'success'} diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 35e6ca1c92..982adb4b5e 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -9,22 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "CommerceLogging.h" -#include "Ledger.h" #include "Wallet.h" -#include "Application.h" -#include "ui/SecurityImageProvider.h" -#include "scripting/HMDScriptingInterface.h" -#include - -#include -#include -#include - -#include -#include -#include -#include #include #include @@ -33,7 +18,6 @@ #include #include #include - // I know, right? But per https://www.openssl.org/docs/faq.html // this avoids OPENSSL_Uplink(00007FF847238000,08): no OPENSSL_Applink // at runtime. @@ -41,6 +25,22 @@ #include #endif +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Application.h" +#include "CommerceLogging.h" +#include "Ledger.h" +#include "ui/SecurityImageProvider.h" +#include "scripting/HMDScriptingInterface.h" + static const char* KEY_FILE = "hifikey"; static const char* INSTRUCTIONS_FILE = "backup_instructions.html"; static const char* IMAGE_HEADER = "-----BEGIN SECURITY IMAGE-----\n"; diff --git a/interface/src/networking/CloseEventSender.cpp b/interface/src/networking/CloseEventSender.cpp index fe939afe05..16549d5510 100644 --- a/interface/src/networking/CloseEventSender.cpp +++ b/interface/src/networking/CloseEventSender.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "CloseEventSender.h" + #include #include #include @@ -22,8 +24,6 @@ #include #include -#include "CloseEventSender.h" - QNetworkRequest createNetworkRequest() { QNetworkRequest request; diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index 0c2883a9a4..7d38e29710 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreePacketProcessor.h" + #include #include "Application.h" #include "Menu.h" -#include "OctreePacketProcessor.h" #include "SceneScriptingInterface.h" OctreePacketProcessor::OctreePacketProcessor() { diff --git a/interface/src/scripting/AccountServicesScriptingInterface.cpp b/interface/src/scripting/AccountServicesScriptingInterface.cpp index fc293098bb..3939fce91d 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.cpp +++ b/interface/src/scripting/AccountServicesScriptingInterface.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AccountServicesScriptingInterface.h" + #include "AccountManager.h" #include "Application.h" #include "DiscoverabilityManager.h" #include "ResourceCache.h" -#include "AccountServicesScriptingInterface.h" - AccountServicesScriptingInterface::AccountServicesScriptingInterface() { auto accountManager = DependencyManager::get(); connect(accountManager.data(), &AccountManager::usernameChanged, this, &AccountServicesScriptingInterface::onUsernameChanged); diff --git a/interface/src/scripting/AccountServicesScriptingInterface.h b/interface/src/scripting/AccountServicesScriptingInterface.h index 5774ee1da5..fb3c329def 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.h +++ b/interface/src/scripting/AccountServicesScriptingInterface.h @@ -18,6 +18,8 @@ #include #include #include + +#include #include class DownloadInfoResult { diff --git a/interface/src/scripting/AudioDevices.cpp b/interface/src/scripting/AudioDevices.cpp index a3c80bf1b6..f08a0bf382 100644 --- a/interface/src/scripting/AudioDevices.cpp +++ b/interface/src/scripting/AudioDevices.cpp @@ -9,18 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioDevices.h" + #include #include #include #include -#include "AudioDevices.h" - #include "Application.h" #include "AudioClient.h" #include "Audio.h" - #include "UserActivityLogger.h" using namespace scripting; diff --git a/interface/src/scripting/GooglePolyScriptingInterface.cpp b/interface/src/scripting/GooglePolyScriptingInterface.cpp index 8ed5d59d07..fde2676986 100644 --- a/interface/src/scripting/GooglePolyScriptingInterface.cpp +++ b/interface/src/scripting/GooglePolyScriptingInterface.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "GooglePolyScriptingInterface.h" + #include #include #include @@ -20,9 +22,7 @@ #include #include #include -#include -#include "GooglePolyScriptingInterface.h" #include "ScriptEngineLogging.h" const QString LIST_POLY_URL = "https://poly.googleapis.com/v1/assets?"; diff --git a/interface/src/scripting/LimitlessVoiceRecognitionScriptingInterface.cpp b/interface/src/scripting/LimitlessVoiceRecognitionScriptingInterface.cpp index ebb5ca9280..2692608106 100644 --- a/interface/src/scripting/LimitlessVoiceRecognitionScriptingInterface.cpp +++ b/interface/src/scripting/LimitlessVoiceRecognitionScriptingInterface.cpp @@ -9,13 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LimitlessVoiceRecognitionScriptingInterface.h" + #include #include -#include -#include -#include "LimitlessVoiceRecognitionScriptingInterface.h" +#include "InterfaceLogging.h" +#include "ui/AvatarInputs.h" const float LimitlessVoiceRecognitionScriptingInterface::_audioLevelThreshold = 0.33f; const int LimitlessVoiceRecognitionScriptingInterface::_voiceTimeoutDuration = 2000; diff --git a/interface/src/ui/DomainConnectionDialog.cpp b/interface/src/ui/DomainConnectionDialog.cpp index c0471dc5e1..57a8d41257 100644 --- a/interface/src/ui/DomainConnectionDialog.cpp +++ b/interface/src/ui/DomainConnectionDialog.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DomainConnectionDialog.h" + #include #include #include @@ -17,8 +19,6 @@ #include #include -#include "DomainConnectionDialog.h" - DomainConnectionDialog::DomainConnectionDialog(QWidget* parent) : QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint) { diff --git a/interface/src/ui/HMDToolsDialog.cpp b/interface/src/ui/HMDToolsDialog.cpp index 55c321723e..63794da60f 100644 --- a/interface/src/ui/HMDToolsDialog.cpp +++ b/interface/src/ui/HMDToolsDialog.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HMDToolsDialog.h" + #include #include #include @@ -25,8 +27,7 @@ #include "Application.h" #include "MainWindow.h" #include "Menu.h" -#include "ui/DialogsManager.h" -#include "ui/HMDToolsDialog.h" +#include "DialogsManager.h" static const int WIDTH = 350; static const int HEIGHT = 100; diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index 34b68a123e..71e5293f30 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LodToolsDialog.h" + #include #include #include @@ -23,7 +25,6 @@ #include #include "Menu.h" -#include "ui/LodToolsDialog.h" LodToolsDialog::LodToolsDialog(QWidget* parent) : diff --git a/interface/src/ui/ModelsBrowser.cpp b/interface/src/ui/ModelsBrowser.cpp index 44089119c6..4709cc0a9c 100644 --- a/interface/src/ui/ModelsBrowser.cpp +++ b/interface/src/ui/ModelsBrowser.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelsBrowser.h" + #include #include #include @@ -27,8 +29,6 @@ #include #include -#include "ModelsBrowser.h" - const char* MODEL_TYPE_NAMES[] = { "entities", "heads", "skeletons", "skeletons", "attachments" }; static const QString S3_URL = "http://s3.amazonaws.com/hifi-public"; diff --git a/interface/src/ui/OctreeStatsDialog.cpp b/interface/src/ui/OctreeStatsDialog.cpp index ec5d800042..ea0f05f47f 100644 --- a/interface/src/ui/OctreeStatsDialog.cpp +++ b/interface/src/ui/OctreeStatsDialog.cpp @@ -9,20 +9,19 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeStatsDialog.h" + #include #include #include - #include #include #include #include "Application.h" - #include "../octree/OctreePacketProcessor.h" -#include "ui/OctreeStatsDialog.h" OctreeStatsDialog::OctreeStatsDialog(QWidget* parent, NodeToOctreeSceneStats* model) : QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint), diff --git a/interface/src/ui/OctreeStatsDialog.h b/interface/src/ui/OctreeStatsDialog.h index 81bf5f251f..c05c8eadba 100644 --- a/interface/src/ui/OctreeStatsDialog.h +++ b/interface/src/ui/OctreeStatsDialog.h @@ -19,7 +19,6 @@ #include #define MAX_STATS 100 -#define DEFAULT_COLOR 0 class OctreeStatsDialog : public QDialog { Q_OBJECT @@ -42,7 +41,7 @@ protected: // Emits a 'closed' signal when this dialog is closed. void closeEvent(QCloseEvent*) override; - int AddStatItem(const char* caption, unsigned colorRGBA = DEFAULT_COLOR); + int AddStatItem(const char* caption, unsigned colorRGBA = 0); void RemoveStatItem(int item); void showAllOctreeServers(); diff --git a/interface/src/ui/OctreeStatsProvider.cpp b/interface/src/ui/OctreeStatsProvider.cpp index a393660c17..8917056be4 100644 --- a/interface/src/ui/OctreeStatsProvider.cpp +++ b/interface/src/ui/OctreeStatsProvider.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Application.h" +#include "OctreeStatsProvider.h" -#include "../octree/OctreePacketProcessor.h" -#include "ui/OctreeStatsProvider.h" +#include "Application.h" +#include "octree/OctreePacketProcessor.h" OctreeStatsProvider::OctreeStatsProvider(QObject* parent, NodeToOctreeSceneStats* model) : QObject(parent), diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index ed8fa53fe2..e7e3c91d13 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -8,13 +8,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OverlayConductor.h" + #include #include #include "Application.h" #include "avatar/AvatarManager.h" #include "InterfaceLogging.h" -#include "OverlayConductor.h" OverlayConductor::OverlayConductor() { diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index 1bdfe2ed79..cdd596a7bc 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -11,6 +11,8 @@ #ifndef hifi_OverlayConductor_h #define hifi_OverlayConductor_h +#include + class OverlayConductor { public: OverlayConductor(); @@ -34,12 +36,12 @@ private: bool _hmdMode { false }; // used by updateAvatarHasDriveInput - quint64 _desiredDrivingTimer { 0 }; + uint64_t _desiredDrivingTimer { 0 }; bool _desiredDriving { false }; bool _currentDriving { false }; // used by updateAvatarIsAtRest - quint64 _desiredAtRestTimer { 0 }; + uint64_t _desiredAtRestTimer { 0 }; bool _desiredAtRest { true }; bool _currentAtRest { true }; }; diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 69103a40b5..c6750ad424 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Snapshot.h" + #include #include #include @@ -31,7 +33,6 @@ #include #include "Application.h" -#include "Snapshot.h" #include "SnapshotUploader.h" // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 62d3ed3db8..93aaed8aa4 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -16,6 +16,7 @@ #include #include +#include #include #include diff --git a/interface/src/ui/SnapshotAnimated.cpp b/interface/src/ui/SnapshotAnimated.cpp index 3c00be8358..7866e742d9 100644 --- a/interface/src/ui/SnapshotAnimated.cpp +++ b/interface/src/ui/SnapshotAnimated.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SnapshotAnimated.h" + #include #include #include @@ -16,7 +18,6 @@ #include #include -#include "SnapshotAnimated.h" QTimer* SnapshotAnimated::snapshotAnimatedTimer = NULL; qint64 SnapshotAnimated::snapshotAnimatedTimestamp = 0; diff --git a/interface/src/ui/SnapshotUploader.cpp b/interface/src/ui/SnapshotUploader.cpp index 37505db629..67902c1a35 100644 --- a/interface/src/ui/SnapshotUploader.cpp +++ b/interface/src/ui/SnapshotUploader.cpp @@ -9,11 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SnapshotUploader.h" + #include #include + #include + #include "scripting/WindowScriptingInterface.h" -#include "SnapshotUploader.h" SnapshotUploader::SnapshotUploader(QUrl inWorldLocation, QString pathname) : _inWorldLocation(inWorldLocation), diff --git a/interface/src/ui/StandAloneJSConsole.cpp b/interface/src/ui/StandAloneJSConsole.cpp index 72b6ecc547..49cf22a9eb 100644 --- a/interface/src/ui/StandAloneJSConsole.cpp +++ b/interface/src/ui/StandAloneJSConsole.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "StandAloneJSConsole.h" + #include #include #include @@ -16,8 +18,6 @@ #include #include -#include "StandAloneJSConsole.h" - void StandAloneJSConsole::toggleConsole() { QMainWindow* mainWindow = qApp->getWindow(); if (!_jsConsole) { diff --git a/interface/src/ui/TestingDialog.cpp b/interface/src/ui/TestingDialog.cpp index 6f499f2a8d..6143f20ee6 100644 --- a/interface/src/ui/TestingDialog.cpp +++ b/interface/src/ui/TestingDialog.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ScriptEngines.h" +#include "TestingDialog.h" -#include "ui/TestingDialog.h" #include "Application.h" +#include "ScriptEngines.h" TestingDialog::TestingDialog(QWidget* parent) : QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint), diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index 7edc03490c..27e3bd0e2d 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelOverlay.h" + #include #include -#include "ModelOverlay.h" #include #include "Application.h" diff --git a/libraries/animation/src/AnimClip.cpp b/libraries/animation/src/AnimClip.cpp index 2ead4558fe..7d358e85cc 100644 --- a/libraries/animation/src/AnimClip.cpp +++ b/libraries/animation/src/AnimClip.cpp @@ -8,8 +8,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "GLMHelpers.h" #include "AnimClip.h" + +#include "GLMHelpers.h" #include "AnimationLogging.h" #include "AnimUtil.h" diff --git a/libraries/animation/src/AnimExpression.cpp b/libraries/animation/src/AnimExpression.cpp index 9777e9c6af..ddcbd01220 100644 --- a/libraries/animation/src/AnimExpression.cpp +++ b/libraries/animation/src/AnimExpression.cpp @@ -8,10 +8,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include "AnimExpression.h" + #include -#include "AnimExpression.h" +#include + #include "AnimationLogging.h" AnimExpression::AnimExpression(const QString& str) : diff --git a/libraries/animation/src/AnimNode.cpp b/libraries/animation/src/AnimNode.cpp index 80093e43db..ba8e095109 100644 --- a/libraries/animation/src/AnimNode.cpp +++ b/libraries/animation/src/AnimNode.cpp @@ -8,9 +8,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "AnimNode.h" +#include + AnimNode::Pointer AnimNode::getParent() { return _parent.lock(); } diff --git a/libraries/animation/src/AnimNodeLoader.cpp b/libraries/animation/src/AnimNodeLoader.cpp index 8173845205..4169ff61a7 100644 --- a/libraries/animation/src/AnimNodeLoader.cpp +++ b/libraries/animation/src/AnimNodeLoader.cpp @@ -8,6 +8,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AnimNodeLoader.h" + #include #include #include @@ -19,7 +21,6 @@ #include "AnimBlendLinearMove.h" #include "AnimationLogging.h" #include "AnimOverlay.h" -#include "AnimNodeLoader.h" #include "AnimStateMachine.h" #include "AnimManipulator.h" #include "AnimInverseKinematics.h" diff --git a/libraries/animation/src/AnimVariant.cpp b/libraries/animation/src/AnimVariant.cpp index 832ab8678c..483a7999c9 100644 --- a/libraries/animation/src/AnimVariant.cpp +++ b/libraries/animation/src/AnimVariant.cpp @@ -1,5 +1,5 @@ // -// AnimVariantMap.cpp +// AnimVariant.cpp // library/animation // // Created by Howard Stearns on 10/15/15. @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AnimVariant.h" // which has AnimVariant/AnimVariantMap + #include #include #include #include -#include "AnimVariant.h" // which has AnimVariant/AnimVariantMap const AnimVariant AnimVariant::False = AnimVariant(); diff --git a/libraries/animation/src/AnimationObject.cpp b/libraries/animation/src/AnimationObject.cpp index 25a5743121..7f0f35b104 100644 --- a/libraries/animation/src/AnimationObject.cpp +++ b/libraries/animation/src/AnimationObject.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AnimationObject.h" + #include #include "AnimationCache.h" -#include "AnimationObject.h" QStringList AnimationObject::getJointNames() const { return qscriptvalue_cast(thisObject())->getJointNames(); diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index f643719a2e..a5f79290cd 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioClient.h" + #include #include #include @@ -50,8 +52,6 @@ #include "AudioLogging.h" #include "AudioHelpers.h" -#include "AudioClient.h" - const int AudioClient::MIN_BUFFER_FRAMES = 1; const int AudioClient::MAX_BUFFER_FRAMES = 20; diff --git a/libraries/audio-client/src/AudioIOStats.cpp b/libraries/audio-client/src/AudioIOStats.cpp index 3bd3f4a47d..1717ad1f9c 100644 --- a/libraries/audio-client/src/AudioIOStats.cpp +++ b/libraries/audio-client/src/AudioIOStats.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioIOStats.h" + #include #include #include @@ -16,8 +18,6 @@ #include "AudioClient.h" -#include "AudioIOStats.h" - // This is called 1x/sec (see AudioClient) and we want it to log the last 5s static const int INPUT_READS_WINDOW = 5; static const int INPUT_UNPLAYED_WINDOW = 5; diff --git a/libraries/audio/src/AudioFOA.cpp b/libraries/audio/src/AudioFOA.cpp index 718b29d1b2..16c0721047 100644 --- a/libraries/audio/src/AudioFOA.cpp +++ b/libraries/audio/src/AudioFOA.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioFOA.h" + #include #include -#include "AudioFOA.h" #include "AudioFOAData.h" #if defined(_MSC_VER) diff --git a/libraries/audio/src/AudioGate.cpp b/libraries/audio/src/AudioGate.cpp index 5ef5ee25b5..e9cdf832d2 100644 --- a/libraries/audio/src/AudioGate.cpp +++ b/libraries/audio/src/AudioGate.cpp @@ -6,12 +6,13 @@ // Copyright 2017 High Fidelity, Inc. // +#include "AudioGate.h" + #include #include #include #include "AudioDynamics.h" -#include "AudioGate.h" // log2 domain headroom bits above 0dB (int32_t) static const int LOG2_HEADROOM_Q30 = 1; diff --git a/libraries/audio/src/AudioHRTF.cpp b/libraries/audio/src/AudioHRTF.cpp index aa951210a6..c0751c6a20 100644 --- a/libraries/audio/src/AudioHRTF.cpp +++ b/libraries/audio/src/AudioHRTF.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioHRTF.h" + #include #include #include -#include "AudioHRTF.h" #include "AudioHRTFData.h" #if defined(_MSC_VER) diff --git a/libraries/audio/src/AudioLimiter.cpp b/libraries/audio/src/AudioLimiter.cpp index e20a070bd6..79bb84f7b1 100644 --- a/libraries/audio/src/AudioLimiter.cpp +++ b/libraries/audio/src/AudioLimiter.cpp @@ -6,10 +6,11 @@ // Copyright 2016 High Fidelity, Inc. // +#include "AudioLimiter.h" + #include #include "AudioDynamics.h" -#include "AudioLimiter.h" // // Limiter (common) diff --git a/libraries/audio/src/AudioReverb.cpp b/libraries/audio/src/AudioReverb.cpp index d457ce7a96..a7c6fefd39 100644 --- a/libraries/audio/src/AudioReverb.cpp +++ b/libraries/audio/src/AudioReverb.cpp @@ -6,12 +6,12 @@ // Copyright 2015 High Fidelity, Inc. // +#include "AudioReverb.h" + #include #include #include -#include "AudioReverb.h" - #ifdef _MSC_VER #include #define MULHI(a,b) ((int32_t)(__emul(a, b) >> 32)) diff --git a/libraries/audio/src/AudioRingBuffer.cpp b/libraries/audio/src/AudioRingBuffer.cpp index 518fdd3c17..d8531ec216 100644 --- a/libraries/audio/src/AudioRingBuffer.cpp +++ b/libraries/audio/src/AudioRingBuffer.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioRingBuffer.h" + #include #include #include @@ -21,8 +23,6 @@ #include "AudioLogging.h" -#include "AudioRingBuffer.h" - static const QString RING_BUFFER_OVERFLOW_DEBUG { "AudioRingBuffer::writeData has overflown the buffer. Overwriting old data." }; static const QString DROPPED_SILENT_DEBUG { "AudioRingBuffer::addSilentSamples dropping silent samples to prevent overflow." }; diff --git a/libraries/audio/src/AudioSRC.cpp b/libraries/audio/src/AudioSRC.cpp index fbdf890246..d488eccb6a 100644 --- a/libraries/audio/src/AudioSRC.cpp +++ b/libraries/audio/src/AudioSRC.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AudioSRC.h" + #include #include #include -#include "AudioSRC.h" #include "AudioSRCData.h" #ifndef MAX diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index d60c5ba4ab..7645a674e4 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -9,13 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "InboundAudioStream.h" + #include #include #include #include -#include "InboundAudioStream.h" #include "AudioLogging.h" const bool InboundAudioStream::DEFAULT_DYNAMIC_JITTER_BUFFER_ENABLED = true; diff --git a/libraries/audio/src/InjectedAudioStream.cpp b/libraries/audio/src/InjectedAudioStream.cpp index a06dba5389..2f357416f2 100644 --- a/libraries/audio/src/InjectedAudioStream.cpp +++ b/libraries/audio/src/InjectedAudioStream.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "InjectedAudioStream.h" + #include #include @@ -17,7 +19,6 @@ #include #include -#include "InjectedAudioStream.h" #include "AudioHelpers.h" InjectedAudioStream::InjectedAudioStream(const QUuid& streamIdentifier, bool isStereo, int numStaticJitterFrames) : diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index 672c0b69b3..cd93f7b52e 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Sound.h" + #include #include @@ -29,8 +31,6 @@ #include "AudioLogging.h" #include "AudioSRC.h" -#include "Sound.h" - QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, const SharedSoundPointer& in) { return engine->newQObject(new SoundScriptingInterface(in), QScriptEngine::ScriptOwnership); } diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index b564ad6a3b..829c98a418 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AvatarHashMap.h" + #include #include @@ -17,7 +19,6 @@ #include #include "AvatarLogging.h" -#include "AvatarHashMap.h" AvatarHashMap::AvatarHashMap() { auto nodeList = DependencyManager::get(); diff --git a/libraries/baking/src/Baker.cpp b/libraries/baking/src/Baker.cpp index 2adedf08a1..78a34ac5e8 100644 --- a/libraries/baking/src/Baker.cpp +++ b/libraries/baking/src/Baker.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ModelBakingLoggingCategory.h" - #include "Baker.h" +#include "ModelBakingLoggingCategory.h" + bool Baker::shouldStop() { if (_shouldAbort) { setWasAborted(true); diff --git a/libraries/baking/src/FBXBaker.cpp b/libraries/baking/src/FBXBaker.cpp index c8ba98f0b1..e3839bb95a 100644 --- a/libraries/baking/src/FBXBaker.cpp +++ b/libraries/baking/src/FBXBaker.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "FBXBaker.h" + #include // need this include so we don't get an error looking for std::isnan #include @@ -31,8 +33,6 @@ #include "ModelBakingLoggingCategory.h" #include "TextureBaker.h" -#include "FBXBaker.h" - void FBXBaker::bake() { qDebug() << "FBXBaker" << _modelURL << "bake starting"; diff --git a/libraries/baking/src/JSBaker.cpp b/libraries/baking/src/JSBaker.cpp index 9932ad633e..b19336f4ca 100644 --- a/libraries/baking/src/JSBaker.cpp +++ b/libraries/baking/src/JSBaker.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "JSBaker.h" + #include -#include "JSBaker.h" #include "Baker.h" const int ASCII_CHARACTERS_UPPER_LIMIT = 126; diff --git a/libraries/baking/src/JSBaker.h b/libraries/baking/src/JSBaker.h index b5889440cb..a7c3e62174 100644 --- a/libraries/baking/src/JSBaker.h +++ b/libraries/baking/src/JSBaker.h @@ -12,6 +12,8 @@ #ifndef hifi_JSBaker_h #define hifi_JSBaker_h +#include + #include "Baker.h" #include "JSBakingLoggingCategory.h" diff --git a/libraries/baking/src/OBJBaker.cpp b/libraries/baking/src/OBJBaker.cpp index 1fe53f26eb..cf62bc4fa8 100644 --- a/libraries/baking/src/OBJBaker.cpp +++ b/libraries/baking/src/OBJBaker.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OBJBaker.h" + #include #include -#include "OBJBaker.h" #include "OBJReader.h" #include "FBXWriter.h" diff --git a/libraries/baking/src/TextureBaker.cpp b/libraries/baking/src/TextureBaker.cpp index 45895494a0..b6957a2712 100644 --- a/libraries/baking/src/TextureBaker.cpp +++ b/libraries/baking/src/TextureBaker.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "TextureBaker.h" + #include #include #include @@ -22,8 +24,6 @@ #include "ModelBakingLoggingCategory.h" -#include "TextureBaker.h" - const QString BAKED_TEXTURE_KTX_EXT = ".ktx"; const QString BAKED_TEXTURE_BCN_SUFFIX = "_bcn.ktx"; const QString BAKED_META_TEXTURE_SUFFIX = ".texmeta.json"; diff --git a/libraries/baking/src/TextureBaker.h b/libraries/baking/src/TextureBaker.h index 93b01080cd..54839c001a 100644 --- a/libraries/baking/src/TextureBaker.h +++ b/libraries/baking/src/TextureBaker.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/libraries/controllers/src/controllers/DeviceProxy.cpp b/libraries/controllers/src/controllers/DeviceProxy.cpp deleted file mode 100644 index f03354c52d..0000000000 --- a/libraries/controllers/src/controllers/DeviceProxy.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// Created by Bradley Austin Davis on 2015/10/18 -// (based on UserInputMapper inner class created by Sam Gateau on 4/27/15) -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "DeviceProxy.h" - diff --git a/libraries/controllers/src/controllers/Pose.cpp b/libraries/controllers/src/controllers/Pose.cpp index 6f0296c09d..967838ef84 100644 --- a/libraries/controllers/src/controllers/Pose.cpp +++ b/libraries/controllers/src/controllers/Pose.cpp @@ -6,13 +6,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Pose.h" + #include #include #include -#include "Pose.h" - namespace controller { Pose::Pose(const vec3& translation, const quat& rotation, diff --git a/libraries/controllers/src/controllers/impl/Mapping.cpp b/libraries/controllers/src/controllers/impl/Mapping.cpp deleted file mode 100644 index dd8e1c1d48..0000000000 --- a/libraries/controllers/src/controllers/impl/Mapping.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/09 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "Mapping.h" diff --git a/libraries/controllers/src/controllers/impl/Route.cpp b/libraries/controllers/src/controllers/impl/Route.cpp deleted file mode 100644 index c74f809195..0000000000 --- a/libraries/controllers/src/controllers/impl/Route.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/09 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "Route.h" diff --git a/libraries/controllers/src/controllers/impl/conditionals/EndpointConditional.cpp b/libraries/controllers/src/controllers/impl/conditionals/EndpointConditional.cpp deleted file mode 100644 index f833eedb60..0000000000 --- a/libraries/controllers/src/controllers/impl/conditionals/EndpointConditional.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/23 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "EndpointConditional.h" \ No newline at end of file diff --git a/libraries/controllers/src/controllers/impl/endpoints/ArrayEndpoint.cpp b/libraries/controllers/src/controllers/impl/endpoints/ArrayEndpoint.cpp deleted file mode 100644 index 5dea1de34e..0000000000 --- a/libraries/controllers/src/controllers/impl/endpoints/ArrayEndpoint.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/23 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "ArrayEndpoint.h" \ No newline at end of file diff --git a/libraries/controllers/src/controllers/impl/endpoints/StandardEndpoint.cpp b/libraries/controllers/src/controllers/impl/endpoints/StandardEndpoint.cpp deleted file mode 100644 index 89bbe5d777..0000000000 --- a/libraries/controllers/src/controllers/impl/endpoints/StandardEndpoint.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/23 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "StandardEndpoint.h" \ No newline at end of file diff --git a/libraries/controllers/src/controllers/impl/filters/ConstrainToIntegerFilter.cpp b/libraries/controllers/src/controllers/impl/filters/ConstrainToIntegerFilter.cpp deleted file mode 100644 index 8bd3d2db89..0000000000 --- a/libraries/controllers/src/controllers/impl/filters/ConstrainToIntegerFilter.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/25 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "ConstrainToIntegerFilter.h" diff --git a/libraries/controllers/src/controllers/impl/filters/ConstrainToPositiveIntegerFilter.cpp b/libraries/controllers/src/controllers/impl/filters/ConstrainToPositiveIntegerFilter.cpp deleted file mode 100644 index f1abc8cecd..0000000000 --- a/libraries/controllers/src/controllers/impl/filters/ConstrainToPositiveIntegerFilter.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/25 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "ConstrainToPositiveIntegerFilter.h" diff --git a/libraries/controllers/src/controllers/impl/filters/InvertFilter.cpp b/libraries/controllers/src/controllers/impl/filters/InvertFilter.cpp deleted file mode 100644 index 5407c6dd1d..0000000000 --- a/libraries/controllers/src/controllers/impl/filters/InvertFilter.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Created by Bradley Austin Davis 2015/10/25 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -// NOTE: we don't need to include this header unless/until we add additional symbols. -// By removing this header we prevent these warnings on windows: -// -// warning LNK4221: This object file does not define any previously undefined public symbols, -// so it will not be used by any link operation that consumes this library -// -//#include "InvertFilter.h" diff --git a/libraries/embedded-webserver/src/HTTPConnection.cpp b/libraries/embedded-webserver/src/HTTPConnection.cpp index 280b44cec0..12da599575 100644 --- a/libraries/embedded-webserver/src/HTTPConnection.cpp +++ b/libraries/embedded-webserver/src/HTTPConnection.cpp @@ -9,15 +9,15 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HTTPConnection.h" #include #include #include +#include -#include "HTTPConnection.h" #include "EmbeddedWebserverLogging.h" #include "HTTPManager.h" -#include const char* HTTPConnection::StatusCode200 = "200 OK"; const char* HTTPConnection::StatusCode301 = "301 Moved Permanently"; diff --git a/libraries/embedded-webserver/src/HTTPManager.cpp b/libraries/embedded-webserver/src/HTTPManager.cpp index bd1b545412..db6fc8e084 100644 --- a/libraries/embedded-webserver/src/HTTPManager.cpp +++ b/libraries/embedded-webserver/src/HTTPManager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HTTPManager.h" + #include #include #include @@ -18,7 +20,6 @@ #include "HTTPConnection.h" #include "EmbeddedWebserverLogging.h" -#include "HTTPManager.h" const int SOCKET_ERROR_EXIT_CODE = 2; const int SOCKET_CHECK_INTERVAL_IN_MS = 30000; diff --git a/libraries/embedded-webserver/src/HTTPSConnection.cpp b/libraries/embedded-webserver/src/HTTPSConnection.cpp index 7af14ce0a7..f5473d577f 100644 --- a/libraries/embedded-webserver/src/HTTPSConnection.cpp +++ b/libraries/embedded-webserver/src/HTTPSConnection.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "EmbeddedWebserverLogging.h" #include "HTTPSConnection.h" +#include "EmbeddedWebserverLogging.h" + HTTPSConnection::HTTPSConnection(QSslSocket* sslSocket, HTTPSManager* parentManager) : HTTPConnection(sslSocket, parentManager) { diff --git a/libraries/embedded-webserver/src/HTTPSManager.cpp b/libraries/embedded-webserver/src/HTTPSManager.cpp index ee61f15457..8ba44f98ac 100644 --- a/libraries/embedded-webserver/src/HTTPSManager.cpp +++ b/libraries/embedded-webserver/src/HTTPSManager.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HTTPSManager.h" + #include #include "HTTPSConnection.h" -#include "HTTPSManager.h" - HTTPSManager::HTTPSManager(QHostAddress listenAddress, quint16 port, const QSslCertificate& certificate, const QSslKey& privateKey, const QString& documentRoot, HTTPSRequestHandler* requestHandler, QObject* parent) : HTTPManager(listenAddress, port, documentRoot, requestHandler, parent), diff --git a/libraries/entities/src/DeleteEntityOperator.cpp b/libraries/entities/src/DeleteEntityOperator.cpp index 347d40ea49..d369e08ecf 100644 --- a/libraries/entities/src/DeleteEntityOperator.cpp +++ b/libraries/entities/src/DeleteEntityOperator.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DeleteEntityOperator.h" + #include "EntityItem.h" #include "EntityTree.h" #include "EntityTreeElement.h" - #include "EntitiesLogging.h" -#include "DeleteEntityOperator.h" DeleteEntityOperator::DeleteEntityOperator(EntityTreePointer tree, const EntityItemID& searchEntityID) : _tree(tree), diff --git a/libraries/entities/src/DeleteEntityOperator.h b/libraries/entities/src/DeleteEntityOperator.h index 135949a53d..3b3ee2a868 100644 --- a/libraries/entities/src/DeleteEntityOperator.h +++ b/libraries/entities/src/DeleteEntityOperator.h @@ -12,6 +12,12 @@ #ifndef hifi_DeleteEntityOperator_h #define hifi_DeleteEntityOperator_h +#include + +#include + +#include "EntityItem.h" + class EntityToDeleteDetails { public: EntityItemPointer entity; diff --git a/libraries/entities/src/EntityDynamicInterface.cpp b/libraries/entities/src/EntityDynamicInterface.cpp index d43bdd7b51..1115559342 100644 --- a/libraries/entities/src/EntityDynamicInterface.cpp +++ b/libraries/entities/src/EntityDynamicInterface.cpp @@ -89,10 +89,9 @@ variables. These argument variables are used by the code which is run when bull */ -#include "EntityItem.h" - #include "EntityDynamicInterface.h" +#include "EntityItem.h" /**jsdoc *

    An entity action may be one of the following types:

    diff --git a/libraries/entities/src/EntityDynamicInterface.h b/libraries/entities/src/EntityDynamicInterface.h index 40e39eecf1..6b82e7df73 100644 --- a/libraries/entities/src/EntityDynamicInterface.h +++ b/libraries/entities/src/EntityDynamicInterface.h @@ -13,9 +13,12 @@ #define hifi_EntityDynamicInterface_h #include -#include + #include +#include +#include + class EntityItem; class EntityItemID; class EntitySimulation; diff --git a/libraries/entities/src/EntityEditFilters.cpp b/libraries/entities/src/EntityEditFilters.cpp index 676b1ce518..94df7eb465 100644 --- a/libraries/entities/src/EntityEditFilters.cpp +++ b/libraries/entities/src/EntityEditFilters.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EntityEditFilters.h" #include #include -#include "EntityEditFilters.h" QList EntityEditFilters::getZonesByPosition(glm::vec3& position) { QList zones; diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index 5d7bd61854..d89dd4f9d0 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -9,16 +9,20 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EntityEditPacketSender.h" + #include + #include + +#include #include #include #include -#include "EntityEditPacketSender.h" + #include "EntitiesLogging.h" #include "EntityItem.h" #include "EntityItemProperties.h" -#include EntityEditPacketSender::EntityEditPacketSender() { auto& packetReceiver = DependencyManager::get()->getPacketReceiver(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 4638b46437..4d7c114176 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -9,24 +9,28 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include -#include -#include +#include "EntityItemProperties.h" + #include #include #include #include -#include + +#include +#include +#include +#include #include #include + +#include #include #include #include #include + #include "EntitiesLogging.h" #include "EntityItem.h" -#include "EntityItemProperties.h" #include "ModelEntityItem.h" #include "PolyLineEntityItem.h" diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 38e4f0c8c0..39ea2e0bdd 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "AnimationPropertyGroup.h" #include "EntityItemID.h" diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index d95dbf2990..ee9fb10554 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -18,15 +18,13 @@ #include #include -class EntityTree; -using EntityTreePointer = std::shared_ptr; - #include "AddEntityOperator.h" #include "EntityTreeElement.h" #include "DeleteEntityOperator.h" #include "MovingEntitiesOperator.h" -class EntityEditFilters; +class EntityTree; +using EntityTreePointer = std::shared_ptr; class EntitySimulation; diff --git a/libraries/entities/src/EntityTypes.cpp b/libraries/entities/src/EntityTypes.cpp index 694542b04e..9611063f8b 100644 --- a/libraries/entities/src/EntityTypes.cpp +++ b/libraries/entities/src/EntityTypes.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EntityTypes.h" + #include #include @@ -16,7 +18,6 @@ #include "EntityItem.h" #include "EntityItemProperties.h" -#include "EntityTypes.h" #include "EntitiesLogging.h" #include "LightEntityItem.h" diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index f137fca5ce..c15b28707c 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HazePropertyGroup.h" + #include -#include "HazePropertyGroup.h" #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index f0fbb20f98..e95af7ebf9 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "LightEntityItem.h" #include @@ -19,7 +20,6 @@ #include "EntityItemProperties.h" #include "EntityTree.h" #include "EntityTreeElement.h" -#include "LightEntityItem.h" const bool LightEntityItem::DEFAULT_IS_SPOTLIGHT = false; const float LightEntityItem::DEFAULT_INTENSITY = 1.0f; diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 0f59bc673d..cf89a73214 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -9,18 +9,20 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelEntityItem.h" + #include +#include + #include #include -#include #include "EntitiesLogging.h" #include "EntityItemProperties.h" #include "EntityTree.h" #include "EntityTreeElement.h" #include "ResourceCache.h" -#include "ModelEntityItem.h" const QString ModelEntityItem::DEFAULT_MODEL_URL = QString(""); const QString ModelEntityItem::DEFAULT_COMPOUND_SHAPE_URL = QString(""); diff --git a/libraries/entities/src/MovingEntitiesOperator.cpp b/libraries/entities/src/MovingEntitiesOperator.cpp index cf043dd93e..4b908745e0 100644 --- a/libraries/entities/src/MovingEntitiesOperator.cpp +++ b/libraries/entities/src/MovingEntitiesOperator.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "MovingEntitiesOperator.h" + #include "EntityItem.h" #include "EntityTree.h" #include "EntityTreeElement.h" #include "EntitiesLogging.h" -#include "MovingEntitiesOperator.h" - MovingEntitiesOperator::MovingEntitiesOperator() { } MovingEntitiesOperator::~MovingEntitiesOperator() { diff --git a/libraries/entities/src/MovingEntitiesOperator.h b/libraries/entities/src/MovingEntitiesOperator.h index d93efa60f2..9e98374fc3 100644 --- a/libraries/entities/src/MovingEntitiesOperator.h +++ b/libraries/entities/src/MovingEntitiesOperator.h @@ -14,8 +14,7 @@ #include -#include "EntityTypes.h" -#include "EntityTreeElement.h" +#include "EntityItem.h" class EntityToMoveDetails { public: diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index d9ef5e2178..d1fc3d2775 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -26,6 +26,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ParticleEffectEntityItem.h" #include #include @@ -38,8 +39,6 @@ #include "EntityTreeElement.h" #include "EntitiesLogging.h" #include "EntityScriptingInterface.h" -#include "ParticleEffectEntityItem.h" - using namespace particle; diff --git a/libraries/entities/src/PolyLineEntityItem.cpp b/libraries/entities/src/PolyLineEntityItem.cpp index 420c570e8d..5b3167b9ba 100644 --- a/libraries/entities/src/PolyLineEntityItem.cpp +++ b/libraries/entities/src/PolyLineEntityItem.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "PolyLineEntityItem.h" #include @@ -19,7 +20,6 @@ #include "EntityTree.h" #include "EntityTreeElement.h" #include "OctreeConstants.h" -#include "PolyLineEntityItem.h" const float PolyLineEntityItem::DEFAULT_LINE_WIDTH = 0.1f; const int PolyLineEntityItem::MAX_POINTS_PER_LINE = 60; diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 520d892682..943ae2e462 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -6,6 +6,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ShapeEntityItem.h" #include @@ -17,7 +18,6 @@ #include "EntityItemProperties.h" #include "EntityTree.h" #include "EntityTreeElement.h" -#include "ShapeEntityItem.h" namespace entity { diff --git a/libraries/entities/src/SkyboxPropertyGroup.cpp b/libraries/entities/src/SkyboxPropertyGroup.cpp index f8baf57856..ba40c3fa6f 100644 --- a/libraries/entities/src/SkyboxPropertyGroup.cpp +++ b/libraries/entities/src/SkyboxPropertyGroup.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SkyboxPropertyGroup.h" + #include -#include "SkyboxPropertyGroup.h" #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" diff --git a/libraries/entities/src/SkyboxPropertyGroup.h b/libraries/entities/src/SkyboxPropertyGroup.h index d7b422bf11..a94365d24d 100644 --- a/libraries/entities/src/SkyboxPropertyGroup.h +++ b/libraries/entities/src/SkyboxPropertyGroup.h @@ -18,6 +18,8 @@ #include +#include + #include "PropertyGroup.h" #include "EntityItemPropertiesMacros.h" diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 97080d3ca2..56e12e66d9 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "TextEntityItem.h" #include @@ -21,7 +22,6 @@ #include "EntitiesLogging.h" #include "EntityTree.h" #include "EntityTreeElement.h" -#include "TextEntityItem.h" const QString TextEntityItem::DEFAULT_TEXT(""); const float TextEntityItem::DEFAULT_LINE_HEIGHT = 0.1f; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index b07d0597bc..3a6095b89f 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ZoneEntityItem.h" #include @@ -18,7 +19,6 @@ #include "EntityItemProperties.h" #include "EntityTree.h" #include "EntityTreeElement.h" -#include "ZoneEntityItem.h" #include "EntityEditFilters.h" bool ZoneEntityItem::_zonesArePickable = false; diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 86422ef70c..81637e82a8 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "FBXReader.h" + #include #include #include @@ -31,7 +33,6 @@ #include #include -#include "FBXReader.h" #include "ModelFormatLogging.h" // TOOL: Uncomment the following line to enable the filtering of all the unkwnon fields of a node so we can break point easily while loading a model with problems... diff --git a/libraries/fbx/src/FSTReader.cpp b/libraries/fbx/src/FSTReader.cpp index d63a5b3cc4..75596862d2 100644 --- a/libraries/fbx/src/FSTReader.cpp +++ b/libraries/fbx/src/FSTReader.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "FSTReader.h" + #include #include #include @@ -17,8 +19,6 @@ #include #include -#include "FSTReader.h" - QVariantHash FSTReader::parseMapping(QIODevice* device) { QVariantHash properties; diff --git a/libraries/fbx/src/GLTFReader.cpp b/libraries/fbx/src/GLTFReader.cpp index 0c04b3d733..f322c2319e 100644 --- a/libraries/fbx/src/GLTFReader.cpp +++ b/libraries/fbx/src/GLTFReader.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "GLTFReader.h" + #include #include #include @@ -28,7 +30,6 @@ #include #include -#include "GLTFReader.h" #include "FBXReader.h" @@ -1377,4 +1378,4 @@ void GLTFReader::fbxDebugDump(const FBXGeometry& fbxgeo) { } qCDebug(modelformat) << "\n"; -} \ No newline at end of file +} diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp index 8e6d4bec9b..585a719638 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp @@ -5,22 +5,24 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Forward.h" - #include "ScriptableMesh.h" -#include "ScriptableMeshPart.h" -#include "GraphicsScriptingUtil.h" -#include "OBJWriter.h" -#include #include -#include + #include #include #include + +#include #include #include #include +#include + +#include "Forward.h" +#include "ScriptableMeshPart.h" +#include "GraphicsScriptingUtil.h" +#include "OBJWriter.h" // #define SCRIPTABLE_MESH_DEBUG 1 diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.cpp index 4414b0ad7e..192071d3af 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMeshPart.cpp @@ -5,22 +5,23 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Forward.h" - #include "ScriptableMeshPart.h" -#include "GraphicsScriptingUtil.h" -#include "OBJWriter.h" -#include -#include -#include #include #include #include + +#include +#include +#include #include #include #include +#include "Forward.h" +#include "GraphicsScriptingUtil.h" +#include "OBJWriter.h" + QString scriptable::ScriptableMeshPart::toOBJ() { if (!getMeshPointer()) { diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp index c65764a225..7aaa182163 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp @@ -8,14 +8,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "GraphicsScriptingUtil.h" #include "ScriptableModel.h" -#include "ScriptableMesh.h" #include +#include "GraphicsScriptingUtil.h" +#include "ScriptableMesh.h" #include "graphics/Material.h" - #include "image/Image.h" // #define SCRIPTABLE_MESH_DEBUG 1 diff --git a/libraries/graphics/src/graphics/Haze.cpp b/libraries/graphics/src/graphics/Haze.cpp index dfe70175f4..d5a060b90b 100644 --- a/libraries/graphics/src/graphics/Haze.cpp +++ b/libraries/graphics/src/graphics/Haze.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "Haze.h" +#include + using namespace graphics; const float Haze::INITIAL_HAZE_RANGE{ 1000.0f }; diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index edb2992128..dd6a7fffe9 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AddressManager.h" + #include #include #include @@ -23,7 +25,6 @@ #include #include -#include "AddressManager.h" #include "NodeList.h" #include "NetworkLogging.h" #include "UserActivityLogger.h" diff --git a/libraries/networking/src/Assignment.cpp b/libraries/networking/src/Assignment.cpp index 58a4446aa6..71a3cfb269 100644 --- a/libraries/networking/src/Assignment.cpp +++ b/libraries/networking/src/Assignment.cpp @@ -9,17 +9,18 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "udt/PacketHeaders.h" -#include "SharedUtil.h" -#include "UUID.h" +#include "Assignment.h" #include #include -#include "Assignment.h" #include #include +#include "udt/PacketHeaders.h" +#include "SharedUtil.h" +#include "UUID.h" + Assignment::Type Assignment::typeForNodeType(NodeType_t nodeType) { switch (nodeType) { case NodeType::AudioMixer: diff --git a/libraries/networking/src/AtpReply.cpp b/libraries/networking/src/AtpReply.cpp index 6417478005..b2b7e8bee7 100644 --- a/libraries/networking/src/AtpReply.cpp +++ b/libraries/networking/src/AtpReply.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ResourceManager.h" #include "AtpReply.h" +#include "ResourceManager.h" + AtpReply::AtpReply(const QUrl& url, QObject* parent) : _resourceRequest(DependencyManager::get()->createResourceRequest(parent, url)) { setOperation(QNetworkAccessManager::GetOperation); diff --git a/libraries/networking/src/BandwidthRecorder.cpp b/libraries/networking/src/BandwidthRecorder.cpp index d43d4cf21f..5ad3494017 100644 --- a/libraries/networking/src/BandwidthRecorder.cpp +++ b/libraries/networking/src/BandwidthRecorder.cpp @@ -11,9 +11,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "BandwidthRecorder.h" +#include BandwidthRecorder::Channel::Channel() { } diff --git a/libraries/networking/src/DataServerAccountInfo.cpp b/libraries/networking/src/DataServerAccountInfo.cpp index 51f93d13b0..8756a0cc4b 100644 --- a/libraries/networking/src/DataServerAccountInfo.cpp +++ b/libraries/networking/src/DataServerAccountInfo.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DataServerAccountInfo.h" + #include #include @@ -20,7 +22,6 @@ #include #include "NetworkLogging.h" -#include "DataServerAccountInfo.h" #ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" diff --git a/libraries/networking/src/HifiSockAddr.cpp b/libraries/networking/src/HifiSockAddr.cpp index e2a3e79c79..a1bfcdd275 100644 --- a/libraries/networking/src/HifiSockAddr.cpp +++ b/libraries/networking/src/HifiSockAddr.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "HifiSockAddr.h" + #include #include #include -#include "HifiSockAddr.h" #include "NetworkLogging.h" int hifiSockAddrMetaTypeId = qRegisterMetaType(); diff --git a/libraries/networking/src/LocationScriptingInterface.cpp b/libraries/networking/src/LocationScriptingInterface.cpp index aae1da73ba..39845558a8 100644 --- a/libraries/networking/src/LocationScriptingInterface.cpp +++ b/libraries/networking/src/LocationScriptingInterface.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "AddressManager.h" - #include "LocationScriptingInterface.h" +#include "AddressManager.h" + LocationScriptingInterface* LocationScriptingInterface::getInstance() { static LocationScriptingInterface sharedInstance; return &sharedInstance; diff --git a/libraries/networking/src/NetworkAccessManager.cpp b/libraries/networking/src/NetworkAccessManager.cpp index fd356c3e94..f73243e675 100644 --- a/libraries/networking/src/NetworkAccessManager.cpp +++ b/libraries/networking/src/NetworkAccessManager.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "NetworkAccessManager.h" + #include #include "AtpReply.h" -#include "NetworkAccessManager.h" #include QThreadStorage networkAccessManagers; diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index 73b7c44e7e..626503d8ae 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Node.h" + #include #include @@ -21,8 +23,6 @@ #include "NodePermissions.h" #include "SharedUtil.h" -#include "Node.h" - const QString UNKNOWN_NodeType_t_NAME = "Unknown"; int NodePtrMetaTypeId = qRegisterMetaType("Node*"); diff --git a/libraries/networking/src/OAuthAccessToken.cpp b/libraries/networking/src/OAuthAccessToken.cpp index 0c14e5e074..44db2a799e 100644 --- a/libraries/networking/src/OAuthAccessToken.cpp +++ b/libraries/networking/src/OAuthAccessToken.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "OAuthAccessToken.h" +#include + OAuthAccessToken::OAuthAccessToken() : token(), refreshToken(), diff --git a/libraries/networking/src/OAuthNetworkAccessManager.cpp b/libraries/networking/src/OAuthNetworkAccessManager.cpp index a30786efa4..272ff47a49 100644 --- a/libraries/networking/src/OAuthNetworkAccessManager.cpp +++ b/libraries/networking/src/OAuthNetworkAccessManager.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OAuthNetworkAccessManager.h" + #include #include #include @@ -18,8 +20,6 @@ #include "NetworkingConstants.h" #include "SharedUtil.h" -#include "OAuthNetworkAccessManager.h" - QThreadStorage oauthNetworkAccessManagers; OAuthNetworkAccessManager* OAuthNetworkAccessManager::getInstance() { diff --git a/libraries/networking/src/PacketSender.cpp b/libraries/networking/src/PacketSender.cpp index 02c4815f1f..6288743c46 100644 --- a/libraries/networking/src/PacketSender.cpp +++ b/libraries/networking/src/PacketSender.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "PacketSender.h" + #include #include #include #include "NodeList.h" -#include "PacketSender.h" #include "SharedUtil.h" const quint64 PacketSender::USECS_PER_SECOND = 1000 * 1000; diff --git a/libraries/networking/src/RSAKeypairGenerator.cpp b/libraries/networking/src/RSAKeypairGenerator.cpp index a98cf74564..8ca8b81ea3 100644 --- a/libraries/networking/src/RSAKeypairGenerator.cpp +++ b/libraries/networking/src/RSAKeypairGenerator.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "RSAKeypairGenerator.h" + #include #include #include @@ -16,8 +18,6 @@ #include #include "NetworkLogging.h" - -#include "RSAKeypairGenerator.h" #ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif diff --git a/libraries/networking/src/ReceivedPacketProcessor.cpp b/libraries/networking/src/ReceivedPacketProcessor.cpp index c18d4ed1e8..7145744206 100644 --- a/libraries/networking/src/ReceivedPacketProcessor.cpp +++ b/libraries/networking/src/ReceivedPacketProcessor.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ReceivedPacketProcessor.h" + #include #include "NodeList.h" -#include "ReceivedPacketProcessor.h" #include "SharedUtil.h" ReceivedPacketProcessor::ReceivedPacketProcessor() { diff --git a/libraries/networking/src/ReceivedPacketProcessor.h b/libraries/networking/src/ReceivedPacketProcessor.h index f71abce1f1..6c590ec54d 100644 --- a/libraries/networking/src/ReceivedPacketProcessor.h +++ b/libraries/networking/src/ReceivedPacketProcessor.h @@ -14,8 +14,12 @@ #include +#include "NodeList.h" + #include "GenericThread.h" +class ReceivedMessage; + /// Generalized threaded processor for handling received inbound packets. class ReceivedPacketProcessor : public GenericThread { Q_OBJECT diff --git a/libraries/networking/src/ThreadedAssignment.cpp b/libraries/networking/src/ThreadedAssignment.cpp index 8b6de7da11..9a69d9b3d8 100644 --- a/libraries/networking/src/ThreadedAssignment.cpp +++ b/libraries/networking/src/ThreadedAssignment.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ThreadedAssignment.h" + #include #include #include @@ -17,8 +19,6 @@ #include -#include "ThreadedAssignment.h" - #include "NetworkLogging.h" ThreadedAssignment::ThreadedAssignment(ReceivedMessage& message) : diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 0cfd1e09e7..7a92d4bad9 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -9,16 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "UserActivityLogger.h" + #include #include #include #include -#include "NetworkLogging.h" - -#include "UserActivityLogger.h" #include + #include "AddressManager.h" +#include "NetworkLogging.h" UserActivityLogger::UserActivityLogger() { _timer.start(); diff --git a/libraries/networking/src/WalletTransaction.cpp b/libraries/networking/src/WalletTransaction.cpp index 0c823555fd..2bb66c67d0 100644 --- a/libraries/networking/src/WalletTransaction.cpp +++ b/libraries/networking/src/WalletTransaction.cpp @@ -9,13 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "WalletTransaction.h" + #include #include -#include "WalletTransaction.h" - - WalletTransaction::WalletTransaction() : _uuid(), _destinationUUID(), diff --git a/libraries/networking/src/udt/ConnectionStats.cpp b/libraries/networking/src/udt/ConnectionStats.cpp index 46d88e680f..986da062f2 100644 --- a/libraries/networking/src/udt/ConnectionStats.cpp +++ b/libraries/networking/src/udt/ConnectionStats.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "ConnectionStats.h" +#include + using namespace udt; using namespace std::chrono; diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 2efd32f2e8..5f943fabf2 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Octree.h" + #include #include #include @@ -43,7 +45,6 @@ #include #include -#include "Octree.h" #include "OctreeConstants.h" #include "OctreeLogging.h" #include "OctreeQueryNode.h" diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 4f10c9bf79..0156013821 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeEditPacketSender.h" + #include #include @@ -16,7 +18,6 @@ #include #include #include "OctreeLogging.h" -#include "OctreeEditPacketSender.h" const int OctreeEditPacketSender::DEFAULT_MAX_PENDING_MESSAGES = PacketSender::DEFAULT_PACKETS_PER_SECOND; diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index a666ba0426..b94d0d57e1 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeElement.h" + #include #include #include @@ -21,17 +23,16 @@ #include #include #include +#include #include "AACube.h" #include "Logging.h" #include "OctalCode.h" #include "Octree.h" #include "OctreeConstants.h" -#include "OctreeElement.h" #include "OctreeLogging.h" #include "OctreeUtils.h" #include "SharedUtil.h" -#include AtomicUIntStat OctreeElement::_octreeMemoryUsage { 0 }; AtomicUIntStat OctreeElement::_octcodeMemoryUsage { 0 }; diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 7108f9a4e4..b938850684 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreePacketData.h" + #include #include #include "OctreeLogging.h" -#include "OctreePacketData.h" #include "NumericalConstants.h" bool OctreePacketData::_debug = false; diff --git a/libraries/octree/src/OctreePersistThread.cpp b/libraries/octree/src/OctreePersistThread.cpp index e6c28f75e8..e6afccab47 100644 --- a/libraries/octree/src/OctreePersistThread.cpp +++ b/libraries/octree/src/OctreePersistThread.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreePersistThread.h" + #include #include @@ -30,7 +32,6 @@ #include #include "OctreeLogging.h" -#include "OctreePersistThread.h" #include "OctreeUtils.h" #include "OctreeDataUtils.h" diff --git a/libraries/octree/src/OctreeProcessor.cpp b/libraries/octree/src/OctreeProcessor.cpp index 43019c7acc..db78e985e6 100644 --- a/libraries/octree/src/OctreeProcessor.cpp +++ b/libraries/octree/src/OctreeProcessor.cpp @@ -8,16 +8,17 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeProcessor.h" + +#include #include -#include #include #include #include #include "OctreeLogging.h" -#include "OctreeProcessor.h" OctreeProcessor::OctreeProcessor() : _tree(NULL), diff --git a/libraries/octree/src/OctreeSceneStats.cpp b/libraries/octree/src/OctreeSceneStats.cpp index b2efdfd595..d8ff6ba0ec 100644 --- a/libraries/octree/src/OctreeSceneStats.cpp +++ b/libraries/octree/src/OctreeSceneStats.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctreeSceneStats.h" + #include #include #include @@ -20,8 +22,6 @@ #include "OctreePacketData.h" #include "OctreeElement.h" #include "OctreeLogging.h" -#include "OctreeSceneStats.h" - const int samples = 100; OctreeSceneStats::OctreeSceneStats() : diff --git a/libraries/octree/src/OctreeScriptingInterface.cpp b/libraries/octree/src/OctreeScriptingInterface.cpp index 618e8ac469..b1729c649e 100644 --- a/libraries/octree/src/OctreeScriptingInterface.cpp +++ b/libraries/octree/src/OctreeScriptingInterface.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "OctreeScriptingInterface.h" +#include + OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender) : _packetSender(packetSender), _managedPacketSender(false), diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 68f21eea87..a801392b66 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EntityMotionState.h" + #include #include @@ -19,7 +21,6 @@ #include #include "BulletUtil.h" -#include "EntityMotionState.h" #include "PhysicsEngine.h" #include "PhysicsHelpers.h" #include "PhysicsLogging.h" diff --git a/libraries/physics/src/MeshMassProperties.cpp b/libraries/physics/src/MeshMassProperties.cpp index a6a33932aa..ad4208e6a1 100644 --- a/libraries/physics/src/MeshMassProperties.cpp +++ b/libraries/physics/src/MeshMassProperties.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "MeshMassProperties.h" + #include #include -#include "MeshMassProperties.h" - // this method is included for unit test verification void computeBoxInertia(btScalar mass, const btVector3& diagonal, btMatrix3x3& inertia) { // formula for box inertia tensor: diff --git a/libraries/physics/src/ObjectAction.cpp b/libraries/physics/src/ObjectAction.cpp index 87732ded03..dfcf1aba33 100644 --- a/libraries/physics/src/ObjectAction.cpp +++ b/libraries/physics/src/ObjectAction.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "EntitySimulation.h" - #include "ObjectAction.h" +#include "EntitySimulation.h" + #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectActionOffset.cpp b/libraries/physics/src/ObjectActionOffset.cpp index e90862266b..4c2ed35f8e 100644 --- a/libraries/physics/src/ObjectActionOffset.cpp +++ b/libraries/physics/src/ObjectActionOffset.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "QVariantGLM.h" - #include "ObjectActionOffset.h" +#include "QVariantGLM.h" + #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectActionTractor.cpp b/libraries/physics/src/ObjectActionTractor.cpp index 9b2da22665..a48989be33 100644 --- a/libraries/physics/src/ObjectActionTractor.cpp +++ b/libraries/physics/src/ObjectActionTractor.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "QVariantGLM.h" - #include "ObjectActionTractor.h" +#include "QVariantGLM.h" + #include "PhysicsLogging.h" const float TRACTOR_MAX_SPEED = 10.0f; diff --git a/libraries/physics/src/ObjectActionTravelOriented.cpp b/libraries/physics/src/ObjectActionTravelOriented.cpp index accade8695..c93cce2482 100644 --- a/libraries/physics/src/ObjectActionTravelOriented.cpp +++ b/libraries/physics/src/ObjectActionTravelOriented.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectActionTravelOriented.h" + #include #include "QVariantGLM.h" -#include "ObjectActionTravelOriented.h" #include "PhysicsLogging.h" const uint16_t ObjectActionTravelOriented::actionVersion = 1; diff --git a/libraries/physics/src/ObjectConstraint.cpp b/libraries/physics/src/ObjectConstraint.cpp index 54fd4777e0..38467b1d83 100644 --- a/libraries/physics/src/ObjectConstraint.cpp +++ b/libraries/physics/src/ObjectConstraint.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "EntitySimulation.h" - #include "ObjectConstraint.h" +#include "EntitySimulation.h" + #include "PhysicsLogging.h" ObjectConstraint::ObjectConstraint(EntityDynamicType type, const QUuid& id, EntityItemPointer ownerEntity) : diff --git a/libraries/physics/src/ObjectConstraintBallSocket.cpp b/libraries/physics/src/ObjectConstraintBallSocket.cpp index 4736f2c9e2..b7a186e187 100644 --- a/libraries/physics/src/ObjectConstraintBallSocket.cpp +++ b/libraries/physics/src/ObjectConstraintBallSocket.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectConstraintBallSocket.h" + #include #include "QVariantGLM.h" #include "EntityTree.h" -#include "ObjectConstraintBallSocket.h" #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectConstraintConeTwist.cpp b/libraries/physics/src/ObjectConstraintConeTwist.cpp index 47228c1c16..e2b86a9e0f 100644 --- a/libraries/physics/src/ObjectConstraintConeTwist.cpp +++ b/libraries/physics/src/ObjectConstraintConeTwist.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectConstraintConeTwist.h" + #include #include "QVariantGLM.h" #include "EntityTree.h" -#include "ObjectConstraintConeTwist.h" #include "PhysicsLogging.h" const uint16_t CONE_TWIST_VERSION_WITH_UNUSED_PAREMETERS = 1; diff --git a/libraries/physics/src/ObjectConstraintHinge.cpp b/libraries/physics/src/ObjectConstraintHinge.cpp index 4793741391..0a01f413dc 100644 --- a/libraries/physics/src/ObjectConstraintHinge.cpp +++ b/libraries/physics/src/ObjectConstraintHinge.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectConstraintHinge.h" + #include #include "QVariantGLM.h" #include "EntityTree.h" -#include "ObjectConstraintHinge.h" #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectConstraintSlider.cpp b/libraries/physics/src/ObjectConstraintSlider.cpp index da5bba7f4d..4776e0e4a6 100644 --- a/libraries/physics/src/ObjectConstraintSlider.cpp +++ b/libraries/physics/src/ObjectConstraintSlider.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectConstraintSlider.h" + #include #include "QVariantGLM.h" #include "EntityTree.h" -#include "ObjectConstraintSlider.h" #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectDynamic.cpp b/libraries/physics/src/ObjectDynamic.cpp index 5bbb5981d1..3341025a8f 100644 --- a/libraries/physics/src/ObjectDynamic.cpp +++ b/libraries/physics/src/ObjectDynamic.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "EntitySimulation.h" - #include "ObjectDynamic.h" +#include "EntitySimulation.h" + #include "PhysicsLogging.h" diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index b11e21366e..64d2368207 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ObjectMotionState.h" + #include #include "BulletUtil.h" -#include "ObjectMotionState.h" #include "PhysicsEngine.h" #include "PhysicsHelpers.h" #include "PhysicsLogging.h" diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 50d516c256..83ffa21a55 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -9,18 +9,18 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include "PhysicsEngine.h" #include #include #include +#include #include #include "CharacterController.h" #include "ObjectMotionState.h" -#include "PhysicsEngine.h" #include "PhysicsHelpers.h" #include "PhysicsDebugDraw.h" #include "ThreadSafeDynamicsWorld.h" diff --git a/libraries/physics/src/ShapeFactory.cpp b/libraries/physics/src/ShapeFactory.cpp index 5abeb022aa..8057eb0e0c 100644 --- a/libraries/physics/src/ShapeFactory.cpp +++ b/libraries/physics/src/ShapeFactory.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ShapeFactory.h" + #include #include // for MILLIMETERS_PER_METER -#include "ShapeFactory.h" #include "BulletUtil.h" diff --git a/libraries/physics/src/ShapeManager.cpp b/libraries/physics/src/ShapeManager.cpp index 97b9e5dab1..ef7a4a1749 100644 --- a/libraries/physics/src/ShapeManager.cpp +++ b/libraries/physics/src/ShapeManager.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include "ShapeManager.h" #include +#include + #include "ShapeFactory.h" -#include "ShapeManager.h" ShapeManager::ShapeManager() { } diff --git a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp index 5b8c0d5843..3f24851dce 100644 --- a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp +++ b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp @@ -15,9 +15,10 @@ * Copied and modified from btDiscreteDynamicsWorld.cpp by AndrewMeadows on 2014.11.12. * */ +#include "ThreadSafeDynamicsWorld.h" + #include -#include "ThreadSafeDynamicsWorld.h" #include "Profile.h" ThreadSafeDynamicsWorld::ThreadSafeDynamicsWorld( diff --git a/libraries/recording/src/recording/ClipCache.cpp b/libraries/recording/src/recording/ClipCache.cpp index 0fbbf1bc8e..c63350de7f 100644 --- a/libraries/recording/src/recording/ClipCache.cpp +++ b/libraries/recording/src/recording/ClipCache.cpp @@ -6,11 +6,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ClipCache.h" + #include #include -#include "ClipCache.h" #include "impl/PointerClip.h" #include "Logging.h" diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index c526f16b75..2ac8e77898 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - -#include +#include "AmbientOcclusionEffect.h" #include //min max and more +#include #include #include @@ -22,7 +22,6 @@ #include "RenderUtilsLogging.h" #include "DeferredLightingEffect.h" -#include "AmbientOcclusionEffect.h" #include "TextureCache.h" #include "FramebufferCache.h" #include "DependencyManager.h" @@ -543,4 +542,4 @@ void DebugAmbientOcclusion::run(const render::RenderContextPointer& renderContex }); } - \ No newline at end of file + diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index c9aa1b8f71..2173aef76a 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AntialiasingEffect.h" #include @@ -17,7 +18,6 @@ #include #include -#include "AntialiasingEffect.h" #include "StencilMaskPass.h" #include "TextureCache.h" #include "DependencyManager.h" diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index 854ff71e20..ceac4ae3c8 100644 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ViewFrustum.h" - #include "LightStage.h" #include +#include "ViewFrustum.h" + std::string LightStage::_stageName { "LIGHT_STAGE"}; const glm::mat4 LightStage::Shadow::_biasMatrix{ 0.5, 0.0, 0.0, 0.0, diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index a3abb24afe..b02266e67b 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -10,10 +10,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "RenderPipelines.h" + #include #include #include +#include #include "StencilMaskPass.h" #include "DeferredLightingEffect.h" @@ -615,9 +618,6 @@ void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) { skinModelShadowFadeDualQuatProgram, state); } -#include "RenderPipelines.h" -#include - // FIXME find a better way to setup the default textures void RenderPipelines::bindMaterial(const graphics::MaterialPointer& material, gpu::Batch& batch, bool enableTextures) { if (!material) { diff --git a/libraries/render/src/render/DrawTask.cpp b/libraries/render/src/render/DrawTask.cpp index 8aabffea46..3a7555f790 100755 --- a/libraries/render/src/render/DrawTask.cpp +++ b/libraries/render/src/render/DrawTask.cpp @@ -9,19 +9,19 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "DrawTask.h" -#include "Logging.h" #include #include +#include #include #include #include #include +#include "Logging.h" + #include "drawItemBounds_vert.h" #include "drawItemBounds_frag.h" diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 35cc66315b..703acc5fa6 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -9,12 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "DependencyManager.h" -#include "Logging.h" #include "ShapePipeline.h" #include +#include "DependencyManager.h" +#include "Logging.h" + using namespace render; ShapePipeline::CustomFactoryMap ShapePipeline::_globalCustomFactoryMap; @@ -182,4 +183,4 @@ const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Ke } return shapePipeline; -} \ No newline at end of file +} diff --git a/libraries/script-engine/src/ArrayBufferClass.cpp b/libraries/script-engine/src/ArrayBufferClass.cpp index 4a06dee391..f64dbeffd6 100644 --- a/libraries/script-engine/src/ArrayBufferClass.cpp +++ b/libraries/script-engine/src/ArrayBufferClass.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ArrayBufferClass.h" + #include #include "ArrayBufferPrototype.h" @@ -16,8 +18,6 @@ #include "ScriptEngine.h" #include "TypedArrays.h" -#include "ArrayBufferClass.h" - static const QString CLASS_NAME = "ArrayBuffer"; diff --git a/libraries/script-engine/src/ArrayBufferPrototype.cpp b/libraries/script-engine/src/ArrayBufferPrototype.cpp index 9739f67381..d75482aa2e 100644 --- a/libraries/script-engine/src/ArrayBufferPrototype.cpp +++ b/libraries/script-engine/src/ArrayBufferPrototype.cpp @@ -9,13 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ArrayBufferPrototype.h" + #include #include #include #include "ArrayBufferClass.h" -#include "ArrayBufferPrototype.h" static const int QCOMPRESS_HEADER_POSITION = 0; static const int QCOMPRESS_HEADER_SIZE = 4; diff --git a/libraries/script-engine/src/BatchLoader.cpp b/libraries/script-engine/src/BatchLoader.cpp index 0c65d5c6f0..4e2943d536 100644 --- a/libraries/script-engine/src/BatchLoader.cpp +++ b/libraries/script-engine/src/BatchLoader.cpp @@ -9,15 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "BatchLoader.h" + #include #include - #include #include -#include "ScriptEngineLogging.h" -#include "BatchLoader.h" + #include #include + +#include "ScriptEngineLogging.h" #include "ResourceManager.h" #include "ScriptEngines.h" #include "ScriptCache.h" diff --git a/libraries/script-engine/src/ConsoleScriptingInterface.cpp b/libraries/script-engine/src/ConsoleScriptingInterface.cpp index b4ef98938d..60de04aa9e 100644 --- a/libraries/script-engine/src/ConsoleScriptingInterface.cpp +++ b/libraries/script-engine/src/ConsoleScriptingInterface.cpp @@ -15,8 +15,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "ConsoleScriptingInterface.h" + +#include + #include "ScriptEngine.h" #define INDENTATION 4 // 1 Tab - 4 spaces diff --git a/libraries/script-engine/src/DataViewClass.cpp b/libraries/script-engine/src/DataViewClass.cpp index a65bdff617..3cc5443973 100644 --- a/libraries/script-engine/src/DataViewClass.cpp +++ b/libraries/script-engine/src/DataViewClass.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "DataViewPrototype.h" - #include "DataViewClass.h" +#include "DataViewPrototype.h" + Q_DECLARE_METATYPE(QByteArray*) static const QString DATA_VIEW_NAME = "DataView"; @@ -91,4 +91,4 @@ QString DataViewClass::name() const { QScriptValue DataViewClass::prototype() const { return _proto; -} \ No newline at end of file +} diff --git a/libraries/script-engine/src/DataViewPrototype.cpp b/libraries/script-engine/src/DataViewPrototype.cpp index 8bab574f33..ef757a5cb4 100644 --- a/libraries/script-engine/src/DataViewPrototype.cpp +++ b/libraries/script-engine/src/DataViewPrototype.cpp @@ -8,14 +8,15 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + +#include "DataViewPrototype.h" + #include #include #include "DataViewClass.h" -#include "DataViewPrototype.h" - Q_DECLARE_METATYPE(QByteArray*) DataViewPrototype::DataViewPrototype(QObject* parent) : QObject(parent) { diff --git a/libraries/script-engine/src/EventTypes.cpp b/libraries/script-engine/src/EventTypes.cpp index abdd934e5a..94c074d44e 100644 --- a/libraries/script-engine/src/EventTypes.cpp +++ b/libraries/script-engine/src/EventTypes.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "EventTypes.h" + #include "KeyEvent.h" #include "MouseEvent.h" #include "SpatialEvent.h" @@ -16,8 +18,6 @@ #include "TouchEvent.h" #include "WheelEvent.h" -#include "EventTypes.h" - void registerEventTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, KeyEvent::toScriptValue, KeyEvent::fromScriptValue); qScriptRegisterMetaType(engine, MouseEvent::toScriptValue, MouseEvent::fromScriptValue); diff --git a/libraries/script-engine/src/KeyEvent.cpp b/libraries/script-engine/src/KeyEvent.cpp index 581f9a816b..b0e622a774 100644 --- a/libraries/script-engine/src/KeyEvent.cpp +++ b/libraries/script-engine/src/KeyEvent.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "KeyEvent.h" + #include #include #include "ScriptEngineLogging.h" -#include "KeyEvent.h" - KeyEvent::KeyEvent() : key(0), text(""), diff --git a/libraries/script-engine/src/Mat4.cpp b/libraries/script-engine/src/Mat4.cpp index 15015782e2..3e75d815c3 100644 --- a/libraries/script-engine/src/Mat4.cpp +++ b/libraries/script-engine/src/Mat4.cpp @@ -9,14 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include +#include "Mat4.h" + #include #include #include + +#include +#include + #include "ScriptEngineLogging.h" #include "ScriptEngine.h" -#include "Mat4.h" glm::mat4 Mat4::multiply(const glm::mat4& m1, const glm::mat4& m2) const { return m1 * m2; diff --git a/libraries/script-engine/src/MenuItemProperties.cpp b/libraries/script-engine/src/MenuItemProperties.cpp index 40254eeccb..2662ba406d 100644 --- a/libraries/script-engine/src/MenuItemProperties.cpp +++ b/libraries/script-engine/src/MenuItemProperties.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include #include "MenuItemProperties.h" +#include +#include MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName, diff --git a/libraries/script-engine/src/MouseEvent.cpp b/libraries/script-engine/src/MouseEvent.cpp index 20bac96087..1bace0425f 100644 --- a/libraries/script-engine/src/MouseEvent.cpp +++ b/libraries/script-engine/src/MouseEvent.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "MouseEvent.h" + #include #include -#include "MouseEvent.h" - MouseEvent::MouseEvent() : x(0.0f), y(0.0f), @@ -104,4 +104,4 @@ QScriptValue MouseEvent::toScriptValue(QScriptEngine* engine, const MouseEvent& void MouseEvent::fromScriptValue(const QScriptValue& object, MouseEvent& event) { // nothing for now... -} \ No newline at end of file +} diff --git a/libraries/script-engine/src/MouseEvent.h b/libraries/script-engine/src/MouseEvent.h index 0fbc688e5f..d9b00a8e01 100644 --- a/libraries/script-engine/src/MouseEvent.h +++ b/libraries/script-engine/src/MouseEvent.h @@ -13,6 +13,9 @@ #define hifi_MouseEvent_h #include +#include + +class QScriptEngine; class MouseEvent { public: @@ -38,4 +41,4 @@ public: Q_DECLARE_METATYPE(MouseEvent) -#endif // hifi_MouseEvent_h \ No newline at end of file +#endif // hifi_MouseEvent_h diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index a6f7acffc8..afff0a6b03 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -9,16 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Quat.h" + #include +#include #include #include -#include -#include + #include "ScriptEngineLogging.h" #include "ScriptEngine.h" -#include "Quat.h" quat Quat::normalize(const glm::quat& q) { return glm::normalize(q); diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index 254757dece..1ccdfdbf31 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -20,6 +20,8 @@ #include #include +#include + /**jsdoc * A quaternion value. See also the {@link Quat(0)|Quat} object. * @typedef {object} Quat diff --git a/libraries/script-engine/src/ScriptAudioInjector.cpp b/libraries/script-engine/src/ScriptAudioInjector.cpp index 516f62401f..8b51377bff 100644 --- a/libraries/script-engine/src/ScriptAudioInjector.cpp +++ b/libraries/script-engine/src/ScriptAudioInjector.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ScriptEngineLogging.h" #include "ScriptAudioInjector.h" +#include "ScriptEngineLogging.h" + QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in) { // The AudioScriptingInterface::playSound method can return null, so we need to account for that. if (!in) { diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 4915a2dc8b..9a383454d4 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ScriptEngine.h" + #include #include @@ -67,7 +69,6 @@ #include "ScriptAvatarData.h" #include "ScriptCache.h" #include "ScriptEngineLogging.h" -#include "ScriptEngine.h" #include "TypedArrays.h" #include "XMLHttpRequestClass.h" #include "WebSocketClass.h" diff --git a/libraries/script-engine/src/ScriptUUID.cpp b/libraries/script-engine/src/ScriptUUID.cpp index ee15f1a760..f88803c87c 100644 --- a/libraries/script-engine/src/ScriptUUID.cpp +++ b/libraries/script-engine/src/ScriptUUID.cpp @@ -11,11 +11,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ScriptUUID.h" + #include #include "ScriptEngineLogging.h" #include "ScriptEngine.h" -#include "ScriptUUID.h" QUuid ScriptUUID::fromString(const QString& s) { return QUuid(s); diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index 9b61f451c5..0af0c1cf8e 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -15,6 +15,7 @@ #define hifi_ScriptUUID_h #include +#include #include /**jsdoc diff --git a/libraries/script-engine/src/SpatialEvent.cpp b/libraries/script-engine/src/SpatialEvent.cpp index f20a0c2b1e..d06cc556d3 100644 --- a/libraries/script-engine/src/SpatialEvent.cpp +++ b/libraries/script-engine/src/SpatialEvent.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "SpatialEvent.h" +#include + SpatialEvent::SpatialEvent() : locTranslation(0.0f), locRotation(), @@ -43,4 +43,4 @@ QScriptValue SpatialEvent::toScriptValue(QScriptEngine* engine, const SpatialEve void SpatialEvent::fromScriptValue(const QScriptValue& object,SpatialEvent& event) { // nothing for now... -} \ No newline at end of file +} diff --git a/libraries/script-engine/src/TouchEvent.cpp b/libraries/script-engine/src/TouchEvent.cpp index 097639d4e8..6ff591decf 100644 --- a/libraries/script-engine/src/TouchEvent.cpp +++ b/libraries/script-engine/src/TouchEvent.cpp @@ -9,15 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "TouchEvent.h" + #include #include -#include #include #include -#include "TouchEvent.h" - TouchEvent::TouchEvent() : x(0.0f), y(0.0f), diff --git a/libraries/script-engine/src/TouchEvent.h b/libraries/script-engine/src/TouchEvent.h index d9eedf50d0..62cb1b1801 100644 --- a/libraries/script-engine/src/TouchEvent.h +++ b/libraries/script-engine/src/TouchEvent.h @@ -13,8 +13,13 @@ #define hifi_TouchEvent_h #include + +#include #include +class QScriptValue; +class QScriptEngine; + class TouchEvent { public: TouchEvent(); @@ -54,4 +59,4 @@ private: Q_DECLARE_METATYPE(TouchEvent) -#endif // hifi_TouchEvent_h \ No newline at end of file +#endif // hifi_TouchEvent_h diff --git a/libraries/script-engine/src/TypedArrayPrototype.cpp b/libraries/script-engine/src/TypedArrayPrototype.cpp index 4de948e806..a1f3ff87e8 100644 --- a/libraries/script-engine/src/TypedArrayPrototype.cpp +++ b/libraries/script-engine/src/TypedArrayPrototype.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "TypedArrays.h" - #include "TypedArrayPrototype.h" +#include "TypedArrays.h" + Q_DECLARE_METATYPE(QByteArray*) TypedArrayPrototype::TypedArrayPrototype(QObject* parent) : QObject(parent) { diff --git a/libraries/script-engine/src/TypedArrays.cpp b/libraries/script-engine/src/TypedArrays.cpp index 4d5181ff33..f2c3d3fd3d 100644 --- a/libraries/script-engine/src/TypedArrays.cpp +++ b/libraries/script-engine/src/TypedArrays.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "TypedArrays.h" + #include #include "ScriptEngine.h" #include "TypedArrayPrototype.h" -#include "TypedArrays.h" - Q_DECLARE_METATYPE(QByteArray*) TypedArray::TypedArray(ScriptEngine* scriptEngine, QString name) : ArrayBufferViewClass(scriptEngine) { diff --git a/libraries/script-engine/src/UndoStackScriptingInterface.cpp b/libraries/script-engine/src/UndoStackScriptingInterface.cpp index 17bf8b1aa6..1171625c04 100644 --- a/libraries/script-engine/src/UndoStackScriptingInterface.cpp +++ b/libraries/script-engine/src/UndoStackScriptingInterface.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "UndoStackScriptingInterface.h" + #include #include #include #include -#include "UndoStackScriptingInterface.h" - UndoStackScriptingInterface::UndoStackScriptingInterface(QUndoStack* undoStack) : _undoStack(undoStack) { } diff --git a/libraries/script-engine/src/Vec3.cpp b/libraries/script-engine/src/Vec3.cpp index c21f96cd47..2d3d4454c3 100644 --- a/libraries/script-engine/src/Vec3.cpp +++ b/libraries/script-engine/src/Vec3.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Vec3.h" + #include #include @@ -16,11 +18,10 @@ #include #include -#include "ScriptEngineLogging.h" #include "NumericalConstants.h" -#include "Vec3.h" - #include "ScriptEngine.h" +#include "ScriptEngineLogging.h" + float Vec3::orientedAngle(const glm::vec3& v1, const glm::vec3& v2, const glm::vec3& v3) { float radians = glm::orientedAngle(glm::normalize(v1), glm::normalize(v2), glm::normalize(v3)); diff --git a/libraries/script-engine/src/WebSocketClass.cpp b/libraries/script-engine/src/WebSocketClass.cpp index 76faaab415..56753f07d1 100644 --- a/libraries/script-engine/src/WebSocketClass.cpp +++ b/libraries/script-engine/src/WebSocketClass.cpp @@ -12,9 +12,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ScriptEngine.h" #include "WebSocketClass.h" +#include "ScriptEngine.h" + WebSocketClass::WebSocketClass(QScriptEngine* engine, QString url) : _webSocket(new QWebSocket()), _engine(engine) diff --git a/libraries/script-engine/src/WebSocketServerClass.cpp b/libraries/script-engine/src/WebSocketServerClass.cpp index 3b723d5b3f..860170a3f9 100644 --- a/libraries/script-engine/src/WebSocketServerClass.cpp +++ b/libraries/script-engine/src/WebSocketServerClass.cpp @@ -11,9 +11,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ScriptEngine.h" #include "WebSocketServerClass.h" +#include "ScriptEngine.h" + WebSocketServerClass::WebSocketServerClass(QScriptEngine* engine, const QString& serverName, const quint16 port) : _webSocketServer(serverName, QWebSocketServer::SslMode::NonSecureMode), _engine(engine) diff --git a/libraries/script-engine/src/WheelEvent.cpp b/libraries/script-engine/src/WheelEvent.cpp index 70004d0d3f..a0a897c991 100644 --- a/libraries/script-engine/src/WheelEvent.cpp +++ b/libraries/script-engine/src/WheelEvent.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include - #include "WheelEvent.h" +#include +#include + WheelEvent::WheelEvent() : x(0.0f), y(0.0f), @@ -99,4 +99,4 @@ QScriptValue WheelEvent::toScriptValue(QScriptEngine* engine, const WheelEvent& void WheelEvent::fromScriptValue(const QScriptValue& object, WheelEvent& event) { // nothing for now... -} \ No newline at end of file +} diff --git a/libraries/script-engine/src/WheelEvent.h b/libraries/script-engine/src/WheelEvent.h index edac4bc3c3..88ac828578 100644 --- a/libraries/script-engine/src/WheelEvent.h +++ b/libraries/script-engine/src/WheelEvent.h @@ -12,8 +12,12 @@ #ifndef hifi_WheelEvent_h #define hifi_WheelEvent_h +#include #include +class QScriptValue; +class QScriptEngine; + class WheelEvent { public: WheelEvent(); @@ -37,4 +41,4 @@ public: Q_DECLARE_METATYPE(WheelEvent) -#endif // hifi_WheelEvent_h \ No newline at end of file +#endif // hifi_WheelEvent_h diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index 62384f9d97..ebc459b2d1 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -12,6 +12,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "XMLHttpRequestClass.h" + #include #include @@ -20,7 +22,6 @@ #include #include "ScriptEngine.h" -#include "XMLHttpRequestClass.h" const QString METAVERSE_API_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/api/"; diff --git a/libraries/shared/src/AACube.cpp b/libraries/shared/src/AACube.cpp index 8cff3255b3..7dd2f8cb5b 100644 --- a/libraries/shared/src/AACube.cpp +++ b/libraries/shared/src/AACube.cpp @@ -9,8 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "AABox.h" #include "AACube.h" + +#include "AABox.h" #include "Extents.h" #include "GeometryUtil.h" #include "NumericalConstants.h" diff --git a/libraries/shared/src/CubeProjectedPolygon.cpp b/libraries/shared/src/CubeProjectedPolygon.cpp index 04d6e8bb4e..acd2fc11d6 100644 --- a/libraries/shared/src/CubeProjectedPolygon.cpp +++ b/libraries/shared/src/CubeProjectedPolygon.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "CubeProjectedPolygon.h" + #include #include @@ -16,8 +18,6 @@ #include "GeometryUtil.h" #include "SharedUtil.h" #include "SharedLogging.h" -#include "CubeProjectedPolygon.h" - glm::vec2 BoundingRectangle::getVertex(int vertexNumber) const { switch (vertexNumber) { diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 309cb30728..3b7a6cee40 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -8,8 +8,7 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -#include - +#include "GPUIdent.h" #ifdef Q_OS_WIN #include @@ -24,8 +23,9 @@ #include #endif +#include + #include "SharedLogging.h" -#include "GPUIdent.h" GPUIdent GPUIdent::_instance {}; diff --git a/libraries/shared/src/GPUIdent.h b/libraries/shared/src/GPUIdent.h index 8615e61b08..f780a4ddbd 100644 --- a/libraries/shared/src/GPUIdent.h +++ b/libraries/shared/src/GPUIdent.h @@ -16,6 +16,8 @@ #include +#include + class GPUIdent { public: diff --git a/libraries/shared/src/GenericThread.cpp b/libraries/shared/src/GenericThread.cpp index 230b9590f1..e35c74e68a 100644 --- a/libraries/shared/src/GenericThread.cpp +++ b/libraries/shared/src/GenericThread.cpp @@ -9,11 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include - #include "GenericThread.h" +#include +#include GenericThread::GenericThread() : _stopThread(false), diff --git a/libraries/shared/src/Gzip.cpp b/libraries/shared/src/Gzip.cpp index 25e214fffb..06b499b88a 100644 --- a/libraries/shared/src/Gzip.cpp +++ b/libraries/shared/src/Gzip.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include #include "Gzip.h" +#include + const int GZIP_WINDOWS_BIT = 31; const int GZIP_CHUNK_SIZE = 4096; const int DEFAULT_MEM_LEVEL = 8; diff --git a/libraries/shared/src/LogUtils.cpp b/libraries/shared/src/LogUtils.cpp index 73667116a0..11a4665ab1 100644 --- a/libraries/shared/src/LogUtils.cpp +++ b/libraries/shared/src/LogUtils.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "LogUtils.h" +#include + void LogUtils::init() { #ifdef Q_OS_WIN // Windows applications buffer stdout/err hard when not run from a terminal, diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index c7ad4a790d..7f7d03c335 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OctalCode.h" + #include // std:min #include #include @@ -17,7 +19,6 @@ #include #include "NumericalConstants.h" -#include "OctalCode.h" #include "SharedUtil.h" int numberOfThreeBitSectionsInCode(const unsigned char* octalCode, int maxBytes) { diff --git a/libraries/shared/src/PIDController.cpp b/libraries/shared/src/PIDController.cpp index 790c26ac25..5850e345cb 100644 --- a/libraries/shared/src/PIDController.cpp +++ b/libraries/shared/src/PIDController.cpp @@ -9,11 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include -#include "SharedLogging.h" #include "PIDController.h" +#include + +#include + +#include "SharedLogging.h" + float PIDController::update(float measuredValue, float dt, bool resetAccumulator) { const float error = getMeasuredValueSetpoint() - measuredValue; // Sign is the direction we want measuredValue to go. Positive means go higher. diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 13b3d44eda..c3bc44b7d3 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "PerfStat.h" + #include #include #include @@ -16,8 +18,6 @@ #include #include -#include "PerfStat.h" - #include "NumericalConstants.h" #include "SharedLogging.h" diff --git a/libraries/shared/src/SimpleMovingAverage.cpp b/libraries/shared/src/SimpleMovingAverage.cpp index f75180afb5..9bcc6b732f 100644 --- a/libraries/shared/src/SimpleMovingAverage.cpp +++ b/libraries/shared/src/SimpleMovingAverage.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "SharedUtil.h" #include "SimpleMovingAverage.h" +#include "SharedUtil.h" + SimpleMovingAverage::SimpleMovingAverage(int numSamplesToAverage) : _numSamples(0), _lastEventTimestamp(0), diff --git a/libraries/shared/src/StDev.cpp b/libraries/shared/src/StDev.cpp index 23afd12b98..99280ba42e 100644 --- a/libraries/shared/src/StDev.cpp +++ b/libraries/shared/src/StDev.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "StDev.h" + #include #include #include -#include "StDev.h" - StDev::StDev() : _sampleCount(0) { diff --git a/libraries/shared/src/StreamUtils.cpp b/libraries/shared/src/StreamUtils.cpp index 876de2e698..9ed0e24593 100644 --- a/libraries/shared/src/StreamUtils.cpp +++ b/libraries/shared/src/StreamUtils.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include "StreamUtils.h" #include -#include "StreamUtils.h" +#include void StreamUtil::dump(std::ostream& s, const QByteArray& buffer) { diff --git a/libraries/shared/src/TriangleSet.cpp b/libraries/shared/src/TriangleSet.cpp index 3f8f748720..d7f685f8d3 100644 --- a/libraries/shared/src/TriangleSet.cpp +++ b/libraries/shared/src/TriangleSet.cpp @@ -9,9 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "GLMHelpers.h" #include "TriangleSet.h" +#include "GLMHelpers.h" void TriangleSet::insert(const Triangle& t) { _isBalanced = false; diff --git a/libraries/shared/src/VariantMapToScriptValue.cpp b/libraries/shared/src/VariantMapToScriptValue.cpp index 00fc2cd682..008c3a5d9b 100644 --- a/libraries/shared/src/VariantMapToScriptValue.cpp +++ b/libraries/shared/src/VariantMapToScriptValue.cpp @@ -9,10 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include -#include "SharedLogging.h" #include "VariantMapToScriptValue.h" +#include + +#include "SharedLogging.h" QScriptValue variantToScriptValue(QVariant& qValue, QScriptEngine& scriptEngine) { switch(qValue.type()) { diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index 3aa70b0897..3e03c13fa4 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ViewFrustum.h" + #include #include @@ -16,15 +18,13 @@ #include #include #include -#include +#include #include "GeometryUtil.h" #include "GLMHelpers.h" #include "NumericalConstants.h" #include "SharedLogging.h" -//#include "OctreeConstants.h" -#include "ViewFrustum.h" using namespace std; diff --git a/libraries/shared/src/shared/StringHelpers.cpp b/libraries/shared/src/shared/StringHelpers.cpp index 1c1730bd5a..39ac23e510 100644 --- a/libraries/shared/src/shared/StringHelpers.cpp +++ b/libraries/shared/src/shared/StringHelpers.cpp @@ -6,10 +6,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "StringHelpers.h" +#include + /// Note: this will not preserve line breaks in the original input. QString simpleWordWrap(const QString& input, int maxCharactersPerLine) { QStringList words = input.split(QRegExp("\\s+")); diff --git a/plugins/pcmCodec/src/PCMCodecManager.cpp b/plugins/pcmCodec/src/PCMCodecManager.cpp index 051f3973a8..04adb367af 100644 --- a/plugins/pcmCodec/src/PCMCodecManager.cpp +++ b/plugins/pcmCodec/src/PCMCodecManager.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "PCMCodecManager.h" + #include #include -#include "PCMCodecManager.h" - const char* PCMCodec::NAME { "pcm" }; void PCMCodec::init() { diff --git a/tests/jitter/src/JitterTests.cpp b/tests/jitter/src/JitterTests.cpp index b09cb40d3e..5c81177b88 100644 --- a/tests/jitter/src/JitterTests.cpp +++ b/tests/jitter/src/JitterTests.cpp @@ -6,6 +6,8 @@ // Copyright (c) 2014 High Fidelity, Inc. All rights reserved. // +#include "JitterTests.h" + #include #ifdef _WINDOWS #include @@ -23,8 +25,6 @@ #include #include -#include "JitterTests.h" - // Uncomment this to run manually //#define RUN_MANUALLY diff --git a/tests/networking/src/ResourceTests.cpp b/tests/networking/src/ResourceTests.cpp index e83eeb66a0..864d7c9939 100644 --- a/tests/networking/src/ResourceTests.cpp +++ b/tests/networking/src/ResourceTests.cpp @@ -7,14 +7,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ResourceTests.h" + #include #include "ResourceCache.h" #include "NetworkAccessManager.h" #include "DependencyManager.h" -#include "ResourceTests.h" - QTEST_MAIN(ResourceTests) void ResourceTests::initTestCase() { diff --git a/tests/networking/src/SequenceNumberStatsTests.cpp b/tests/networking/src/SequenceNumberStatsTests.cpp index aaaeea53fc..0f01fb5b66 100644 --- a/tests/networking/src/SequenceNumberStatsTests.cpp +++ b/tests/networking/src/SequenceNumberStatsTests.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SequenceNumberStatsTests.h" + #include #include -#include "SequenceNumberStatsTests.h" - QTEST_MAIN(SequenceNumberStatsTests) const quint32 UINT16_RANGE = std::numeric_limits::max() + 1; diff --git a/tests/octree/src/AABoxCubeTests.cpp b/tests/octree/src/AABoxCubeTests.cpp index 8180e6f674..4e0a75e3b9 100644 --- a/tests/octree/src/AABoxCubeTests.cpp +++ b/tests/octree/src/AABoxCubeTests.cpp @@ -9,11 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "AABoxCubeTests.h" + #include #include -#include "AABoxCubeTests.h" - QTEST_MAIN(AABoxCubeTests) void AABoxCubeTests::raycastOutHitsXMinFace() { diff --git a/tests/octree/src/ModelTests.cpp b/tests/octree/src/ModelTests.cpp index c2d170da9a..f3e17a56a5 100644 --- a/tests/octree/src/ModelTests.cpp +++ b/tests/octree/src/ModelTests.cpp @@ -12,6 +12,9 @@ // * need to add expected results and accumulation of test success/failure // +#include "ModelTests.h" // needs to be EntityTests.h soon +//#include "EntityTests.h" + #include #include @@ -22,9 +25,6 @@ #include #include -//#include "EntityTests.h" -#include "ModelTests.h" // needs to be EntityTests.h soon - QTEST_MAIN(EntityTests) /* diff --git a/tests/octree/src/OctreeTests.cpp b/tests/octree/src/OctreeTests.cpp index 81300a1293..ae04313a6a 100644 --- a/tests/octree/src/OctreeTests.cpp +++ b/tests/octree/src/OctreeTests.cpp @@ -12,6 +12,8 @@ // * need to add expected results and accumulation of test success/failure // +#include "OctreeTests.h" + #include #include @@ -23,8 +25,6 @@ #include #include -#include "OctreeTests.h" - enum ExamplePropertyList { EXAMPLE_PROP_PAGED_PROPERTY, EXAMPLE_PROP_CUSTOM_PROPERTIES_INCLUDED, diff --git a/tests/physics/src/ShapeInfoTests.cpp b/tests/physics/src/ShapeInfoTests.cpp index 79d0092dc3..efc88a4032 100644 --- a/tests/physics/src/ShapeInfoTests.cpp +++ b/tests/physics/src/ShapeInfoTests.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ShapeInfoTests.h" + #include #include @@ -19,8 +21,6 @@ #include #include -#include "ShapeInfoTests.h" - QTEST_MAIN(ShapeInfoTests) // Enable this to manually run testHashCollisions diff --git a/tests/physics/src/ShapeManagerTests.cpp b/tests/physics/src/ShapeManagerTests.cpp index f214601a42..393bfdcd07 100644 --- a/tests/physics/src/ShapeManagerTests.cpp +++ b/tests/physics/src/ShapeManagerTests.cpp @@ -9,13 +9,14 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ShapeManagerTests.h" + #include + #include #include #include -#include "ShapeManagerTests.h" - QTEST_MAIN(ShapeManagerTests) void ShapeManagerTests::testShapeAccounting() { diff --git a/tests/shared/src/AABoxTests.cpp b/tests/shared/src/AABoxTests.cpp index 2e9dfab497..865a82e86c 100644 --- a/tests/shared/src/AABoxTests.cpp +++ b/tests/shared/src/AABoxTests.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "AABoxTests.h" +#include + #include #include #include diff --git a/tests/shared/src/AACubeTests.cpp b/tests/shared/src/AACubeTests.cpp index 177daf89f1..4d684b4677 100644 --- a/tests/shared/src/AACubeTests.cpp +++ b/tests/shared/src/AACubeTests.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "AACubeTests.h" +#include + #include #include #include diff --git a/tests/shared/src/DualQuaternionTests.cpp b/tests/shared/src/DualQuaternionTests.cpp index fe14d9d166..276eb44f64 100644 --- a/tests/shared/src/DualQuaternionTests.cpp +++ b/tests/shared/src/DualQuaternionTests.cpp @@ -8,10 +8,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "DualQuaternionTests.h" +#include + #include #include #include diff --git a/tests/shared/src/GeometryUtilTests.cpp b/tests/shared/src/GeometryUtilTests.cpp index eb9be4987f..9b4f0f250f 100644 --- a/tests/shared/src/GeometryUtilTests.cpp +++ b/tests/shared/src/GeometryUtilTests.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "GeometryUtilTests.h" +#include + #include #include #include diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index 4711dc4102..cfede87c53 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -9,10 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ACClientApp.h" + #include #include #include #include + #include #include #include @@ -20,8 +23,6 @@ #include #include -#include "ACClientApp.h" - ACClientApp::ACClientApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { diff --git a/tools/atp-client/src/ATPClientApp.cpp b/tools/atp-client/src/ATPClientApp.cpp index 526065b2f7..c688ba9c82 100644 --- a/tools/atp-client/src/ATPClientApp.cpp +++ b/tools/atp-client/src/ATPClientApp.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ATPClientApp.h" + #include #include #include @@ -25,8 +27,6 @@ #include #include -#include "ATPClientApp.h" - #define HIGH_FIDELITY_ATP_CLIENT_USER_AGENT "Mozilla/5.0 (HighFidelityATPClient)" #define TIMEOUT_MILLISECONDS 8000 diff --git a/tools/ice-client/src/ICEClientApp.cpp b/tools/ice-client/src/ICEClientApp.cpp index f9e7a76142..0301fad6f4 100644 --- a/tools/ice-client/src/ICEClientApp.cpp +++ b/tools/ice-client/src/ICEClientApp.cpp @@ -9,15 +9,16 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ICEClientApp.h" + #include #include #include + #include #include #include -#include "ICEClientApp.h" - ICEClientApp::ICEClientApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { diff --git a/tools/oven/src/BakerCLI.cpp b/tools/oven/src/BakerCLI.cpp index 35550cdca8..a7b8401269 100644 --- a/tools/oven/src/BakerCLI.cpp +++ b/tools/oven/src/BakerCLI.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "BakerCLI.h" + #include #include #include @@ -16,7 +18,6 @@ #include "OvenCLIApplication.h" #include "ModelBakingLoggingCategory.h" -#include "BakerCLI.h" #include "FBXBaker.h" #include "JSBaker.h" #include "TextureBaker.h" diff --git a/tools/oven/src/OvenCLIApplication.cpp b/tools/oven/src/OvenCLIApplication.cpp index 2fb8ea03f2..ab3178db01 100644 --- a/tools/oven/src/OvenCLIApplication.cpp +++ b/tools/oven/src/OvenCLIApplication.cpp @@ -9,13 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OvenCLIApplication.h" + #include #include #include "BakerCLI.h" -#include "OvenCLIApplication.h" - static const QString CLI_INPUT_PARAMETER = "i"; static const QString CLI_OUTPUT_PARAMETER = "o"; static const QString CLI_TYPE_PARAMETER = "t"; diff --git a/tools/oven/src/ui/BakeWidget.cpp b/tools/oven/src/ui/BakeWidget.cpp index 43f4c50328..931ef1de43 100644 --- a/tools/oven/src/ui/BakeWidget.cpp +++ b/tools/oven/src/ui/BakeWidget.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "BakeWidget.h" + #include #include "../OvenGUIApplication.h" -#include "BakeWidget.h" - BakeWidget::BakeWidget(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags) { diff --git a/tools/oven/src/ui/DomainBakeWidget.cpp b/tools/oven/src/ui/DomainBakeWidget.cpp index bf79319458..1121041e39 100644 --- a/tools/oven/src/ui/DomainBakeWidget.cpp +++ b/tools/oven/src/ui/DomainBakeWidget.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "DomainBakeWidget.h" + #include #include @@ -23,8 +25,6 @@ #include "../OvenGUIApplication.h" -#include "DomainBakeWidget.h" - static const QString DOMAIN_NAME_SETTING_KEY = "domain_name"; static const QString EXPORT_DIR_SETTING_KEY = "domain_export_directory"; static const QString BROWSE_START_DIR_SETTING_KEY = "domain_search_directory"; diff --git a/tools/oven/src/ui/ModelBakeWidget.cpp b/tools/oven/src/ui/ModelBakeWidget.cpp index f80185df0f..9fa586871e 100644 --- a/tools/oven/src/ui/ModelBakeWidget.cpp +++ b/tools/oven/src/ui/ModelBakeWidget.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModelBakeWidget.h" + #include #include #include @@ -26,7 +28,6 @@ #include "OvenMainWindow.h" #include "FBXBaker.h" #include "OBJBaker.h" -#include "ModelBakeWidget.h" static const auto EXPORT_DIR_SETTING_KEY = "model_export_directory"; diff --git a/tools/oven/src/ui/ModesWidget.cpp b/tools/oven/src/ui/ModesWidget.cpp index 624aa949cc..1fdfce2c97 100644 --- a/tools/oven/src/ui/ModesWidget.cpp +++ b/tools/oven/src/ui/ModesWidget.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ModesWidget.h" + #include #include #include @@ -17,8 +19,6 @@ #include "ModelBakeWidget.h" #include "SkyboxBakeWidget.h" -#include "ModesWidget.h" - ModesWidget::ModesWidget(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags) { diff --git a/tools/oven/src/ui/OvenMainWindow.cpp b/tools/oven/src/ui/OvenMainWindow.cpp index bebc2fa7dc..59cad3aac5 100644 --- a/tools/oven/src/ui/OvenMainWindow.cpp +++ b/tools/oven/src/ui/OvenMainWindow.cpp @@ -9,12 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "OvenMainWindow.h" + #include #include "ModesWidget.h" -#include "OvenMainWindow.h" - OvenMainWindow::OvenMainWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) { diff --git a/tools/oven/src/ui/ResultsWindow.cpp b/tools/oven/src/ui/ResultsWindow.cpp index 3a37a328de..feb7fbc4f1 100644 --- a/tools/oven/src/ui/ResultsWindow.cpp +++ b/tools/oven/src/ui/ResultsWindow.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "ResultsWindow.h" + #include #include #include @@ -17,8 +19,6 @@ #include "OvenMainWindow.h" -#include "ResultsWindow.h" - ResultsWindow::ResultsWindow(QWidget* parent) : QWidget(parent) { diff --git a/tools/oven/src/ui/SkyboxBakeWidget.cpp b/tools/oven/src/ui/SkyboxBakeWidget.cpp index 369b06c39f..71ae0cbab0 100644 --- a/tools/oven/src/ui/SkyboxBakeWidget.cpp +++ b/tools/oven/src/ui/SkyboxBakeWidget.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "SkyboxBakeWidget.h" + #include #include #include @@ -21,9 +23,9 @@ #include #include -#include "../OvenGUIApplication.h" +#include -#include "SkyboxBakeWidget.h" +#include "../OvenGUIApplication.h" static const auto EXPORT_DIR_SETTING_KEY = "skybox_export_directory"; static const auto SELECTION_START_DIR_SETTING_KEY = "skybox_search_directory"; diff --git a/tools/vhacd-util/src/VHACDUtilApp.cpp b/tools/vhacd-util/src/VHACDUtilApp.cpp index 4d48bdf2bf..c263dce609 100644 --- a/tools/vhacd-util/src/VHACDUtilApp.cpp +++ b/tools/vhacd-util/src/VHACDUtilApp.cpp @@ -9,10 +9,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "VHACDUtilApp.h" + #include + #include #include -#include "VHACDUtilApp.h" + #include "VHACDUtil.h" #include "PathUtils.h" From 72526781d9b1fabaeede002d972c48d76e1f631b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 19 Apr 2018 16:15:22 -0700 Subject: [PATCH 138/192] Additional work on splash screen --- interface/resources/shaders/splashSkybox.frag | 37 +++ interface/src/Application.cpp | 258 +++++++++++------- interface/src/Application.h | 2 + interface/src/Application_render.cpp | 4 +- interface/src/avatar/MyAvatar.cpp | 2 +- interface/src/avatar/MyAvatar.h | 2 +- .../display-plugins/OpenGLDisplayPlugin.cpp | 3 +- .../procedural/src/procedural/Procedural.cpp | 4 +- .../src/ui-plugins/PluginContainer.h | 6 + .../oculus/src/OculusBaseDisplayPlugin.cpp | 11 +- 10 files changed, 221 insertions(+), 108 deletions(-) create mode 100644 interface/resources/shaders/splashSkybox.frag diff --git a/interface/resources/shaders/splashSkybox.frag b/interface/resources/shaders/splashSkybox.frag new file mode 100644 index 0000000000..8088b745bc --- /dev/null +++ b/interface/resources/shaders/splashSkybox.frag @@ -0,0 +1,37 @@ + +float noise3D(vec3 p) +{ + return fract(sin(dot(p ,vec3(12.9898,78.233,126.7235))) * 43758.5453); +} + +float worley3D(vec3 p) +{ + float r = 3.0; + vec3 f = floor(p); + vec3 x = fract(p); + for(int i = -1; i<=1; i++) + { + for(int j = -1; j<=1; j++) + { + for(int k = -1; k<=1; k++) + { + vec3 q = vec3(float(i),float(j),float(k)); + vec3 v = q + vec3(noise3D((q+f)*1.11), noise3D((q+f)*1.14), noise3D((q+f)*1.17)) - x; + float d = dot(v, v); + r = min(r, d); + } + } + } + return sqrt(r); +} + + +vec3 getSkyboxColor() { + vec3 color = abs(normalize(_normal)); +// vec2 uv; +// uv.x = 0.5 + atan(_normal.z, _normal.x); +// uv.y = 0.5 - asin(_normal.y); +// uv *= 20.0; +// color.r = worley3D(vec3(uv, iGlobalTime)); + return color; +} \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 59541a3182..4a59cf3549 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -144,6 +144,7 @@ #include #include #include +#include #include #include @@ -385,7 +386,7 @@ Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTRE static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com"; static const int INTERVAL_TO_CHECK_HMD_WORN_STATUS = 500; // milliseconds static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop"; - +static const QString ACTIVE_DISPLAY_PLUGIN_SETTING_NAME = "activeDisplayPlugin"; static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system"; const std::vector> Application::_acceptedExtensions { @@ -1322,10 +1323,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo QCoreApplication::processEvents(); _glWidget->createContext(); - // Create the main thread context, the GPU backend, and the display plugins + // Create the main thread context, the GPU backend initializeGL(); - DependencyManager::get()->setGPUContext(_gpuContext); - qCDebug(interfaceapp, "Initialized Display."); + qCDebug(interfaceapp, "Initialized GL"); + + // Initialize the display plugin architecture + initializeDisplayPlugins(); + qCDebug(interfaceapp, "Initialized Display"); + // Create the rendering engine. This can be slow on some machines due to lots of // GPU pipeline creation. initializeRenderEngine(); @@ -2359,6 +2364,10 @@ void Application::onAboutToQuit() { } } + // The active display plugin needs to be loaded before the menu system is active, + // so its persisted explicitly here + Setting::Handle{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME }.set(getActiveDisplayPlugin()->getName()); + getActiveDisplayPlugin()->deactivate(); if (_autoSwitchDisplayModeSupportedHMDPlugin && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { @@ -2598,10 +2607,81 @@ void Application::initializeGL() { _glWidget->makeCurrent(); _gpuContext = std::make_shared(); + DependencyManager::get()->setGPUContext(_gpuContext); + // Restore the default main thread context _offscreenContext->makeCurrent(); +} - updateDisplayMode(); +static const QString SPLASH_SKYBOX{ "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" }; + +void Application::initializeDisplayPlugins() { + auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); + Setting::Handle activeDisplayPluginSetting{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME, displayPlugins.at(0)->getName() }; + auto lastActiveDisplayPluginName = activeDisplayPluginSetting.get(); + + auto defaultDisplayPlugin = displayPlugins.at(0); + // Once time initialization code + DisplayPluginPointer targetDisplayPlugin; + foreach(auto displayPlugin, displayPlugins) { + displayPlugin->setContext(_gpuContext); + if (displayPlugin->getName() == lastActiveDisplayPluginName) { + targetDisplayPlugin = displayPlugin; + } + QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, + [this](const QSize& size) { resizeGL(); }); + QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset); + } + + // The default display plugin needs to be activated first, otherwise the display plugin thread + // may be launched by an external plugin, which is bad + setDisplayPlugin(defaultDisplayPlugin); + + // Now set the desired plugin if it's not the same as the default plugin + if (targetDisplayPlugin != defaultDisplayPlugin) { + setDisplayPlugin(targetDisplayPlugin); + } + + // Submit a default frame to render until the engine starts up + updateRenderArgs(0.0f); + + _offscreenContext->makeCurrent(); + { + QMutexLocker viewLocker(&_renderArgsMutex); + + if (_appRenderArgs._isStereo) { + _gpuContext->enableStereo(true); + _gpuContext->setStereoProjections(_appRenderArgs._eyeProjections); + _gpuContext->setStereoViews(_appRenderArgs._eyeOffsets); + } + + // Frame resources + auto framebufferCache = DependencyManager::get(); + gpu::FramebufferPointer finalFramebuffer = framebufferCache->getFramebuffer(); + std::shared_ptr procedural = std::make_shared(); + procedural->parse(SPLASH_SKYBOX); + + _gpuContext->beginFrame(_appRenderArgs._view, _appRenderArgs._headPose); + gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { + batch.resetStages(); + batch.enableStereo(false); + batch.setFramebuffer(finalFramebuffer); + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 1, 1, 1 }); + + batch.enableSkybox(true); + batch.enableStereo(_appRenderArgs._isStereo); + batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); + procedural->render(batch, _appRenderArgs._renderArgs.getViewFrustum()); + }); + auto frame = _gpuContext->endFrame(); + frame->frameIndex = 0; + frame->framebuffer = finalFramebuffer; + frame->pose = _appRenderArgs._headPose; + frame->framebufferRecycler = [framebufferCache, procedural](const gpu::FramebufferPointer& framebuffer) { + framebufferCache->releaseFramebuffer(framebuffer); + }; + _displayPlugin->submitFrame(frame); + } } void Application::initializeRenderEngine() { @@ -2625,6 +2705,7 @@ void Application::initializeRenderEngine() { } extern void setupPreferences(); +static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, bool active); void Application::initializeUi() { // Build a shared canvas / context for the Chromium processes @@ -2766,10 +2847,25 @@ void Application::initializeUi() { offscreenSurfaceCache->reserve(TabletScriptingInterface::QML, 1); offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2); - // Now that the menu is instantiated, ensure the display plugin menu is properly updated - updateDisplayMode(); flushMenuUpdates(); + // Now that the menu is instantiated, ensure the display plugin menu is properly updated + { + auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); + // first sort the plugins into groupings: standard, advanced, developer + std::stable_sort(displayPlugins.begin(), displayPlugins.end(), + [](const DisplayPluginPointer& a, const DisplayPluginPointer& b)->bool { return a->getGrouping() < b->getGrouping(); }); + + // concatenate the groupings into a single list in the order: standard, advanced, developer + for(const auto& displayPlugin : displayPlugins) { + addDisplayPluginToMenu(displayPlugin, _displayPlugin == displayPlugin); + } + + // after all plugins have been added to the menu, add a separator to the menu + auto parent = getPrimaryMenu()->getMenu(MenuOption::OutputMenu); + parent->addSeparator(); + } + // The display plugins are created before the menu now, so we need to do this here to hide the menu bar // now that it exists if (_window && _window->isFullScreen()) { @@ -5723,6 +5819,32 @@ void Application::update(float deltaTime) { } + updateRenderArgs(deltaTime); + + // HACK + // load the view frustum + // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. + // Then we can move this logic into the Avatar::simulate call. + myAvatar->preDisplaySide(&_appRenderArgs._renderArgs); + + + { + PerformanceTimer perfTimer("limitless"); + AnimDebugDraw::getInstance().update(); + } + + { + PerformanceTimer perfTimer("limitless"); + DependencyManager::get()->update(); + } + + { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over + PerformanceTimer perfTimer("enqueueFrame"); + getMain3DScene()->enqueueFrame(); + } +} + +void Application::updateRenderArgs(float deltaTime) { editRenderArgs([this, deltaTime](AppRenderArgs& appRenderArgs) { PerformanceTimer perfTimer("editRenderArgs"); appRenderArgs._headPose = getHMDSensorPose(); @@ -5746,9 +5868,9 @@ void Application::update(float deltaTime) { QMutexLocker viewLocker(&_viewMutex); // adjust near clip plane to account for sensor scaling. auto adjustedProjection = glm::perspective(glm::radians(_fieldOfView.get()), - getActiveDisplayPlugin()->getRecommendedAspectRatio(), - DEFAULT_NEAR_CLIP * sensorToWorldScale, - DEFAULT_FAR_CLIP); + getActiveDisplayPlugin()->getRecommendedAspectRatio(), + DEFAULT_NEAR_CLIP * sensorToWorldScale, + DEFAULT_FAR_CLIP); _viewFrustum.setProjection(adjustedProjection); _viewFrustum.calculate(); } @@ -5764,8 +5886,14 @@ void Application::update(float deltaTime) { } { PROFILE_RANGE(render, "/resizeGL"); - PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); + bool showWarnings = false; + bool suppressShortTimings = false; + auto menu = Menu::getInstance(); + if (menu) { + suppressShortTimings = menu->isOptionChecked(MenuOption::SuppressShortTimings); + showWarnings = menu->isOptionChecked(MenuOption::PipelineWarnings); + } + PerformanceWarning::setSuppressShortTimings(suppressShortTimings); PerformanceWarning warn(showWarnings, "Application::paintGL()"); resizeGL(); } @@ -5821,12 +5949,6 @@ void Application::update(float deltaTime) { } } - // HACK - // load the view frustum - // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. - // Then we can move this logic into the Avatar::simulate call. - myAvatar->preDisplaySide(&appRenderArgs._renderArgs); - { QMutexLocker viewLocker(&_viewMutex); _myCamera.loadViewFrustum(_displayViewFrustum); @@ -5838,21 +5960,6 @@ void Application::update(float deltaTime) { appRenderArgs._renderArgs.setViewFrustum(_displayViewFrustum); } }); - - { - PerformanceTimer perfTimer("limitless"); - AnimDebugDraw::getInstance().update(); - } - - { - PerformanceTimer perfTimer("limitless"); - DependencyManager::get()->update(); - } - - { // Game loop is done, mark the end of the frame for the scene transactions and the render loop to take over - PerformanceTimer perfTimer("enqueueFrame"); - getMain3DScene()->enqueueFrame(); - } } void Application::queryAvatars() { @@ -7493,15 +7600,19 @@ void Application::shareSnapshot(const QString& path, const QUrl& href) { } float Application::getRenderResolutionScale() const { - if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) { + auto menu = Menu::getInstance(); + if (!menu) { return 1.0f; - } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) { + } + if (menu->isOptionChecked(MenuOption::RenderResolutionOne)) { + return 1.0f; + } else if (menu->isOptionChecked(MenuOption::RenderResolutionTwoThird)) { return 0.666f; - } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) { + } else if (menu->isOptionChecked(MenuOption::RenderResolutionHalf)) { return 0.5f; - } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionThird)) { + } else if (menu->isOptionChecked(MenuOption::RenderResolutionThird)) { return 0.333f; - } else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) { + } else if (menu->isOptionChecked(MenuOption::RenderResolutionQuarter)) { return 0.25f; } else { return 1.0f; @@ -7725,7 +7836,7 @@ DisplayPluginPointer Application::getActiveDisplayPlugin() const { static const char* EXCLUSION_GROUP_KEY = "exclusionGroup"; -static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { +static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, bool active) { auto menu = Menu::getInstance(); QString name = displayPlugin->getName(); auto grouping = displayPlugin->getGrouping(); @@ -7770,65 +7881,12 @@ void Application::updateDisplayMode() { qFatal("Attempted to switch display plugins from a non-main thread"); } - auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); - - // Once time initialization code - static std::once_flag once; - std::call_once(once, [&] { - foreach(auto displayPlugin, displayPlugins) { - displayPlugin->setContext(_gpuContext); - QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, - [this](const QSize& size) { resizeGL(); }); - QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset); - } - }); - // Once time initialization code that depends on the UI being available - auto menu = Menu::getInstance(); - if (menu) { - static std::once_flag onceUi; - std::call_once(onceUi, [&] { - bool first = true; - - // first sort the plugins into groupings: standard, advanced, developer - DisplayPluginList standard; - DisplayPluginList advanced; - DisplayPluginList developer; - foreach(auto displayPlugin, displayPlugins) { - displayPlugin->setContext(_gpuContext); - auto grouping = displayPlugin->getGrouping(); - switch (grouping) { - case Plugin::ADVANCED: - advanced.push_back(displayPlugin); - break; - case Plugin::DEVELOPER: - developer.push_back(displayPlugin); - break; - default: - standard.push_back(displayPlugin); - break; - } - } - - // concatenate the groupings into a single list in the order: standard, advanced, developer - standard.insert(std::end(standard), std::begin(advanced), std::end(advanced)); - standard.insert(std::end(standard), std::begin(developer), std::end(developer)); - - foreach(auto displayPlugin, standard) { - addDisplayPluginToMenu(displayPlugin, first); - first = false; - } - - // after all plugins have been added to the menu, add a separator to the menu - auto parent = menu->getMenu(MenuOption::OutputMenu); - parent->addSeparator(); - }); - - } - + auto displayPlugins = getDisplayPlugins(); // Default to the first item on the list, in case none of the menu items match DisplayPluginPointer newDisplayPlugin = displayPlugins.at(0); + auto menu = getPrimaryMenu(); if (menu) { foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { QString name = displayPlugin->getName(); @@ -7852,6 +7910,14 @@ void Application::updateDisplayMode() { } void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { + if (newDisplayPlugin == _displayPlugin) { + return; + } + + // FIXME don't have the application directly set the state of the UI, + // instead emit a signal that the display plugin is changing and let + // the desktop lock itself. Reduces coupling between the UI and display + // plugins auto offscreenUi = DependencyManager::get(); auto desktop = offscreenUi->getDesktop(); auto menu = Menu::getInstance(); @@ -7862,8 +7928,8 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { bool wasRepositionLocked = false; if (desktop) { // Tell the desktop to no reposition (which requires plugin info), until we have set the new plugin, below. - wasRepositionLocked = offscreenUi->getDesktop()->property("repositionLocked").toBool(); - offscreenUi->getDesktop()->setProperty("repositionLocked", true); + wasRepositionLocked = desktop->property("repositionLocked").toBool(); + desktop->setProperty("repositionLocked", true); } if (_displayPlugin) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 654b5c797b..b801ec6d34 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -148,6 +148,7 @@ public: Q_INVOKABLE QString getUserAgent(); void initializeGL(); + void initializeDisplayPlugins(); void initializeRenderEngine(); void initializeUi(); @@ -671,6 +672,7 @@ private: using RenderArgsEditor = std::function ; void editRenderArgs(RenderArgsEditor editor); + void updateRenderArgs(float deltaTime); Overlays _overlays; diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index e1015ca5d1..76babe3682 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -13,8 +13,9 @@ #include #include -#include "ui/Stats.h" +#include #include +#include "ui/Stats.h" #include "Util.h" @@ -233,3 +234,4 @@ void Application::runRenderFrame(RenderArgs* renderArgs) { _renderEngine->run(); } } + diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 15b220c63b..6c6f6d4d41 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -2039,7 +2039,7 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) { } } -void MyAvatar::preDisplaySide(RenderArgs* renderArgs) { +void MyAvatar::preDisplaySide(const RenderArgs* renderArgs) { // toggle using the cauterizedBones depending on where the camera is and the rendering pass type. const bool shouldDrawHead = shouldRenderHead(renderArgs); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index ac3d3cd2f4..154e2e4d09 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -272,7 +272,7 @@ public: void update(float deltaTime); virtual void postUpdate(float deltaTime, const render::ScenePointer& scene) override; - void preDisplaySide(RenderArgs* renderArgs); + void preDisplaySide(const RenderArgs* renderArgs); const glm::mat4& getHMDSensorMatrix() const { return _hmdSensorMatrix; } const glm::vec3& getHMDSensorPosition() const { return _hmdSensorPosition; } diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 4b33565bfd..3cfc0651d8 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -336,9 +336,8 @@ void OpenGLDisplayPlugin::deactivate() { _container->showDisplayPluginsTools(false); if (!_container->currentDisplayActions().isEmpty()) { - auto menu = _container->getPrimaryMenu(); foreach(auto itemInfo, _container->currentDisplayActions()) { - menu->removeMenuItem(itemInfo.first, itemInfo.second); + _container->removeMenuItem(itemInfo.first, itemInfo.second); } _container->currentDisplayActions().clear(); } diff --git a/libraries/procedural/src/procedural/Procedural.cpp b/libraries/procedural/src/procedural/Procedural.cpp index c155d5bd7f..19c4a62443 100644 --- a/libraries/procedural/src/procedural/Procedural.cpp +++ b/libraries/procedural/src/procedural/Procedural.cpp @@ -19,7 +19,7 @@ #include #include #include - +#include #include "ProceduralCommon_frag.h" #include "Logging.h" @@ -178,6 +178,8 @@ void Procedural::setProceduralData(const ProceduralData& proceduralData) { return; } _shaderPath = shaderUrl.toLocalFile(); + } else if (shaderUrl.scheme() == URL_SCHEME_QRC) { + _shaderPath = ":" + shaderUrl.path(); } else { _networkShader = ShaderCache::instance().getShader(shaderUrl); } diff --git a/libraries/ui-plugins/src/ui-plugins/PluginContainer.h b/libraries/ui-plugins/src/ui-plugins/PluginContainer.h index da9ea46cf4..5df20ff30c 100644 --- a/libraries/ui-plugins/src/ui-plugins/PluginContainer.h +++ b/libraries/ui-plugins/src/ui-plugins/PluginContainer.h @@ -54,6 +54,12 @@ public: void setFullscreen(const QScreen* targetScreen, bool hideMenu = false); void unsetFullscreen(const QScreen* avoidScreen = nullptr); + // FIXME remove access tot he menu from the plugin container + // Instead let display plugins expose a structure about the kinds + // of actions and menu items they want to have appear when they are + // active and allow the application to act on that when the display + // plugin becomes active (or when the UI is initialized, and a + // display plugin is already active) virtual ui::Menu* getPrimaryMenu() = 0; virtual void showDisplayPluginsTools(bool show = true) = 0; virtual void requestReset() = 0; diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp index d8f2db75c9..7e337070d3 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp @@ -166,12 +166,11 @@ void OculusBaseDisplayPlugin::deactivateSession() { //_session = nullptr; } void OculusBaseDisplayPlugin::updatePresentPose() { - //mat4 sensorResetMat; - //_currentPresentFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds(); - //_currentPresentFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, _currentFrame->frameIndex); - //auto trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrFalse); - //_currentPresentFrameInfo.presentPose = toGlm(trackingState.HeadPose.ThePose); - _currentPresentFrameInfo.presentPose = _currentPresentFrameInfo.renderPose; + _currentPresentFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds(); + _currentPresentFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, 0); + auto trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrFalse); + _currentPresentFrameInfo.presentPose = toGlm(trackingState.HeadPose.ThePose); + _currentPresentFrameInfo.renderPose = _currentPresentFrameInfo.presentPose; } OculusBaseDisplayPlugin::~OculusBaseDisplayPlugin() { From 803bd284a644366e315138fa3c80a98e51ec17ae Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 14:41:23 -0700 Subject: [PATCH 139/192] Alternate shader --- interface/resources/shaders/splashSkybox.frag | 70 +++++++++++-------- interface/src/Application.cpp | 5 +- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/interface/resources/shaders/splashSkybox.frag b/interface/resources/shaders/splashSkybox.frag index 8088b745bc..38c89b4d26 100644 --- a/interface/resources/shaders/splashSkybox.frag +++ b/interface/resources/shaders/splashSkybox.frag @@ -1,37 +1,47 @@ +const vec3 COLOR = vec3(0x00, 0xD8, 0x02) / vec3(0xFF); +const float CUTOFF = 0.65; +const float NOISE_MULT = 8.0; +const float NOISE_POWER = 1.0; -float noise3D(vec3 p) -{ - return fract(sin(dot(p ,vec3(12.9898,78.233,126.7235))) * 43758.5453); +float noise4D(vec4 p) { + return fract(sin(dot(p ,vec4(12.9898,78.233,126.7235, 593.2241))) * 43758.5453); } -float worley3D(vec3 p) -{ - float r = 3.0; - vec3 f = floor(p); - vec3 x = fract(p); - for(int i = -1; i<=1; i++) - { - for(int j = -1; j<=1; j++) - { - for(int k = -1; k<=1; k++) - { - vec3 q = vec3(float(i),float(j),float(k)); - vec3 v = q + vec3(noise3D((q+f)*1.11), noise3D((q+f)*1.14), noise3D((q+f)*1.17)) - x; - float d = dot(v, v); - r = min(r, d); - } - } - } +float worley4D(vec4 p) { + float r = 3.0; + vec4 f = floor(p); + vec4 x = fract(p); + for(int i = -1; i<=1; i++) + { + for(int j = -1; j<=1; j++) + { + for(int k = -1; k<=1; k++) + { + for (int l = -1; l <= 1; l++) { + vec4 q = vec4(float(i),float(j),float(k), float(l)); + vec4 v = q + vec4(noise4D((q+f)*1.11), noise4D((q+f)*1.14), noise4D((q+f)*1.17), noise4D((q+f)*1.20)) - x; + float d = dot(v, v); + r = min(r, d); + } + } + } + } return sqrt(r); -} +} +vec3 mainColor(vec3 direction) { + float n = worley4D(vec4(direction * NOISE_MULT, iGlobalTime / 3.0)); + n = 1.0 - n; + n = pow(n, NOISE_POWER); + if (n < CUTOFF) { + return vec3(0.0); + } + + n = (n - CUTOFF) / (1.0 - CUTOFF); + return COLOR * (1.0 - n); +} + vec3 getSkyboxColor() { - vec3 color = abs(normalize(_normal)); -// vec2 uv; -// uv.x = 0.5 + atan(_normal.z, _normal.x); -// uv.y = 0.5 - asin(_normal.y); -// uv *= 20.0; -// color.r = worley3D(vec3(uv, iGlobalTime)); - return color; -} \ No newline at end of file + return mainColor(normalize(_normal)); +} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4a59cf3549..e6830a04c8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2671,6 +2671,9 @@ void Application::initializeDisplayPlugins() { batch.enableSkybox(true); batch.enableStereo(_appRenderArgs._isStereo); batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); + batch.runLambda([] { + // update uniform values + }); procedural->render(batch, _appRenderArgs._renderArgs.getViewFrustum()); }); auto frame = _gpuContext->endFrame(); @@ -3016,7 +3019,7 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) { _thirdPersonHMDCameraBoomValid = false; _myCamera.setOrientation(myAvatar->getHead()->getOrientation()); - if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { + if (isOptionChecked(MenuOption::CenterPlayerInView)) { _myCamera.setPosition(myAvatar->getDefaultEyePosition() + _myCamera.getOrientation() * boomOffset); } From 38f43bdc6802e695cb78470eb65a75c62fd027de Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 1 May 2018 16:49:00 -0700 Subject: [PATCH 140/192] Disable current splash frame implementaton --- interface/src/Application.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e6830a04c8..ea487c2239 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2646,6 +2646,9 @@ void Application::initializeDisplayPlugins() { updateRenderArgs(0.0f); _offscreenContext->makeCurrent(); + +#define ENABLE_SPLASH_FRAME 0 +#if ENABLE_SPLASH_FRAME { QMutexLocker viewLocker(&_renderArgsMutex); @@ -2666,14 +2669,10 @@ void Application::initializeDisplayPlugins() { batch.resetStages(); batch.enableStereo(false); batch.setFramebuffer(finalFramebuffer); - batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 1, 1, 1 }); - + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 0, 0, 1 }); batch.enableSkybox(true); batch.enableStereo(_appRenderArgs._isStereo); batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); - batch.runLambda([] { - // update uniform values - }); procedural->render(batch, _appRenderArgs._renderArgs.getViewFrustum()); }); auto frame = _gpuContext->endFrame(); @@ -2685,6 +2684,7 @@ void Application::initializeDisplayPlugins() { }; _displayPlugin->submitFrame(frame); } +#endif } void Application::initializeRenderEngine() { From 5a3773ba72811d8dfbe04ad0c2703adc87147764 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 4 May 2018 17:08:42 -0700 Subject: [PATCH 141/192] Fix compile error on linux/windows --- interface/src/LocationBookmarks.cpp | 5 ----- interface/src/LocationBookmarks.h | 1 + interface/src/ModelPackager.h | 2 ++ libraries/entities/src/EntityTypes.h | 1 + 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/LocationBookmarks.cpp b/interface/src/LocationBookmarks.cpp index f29a8f18f9..8415c84282 100644 --- a/interface/src/LocationBookmarks.cpp +++ b/interface/src/LocationBookmarks.cpp @@ -12,16 +12,11 @@ #include "LocationBookmarks.h" #include -#include -#include #include -#include #include -#include #include -#include "MainWindow.h" #include "Menu.h" const QString LocationBookmarks::HOME_BOOKMARK = "Home"; diff --git a/interface/src/LocationBookmarks.h b/interface/src/LocationBookmarks.h index 9a800ba35e..39abea9ba4 100644 --- a/interface/src/LocationBookmarks.h +++ b/interface/src/LocationBookmarks.h @@ -13,6 +13,7 @@ #define hifi_LocationBookmarks_h #include + #include "Bookmarks.h" class LocationBookmarks : public Bookmarks, public Dependency { diff --git a/interface/src/ModelPackager.h b/interface/src/ModelPackager.h index acd4d85f68..76295e5a85 100644 --- a/interface/src/ModelPackager.h +++ b/interface/src/ModelPackager.h @@ -12,6 +12,8 @@ #ifndef hifi_ModelPackager_h #define hifi_ModelPackager_h +#include + #include #include diff --git a/libraries/entities/src/EntityTypes.h b/libraries/entities/src/EntityTypes.h index 0e2fca8180..1f3434d254 100644 --- a/libraries/entities/src/EntityTypes.h +++ b/libraries/entities/src/EntityTypes.h @@ -12,6 +12,7 @@ #ifndef hifi_EntityTypes_h #define hifi_EntityTypes_h +#include #include #include From 6a55e67ce9cd01ed29825d14889a1d0d2ad902c6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 5 May 2018 16:39:03 -0700 Subject: [PATCH 142/192] avoid misaligned pointer deref --- libraries/gpu/src/gpu/Texture_ktx.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 0822af3cfb..bb081637be 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -46,13 +46,14 @@ struct GPUKTXPayload { memcpy(data, &_samplerDesc, sizeof(Sampler::Desc)); data += sizeof(Sampler::Desc); - + // We can't copy the bitset in Texture::Usage in a crossplateform manner // So serialize it manually - *(uint32*)data = _usage._flags.to_ulong(); + uint32 usageData = _usage._flags.to_ulong(); + memcpy(data, &usageData, sizeof(uint32)); data += sizeof(uint32); - *(TextureUsageType*)data = _usageType; + memcpy(data, &_usageType, sizeof(TextureUsageType)); data += sizeof(TextureUsageType); return data + PADDING; @@ -77,10 +78,12 @@ struct GPUKTXPayload { memcpy(&_samplerDesc, data, sizeof(Sampler::Desc)); data += sizeof(Sampler::Desc); - + // We can't copy the bitset in Texture::Usage in a crossplateform manner // So unserialize it manually - _usage = Texture::Usage(*(const uint32*)data); + uint32 usageData; + memcpy(&usageData, data, sizeof(uint32)); + _usage = Texture::Usage(usageData); data += sizeof(uint32); _usageType = *(const TextureUsageType*)data; @@ -710,4 +713,4 @@ bool Texture::evalTextureFormat(const ktx::Header& header, Element& mipFormat, E return false; } return true; -} \ No newline at end of file +} From 677c99abd46e429090a4ebd3d85b2f7145e9ea6e Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 5 May 2018 20:50:54 -0700 Subject: [PATCH 143/192] use memcpy on _usageType as well --- libraries/gpu/src/gpu/Texture_ktx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index bb081637be..129c125411 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -86,7 +86,7 @@ struct GPUKTXPayload { _usage = Texture::Usage(usageData); data += sizeof(uint32); - _usageType = *(const TextureUsageType*)data; + memcpy(&_usageType, data, sizeof(TextureUsageType)); return true; } From b4cfea2fbc4793bc9f3fddcf8949ab67cf826c19 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Sun, 6 May 2018 17:17:06 +0300 Subject: [PATCH 144/192] FB14818 Login page for steam is blank --- interface/resources/qml/LoginDialog/SignInBody.qml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/LoginDialog/SignInBody.qml b/interface/resources/qml/LoginDialog/SignInBody.qml index c4b6c2aee1..9cb1add704 100644 --- a/interface/resources/qml/LoginDialog/SignInBody.qml +++ b/interface/resources/qml/LoginDialog/SignInBody.qml @@ -84,11 +84,9 @@ Item { height: undefined // invalidate so that the image's size sets the height focus: true - style: OriginalStyles.ButtonStyle { - background: Image { - id: buttonImage - source: "../../images/steam-sign-in.png" - } + background: Image { + id: buttonImage + source: "../../images/steam-sign-in.png" } onClicked: signInBody.login() } From c2004debd57921c6d2f3658ea05e0b0e2232b94a Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 7 May 2018 11:41:19 -0700 Subject: [PATCH 145/192] test using highp floats everywhere for android --- .../gpu-gl/src/gpu/gl41/GL41BackendShader.cpp | 1 - .../gpu-gl/src/gpu/gl45/GL45BackendShader.cpp | 1 - .../src/gpu/gles/GLESBackendShader.cpp | 7 +++---- libraries/graphics/src/graphics/Light.slh | 2 +- .../src/graphics/LightIrradiance.shared.slh | 4 ++-- .../src/graphics/LightVolume.shared.slh | 4 ++-- libraries/graphics/src/graphics/Material.slh | 11 ++++------- .../src/graphics/SphericalHarmonics.shared.slh | 18 +++++++++--------- libraries/render-utils/src/LightingModel.slh | 8 ++++---- 9 files changed, 25 insertions(+), 31 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp index 151b5bd1f9..64c9033cf7 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp @@ -17,7 +17,6 @@ std::string GL41Backend::getBackendShaderHeader() const { static const std::string header( R"SHADER(#version 410 core #define GPU_GL410 - #define PRECISIONQ #define BITFIELD int )SHADER"); return header; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendShader.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendShader.cpp index 6f6ded518f..44e439df55 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendShader.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendShader.cpp @@ -18,7 +18,6 @@ std::string GL45Backend::getBackendShaderHeader() const { static const std::string header( R"SHADER(#version 450 core #define GPU_GL450 - #define PRECISIONQ #define BITFIELD int )SHADER" #ifdef GPU_SSBO_TRANSFORM_OBJECT diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendShader.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendShader.cpp index 4278d732c8..7e8056ba79 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendShader.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendShader.cpp @@ -17,10 +17,9 @@ std::string GLESBackend::getBackendShaderHeader() const { static const std::string header( R"SHADER(#version 310 es #extension GL_EXT_texture_buffer : enable - precision lowp float; // check precision 2 - precision lowp samplerBuffer; - precision lowp sampler2DShadow; - #define PRECISIONQ highp + precision highp float; + precision highp samplerBuffer; + precision highp sampler2DShadow; #define BITFIELD highp int )SHADER"); return header; diff --git a/libraries/graphics/src/graphics/Light.slh b/libraries/graphics/src/graphics/Light.slh index c8992730f0..53b840f5fb 100644 --- a/libraries/graphics/src/graphics/Light.slh +++ b/libraries/graphics/src/graphics/Light.slh @@ -34,7 +34,7 @@ vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradi // Light Ambient struct LightAmbient { - PRECISIONQ vec4 _ambient; + vec4 _ambient; SphericalHarmonics _ambientSphere; mat4 transform; }; diff --git a/libraries/graphics/src/graphics/LightIrradiance.shared.slh b/libraries/graphics/src/graphics/LightIrradiance.shared.slh index 4ae7967bf5..13d6cf4b93 100644 --- a/libraries/graphics/src/graphics/LightIrradiance.shared.slh +++ b/libraries/graphics/src/graphics/LightIrradiance.shared.slh @@ -14,9 +14,9 @@ #define LightIrradianceConstRef LightIrradiance struct LightIrradiance { - PRECISIONQ vec4 colorIntensity; + vec4 colorIntensity; // falloffRadius, cutoffRadius, falloffSpot, spare - PRECISIONQ vec4 attenuation; + vec4 attenuation; }; diff --git a/libraries/graphics/src/graphics/LightVolume.shared.slh b/libraries/graphics/src/graphics/LightVolume.shared.slh index 4e4359eac0..3f0cb135f5 100644 --- a/libraries/graphics/src/graphics/LightVolume.shared.slh +++ b/libraries/graphics/src/graphics/LightVolume.shared.slh @@ -16,8 +16,8 @@ #define LightVolumeConstRef LightVolume struct LightVolume { - PRECISIONQ vec4 positionRadius; - PRECISIONQ vec4 directionSpotCos; + vec4 positionRadius; + vec4 directionSpotCos; }; bool lightVolume_isPoint(LightVolume lv) { return bool(lv.directionSpotCos.w < 0.f); } diff --git a/libraries/graphics/src/graphics/Material.slh b/libraries/graphics/src/graphics/Material.slh index ecf3c18a0e..dd2985b4da 100644 --- a/libraries/graphics/src/graphics/Material.slh +++ b/libraries/graphics/src/graphics/Material.slh @@ -15,10 +15,10 @@ // to what is provided by the uniform buffer, or the material key has the wrong bits struct Material { - PRECISIONQ vec4 _emissiveOpacity; - PRECISIONQ vec4 _albedoRoughness; - PRECISIONQ vec4 _fresnelMetallic; - PRECISIONQ vec4 _scatteringSpare2Key; + vec4 _emissiveOpacity; + vec4 _albedoRoughness; + vec4 _fresnelMetallic; + vec4 _scatteringSpare2Key; }; uniform materialBuffer { @@ -64,7 +64,4 @@ const BITFIELD OCCLUSION_MAP_BIT = 0x00004000; const BITFIELD LIGHTMAP_MAP_BIT = 0x00008000; const BITFIELD SCATTERING_MAP_BIT = 0x00010000; -#ifdef GL_ES -precision lowp float; -#endif <@endif@> diff --git a/libraries/graphics/src/graphics/SphericalHarmonics.shared.slh b/libraries/graphics/src/graphics/SphericalHarmonics.shared.slh index 6e1763dcba..312824c5a3 100644 --- a/libraries/graphics/src/graphics/SphericalHarmonics.shared.slh +++ b/libraries/graphics/src/graphics/SphericalHarmonics.shared.slh @@ -16,15 +16,15 @@ #define SphericalHarmonicsConstRef SphericalHarmonics struct SphericalHarmonics { - PRECISIONQ vec4 L00; - PRECISIONQ vec4 L1m1; - PRECISIONQ vec4 L10; - PRECISIONQ vec4 L11; - PRECISIONQ vec4 L2m2; - PRECISIONQ vec4 L2m1; - PRECISIONQ vec4 L20; - PRECISIONQ vec4 L21; - PRECISIONQ vec4 L22; + vec4 L00; + vec4 L1m1; + vec4 L10; + vec4 L11; + vec4 L2m2; + vec4 L2m1; + vec4 L20; + vec4 L21; + vec4 L22; }; vec4 sphericalHarmonics_evalSphericalLight(SphericalHarmonicsConstRef sh, vec3 direction) { diff --git a/libraries/render-utils/src/LightingModel.slh b/libraries/render-utils/src/LightingModel.slh index 6a5982f1e8..8abdb5cbf9 100644 --- a/libraries/render-utils/src/LightingModel.slh +++ b/libraries/render-utils/src/LightingModel.slh @@ -14,10 +14,10 @@ <@func declareLightingModel()@> struct LightingModel { - PRECISIONQ vec4 _UnlitEmissiveLightmapBackground; - PRECISIONQ vec4 _ScatteringDiffuseSpecularAlbedo; - PRECISIONQ vec4 _AmbientDirectionalPointSpot; - PRECISIONQ vec4 _ShowContourObscuranceWireframe; + vec4 _UnlitEmissiveLightmapBackground; + vec4 _ScatteringDiffuseSpecularAlbedo; + vec4 _AmbientDirectionalPointSpot; + vec4 _ShowContourObscuranceWireframe; }; uniform lightingModelBuffer{ From 646c0ec987eb285e641ef1ca9a75bfc45f888136 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 7 May 2018 11:56:47 -0700 Subject: [PATCH 146/192] MS14878: Prevent wallet passphrase leak in specific case --- scripts/system/marketplaces/marketplaces.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index a05778e2dd..c3edee264f 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -789,10 +789,14 @@ var selectionDisplay = null; // for gridTool.js to ignore var savedDisablePreviewOptionLocked = false; var savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");; function maybeEnableHMDPreview() { - setTabletVisibleInSecondaryCamera(true); - DesktopPreviewProvider.setPreviewDisabledReason("USER"); - Menu.setIsOptionChecked("Disable Preview", savedDisablePreviewOption); - savedDisablePreviewOptionLocked = false; + // Set a small timeout to prevent sensitive data from being shown during + // UI fade + Script.setTimeout(function () { + setTabletVisibleInSecondaryCamera(true); + DesktopPreviewProvider.setPreviewDisabledReason("USER"); + Menu.setIsOptionChecked("Disable Preview", savedDisablePreviewOption); + savedDisablePreviewOptionLocked = false; + }, 150); } // Function Name: fromQml() From c3ef6aab1c96158ea4edb67f188da9e39c2f69be Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 7 May 2018 12:51:41 -0700 Subject: [PATCH 147/192] Don't save test scripts --- libraries/script-engine/src/ScriptEngine.h | 5 +++++ libraries/script-engine/src/ScriptEngines.cpp | 15 ++++----------- libraries/script-engine/src/ScriptEngines.h | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 7a9af2278c..3001666b5d 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -526,6 +526,9 @@ public: void setUserLoaded(bool isUserLoaded) { _isUserLoaded = isUserLoaded; } bool isUserLoaded() const { return _isUserLoaded; } + void setQuitWhenFinished(const bool quitWhenFinished) { _quitWhenFinished = quitWhenFinished; } + bool isQuitWhenFinished() const { return _quitWhenFinished; } + // NOTE - this is used by the TypedArray implementation. we need to review this for thread safety ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; } @@ -768,6 +771,8 @@ protected: std::atomic _isUserLoaded { false }; bool _isReloading { false }; + std::atomic _quitWhenFinished; + ArrayBufferClass* _arrayBufferClass; AssetScriptingInterface* _assetScriptingInterface; diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index d2834e8c4a..b5a7cff0ab 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -347,7 +347,8 @@ void ScriptEngines::saveScripts() { { QReadLocker lock(&_scriptEnginesHashLock); for (auto it = _scriptEnginesHash.begin(); it != _scriptEnginesHash.end(); ++it) { - if (it.value() && it.value()->isUserLoaded()) { + // Save user-loaded scripts, only if they are set to quit when finished + if (it.value() && it.value()->isUserLoaded() && !it.value()->isQuitWhenFinished()) { auto normalizedUrl = normalizeScriptURL(it.key()); list.append(normalizedUrl.toString()); } @@ -456,7 +457,7 @@ void ScriptEngines::reloadAllScripts() { } ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, - bool activateMainWindow, bool reload, bool exitWhenFinished) { + bool activateMainWindow, bool reload, bool quitWhenFinished) { if (thread() != QThread::currentThread()) { ScriptEnginePointer result { nullptr }; BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), @@ -488,6 +489,7 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i scriptEngine = ScriptEnginePointer(new ScriptEngine(_context, NO_SCRIPT, "about:" + scriptFilename.fileName())); addScriptEngine(scriptEngine); scriptEngine->setUserLoaded(isUserLoaded); + scriptEngine->setQuitWhenFinished(quitWhenFinished); if (scriptFilename.isEmpty() || !scriptUrl.isValid()) { launchScriptEngine(scriptEngine); @@ -496,11 +498,6 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); - // Shutdown Interface when script finishes, if requested - if (exitWhenFinished) { - connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished); - } - // get the script engine object to load the script at the designated script URL scriptEngine->loadURL(scriptUrl, reload); } @@ -541,10 +538,6 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { emit scriptCountChanged(); } -void ScriptEngines::exitWhenFinished() { - qApp->quit(); -} - int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { int ii=0; for (auto initializer : _scriptInitializers) { diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 6f88e8978d..51eec8ab3e 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -88,10 +88,11 @@ public: * @param {boolean} [loadScriptFromEditor=false] * @param {boolean} [activateMainWindow=false] * @param {boolean} [reload=false] + * @param {boolean} [quitWhenFinished=false] * @returns {boolean} */ Q_INVOKABLE ScriptEnginePointer loadScript(const QUrl& scriptFilename = QString(), - bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false, bool exitWhenFinished = false); + bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false, bool quitWhenFinished = false); /**jsdoc * @function ScriptDiscoveryService.stopScript @@ -266,7 +267,6 @@ protected: ScriptEnginePointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); } void removeScriptEngine(ScriptEnginePointer); void onScriptEngineLoaded(const QString& scriptFilename); - void exitWhenFinished(); void onScriptEngineError(const QString& scriptFilename); void launchScriptEngine(ScriptEnginePointer); From 2e51a66441cc89e21337b7c38774b234b094872c Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 7 May 2018 13:01:18 -0700 Subject: [PATCH 148/192] Use 'standard' format for command line parameter with multiple options. --- interface/src/Application.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8ee577c282..bb04c3bf40 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -744,9 +744,9 @@ extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); // Parameters used for running tests from teh command line -const QString TEST_SCRIPT { "--testScript" }; -const QString TEST_QUIT_WHEN_FINISHED { "--quitWhenFinished" }; -const QString TEST_SNAPSHOT_LOCATION { "--testSnapshotLocation" }; +const QString TEST_SCRIPT_COMMAND { "--testScript" }; +const QString TEST_QUIT_WHEN_FINISHED_OPTION { "quitWhenFinished" }; +const QString TEST_SNAPSHOT_LOCATION_COMMAND { "--testSnapshotLocation" }; bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); @@ -787,7 +787,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { bool inTestMode { false }; for (int i = 0; i < argc; ++i) { QString parameter(argv[i]); - if (parameter == TEST_SCRIPT) { + if (parameter == TEST_SCRIPT_COMMAND) { inTestMode = true; break; } @@ -1019,7 +1019,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo const QStringList args = arguments(); for (int i = 0; i < args.size() - 1; ++i) { - if (args.at(i) == TEST_SCRIPT && (i + 1) < args.size()) { + if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) { QString testScriptPath = args.at(i + 1); // If the URL scheme is "http(s)" then use as is, else - treat it as a local file @@ -1031,10 +1031,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo } // quite when finished parameter must directly follow the test script - if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED) { + if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) { quitWhenFinished = true; } - } else if (args.at(i) == TEST_SNAPSHOT_LOCATION) { + } else if (args.at(i) == TEST_SNAPSHOT_LOCATION_COMMAND) { // Set test snapshot location only if it is a writeable directory QString pathname(args.at(i + 1)); QFileInfo fileInfo(pathname); From fd4530e671b96d17af052ef7882fc674800a66f6 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 7 May 2018 14:39:31 -0700 Subject: [PATCH 149/192] MS3128: Remove vestigal Edit menu item --- scripts/system/edit.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 6bb815a597..523582836f 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1165,17 +1165,11 @@ function setupModelMenus() { }); modelMenuAddedDelete = true; } - Menu.addMenuItem({ - menuName: "Edit", - menuItemName: "Entity List...", - afterItem: "Entities", - grouping: "Advanced" - }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Parent Entity to Last", - afterItem: "Entity List...", + afterItem: "Entities", grouping: "Advanced" }); @@ -1297,7 +1291,6 @@ function cleanupModelMenus() { Menu.removeMenuItem("Edit", "Parent Entity to Last"); Menu.removeMenuItem("Edit", "Unparent Entity"); - Menu.removeMenuItem("Edit", "Entity List..."); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Lights"); @@ -1659,8 +1652,6 @@ function handeMenuEvent(menuItem) { Window.promptTextChanged.connect(onPromptTextChanged); Window.promptAsync("URL of SVO to import", ""); } - } else if (menuItem === "Entity List...") { - entityListTool.toggleVisible(); } else if (menuItem === "Select All Entities In Box") { selectAllEtitiesInCurrentSelectionBox(false); } else if (menuItem === "Select All Entities Touching Box") { From a593209ec132ee828f454d6f505ee7ee9cc0ea38 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 7 May 2018 15:30:17 -0700 Subject: [PATCH 150/192] remove highlight when point to the sky --- .../controllers/controllerModules/farActionGrabEntity.js | 3 +++ .../controllers/controllerModules/mouseHighlightEntities.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index cc884cdbc7..66cd197abd 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -564,6 +564,9 @@ Script.include("/~/system/libraries/Xform.js"); } } else if (this.distanceRotating) { this.distanceRotate(otherFarGrabModule); + } else if (this.highlightedEntity) { + Selection.removeFromSelectedItemsList(DISPATCHER_HOVERING_LIST, "entity", this.highlightedEntity); + this.highlightedEntity = null; } } return this.exitIfDisabled(controllerData); diff --git a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js index 3180e58e2c..ac57c8691f 100644 --- a/scripts/system/controllers/controllerModules/mouseHighlightEntities.js +++ b/scripts/system/controllers/controllerModules/mouseHighlightEntities.js @@ -63,6 +63,9 @@ this.highlightedEntity = targetEntityID; } } + } else if (this.highlightedEntity) { + dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity); + this.highlightedEntity = null; } } From eb14658bc554c58e72e40474bbb7bdc328570d83 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 8 May 2018 11:13:06 -0700 Subject: [PATCH 151/192] Per Austin's comments. --- interface/src/Application.cpp | 4 +- tools/auto-tester/src/Downloader.cpp | 5 +-- tools/auto-tester/src/Test.cpp | 54 +++++++++++++------------ tools/auto-tester/src/Test.h | 2 - tools/auto-tester/src/ui/AutoTester.cpp | 3 +- 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8d1db32cdd..544d767370 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1022,9 +1022,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) { QString testScriptPath = args.at(i + 1); - // If the URL scheme is "http(s)" then use as is, else - treat it as a local file + // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file // This is done so as not break previous command line scripts - if (testScriptPath.left(4) == "http") { + if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP || testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) { setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath)); } else if (QFileInfo(testScriptPath).exists()) { setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); diff --git a/tools/auto-tester/src/Downloader.cpp b/tools/auto-tester/src/Downloader.cpp index e66b498bd5..530a3b61bd 100644 --- a/tools/auto-tester/src/Downloader.cpp +++ b/tools/auto-tester/src/Downloader.cpp @@ -9,7 +9,7 @@ // #include "Downloader.h" -#include +#include Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { connect( @@ -24,8 +24,7 @@ Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { void Downloader::fileDownloaded(QNetworkReply* reply) { QNetworkReply::NetworkError error = reply->error(); if (error != QNetworkReply::NetworkError::NoError) { - QMessageBox messageBox; - messageBox.information(0, "Test Aborted", "Failed to download image: " + reply->errorString()); + QMessageBox::information(0, "Test Aborted", "Failed to download image: " + reply->errorString()); return; } diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index e00bc920e5..0eec03a782 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -72,7 +72,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) QImage expectedImage(expectedImagesFullFilenames[i]); if (resultImage.width() != expectedImage.width() || resultImage.height() != expectedImage.height()) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Images are not the same size"); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Images are not the same size"); exit(-1); } @@ -80,7 +80,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) try { similarityIndex = imageComparer.compareImages(resultImage, expectedImage); } catch (...) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format"); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format"); exit(-1); } @@ -127,20 +127,20 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFailure testFailure, QPixmap comparisonImage) { if (!QDir().exists(testResultsFolderPath)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Folder " + testResultsFolderPath + " not found"); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Folder " + testResultsFolderPath + " not found"); exit(-1); } QString failureFolderPath { testResultsFolderPath + "/" + "Failure_" + QString::number(index) }; if (!QDir().mkdir(failureFolderPath)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create folder " + failureFolderPath); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create folder " + failureFolderPath); exit(-1); } ++index; QFile descriptionFile(failureFolderPath + "/" + TEST_RESULTS_FILENAME); if (!descriptionFile.open(QIODevice::ReadWrite)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + TEST_RESULTS_FILENAME); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + TEST_RESULTS_FILENAME); exit(-1); } @@ -160,14 +160,14 @@ void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFai sourceFile = testFailure._pathname + testFailure._expectedImageFilename; destinationFile = failureFolderPath + "/" + "Expected Image.jpg"; if (!QFile::copy(sourceFile, destinationFile)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to copy " + sourceFile + " to " + destinationFile); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to copy " + sourceFile + " to " + destinationFile); exit(-1); } sourceFile = testFailure._pathname + testFailure._actualImageFilename; destinationFile = failureFolderPath + "/" + "Actual Image.jpg"; if (!QFile::copy(sourceFile, destinationFile)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to copy " + sourceFile + " to " + destinationFile); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to copy " + sourceFile + " to " + destinationFile); exit(-1); } @@ -248,9 +248,9 @@ void Test::finishTestsEvaluation(bool isRunningFromCommandline, bool interactive if (!isRunningFromCommandline) { if (success) { - messageBox.information(0, "Success", "All images are as expected"); + QMessageBox::information(0, "Success", "All images are as expected"); } else { - messageBox.information(0, "Failure", "One or more images are not as expected"); + QMessageBox::information(0, "Failure", "One or more images are not as expected"); } } @@ -281,7 +281,7 @@ QString Test::extractPathFromTestsDown(const QString& fullPath) { } if (i == pathParts.length()) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Bad testPathname"); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Bad testPathname"); exit(-1); } @@ -350,14 +350,14 @@ void Test::createAllRecursiveScripts() { } } - messageBox.information(0, "Success", "Scripts have been created"); + QMessageBox::information(0, "Success", "Scripts have been created"); } void Test::createRecursiveScript(const QString& topLevelDirectory, bool interactiveMode) { const QString recursiveTestsFilename("testRecursive.js"); QFile allTestsFilename(topLevelDirectory + "/" + recursiveTestsFilename); if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) { - messageBox.critical(0, + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create \"" + recursiveTestsFilename + "\" in directory \"" + topLevelDirectory + "\"" ); @@ -366,7 +366,9 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact } QTextStream textStream(&allTestsFilename); - textStream << "// This is an automatically generated file, created by auto-tester on " << __DATE__ << ", " << __TIME__ << endl << endl; + + const QString DATE_TIME_FORMAT("MMM d yyyy, h:mm"); + textStream << "// This is an automatically generated file, created by auto-tester on " << QDateTime::currentDateTime().toString(DATE_TIME_FORMAT) << endl << endl; textStream << "var autoTester = Script.require(\"https://github.com/" + githubUser + "/hifi_tests/blob/" + gitHubBranch + "/tests/utils/autoTester.js?raw=true\");" << endl << endl; @@ -407,7 +409,7 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact } if (interactiveMode && testPathnames.length() <= 0) { - messageBox.information(0, "Failure", "No \"" + TEST_FILENAME + "\" files found"); + QMessageBox::information(0, "Failure", "No \"" + TEST_FILENAME + "\" files found"); allTestsFilename.close(); return; } @@ -418,7 +420,7 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact allTestsFilename.close(); if (interactiveMode) { - messageBox.information(0, "Success", "Script has been created"); + QMessageBox::information(0, "Success", "Script has been created"); } } @@ -443,7 +445,7 @@ void Test::createTest() { QString fullCurrentFilename = imageSourceDirectory + "/" + currentFilename; if (isInSnapshotFilenameFormat("jpg", currentFilename)) { if (i >= maxImages) { - messageBox.critical(0, "Error", "More than " + QString::number(maxImages) + " images not supported"); + QMessageBox::critical(0, "Error", "More than " + QString::number(maxImages) + " images not supported"); exit(-1); } QString newFilename = "ExpectedImage_" + QString::number(i - 1).rightJustified(5, '0') + ".png"; @@ -452,14 +454,14 @@ void Test::createTest() { try { copyJPGtoPNG(fullCurrentFilename, fullNewFileName); } catch (...) { - messageBox.critical(0, "Error", "Could not delete existing file: " + currentFilename + "\nTest creation aborted"); + QMessageBox::critical(0, "Error", "Could not delete existing file: " + currentFilename + "\nTest creation aborted"); exit(-1); } ++i; } } - messageBox.information(0, "Success", "Test images have been created"); + QMessageBox::information(0, "Success", "Test images have been created"); } ExtractedText Test::getTestScriptLines(QString testFileName) { @@ -468,7 +470,7 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { QFile inputFile(testFileName); inputFile.open(QIODevice::ReadOnly); if (!inputFile.isOpen()) { - messageBox.critical(0, + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to open \"" + testFileName ); @@ -598,7 +600,7 @@ void Test::createAllMDFiles() { } } - messageBox.information(0, "Success", "MD files have been created"); + QMessageBox::information(0, "Success", "MD files have been created"); } void Test::createMDFile(const QString& testDirectory) { @@ -606,7 +608,7 @@ void Test::createMDFile(const QString& testDirectory) { QString testFileName(testDirectory + "/" + TEST_FILENAME); QFileInfo testFileInfo(testFileName); if (!testFileInfo.exists()) { - messageBox.critical(0, "Error", "Could not find file: " + TEST_FILENAME); + QMessageBox::critical(0, "Error", "Could not find file: " + TEST_FILENAME); return; } @@ -615,7 +617,7 @@ void Test::createMDFile(const QString& testDirectory) { QString mdFilename(testDirectory + "/" + "test.md"); QFile mdFile(mdFilename); if (!mdFile.open(QIODevice::WriteOnly)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename); exit(-1); } @@ -650,7 +652,7 @@ void Test::createMDFile(const QString& testDirectory) { mdFile.close(); - messageBox.information(0, "Success", "Test MD file " + mdFilename + " has been created"); + QMessageBox::information(0, "Success", "Test MD file " + mdFilename + " has been created"); } void Test::createTestsOutline() { @@ -663,7 +665,7 @@ void Test::createTestsOutline() { QString mdFilename(testsRootDirectory + "/" + testsOutlineFilename); QFile mdFile(mdFilename); if (!mdFile.open(QIODevice::WriteOnly)) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename); exit(-1); } @@ -721,7 +723,7 @@ void Test::createTestsOutline() { mdFile.close(); - messageBox.information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created"); + QMessageBox::information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created"); } void Test::copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename) { @@ -796,7 +798,7 @@ QString Test::getExpectedImagePartialSourceDirectory(const QString& filename) { } if (i < 0) { - messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Bad filename"); + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Bad filename"); exit(-1); } diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index b341c1d00f..bc28d6ad0a 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -76,8 +76,6 @@ private: const QString TEST_RESULTS_FOLDER { "TestResults" }; const QString TEST_RESULTS_FILENAME { "TestResults.txt" }; - QMessageBox messageBox; - QDir imageDirectory; MismatchWindow mismatchWindow; diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 59fe5d9de2..8fd81efc1f 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -115,6 +115,5 @@ void AutoTester::saveImage(int index) { } void AutoTester::about() { - QMessageBox messageBox; - messageBox.information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); + QMessageBox::information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); } From d5bb582811dd8f73d68e06add7b4589c766b25b7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 8 May 2018 11:40:56 -0700 Subject: [PATCH 152/192] Per Austin's comments. --- interface/src/ui/Snapshot.cpp | 2 +- interface/src/ui/Snapshot.h | 5 ++++- tools/auto-tester/src/ui/AutoTester.cpp | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 73ea8398e7..39fef1d742 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -90,7 +90,7 @@ QString Snapshot::saveSnapshot(QImage image, const QString& filename, const QStr QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) { // return whatever we get back from saved file for snapshot - return static_cast(savedFileForSnapshot(image, true, QString(), QString())); + return static_cast(savedFileForSnapshot(image, true)); } QFile* Snapshot::savedFileForSnapshot(QImage & shot, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname) { diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index aad63d1037..606313f3c3 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -52,7 +52,10 @@ public slots: Q_INVOKABLE QString getSnapshotsLocation(); Q_INVOKABLE void setSnapshotsLocation(const QString& location); private: - static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename, const QString& userSelectedPathname); + static QFile* savedFileForSnapshot(QImage& image, + bool isTemporary, + const QString& userSelectedFilename = QString(), + const QString& userSelectedPathname = QString()); }; #endif // hifi_Snapshot_h diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 8fd81efc1f..db9974a250 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -99,8 +99,7 @@ void AutoTester::saveImage(int index) { QString fullPathname = _directoryName + "/" + _filenames[index]; if (!image.save(fullPathname, 0, 100)) { - QMessageBox messageBox; - messageBox.information(0, "Test Aborted", "Failed to save image: " + _filenames[index]); + QMessageBox::information(0, "Test Aborted", "Failed to save image: " + _filenames[index]); ui.progressBar->setVisible(false); return; } From 0513204781cc4104faf3d0fd4d35b2c034d0a47f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 8 May 2018 15:05:55 -0700 Subject: [PATCH 153/192] fix hmd.js --- scripts/system/hmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/hmd.js b/scripts/system/hmd.js index b9fd7f725c..bf1e048bc4 100644 --- a/scripts/system/hmd.js +++ b/scripts/system/hmd.js @@ -18,7 +18,7 @@ var headset; // The preferred headset. Default to the first one found in the following list. var displayMenuName = "Display"; var desktopMenuItemName = "Desktop"; -['OpenVR (Vive)', 'Oculus Rift'].forEach(function (name) { +['HTC Vive', 'Oculus Rift'].forEach(function (name) { if (!headset && Menu.menuItemExists(displayMenuName, name)) { headset = name; } From 1a0ded4526d7f37fd4ce25df4567b249c4859a65 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 8 May 2018 15:10:57 -0700 Subject: [PATCH 154/192] adding windows --- scripts/system/hmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/hmd.js b/scripts/system/hmd.js index bf1e048bc4..2d4a2d3e97 100644 --- a/scripts/system/hmd.js +++ b/scripts/system/hmd.js @@ -18,7 +18,7 @@ var headset; // The preferred headset. Default to the first one found in the following list. var displayMenuName = "Display"; var desktopMenuItemName = "Desktop"; -['HTC Vive', 'Oculus Rift'].forEach(function (name) { +['HTC Vive', 'Oculus Rift', 'WindowMS'].forEach(function (name) { if (!headset && Menu.menuItemExists(displayMenuName, name)) { headset = name; } From 7f9f9d769adfe5e96159ae1c836322dcb643acb7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 8 May 2018 15:51:52 -0700 Subject: [PATCH 155/192] Corrected bug causing Interface not to exit at end of test. --- libraries/script-engine/src/ScriptEngines.cpp | 9 +++++++++ libraries/script-engine/src/ScriptEngines.h | 1 + 2 files changed, 10 insertions(+) diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index b5a7cff0ab..ad6e1debe9 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -498,6 +498,11 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); + // Shutdown Interface when script finishes, if requested + if (quitWhenFinished) { + connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::quitWhenFinished); + } + // get the script engine object to load the script at the designated script URL scriptEngine->loadURL(scriptUrl, reload); } @@ -538,6 +543,10 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { emit scriptCountChanged(); } +void ScriptEngines::quitWhenFinished() { + qApp->quit(); +} + int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { int ii=0; for (auto initializer : _scriptInitializers) { diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 51eec8ab3e..4d5964e462 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -267,6 +267,7 @@ protected: ScriptEnginePointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); } void removeScriptEngine(ScriptEnginePointer); void onScriptEngineLoaded(const QString& scriptFilename); + void quitWhenFinished(); void onScriptEngineError(const QString& scriptFilename); void launchScriptEngine(ScriptEnginePointer); From 44e7541888d203cd79ba2f06a079b3cdaf382ded Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 8 May 2018 15:57:27 -0700 Subject: [PATCH 156/192] Fixing the size evaluation for compressed texture and gpu::Element Type enum --- libraries/gpu/src/gpu/Format.h | 73 ++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/libraries/gpu/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h index d4e4a89636..7a3e0a2f82 100644 --- a/libraries/gpu/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -50,47 +50,50 @@ enum Type : uint8_t { }; // Array providing the size in bytes for a given scalar type static const int TYPE_SIZE[NUM_TYPES] = { - 4, - 4, - 4, - 2, - 2, - 2, - 1, - 1, + 4, // FLOAT + 4, // INT32 + 4, // UINT32 + 2, // HALF + 2, // INT16 + 2, // UINT16 + 1, // INT8 + 1, // UINT8 // normalized values - 4, - 4, - 2, - 2, - 1, - 1, - 4, + 4, // NINT32 + 4, // NUINT32 + 2, // NINT16 + 2, // NUINT16 + 1, // NINT8 + 1, // NUINT8 + 1, // NUINT2 + 1, // NINT2_10_10_10 - 1 + 1, // COMPRESSED }; + // Array answering the question Does this type is integer or not static const bool TYPE_IS_INTEGER[NUM_TYPES] = { - false, - true, - true, - false, - true, - true, - true, - true, + false, // FLOAT + true, // INT32 + true, // UINT32 + false, // HALF + true, // INT16 + true, // UINT16 + true, // INT8 + true, // UINT8 // Normalized values - false, - false, - false, - false, - false, - false, - false, + false, // NINT32 + false, // NUINT32 + false, // NINT16 + false, // NUINT16 + false, // NINT8 + false, // NUINT8 + false, // NUINT2 + false, // NINT2_10_10_10 - false, + false, // COMPRESSED }; // Dimension of an Element @@ -367,9 +370,9 @@ public: static const Element PART_DRAWCALL; protected: - uint8 _semantic; - uint8 _dimension : 4; - uint8 _type : 4; + uint16 _semantic : 7; + uint16 _dimension : 4; + uint16 _type : 5; }; From 540f200b99a6df817799bb9b1f29588985c939ef Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 8 May 2018 16:34:28 -0700 Subject: [PATCH 157/192] MS14937: Fix Replace button for content sets during Checkout --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 1cfbcf9075..f25282c738 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -787,7 +787,7 @@ Rectangle { } lightboxPopup.button2text = "CONFIRM"; lightboxPopup.button2method = function() { - Commerce.replaceContentSet(root.itemHref); + Commerce.replaceContentSet(root.itemHref, root.certificateId); lightboxPopup.visible = false; rezzedNotifContainer.visible = true; rezzedNotifContainerTimer.start(); From 22c26c348dcf39d313a631ab2f52e80e33c7dee4 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 8 May 2018 16:34:28 -0700 Subject: [PATCH 158/192] MS14937: Fix Replace button for content sets during Checkout --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 1cfbcf9075..f25282c738 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -787,7 +787,7 @@ Rectangle { } lightboxPopup.button2text = "CONFIRM"; lightboxPopup.button2method = function() { - Commerce.replaceContentSet(root.itemHref); + Commerce.replaceContentSet(root.itemHref, root.certificateId); lightboxPopup.visible = false; rezzedNotifContainer.visible = true; rezzedNotifContainerTimer.start(); From ee4b1af3aa4ff93eb1348fb5d8a924b49237a9e2 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 8 May 2018 16:51:58 -0700 Subject: [PATCH 159/192] Corrected missing images in test.md files --- tools/auto-tester/src/Test.cpp | 76 ---------------------------------- tools/auto-tester/src/Test.h | 4 -- 2 files changed, 80 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 99f9025fdd..bdf734897e 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -478,26 +478,6 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { QString regexTestTitle(ws + functionPerformName + "\\(" + quotedString + "\\," + ws + ownPath + "\\," + ws + functionParameter + ws + "{" + ".*"); QRegularExpression lineContainingTitle = QRegularExpression(regexTestTitle); - // Assert platform checks that test is running on the correct OS - const QString functionAssertPlatform(ws + "autoTester" + ws + "\\." + ws + "assertPlatform"); - const QString regexAssertPlatform(ws + functionAssertPlatform + ws + "\\(" + ws + quotedString + ".*"); - const QRegularExpression lineAssertPlatform = QRegularExpression(regexAssertPlatform); - - // Assert display checks that test is running on the correct display - const QString functionAssertDisplay(ws + "autoTester" + ws + "\\." + ws + "assertDisplay"); - const QString regexAssertDisplay(ws + functionAssertDisplay + ws + "\\(" + ws + quotedString + ".*"); - const QRegularExpression lineAssertDisplay = QRegularExpression(regexAssertDisplay); - - // Assert CPU checks that test is running on the correct type of CPU - const QString functionAssertCPU(ws + "autoTester" + ws + "\\." + ws + "assertCPU"); - const QString regexAssertCPU(ws + functionAssertCPU + ws + "\\(" + ws + quotedString + ".*"); - const QRegularExpression lineAssertCPU = QRegularExpression(regexAssertCPU); - - // Assert GPU checks that test is running on the correct type of GPU - const QString functionAssertGPU(ws + "autoTester" + ws + "\\." + ws + "assertGPU"); - const QString regexAssertGPU(ws + functionAssertGPU + ws + "\\(" + ws + quotedString + ".*"); - const QRegularExpression lineAssertGPU = QRegularExpression(regexAssertGPU); - // Each step is either of the following forms: // autoTester.addStepSnapshot("Take snapshot"... // autoTester.addStep("Clean up after test"... @@ -514,18 +494,6 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { if (lineContainingTitle.match(line).hasMatch()) { QStringList tokens = line.split('"'); relevantTextFromTest.title = tokens[1]; - } else if (lineAssertPlatform.match(line).hasMatch()) { - QStringList platforms = line.split('"'); - relevantTextFromTest.platform = platforms[1]; - } else if (lineAssertDisplay.match(line).hasMatch()) { - QStringList displays = line.split('"'); - relevantTextFromTest.display = displays[1]; - } else if (lineAssertCPU.match(line).hasMatch()) { - QStringList cpus = line.split('"'); - relevantTextFromTest.cpu = cpus[1]; - } else if (lineAssertGPU.match(line).hasMatch()) { - QStringList gpus = line.split('"'); - relevantTextFromTest.gpu = gpus[1]; } else if (lineStepSnapshot.match(line).hasMatch()) { QStringList tokens = line.split('"'); QString nameOfStep = tokens[1]; @@ -628,50 +596,6 @@ void Test::createMDFile(QString testDirectory) { stream << "## Preconditions" << "\n"; stream << "- In an empty region of a domain with editing rights." << "\n\n"; - // Platform - QStringList platforms = testScriptLines.platform.split(" ");; - stream << "## Platforms\n"; - stream << "Run the test on each of the following platforms\n"; - for (int i = 0; i < platforms.size(); ++i) { - // Note that the platforms parameter may include extra spaces, these appear as empty strings in the list - if (platforms[i] != QString()) { - stream << " - " << platforms[i] << "\n"; - } - } - - // Display - QStringList displays = testScriptLines.display.split(" "); - stream << "## Displays\n"; - stream << "Run the test on each of the following displays\n"; - for (int i = 0; i < displays.size(); ++i) { - // Note that the displays parameter may include extra spaces, these appear as empty strings in the list - if (displays[i] != QString()) { - stream << " - " << displays[i] << "\n"; - } - } - - // CPU - QStringList cpus = testScriptLines.cpu.split(" "); - stream << "## Processors\n"; - stream << "Run the test on each of the following processors\n"; - for (int i = 0; i < cpus.size(); ++i) { - // Note that the cpus parameter may include extra spaces, these appear as empty strings in the list - if (cpus[i] != QString()) { - stream << " - " << cpus[i] << "\n"; - } - } - - // GPU - QStringList gpus = testScriptLines.gpu.split(" "); - stream << "## Graphics Cards\n"; - stream << "Run the test on graphics cards from each of the following vendors\n"; - for (int i = 0; i < gpus.size(); ++i) { - // Note that the gpus parameter may include extra spaces, these appear as empty strings in the list - if (gpus[i] != QString()) { - stream << " - " << gpus[i] << "\n"; - } - } - stream << "## Steps\n"; stream << "Press space bar to advance step by step\n\n"; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index e69459fef2..975d5dfdaf 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -30,10 +30,6 @@ using StepList = std::vector; class ExtractedText { public: QString title; - QString platform; - QString display; - QString cpu; - QString gpu; StepList stepList; }; From 0349847857fb2393c0894426b22011a60c2475a5 Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Tue, 8 May 2018 17:46:25 -0700 Subject: [PATCH 160/192] Add comment re threading issues --- libraries/networking/src/HMACAuth.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/HMACAuth.h b/libraries/networking/src/HMACAuth.h index 59870bb7b6..1346bdee17 100644 --- a/libraries/networking/src/HMACAuth.h +++ b/libraries/networking/src/HMACAuth.h @@ -30,8 +30,12 @@ public: bool setKey(const QUuid& uidKey); // Calculate complete hash in one. bool calculateHash(HMACHash& hashResult, const char* data, int dataLen); - // Append data to be hashed. + + // Append to data to be hashed. bool addData(const char* data, int dataLen); + // Get the resulting hash from calls to addData(). + // Note that only one hash may be calculated at a time for each + // HMACAuth instance if this interface is used. HMACHash result(); private: From 06c6f5506904f964b8c77e99ca7b083e5546c468 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 9 May 2018 09:35:42 -0700 Subject: [PATCH 161/192] MS14951: Fix Snapshot hotkey sound playback --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 038180a60d..525f0f2ee7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2128,7 +2128,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo return entityServerNode && !isPhysicsEnabled(); }); - _snapshotSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/snap.wav")); + _snapshotSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav")); QVariant testProperty = property(hifi::properties::TEST); qDebug() << testProperty; From 542e707de8d6d1cacb0e6b3e05f4b5258bff9921 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 9 May 2018 09:35:42 -0700 Subject: [PATCH 162/192] MS14951: Fix Snapshot hotkey sound playback --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 789f60bdb1..6a063fb990 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2093,7 +2093,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo return entityServerNode && !isPhysicsEnabled(); }); - _snapshotSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/snap.wav")); + _snapshotSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav")); QVariant testProperty = property(hifi::properties::TEST); qDebug() << testProperty; From db03265a6b8e0f2fa4873929fc5ec3c932e71d71 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 8 May 2018 18:49:55 -0700 Subject: [PATCH 163/192] when in serverless mode, short-circuit simulation ownership bids --- .../entities/src/EntityEditPacketSender.cpp | 8 -------- libraries/octree/src/OctreeEditPacketSender.cpp | 9 --------- libraries/octree/src/OctreeEditPacketSender.h | 3 --- libraries/physics/src/EntityMotionState.cpp | 8 +++++++- libraries/physics/src/EntityMotionState.h | 2 ++ .../physics/src/PhysicalEntitySimulation.cpp | 16 ++++++++++++---- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index 5d7bd61854..c0a45936ac 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -73,7 +73,6 @@ void EntityEditPacketSender::queueEditAvatarEntityMessage(PacketType type, _myAvatar->updateAvatarEntity(entityItemID, binaryProperties); entity->setLastBroadcast(usecTimestampNow()); - return; } @@ -81,10 +80,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityTreePointer entityTree, EntityItemID entityItemID, const EntityItemProperties& properties) { - if (!_shouldSend) { - return; // bail early - } - if (properties.getClientOnly() && properties.getOwningAvatarID() == _myAvatar->getID()) { // this is an avatar-based entity --> update our avatar-data rather than sending to the entity-server queueEditAvatarEntityMessage(type, entityTree, entityItemID, properties); @@ -143,9 +138,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, } void EntityEditPacketSender::queueEraseEntityMessage(const EntityItemID& entityItemID) { - if (!_shouldSend) { - return; // bail early - } // in case this was a clientOnly entity: if(_myAvatar) { diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 4f10c9bf79..4bc20c80c6 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -22,7 +22,6 @@ const int OctreeEditPacketSender::DEFAULT_MAX_PENDING_MESSAGES = PacketSender::D OctreeEditPacketSender::OctreeEditPacketSender() : - _shouldSend(true), _maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES), _releaseQueuedMessagesPending(false) { @@ -145,10 +144,6 @@ void OctreeEditPacketSender::queuePendingPacketToNodes(std::unique_ptr } void OctreeEditPacketSender::queuePacketToNodes(std::unique_ptr packet) { - if (!_shouldSend) { - return; // bail early - } - assert(serversExist()); // we must have servers to be here!! auto node = DependencyManager::get()->soloNodeOfType(getMyNodeType()); @@ -161,10 +156,6 @@ void OctreeEditPacketSender::queuePacketToNodes(std::unique_ptr packet // NOTE: editMessage - is JUST the octcode/color and does not contain the packet header void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, QByteArray& editMessage) { - if (!_shouldSend) { - return; // bail early - } - // If we don't have servers, then we will simply queue up all of these packets and wait till we have // servers for processing if (!serversExist()) { diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index 8a33eb8b73..1dad5b74c7 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -41,12 +41,10 @@ public: /// are we in sending mode. If we're not in sending mode then all packets and messages will be ignored and /// not queued and not sent - bool getShouldSend() const { return _shouldSend; } /// set sending mode. By default we are set to shouldSend=TRUE and packets will be sent. If shouldSend=FALSE, then we'll /// switch to not sending mode, and all packets and messages will be ignored, not queued, and not sent. This might be used /// in an application like interface when all octree features are disabled. - void setShouldSend(bool shouldSend) { _shouldSend = shouldSend; } /// if you're running in non-threaded mode, you must call this method regularly virtual bool process() override; @@ -76,7 +74,6 @@ public slots: protected: using EditMessagePair = std::pair; - bool _shouldSend; void queuePacketToNode(const QUuid& nodeID, std::unique_ptr packet); void queuePacketListToNode(const QUuid& nodeUUID, std::unique_ptr packetList); diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index c2bacd4949..47297adef5 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -348,7 +348,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) { if (_numInactiveUpdates > 0) { const uint8_t MAX_NUM_INACTIVE_UPDATES = 20; - if (_numInactiveUpdates > MAX_NUM_INACTIVE_UPDATES) { + if (_numInactiveUpdates > MAX_NUM_INACTIVE_UPDATES || isServerlessMode()) { // clear local ownership (stop sending updates) and let the server clear itself _entity->clearSimulationOwnership(); return false; @@ -827,3 +827,9 @@ void EntityMotionState::clearObjectVelocities() const { } _entity->setAcceleration(glm::vec3(0.0f)); } + +bool EntityMotionState::isServerlessMode() { + EntityTreeElementPointer element = _entity->getElement(); + EntityTreePointer tree = element ? element->getTree() : nullptr; + return tree ? tree->isServerlessMode() : false; +} diff --git a/libraries/physics/src/EntityMotionState.h b/libraries/physics/src/EntityMotionState.h index a542c61d43..376cc5afe2 100644 --- a/libraries/physics/src/EntityMotionState.h +++ b/libraries/physics/src/EntityMotionState.h @@ -156,6 +156,8 @@ protected: uint8_t _numInactiveUpdates { 1 }; uint8_t _bidPriority { 0 }; bool _serverVariablesSet { false }; + + bool isServerlessMode(); }; #endif // hifi_EntityMotionState_h diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index ab7c2ec252..467de22591 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -327,10 +327,18 @@ void PhysicalEntitySimulation::handleChangedMotionStates(const VectorOfMotionSta } void PhysicalEntitySimulation::addOwnershipBid(EntityMotionState* motionState) { - motionState->initForBid(); - motionState->sendBid(_entityPacketSender, _physicsEngine->getNumSubsteps()); - _bids.push_back(motionState); - _nextBidExpiry = glm::min(_nextBidExpiry, motionState->getNextBidExpiry()); + if (getEntityTree()->isServerlessMode()) { + EntityItemPointer entity = motionState->getEntity(); + auto nodeList = DependencyManager::get(); + auto sessionID = nodeList->getSessionUUID(); + entity->setSimulationOwner(SimulationOwner(sessionID, SCRIPT_GRAB_SIMULATION_PRIORITY)); + _owned.push_back(motionState); + } else { + motionState->initForBid(); + motionState->sendBid(_entityPacketSender, _physicsEngine->getNumSubsteps()); + _bids.push_back(motionState); + _nextBidExpiry = glm::min(_nextBidExpiry, motionState->getNextBidExpiry()); + } } void PhysicalEntitySimulation::addOwnership(EntityMotionState* motionState) { From 32f2494416a64a210a2da668be9a87485018e029 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 9 May 2018 11:58:16 -0700 Subject: [PATCH 164/192] Stores previous user-selected folders. --- tools/auto-tester/src/Test.cpp | 128 +++++++++++++++++++++++---------- tools/auto-tester/src/Test.h | 7 +- 2 files changed, 96 insertions(+), 39 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index bdf734897e..1ab934cf63 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -176,33 +176,38 @@ void Test::appendTestResultsToFile(QString testResultsFolderPath, TestFailure te void Test::startTestsEvaluation() { // Get list of JPEG images in folder, sorted by name - pathToTestResultsDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly); - if (pathToTestResultsDirectory == "") { + QString previousSelection = snapshotDirectory; + + snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", + previousSelection, QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (snapshotDirectory == "") { + snapshotDirectory = previousSelection; return; } // Quit if test results folder could not be created - if (!createTestResultsFolderPath(pathToTestResultsDirectory)) { + if (!createTestResultsFolderPath(snapshotDirectory)) { return; } // Before any processing - all images are converted to PNGs, as this is the format stored on GitHub - QStringList sortedSnapshotFilenames = createListOfAll_imagesInDirectory("jpg", pathToTestResultsDirectory); + QStringList sortedSnapshotFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory); foreach(QString filename, sortedSnapshotFilenames) { QStringList stringParts = filename.split("."); - copyJPGtoPNG( - pathToTestResultsDirectory + "/" + stringParts[0] + ".jpg", - pathToTestResultsDirectory + "/" + stringParts[0] + ".png" + copyJPGtoPNG(snapshotDirectory + "/" + stringParts[0] + ".jpg", + snapshotDirectory + "/" + stringParts[0] + ".png" ); - QFile::remove(pathToTestResultsDirectory + "/" + stringParts[0] + ".jpg"); + QFile::remove(snapshotDirectory + "/" + stringParts[0] + ".jpg"); } // Create two lists. The first is the test results, the second is the expected images // The expected images are represented as a URL to enable download from GitHub // Images that are in the wrong format are ignored. - QStringList sortedTestResultsFilenames = createListOfAll_imagesInDirectory("png", pathToTestResultsDirectory); + QStringList sortedTestResultsFilenames = createListOfAll_imagesInDirectory("png", snapshotDirectory); QStringList expectedImagesURLs; resultImagesFullFilenames.clear(); @@ -210,7 +215,7 @@ void Test::startTestsEvaluation() { expectedImagesFullFilenames.clear(); foreach(QString currentFilename, sortedTestResultsFilenames) { - QString fullCurrentFilename = pathToTestResultsDirectory + "/" + currentFilename; + QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; if (isInSnapshotFilenameFormat("png", currentFilename)) { resultImagesFullFilenames << fullCurrentFilename; @@ -230,11 +235,11 @@ void Test::startTestsEvaluation() { QString expectedImageFilename = currentFilename.replace("/", "_").replace(".", "_EI."); expectedImagesFilenames << expectedImageFilename; - expectedImagesFullFilenames << pathToTestResultsDirectory + "/" + expectedImageFilename; + expectedImagesFullFilenames << snapshotDirectory + "/" + expectedImageFilename; } } - autoTester->downloadImages(expectedImagesURLs, pathToTestResultsDirectory, expectedImagesFilenames); + autoTester->downloadImages(expectedImagesURLs, snapshotDirectory, expectedImagesFilenames); } void Test::finishTestsEvaluation(bool interactiveMode, QProgressBar* progressBar) { @@ -295,25 +300,39 @@ void Test::importTest(QTextStream& textStream, const QString& testPathname) { // This script will run all text.js scripts in every applicable sub-folder void Test::createRecursiveScript() { // Select folder to start recursing from - QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder that will contain the top level test script", ".", QFileDialog::ShowDirsOnly); - if (topLevelDirectory == "") { + QString previousSelection = testDirectory; + + testDirectory = + QFileDialog::getExistingDirectory(nullptr, "Please select folder that will contain the top level test script", + previousSelection, QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (testDirectory == "") { + testDirectory = previousSelection; return; } - createRecursiveScript(topLevelDirectory, true); + createRecursiveScript(testDirectory, true); } // This method creates a `testRecursive.js` script in every sub-folder. void Test::createAllRecursiveScripts() { // Select folder to start recursing from - QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the recursive scripts", ".", QFileDialog::ShowDirsOnly); - if (topLevelDirectory == "") { + QString previousSelection = testDirectory; + + testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the recursive scripts", + previousSelection, + QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (testDirectory == "") { + testDirectory = previousSelection; return; } - createRecursiveScript(topLevelDirectory, false); + createRecursiveScript(testDirectory, false); - QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories); + QDirIterator it(testDirectory.toStdString().c_str(), QDirIterator::Subdirectories); while (it.hasNext()) { QString directory = it.next(); @@ -416,29 +435,42 @@ void Test::createRecursiveScript(QString topLevelDirectory, bool interactiveMode void Test::createTest() { // Rename files sequentially, as ExpectedResult_00000.jpeg, ExpectedResult_00001.jpg and so on // Any existing expected result images will be deleted - QString imageSourceDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly); - if (imageSourceDirectory == "") { + QString previousSelection = snapshotDirectory; + + snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", + previousSelection, + QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (snapshotDirectory == "") { + snapshotDirectory = previousSelection; return; } - QString imageDestinationDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder to save the test images", ".", QFileDialog::ShowDirsOnly); - if (imageDestinationDirectory == "") { + previousSelection = testDirectory; + + QString testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder to save the test images", + previousSelection, QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (testDirectory == "") { + testDirectory = previousSelection; return; } - QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("jpg", imageSourceDirectory); + QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory); int i = 1; const int maxImages = pow(10, NUM_DIGITS); foreach (QString currentFilename, sortedImageFilenames) { - QString fullCurrentFilename = imageSourceDirectory + "/" + currentFilename; + QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; if (isInSnapshotFilenameFormat("jpg", currentFilename)) { if (i >= maxImages) { messageBox.critical(0, "Error", "More than " + QString::number(maxImages) + " images not supported"); exit(-1); } QString newFilename = "ExpectedImage_" + QString::number(i - 1).rightJustified(5, '0') + ".png"; - QString fullNewFileName = imageDestinationDirectory + "/" + newFilename; + QString fullNewFileName = testDirectory + "/" + newFilename; try { copyJPGtoPNG(fullCurrentFilename, fullNewFileName); @@ -486,7 +518,7 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { const QRegularExpression lineStepSnapshot = QRegularExpression(regexStepSnapshot); const QString functionAddStepName(ws + "autoTester" + ws + "\\." + ws + "addStep"); - const QString regexStep(ws + functionAddStepName + ws + "\\(" + ws + quotedString + ws + "\\)" + ".*"); + const QString regexStep(ws + functionAddStepName + ws + "\\(" + ws + quotedString + ".*"); const QRegularExpression lineStep = QRegularExpression(regexStep); while (!line.isNull()) { @@ -522,29 +554,43 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { // The folder selected must contain a script named "test.js", the file produced is named "test.md" void Test::createMDFile() { // Folder selection - QString testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test", ".", QFileDialog::ShowDirsOnly); + QString previousSelection = testDirectory; + + testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test", previousSelection, + QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return if (testDirectory == "") { + testDirectory = previousSelection; return; } createMDFile(testDirectory); + + messageBox.information(0, "Success", "MD file has been created"); } void Test::createAllMDFiles() { // Select folder to start recursing from - QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the MD files", ".", QFileDialog::ShowDirsOnly); - if (topLevelDirectory == "") { + QString previousSelection = testDirectory; + + testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the root folder for the MD files", + previousSelection, QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (testDirectory == "") { + testDirectory = previousSelection; return; } // First test if top-level folder has a test.js file - const QString testPathname{ topLevelDirectory + "/" + TEST_FILENAME }; + const QString testPathname { testDirectory + "/" + TEST_FILENAME }; QFileInfo fileInfo(testPathname); if (fileInfo.exists()) { - createMDFile(topLevelDirectory); + createMDFile(testDirectory); } - QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories); + QDirIterator it(testDirectory.toStdString().c_str(), QDirIterator::Subdirectories); while (it.hasNext()) { QString directory = it.next(); @@ -613,13 +659,19 @@ void Test::createMDFile(QString testDirectory) { } void Test::createTestsOutline() { - QString testsRootDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", ".", QFileDialog::ShowDirsOnly); - if (testsRootDirectory == "") { + QString previousSelection = testDirectory; + + testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", previousSelection, + QFileDialog::ShowDirsOnly); + + // If user cancelled then restore previous selection and return + if (testDirectory == "") { + testDirectory = previousSelection; return; } const QString testsOutlineFilename { "testsOutline.md" }; - QString mdFilename(testsRootDirectory + "/" + testsOutlineFilename); + QString mdFilename(testDirectory + "/" + testsOutlineFilename); QFile mdFile(mdFilename); if (!mdFile.open(QIODevice::WriteOnly)) { messageBox.critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Failed to create file " + mdFilename); @@ -633,10 +685,10 @@ void Test::createTestsOutline() { stream << "Directories with an appended (*) have an automatic test\n\n"; // We need to know our current depth, as this isn't given by QDirIterator - int rootDepth { testsRootDirectory.count('/') }; + int rootDepth { testDirectory.count('/') }; // Each test is shown as the folder name linking to the matching GitHub URL, and the path to the associated test.md file - QDirIterator it(testsRootDirectory.toStdString().c_str(), QDirIterator::Subdirectories); + QDirIterator it(testDirectory.toStdString().c_str(), QDirIterator::Subdirectories); while (it.hasNext()) { QString directory = it.next(); diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 975d5dfdaf..896fe24fcc 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -91,7 +91,12 @@ private: const int NUM_DIGITS { 5 }; const QString EXPECTED_IMAGE_PREFIX { "ExpectedImage_" }; - QString pathToTestResultsDirectory; + // We have to directories to work with. + // The first is the directory containing the test we are working with + // The second contains the snapshots taken for test runs that need to be evaluated + QString testDirectory; + QString snapshotDirectory; + QStringList expectedImagesFilenames; QStringList expectedImagesFullFilenames; QStringList resultImagesFullFilenames; From f454dac709d5b709545a7e484f7c3eed30333594 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 9 May 2018 12:04:44 -0700 Subject: [PATCH 165/192] avoid div by zero when measuring acceleration --- libraries/physics/src/EntityMotionState.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index a801392b66..fbb4b69ce0 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -731,7 +731,9 @@ void EntityMotionState::measureBodyAcceleration() { // hence the equation for acceleration is: a = (v1 / (1 - D)^dt - v0) / dt glm::vec3 velocity = getBodyLinearVelocityGTSigma(); - _measuredAcceleration = (velocity / powf(1.0f - _body->getLinearDamping(), dt) - _lastVelocity) * invDt; + const float MIN_DAMPING_FACTOR = 0.01f; + float dampingAttenuationFactor = 1.0f / glm::max(powf(1.0f - _body->getLinearDamping(), dt), MIN_DAMPING_FACTOR); + _measuredAcceleration = (velocity * dampingAttenuationFactor - _lastVelocity) * invDt; _lastVelocity = velocity; if (numSubsteps > PHYSICS_ENGINE_MAX_NUM_SUBSTEPS) { // we fall in here when _lastMeasureStep is old: the body has just become active From b8d34f4b8fee9f754f7312f6351bc347db31ba85 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 9 May 2018 12:13:27 -0700 Subject: [PATCH 166/192] more correct variable name --- libraries/physics/src/EntityMotionState.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index fbb4b69ce0..e04055ec32 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -732,8 +732,8 @@ void EntityMotionState::measureBodyAcceleration() { glm::vec3 velocity = getBodyLinearVelocityGTSigma(); const float MIN_DAMPING_FACTOR = 0.01f; - float dampingAttenuationFactor = 1.0f / glm::max(powf(1.0f - _body->getLinearDamping(), dt), MIN_DAMPING_FACTOR); - _measuredAcceleration = (velocity * dampingAttenuationFactor - _lastVelocity) * invDt; + float invDampingAttenuationFactor = 1.0f / glm::max(powf(1.0f - _body->getLinearDamping(), dt), MIN_DAMPING_FACTOR); + _measuredAcceleration = (velocity * invDampingAttenuationFactor - _lastVelocity) * invDt; _lastVelocity = velocity; if (numSubsteps > PHYSICS_ENGINE_MAX_NUM_SUBSTEPS) { // we fall in here when _lastMeasureStep is old: the body has just become active From 7466d08f1f3c3d5ee500d4a499839c88469667a9 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 5 May 2018 16:42:44 -0700 Subject: [PATCH 167/192] more suppression of logging --- interface/src/Application.cpp | 43 +++++++++++++++++-- libraries/entities/src/EntityItem.cpp | 2 +- libraries/qml/src/qml/Logging.h | 4 +- libraries/script-engine/src/ScriptEngine.cpp | 6 +-- .../script-engine/src/ScriptEngineLogging.cpp | 1 + .../script-engine/src/ScriptEngineLogging.h | 1 + 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ec28dcb3dd..c9055e92b2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -154,6 +154,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include "AudioClient.h" #include "audio/AudioScope.h" @@ -1372,8 +1379,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Needs to happen AFTER the render engine initialization to access its configuration initializeUi(); - updateVerboseLogging(); - init(); qCDebug(interfaceapp, "init() complete."); @@ -1713,6 +1718,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo loadSettings(); + updateVerboseLogging(); + // Now that we've loaded the menu and thus switched to the previous display plugin // we can unlock the desktop repositioning code, since all the positions will be // relative to the desktop size for this plugin @@ -2254,10 +2261,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _pendingRenderEvent = false; qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); + + updateVerboseLogging(); } void Application::updateVerboseLogging() { - bool enable = Menu::getInstance()->isOptionChecked(MenuOption::VerboseLogging); + auto menu = Menu::getInstance(); + if (!menu) { + return; + } + bool enable = menu->isOptionChecked(MenuOption::VerboseLogging); const_cast(&animation())->setEnabled(QtDebugMsg, enable); const_cast(&animation())->setEnabled(QtInfoMsg, enable); @@ -2268,6 +2281,12 @@ void Application::updateVerboseLogging() { const_cast(&scriptengine())->setEnabled(QtDebugMsg, enable); const_cast(&scriptengine())->setEnabled(QtInfoMsg, enable); + const_cast(&scriptengine_module())->setEnabled(QtDebugMsg, enable); + const_cast(&scriptengine_module())->setEnabled(QtInfoMsg, enable); + + const_cast(&scriptengine_script())->setEnabled(QtDebugMsg, enable); + const_cast(&scriptengine_script())->setEnabled(QtInfoMsg, enable); + const_cast(&modelformat())->setEnabled(QtDebugMsg, enable); const_cast(&modelformat())->setEnabled(QtInfoMsg, enable); @@ -2294,6 +2313,24 @@ void Application::updateVerboseLogging() { const_cast(&glLogging())->setEnabled(QtDebugMsg, enable); const_cast(&glLogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&shared())->setEnabled(QtDebugMsg, enable); + const_cast(&shared())->setEnabled(QtInfoMsg, enable); + + const_cast(&plugins())->setEnabled(QtDebugMsg, enable); + const_cast(&plugins())->setEnabled(QtInfoMsg, enable); + + const_cast(&gpulogging())->setEnabled(QtDebugMsg, enable); + const_cast(&gpulogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&gpugllogging())->setEnabled(QtDebugMsg, enable); + const_cast(&gpugllogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&qmlLogging())->setEnabled(QtDebugMsg, enable); + const_cast(&qmlLogging())->setEnabled(QtInfoMsg, enable); + + const_cast(&entities())->setEnabled(QtDebugMsg, enable); + const_cast(&entities())->setEnabled(QtInfoMsg, enable); } void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 1d81a6ae6d..d35c01a51b 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1070,7 +1070,7 @@ bool EntityItem::stepKinematicMotion(float timeElapsed) { const float MAX_TIME_ELAPSED = 1.0f; // seconds if (timeElapsed > MAX_TIME_ELAPSED) { - qCWarning(entities) << "kinematic timestep = " << timeElapsed << " truncated to " << MAX_TIME_ELAPSED; + qCDebug(entities) << "kinematic timestep = " << timeElapsed << " truncated to " << MAX_TIME_ELAPSED; } timeElapsed = glm::min(timeElapsed, MAX_TIME_ELAPSED); diff --git a/libraries/qml/src/qml/Logging.h b/libraries/qml/src/qml/Logging.h index 487566701d..48efdd1da9 100644 --- a/libraries/qml/src/qml/Logging.h +++ b/libraries/qml/src/qml/Logging.h @@ -6,8 +6,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_Controllers_Logging_h -#define hifi_Controllers_Logging_h +#ifndef hifi_QML_Logging_h +#define hifi_QML_Logging_h #include diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 9a383454d4..23ffbabe77 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -101,8 +101,6 @@ int functionSignatureMetaID = qRegisterMetaType(); -Q_LOGGING_CATEGORY(scriptengineScript, "hifi.scriptengine.script") - static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { QString message = ""; for (int i = 0; i < context->argumentCount(); i++) { @@ -115,9 +113,9 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { if (ScriptEngine *scriptEngine = qobject_cast(engine)) { scriptEngine->print(message); // prefix the script engine name to help disambiguate messages in the main debug log - qCDebug(scriptengineScript, "[%s] %s", qUtf8Printable(scriptEngine->getFilename()), qUtf8Printable(message)); + qCDebug(scriptengine_script, "[%s] %s", qUtf8Printable(scriptEngine->getFilename()), qUtf8Printable(message)); } else { - qCDebug(scriptengineScript, "%s", qUtf8Printable(message)); + qCDebug(scriptengine_script, "%s", qUtf8Printable(message)); } return QScriptValue(); diff --git a/libraries/script-engine/src/ScriptEngineLogging.cpp b/libraries/script-engine/src/ScriptEngineLogging.cpp index 392bc05129..b51d7c3780 100644 --- a/libraries/script-engine/src/ScriptEngineLogging.cpp +++ b/libraries/script-engine/src/ScriptEngineLogging.cpp @@ -13,3 +13,4 @@ Q_LOGGING_CATEGORY(scriptengine, "hifi.scriptengine") Q_LOGGING_CATEGORY(scriptengine_module, "hifi.scriptengine.module") +Q_LOGGING_CATEGORY(scriptengine_script, "hifi.scriptengine.script") diff --git a/libraries/script-engine/src/ScriptEngineLogging.h b/libraries/script-engine/src/ScriptEngineLogging.h index 62e46632a6..3096dd4927 100644 --- a/libraries/script-engine/src/ScriptEngineLogging.h +++ b/libraries/script-engine/src/ScriptEngineLogging.h @@ -16,6 +16,7 @@ Q_DECLARE_LOGGING_CATEGORY(scriptengine) Q_DECLARE_LOGGING_CATEGORY(scriptengine_module) +Q_DECLARE_LOGGING_CATEGORY(scriptengine_script) #endif // hifi_ScriptEngineLogging_h From 16e832ac0894a2c2413dbdc3328da148757c00d0 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 9 May 2018 13:01:33 -0700 Subject: [PATCH 168/192] use setFilterRules rather than specifying each logging category to suppress --- interface/src/Application.cpp | 82 ++--------------------------------- 1 file changed, 4 insertions(+), 78 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c9055e92b2..20efe73f08 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -145,23 +145,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "AudioClient.h" #include "audio/AudioScope.h" #include "avatar/AvatarManager.h" @@ -2261,8 +2244,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _pendingRenderEvent = false; qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); - - updateVerboseLogging(); } void Application::updateVerboseLogging() { @@ -2272,65 +2253,10 @@ void Application::updateVerboseLogging() { } bool enable = menu->isOptionChecked(MenuOption::VerboseLogging); - const_cast(&animation())->setEnabled(QtDebugMsg, enable); - const_cast(&animation())->setEnabled(QtInfoMsg, enable); - - const_cast(&avatars())->setEnabled(QtDebugMsg, enable); - const_cast(&avatars())->setEnabled(QtInfoMsg, enable); - - const_cast(&scriptengine())->setEnabled(QtDebugMsg, enable); - const_cast(&scriptengine())->setEnabled(QtInfoMsg, enable); - - const_cast(&scriptengine_module())->setEnabled(QtDebugMsg, enable); - const_cast(&scriptengine_module())->setEnabled(QtInfoMsg, enable); - - const_cast(&scriptengine_script())->setEnabled(QtDebugMsg, enable); - const_cast(&scriptengine_script())->setEnabled(QtInfoMsg, enable); - - const_cast(&modelformat())->setEnabled(QtDebugMsg, enable); - const_cast(&modelformat())->setEnabled(QtInfoMsg, enable); - - const_cast(&controllers())->setEnabled(QtDebugMsg, enable); - const_cast(&controllers())->setEnabled(QtInfoMsg, enable); - - const_cast(&resourceLog())->setEnabled(QtDebugMsg, enable); - const_cast(&resourceLog())->setEnabled(QtInfoMsg, enable); - - const_cast(&networking())->setEnabled(QtDebugMsg, enable); - const_cast(&networking())->setEnabled(QtInfoMsg, enable); - - const_cast(&asset_client())->setEnabled(QtDebugMsg, enable); - const_cast(&asset_client())->setEnabled(QtInfoMsg, enable); - - const_cast(&messages_client())->setEnabled(QtDebugMsg, enable); - const_cast(&messages_client())->setEnabled(QtInfoMsg, enable); - - const_cast(&storagelogging())->setEnabled(QtDebugMsg, enable); - const_cast(&storagelogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&uiLogging())->setEnabled(QtDebugMsg, enable); - const_cast(&uiLogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&glLogging())->setEnabled(QtDebugMsg, enable); - const_cast(&glLogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&shared())->setEnabled(QtDebugMsg, enable); - const_cast(&shared())->setEnabled(QtInfoMsg, enable); - - const_cast(&plugins())->setEnabled(QtDebugMsg, enable); - const_cast(&plugins())->setEnabled(QtInfoMsg, enable); - - const_cast(&gpulogging())->setEnabled(QtDebugMsg, enable); - const_cast(&gpulogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&gpugllogging())->setEnabled(QtDebugMsg, enable); - const_cast(&gpugllogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&qmlLogging())->setEnabled(QtDebugMsg, enable); - const_cast(&qmlLogging())->setEnabled(QtInfoMsg, enable); - - const_cast(&entities())->setEnabled(QtDebugMsg, enable); - const_cast(&entities())->setEnabled(QtInfoMsg, enable); + QString rules = "*.debug=%1\n" + "*.info=%1"; + rules = rules.arg(enable ? "true" : "false"); + QLoggingCategory::setFilterRules(rules); } void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { From d5afb3a49b81d1b4d1070211b604e04f938a42d5 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 09:04:59 -0700 Subject: [PATCH 169/192] Move non-automated tests into new folder --- .../controllers/CMakeLists.txt | 0 .../controllers/qml/main.qml | 0 .../controllers/src/main.cpp | 0 .../entities/CMakeLists.txt | 0 {tests => tests-manual}/entities/packet.bin | Bin {tests => tests-manual}/entities/src/main.cpp | 0 {tests => tests-manual}/gl/CMakeLists.txt | 0 {tests => tests-manual}/gl/src/main.cpp | 0 tests-manual/gpu-textures/CMakeLists.txt | 16 ++ .../gpu-textures/qml/textureStats.qml | 52 ++++++ tests-manual/gpu-textures/src/TestHelpers.cpp | 26 +++ tests-manual/gpu-textures/src/TestHelpers.h | 40 +++++ .../gpu-textures/src/TestTextures.cpp | 168 +++++++++++++++++ tests-manual/gpu-textures/src/TestTextures.h | 74 ++++++++ tests-manual/gpu-textures/src/TestWindow.cpp | 117 ++++++++++++ tests-manual/gpu-textures/src/TestWindow.h | 41 +++++ tests-manual/gpu-textures/src/main.cpp | 170 ++++++++++++++++++ .../gpu}/CMakeLists.txt | 0 .../gpu}/src/TestFbx.cpp | 0 .../gpu}/src/TestFbx.h | 0 .../gpu}/src/TestFloorGrid.cpp | 0 .../gpu}/src/TestFloorGrid.h | 0 .../gpu}/src/TestFloorTexture.cpp | 0 .../gpu}/src/TestFloorTexture.h | 0 .../gpu}/src/TestHelpers.cpp | 0 .../gpu}/src/TestHelpers.h | 0 .../gpu}/src/TestInstancedShapes.cpp | 0 .../gpu}/src/TestInstancedShapes.h | 0 .../gpu}/src/TestShapes.cpp | 0 .../gpu}/src/TestShapes.h | 0 .../gpu}/src/TestWindow.cpp | 0 .../gpu}/src/TestWindow.h | 0 .../gpu}/src/main.cpp | 0 {tests => tests-manual}/qml/CMakeLists.txt | 0 .../qml/qml/controls/WebEntityView.qml | 0 {tests => tests-manual}/qml/qml/main.qml | 0 .../qml/qml/qml/+android/UI.js | 0 .../qml/qml/qml/+ios/UI.js | 0 .../qml/qml/qml/+osx/UI.js | 0 .../qml/qml/qml/ButtonPage.qml | 0 .../qml/qml/qml/InputPage.qml | 0 .../qml/qml/qml/ProgressPage.qml | 0 {tests => tests-manual}/qml/qml/qml/UI.js | 0 {tests => tests-manual}/qml/src/main.cpp | 0 {tests => tests-manual}/qt59/CMakeLists.txt | 0 {tests => tests-manual}/qt59/src/main.cpp | 0 .../render-perf/CMakeLists.txt | 0 .../render-perf/src/Camera.hpp | 0 .../render-perf/src/main.cpp | 0 .../render-texture-load/CMakeLists.txt | 0 .../render-texture-load/src/GLIHelpers.cpp | 0 .../render-texture-load/src/GLIHelpers.h | 0 .../render-texture-load/src/main.cpp | 0 .../render-utils/CMakeLists.txt | 0 .../render-utils/src/main.cpp | 0 .../shaders/CMakeLists.txt | 0 {tests => tests-manual}/shaders/src/main.cpp | 0 {tests => tests-manual}/ui/CMakeLists.txt | 0 {tests => tests-manual}/ui/qml/Palettes.qml | 0 .../ui/qml/ScrollingGraph.qml | 0 {tests => tests-manual}/ui/qml/StubMenu.qml | 0 {tests => tests-manual}/ui/qml/Stubs.qml | 0 .../ui/qml/TestControllers.qml | 0 {tests => tests-manual}/ui/qml/TestDialog.qml | 0 {tests => tests-manual}/ui/qml/TestMenu.qml | 0 {tests => tests-manual}/ui/qml/TestRoot.qml | 0 .../ui/qml/controlDemo/ButtonPage.qml | 0 .../ui/qml/controlDemo/InputPage.qml | 0 .../ui/qml/controlDemo/ProgressPage.qml | 0 .../ui/qml/controlDemo/main.qml | 0 {tests => tests-manual}/ui/qml/main.qml | 0 {tests => tests-manual}/ui/qmlscratch.pro | 0 {tests => tests-manual}/ui/src/main.cpp | 0 73 files changed, 704 insertions(+) rename {tests => tests-manual}/controllers/CMakeLists.txt (100%) rename {tests => tests-manual}/controllers/qml/main.qml (100%) rename {tests => tests-manual}/controllers/src/main.cpp (100%) rename {tests => tests-manual}/entities/CMakeLists.txt (100%) rename {tests => tests-manual}/entities/packet.bin (100%) rename {tests => tests-manual}/entities/src/main.cpp (100%) rename {tests => tests-manual}/gl/CMakeLists.txt (100%) rename {tests => tests-manual}/gl/src/main.cpp (100%) create mode 100644 tests-manual/gpu-textures/CMakeLists.txt create mode 100644 tests-manual/gpu-textures/qml/textureStats.qml create mode 100644 tests-manual/gpu-textures/src/TestHelpers.cpp create mode 100644 tests-manual/gpu-textures/src/TestHelpers.h create mode 100644 tests-manual/gpu-textures/src/TestTextures.cpp create mode 100644 tests-manual/gpu-textures/src/TestTextures.h create mode 100644 tests-manual/gpu-textures/src/TestWindow.cpp create mode 100644 tests-manual/gpu-textures/src/TestWindow.h create mode 100644 tests-manual/gpu-textures/src/main.cpp rename {tests/gpu-test => tests-manual/gpu}/CMakeLists.txt (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFbx.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFbx.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFloorGrid.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFloorGrid.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFloorTexture.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestFloorTexture.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestHelpers.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestHelpers.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestInstancedShapes.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestInstancedShapes.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestShapes.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestShapes.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestWindow.cpp (100%) rename {tests/gpu-test => tests-manual/gpu}/src/TestWindow.h (100%) rename {tests/gpu-test => tests-manual/gpu}/src/main.cpp (100%) rename {tests => tests-manual}/qml/CMakeLists.txt (100%) rename {tests => tests-manual}/qml/qml/controls/WebEntityView.qml (100%) rename {tests => tests-manual}/qml/qml/main.qml (100%) rename {tests => tests-manual}/qml/qml/qml/+android/UI.js (100%) rename {tests => tests-manual}/qml/qml/qml/+ios/UI.js (100%) rename {tests => tests-manual}/qml/qml/qml/+osx/UI.js (100%) rename {tests => tests-manual}/qml/qml/qml/ButtonPage.qml (100%) rename {tests => tests-manual}/qml/qml/qml/InputPage.qml (100%) rename {tests => tests-manual}/qml/qml/qml/ProgressPage.qml (100%) rename {tests => tests-manual}/qml/qml/qml/UI.js (100%) rename {tests => tests-manual}/qml/src/main.cpp (100%) rename {tests => tests-manual}/qt59/CMakeLists.txt (100%) rename {tests => tests-manual}/qt59/src/main.cpp (100%) rename {tests => tests-manual}/render-perf/CMakeLists.txt (100%) rename {tests => tests-manual}/render-perf/src/Camera.hpp (100%) rename {tests => tests-manual}/render-perf/src/main.cpp (100%) rename {tests => tests-manual}/render-texture-load/CMakeLists.txt (100%) rename {tests => tests-manual}/render-texture-load/src/GLIHelpers.cpp (100%) rename {tests => tests-manual}/render-texture-load/src/GLIHelpers.h (100%) rename {tests => tests-manual}/render-texture-load/src/main.cpp (100%) rename {tests => tests-manual}/render-utils/CMakeLists.txt (100%) rename {tests => tests-manual}/render-utils/src/main.cpp (100%) rename {tests => tests-manual}/shaders/CMakeLists.txt (100%) rename {tests => tests-manual}/shaders/src/main.cpp (100%) rename {tests => tests-manual}/ui/CMakeLists.txt (100%) rename {tests => tests-manual}/ui/qml/Palettes.qml (100%) rename {tests => tests-manual}/ui/qml/ScrollingGraph.qml (100%) rename {tests => tests-manual}/ui/qml/StubMenu.qml (100%) rename {tests => tests-manual}/ui/qml/Stubs.qml (100%) rename {tests => tests-manual}/ui/qml/TestControllers.qml (100%) rename {tests => tests-manual}/ui/qml/TestDialog.qml (100%) rename {tests => tests-manual}/ui/qml/TestMenu.qml (100%) rename {tests => tests-manual}/ui/qml/TestRoot.qml (100%) rename {tests => tests-manual}/ui/qml/controlDemo/ButtonPage.qml (100%) rename {tests => tests-manual}/ui/qml/controlDemo/InputPage.qml (100%) rename {tests => tests-manual}/ui/qml/controlDemo/ProgressPage.qml (100%) rename {tests => tests-manual}/ui/qml/controlDemo/main.qml (100%) rename {tests => tests-manual}/ui/qml/main.qml (100%) rename {tests => tests-manual}/ui/qmlscratch.pro (100%) rename {tests => tests-manual}/ui/src/main.cpp (100%) diff --git a/tests/controllers/CMakeLists.txt b/tests-manual/controllers/CMakeLists.txt similarity index 100% rename from tests/controllers/CMakeLists.txt rename to tests-manual/controllers/CMakeLists.txt diff --git a/tests/controllers/qml/main.qml b/tests-manual/controllers/qml/main.qml similarity index 100% rename from tests/controllers/qml/main.qml rename to tests-manual/controllers/qml/main.qml diff --git a/tests/controllers/src/main.cpp b/tests-manual/controllers/src/main.cpp similarity index 100% rename from tests/controllers/src/main.cpp rename to tests-manual/controllers/src/main.cpp diff --git a/tests/entities/CMakeLists.txt b/tests-manual/entities/CMakeLists.txt similarity index 100% rename from tests/entities/CMakeLists.txt rename to tests-manual/entities/CMakeLists.txt diff --git a/tests/entities/packet.bin b/tests-manual/entities/packet.bin similarity index 100% rename from tests/entities/packet.bin rename to tests-manual/entities/packet.bin diff --git a/tests/entities/src/main.cpp b/tests-manual/entities/src/main.cpp similarity index 100% rename from tests/entities/src/main.cpp rename to tests-manual/entities/src/main.cpp diff --git a/tests/gl/CMakeLists.txt b/tests-manual/gl/CMakeLists.txt similarity index 100% rename from tests/gl/CMakeLists.txt rename to tests-manual/gl/CMakeLists.txt diff --git a/tests/gl/src/main.cpp b/tests-manual/gl/src/main.cpp similarity index 100% rename from tests/gl/src/main.cpp rename to tests-manual/gl/src/main.cpp diff --git a/tests-manual/gpu-textures/CMakeLists.txt b/tests-manual/gpu-textures/CMakeLists.txt new file mode 100644 index 0000000000..c10f2eda3f --- /dev/null +++ b/tests-manual/gpu-textures/CMakeLists.txt @@ -0,0 +1,16 @@ +set(TARGET_NAME gpu-textures-tests) +AUTOSCRIBE_SHADER_LIB(gpu graphics render-utils) +# This is not a testcase -- just set it up as a regular hifi project +setup_hifi_project(Quick Gui Script) +setup_memory_debugger() +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") +link_hifi_libraries( + shared task networking gl + ktx gpu octree + ${PLATFORM_GL_BACKEND} +) + +set(EXTRA_DEPLOY_OPTIONS "--qmldir \"${PROJECT_SOURCE_DIR}/qml\"") +package_libraries_for_deployment() + +target_nsight() diff --git a/tests-manual/gpu-textures/qml/textureStats.qml b/tests-manual/gpu-textures/qml/textureStats.qml new file mode 100644 index 0000000000..d3700c3eac --- /dev/null +++ b/tests-manual/gpu-textures/qml/textureStats.qml @@ -0,0 +1,52 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.3 + +Item { + width: 400 + height: 600 + + Column { + spacing: 10 + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: 10 + + Text { text: qsTr("Total") } + Text { text: Stats.total + " MB" } + Text { text: qsTr("Allocated") } + Text { text: Stats.allocated } + Text { text: qsTr("Populated") } + Text { text: Stats.populated } + Text { text: qsTr("Pending") } + Text { text: Stats.pending } + Text { text: qsTr("Current Index") } + Text { text: Stats.index } + Text { text: qsTr("Current Source") } + Text { text: Stats.source } + Text { text: qsTr("Current Rez") } + Text { text: Stats.rez.width + " x " + Stats.rez.height } + } + + Row { + id: row1 + spacing: 10 + anchors.bottom: row2.top + anchors.left: parent.left + anchors.margins: 10 + Button { text: "1024"; onClicked: Stats.maxTextureMemory(1024); } + Button { text: "256"; onClicked: Stats.maxTextureMemory(256); } + } + + Row { + id: row2 + spacing: 10 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 10 + Button { text: "Change Textures"; onClicked: Stats.changeTextures(); } + Button { text: "Next"; onClicked: Stats.nextTexture(); } + Button { text: "Previous"; onClicked: Stats.prevTexture(); } + } + +} + diff --git a/tests-manual/gpu-textures/src/TestHelpers.cpp b/tests-manual/gpu-textures/src/TestHelpers.cpp new file mode 100644 index 0000000000..f952a4385f --- /dev/null +++ b/tests-manual/gpu-textures/src/TestHelpers.cpp @@ -0,0 +1,26 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TestHelpers.h" +#include + +gpu::ShaderPointer makeShader(const std::string & vertexShaderSrc, const std::string & fragmentShaderSrc, const gpu::Shader::BindingSet & bindings) { + auto vs = gpu::Shader::createVertex(vertexShaderSrc); + auto fs = gpu::Shader::createPixel(fragmentShaderSrc); + auto shader = gpu::Shader::createProgram(vs, fs); + if (!gpu::Shader::makeProgram(*shader, bindings)) { + printf("Could not compile shader\n"); + exit(-1); + } + return shader; +} + +QString projectRootDir() { + static QString projectRootPath = QFileInfo(QFileInfo(__FILE__).absolutePath() + "/..").absoluteFilePath(); + return projectRootPath; +} diff --git a/tests-manual/gpu-textures/src/TestHelpers.h b/tests-manual/gpu-textures/src/TestHelpers.h new file mode 100644 index 0000000000..17730c3642 --- /dev/null +++ b/tests-manual/gpu-textures/src/TestHelpers.h @@ -0,0 +1,40 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once + +#include + +#include +#include +#include + +#include +#include +#include +#include + +struct RenderArgs { + gpu::ContextPointer _context; + ivec4 _viewport; + gpu::Batch* _batch; +}; + +class GpuTestBase : public QObject { +public: + virtual ~GpuTestBase() {} + virtual bool isReady() const { return true; } + virtual size_t getTestCount() const { return 1; } + virtual void renderTest(size_t test, const RenderArgs& args) = 0; + virtual QObject * statsObject() { return nullptr; } + virtual QUrl statUrl() { return QUrl(); } +}; + +uint32_t toCompactColor(const glm::vec4& color); +gpu::ShaderPointer makeShader(const std::string & vertexShaderSrc, const std::string & fragmentShaderSrc, const gpu::Shader::BindingSet & bindings); +QString projectRootDir(); diff --git a/tests-manual/gpu-textures/src/TestTextures.cpp b/tests-manual/gpu-textures/src/TestTextures.cpp new file mode 100644 index 0000000000..57cf1bccbf --- /dev/null +++ b/tests-manual/gpu-textures/src/TestTextures.cpp @@ -0,0 +1,168 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TestTextures.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "TestHelpers.h" + +#pragma optimize("", off) + +std::string vertexShaderSource = R"SHADER( +#line 14 +layout(location = 0) out vec2 outTexCoord0; + +const vec4 VERTICES[] = vec4[]( + vec4(-1.0, -1.0, 0.0, 1.0), + vec4( 1.0, -1.0, 0.0, 1.0), + vec4(-1.0, 1.0, 0.0, 1.0), + vec4( 1.0, 1.0, 0.0, 1.0) +); + +void main() { + outTexCoord0 = VERTICES[gl_VertexID].xy; + outTexCoord0 += 1.0; + outTexCoord0 /= 2.0; + gl_Position = VERTICES[gl_VertexID]; +} +)SHADER"; + +std::string fragmentShaderSource = R"SHADER( +#line 28 + +uniform sampler2D tex; + +layout(location = 0) in vec2 inTexCoord0; +layout(location = 0) out vec4 outFragColor; + +void main() { + outFragColor = texture(tex, inTexCoord0); + outFragColor.a = 1.0; + //outFragColor.rb = inTexCoord0; +} + +)SHADER"; + +#define STAT_UPDATE(name, src) \ + { \ + auto val = src; \ + if (_##name != val) { \ + _##name = val; \ + emit name##Changed(); \ + } \ + } + + +void TextureTestStats::update(int curIndex, const gpu::TexturePointer& texture) { + STAT_UPDATE(total, (int)BYTES_TO_MB(gpu::Context::getTextureGPUMemSize())); + STAT_UPDATE(allocated, (int)gpu::Context::getTextureResourceGPUMemSize()); + STAT_UPDATE(pending, (int)gpu::Context::getTexturePendingGPUTransferMemSize()); + STAT_UPDATE(populated, (int)gpu::Context::getTextureResourcePopulatedGPUMemSize()); + STAT_UPDATE(source, texture->source().c_str()); + STAT_UPDATE(index, curIndex); + auto dims = texture->getDimensions(); + STAT_UPDATE(rez, QSize(dims.x, dims.y)); +} + +TexturesTest::TexturesTest() { + connect(&stats, &TextureTestStats::changeTextures, this, &TexturesTest::onChangeTextures); + connect(&stats, &TextureTestStats::nextTexture, this, &TexturesTest::onNextTexture); + connect(&stats, &TextureTestStats::prevTexture, this, &TexturesTest::onPrevTexture); + connect(&stats, &TextureTestStats::maxTextureMemory, this, &TexturesTest::onMaxTextureMemory); + { + auto VS = gpu::Shader::createVertex(vertexShaderSource); + auto PS = gpu::Shader::createPixel(fragmentShaderSource); + auto program = gpu::Shader::createProgram(VS, PS); + gpu::Shader::BindingSet slotBindings; + gpu::Shader::makeProgram(*program, slotBindings); + // If the pipeline did not exist, make it + auto state = std::make_shared(); + state->setCullMode(gpu::State::CULL_NONE); + state->setDepthTest({}); + state->setBlendFunction({ false }); + pipeline = gpu::Pipeline::create(program, state); + } + + onChangeTextures(); +} + + +void TexturesTest::renderTest(size_t testId, const RenderArgs& args) { + stats.update((int)index, textures[index]); + gpu::Batch& batch = *(args._batch); + batch.setPipeline(pipeline); + batch.setInputFormat(vertexFormat); + for (const auto& texture : textures) { + batch.setResourceTexture(0, texture); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); + } + batch.setResourceTexture(0, textures[index]); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); +} + +#define LOAD_TEXTURE_COUNT 64 + +void TexturesTest::onChangeTextures() { + static const QDir TEST_DIR("D:/ktx_texture_test"); + static std::vector ALL_TEXTURE_FILES; + if (ALL_TEXTURE_FILES.empty()) { + auto entryList = TEST_DIR.entryList({ "*.ktx" }, QDir::Filter::Files); + ALL_TEXTURE_FILES.reserve(entryList.size()); + for (auto entry : entryList) { + auto textureFile = TEST_DIR.absoluteFilePath(entry).toStdString(); + ALL_TEXTURE_FILES.push_back(textureFile); + } + } + + oldTextures.clear(); + oldTextures.swap(textures); + +#if 0 + static const std::string bad = "D:/ktx_texture_test/b4beed38675dbc7a827ecd576399c1f4.ktx"; + auto texture = gpu::Texture::unserialize(bad); + auto texelFormat = texture->getTexelFormat(); + qDebug() << texture->getTexelFormat().getSemantic(); + qDebug() << texture->getTexelFormat().getScalarCount(); + textures.push_back(texture); +#else + std::shuffle(ALL_TEXTURE_FILES.begin(), ALL_TEXTURE_FILES.end(), std::default_random_engine()); + size_t newTextureCount = std::min(ALL_TEXTURE_FILES.size(), LOAD_TEXTURE_COUNT); + for (size_t i = 0; i < newTextureCount; ++i) { + const auto& textureFile = ALL_TEXTURE_FILES[i]; + auto texture = gpu::Texture::unserialize(textureFile); + qDebug() << textureFile.c_str(); + qDebug() << texture->getTexelFormat().getSemantic(); + qDebug() << texture->getTexelFormat().getScalarCount(); + textures.push_back(texture); + } +#endif + index = 0; + qDebug() << "Done"; +} + +void TexturesTest::onNextTexture() { + index += textures.size() + 1; + index %= textures.size(); +} + +void TexturesTest::onPrevTexture() { + index += textures.size() - 1; + index %= textures.size(); +} + +void TexturesTest::onMaxTextureMemory(int maxTextureMemory) { + gpu::Texture::setAllowedGPUMemoryUsage(MB_TO_BYTES(maxTextureMemory)); +} \ No newline at end of file diff --git a/tests-manual/gpu-textures/src/TestTextures.h b/tests-manual/gpu-textures/src/TestTextures.h new file mode 100644 index 0000000000..e446ce6132 --- /dev/null +++ b/tests-manual/gpu-textures/src/TestTextures.h @@ -0,0 +1,74 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#pragma once + +#include "TestHelpers.h" + +#define STATS_PROPERTY(type, name, initialValue) \ + Q_PROPERTY(type name READ name NOTIFY name##Changed) \ +public: \ + type name() { return _##name; }; \ +private: \ + type _##name{ initialValue }; + + +class TextureTestStats : public QObject { + Q_OBJECT; + STATS_PROPERTY(int, pending, 0) + STATS_PROPERTY(int, total, 0) + STATS_PROPERTY(int, populated, 0) + STATS_PROPERTY(int, allocated, 0) + STATS_PROPERTY(int, index, 0) + + STATS_PROPERTY(QString, source, QString()) + STATS_PROPERTY(QSize, rez, QSize(0, 0)) + +public: + void update(int index, const gpu::TexturePointer& texture); + +signals: + void pendingChanged(); + void totalChanged(); + void populatedChanged(); + void allocatedChanged(); + void changeTextures(); + void rezChanged(); + void indexChanged(); + void sourceChanged(); + void maxTextureMemory(int); + + void nextTexture(); + void prevTexture(); +}; + + +class TexturesTest : public GpuTestBase { + Q_OBJECT + + gpu::Stream::FormatPointer vertexFormat { std::make_shared() }; + std::vector textures; + std::vector oldTextures; + gpu::PipelinePointer pipeline; + TextureTestStats stats; + size_t index{ 0 }; + +public: + TexturesTest(); + QObject* statsObject() override { return &stats; } + QUrl statUrl() override { return QUrl::fromLocalFile(projectRootDir() + "/qml/textureStats.qml"); } + void renderTest(size_t testId, const RenderArgs& args) override; + +protected slots: + void onChangeTextures(); + void onMaxTextureMemory(int newValue); + void onNextTexture(); + void onPrevTexture(); + +}; + + diff --git a/tests-manual/gpu-textures/src/TestWindow.cpp b/tests-manual/gpu-textures/src/TestWindow.cpp new file mode 100644 index 0000000000..038b0b9b80 --- /dev/null +++ b/tests-manual/gpu-textures/src/TestWindow.cpp @@ -0,0 +1,117 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TestWindow.h" + +#include +#include + +#include +#include + +#include + +#include + +TestWindow::TestWindow() { + + auto timer = new QTimer(this); + timer->setTimerType(Qt::PreciseTimer); + timer->setInterval(5); + connect(timer, &QTimer::timeout, [&] { draw(); }); + timer->start(); + + connect(qApp, &QCoreApplication::aboutToQuit, [this, timer] { + timer->stop(); + _aboutToQuit = true; + }); + + setSurfaceType(QSurface::OpenGLSurface); + + QSurfaceFormat format = getDefaultOpenGLSurfaceFormat(); + format.setOption(QSurfaceFormat::DebugContext); + setFormat(format); + _glContext.setFormat(format); + _glContext.create(); + _glContext.makeCurrent(this); + + show(); +} + +void TestWindow::initGl() { + _glContext.makeCurrent(this); + gl::initModuleGl(); + gpu::Context::init(); + _renderArgs->_context = std::make_shared(); + _glContext.makeCurrent(this); + resize(QSize(800, 600)); +} + +void TestWindow::resizeWindow(const QSize& size) { + _size = size; + _renderArgs->_viewport = ivec4(0, 0, _size.width(), _size.height()); +} + +void TestWindow::beginFrame() { + _renderArgs->_context->recycle(); + _renderArgs->_context->beginFrame(); + gpu::doInBatch("TestWindow::beginFrame", _renderArgs->_context, [&](gpu::Batch& batch) { + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLORS, { 0.0f, 0.1f, 0.2f, 1.0f }); + batch.clearDepthFramebuffer(1e4); + batch.setViewportTransform({ 0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio() }); + }); + + gpu::doInBatch("TestWindow::beginFrame", _renderArgs->_context, [&](gpu::Batch& batch) { + batch.setViewportTransform(_renderArgs->_viewport); + batch.setStateScissorRect(_renderArgs->_viewport); + batch.setProjectionTransform(_projectionMatrix); + }); +} + +void TestWindow::endFrame() { + gpu::doInBatch("TestWindow::endFrame::finish", _renderArgs->_context, [&](gpu::Batch& batch) { + batch.resetStages(); + }); + auto framePointer = _renderArgs->_context->endFrame(); + _renderArgs->_context->consumeFrameUpdates(framePointer); + _renderArgs->_context->executeFrame(framePointer); + _glContext.swapBuffers(this); +} + +void TestWindow::draw() { + if (_aboutToQuit) { + return; + } + + // Attempting to draw before we're visible and have a valid size will + // produce GL errors. + if (!isVisible() || _size.width() <= 0 || _size.height() <= 0) { + return; + } + + if (!_glContext.makeCurrent(this)) { + return; + } + + static std::once_flag once; + std::call_once(once, [&] { initGl(); }); + beginFrame(); + + renderFrame(); + + endFrame(); +} + +void TestWindow::resizeEvent(QResizeEvent* ev) { + resizeWindow(ev->size()); + float fov_degrees = 60.0f; + float aspect_ratio = (float)_size.width() / _size.height(); + float near_clip = 0.1f; + float far_clip = 1000.0f; + _projectionMatrix = glm::perspective(glm::radians(fov_degrees), aspect_ratio, near_clip, far_clip); +} diff --git a/tests-manual/gpu-textures/src/TestWindow.h b/tests-manual/gpu-textures/src/TestWindow.h new file mode 100644 index 0000000000..00bbf03836 --- /dev/null +++ b/tests-manual/gpu-textures/src/TestWindow.h @@ -0,0 +1,41 @@ +// +// Created by Bradley Austin Davis on 2016/05/16 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once + +#include +#include + +#include +#include +#include +#include "TestHelpers.h" + +#define DEFERRED_LIGHTING + +class TestWindow : public QWindow { +protected: + QOpenGLContextWrapper _glContext; + QSize _size; + glm::mat4 _projectionMatrix; + bool _aboutToQuit { false }; + std::shared_ptr _renderArgs{ std::make_shared() }; + + TestWindow(); + virtual void initGl(); + virtual void renderFrame() = 0; + +private: + void resizeWindow(const QSize& size); + + void beginFrame(); + void endFrame(); + void draw(); + void resizeEvent(QResizeEvent* ev) override; +}; + diff --git a/tests-manual/gpu-textures/src/main.cpp b/tests-manual/gpu-textures/src/main.cpp new file mode 100644 index 0000000000..3d0051dc1d --- /dev/null +++ b/tests-manual/gpu-textures/src/main.cpp @@ -0,0 +1,170 @@ +// +// main.cpp +// tests/gpu-test/src +// +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "TestWindow.h" +#include "TestTextures.h" + +using TestBuilder = std::function; +using TestBuilders = std::list; + +#define INTERACTIVE + +class MyTestWindow : public TestWindow { + using Parent = TestWindow; + TestBuilders _testBuilders; + GpuTestBase* _currentTest{ nullptr }; + size_t _currentTestId{ 0 }; + size_t _currentMaxTests{ 0 }; + glm::mat4 _camera; + QTime _time; + + void initGl() override { + Parent::initGl(); + _time.start(); + updateCamera(); + _testBuilders = TestBuilders({ + [] { return new TexturesTest(); }, + }); + } + + void updateCamera() { + float t = _time.elapsed() * 1e-3f; + glm::vec3 unitscale{ 1.0f }; + glm::vec3 up{ 0.0f, 1.0f, 0.0f }; + + float distance = 3.0f; + glm::vec3 camera_position{ distance * sinf(t), 0.5f, distance * cosf(t) }; + + static const vec3 camera_focus(0); + static const vec3 camera_up(0, 1, 0); + _camera = glm::inverse(glm::lookAt(camera_position, camera_focus, up)); + + ViewFrustum frustum; + frustum.setPosition(camera_position); + frustum.setOrientation(glm::quat_cast(_camera)); + frustum.setProjection(_projectionMatrix); + } + + void renderFrame() override { + updateCamera(); + + while ((!_currentTest || (_currentTestId >= _currentMaxTests)) && !_testBuilders.empty()) { + if (_currentTest) { + delete _currentTest; + _currentTest = nullptr; + } + + _currentTest = _testBuilders.front()(); + _testBuilders.pop_front(); + + if (_currentTest) { + auto statsObject = _currentTest->statsObject(); + QUrl url = _currentTest->statUrl(); + if (statsObject) { + auto screens = qApp->screens(); + auto primaryScreen = qApp->primaryScreen(); + auto targetScreen = primaryScreen; + for (const auto& screen : screens) { + if (screen == primaryScreen) { + continue; + } + targetScreen = screen; + break; + } + + auto destPoint = targetScreen->availableGeometry().topLeft(); + QQuickView* view = new QQuickView(); + view->rootContext()->setContextProperty("Stats", statsObject); + view->setSource(url); + view->show(); + view->setPosition({ destPoint.x() + 100, destPoint.y() + 100 }); + } + _currentMaxTests = _currentTest->getTestCount(); + _currentTestId = 0; + } + } + + if (!_currentTest && _testBuilders.empty()) { + qApp->quit(); + return; + } + + // Tests might need to wait for resources to download + if (!_currentTest->isReady()) { + return; + } + + gpu::doInBatch("main::renderFrame", _renderArgs->_context, [&](gpu::Batch& batch) { + batch.setViewTransform(_camera); + _renderArgs->_batch = &batch; + _currentTest->renderTest(_currentTestId, *_renderArgs); + _renderArgs->_batch = nullptr; + }); + } +}; + +int main(int argc, char** argv) { + setupHifiApplication("GPU Test"); + qputenv("HIFI_DEBUG_OPENGL", QByteArray("1")); + QApplication app(argc, argv); + MyTestWindow window; + app.exec(); + + return 0; +} diff --git a/tests/gpu-test/CMakeLists.txt b/tests-manual/gpu/CMakeLists.txt similarity index 100% rename from tests/gpu-test/CMakeLists.txt rename to tests-manual/gpu/CMakeLists.txt diff --git a/tests/gpu-test/src/TestFbx.cpp b/tests-manual/gpu/src/TestFbx.cpp similarity index 100% rename from tests/gpu-test/src/TestFbx.cpp rename to tests-manual/gpu/src/TestFbx.cpp diff --git a/tests/gpu-test/src/TestFbx.h b/tests-manual/gpu/src/TestFbx.h similarity index 100% rename from tests/gpu-test/src/TestFbx.h rename to tests-manual/gpu/src/TestFbx.h diff --git a/tests/gpu-test/src/TestFloorGrid.cpp b/tests-manual/gpu/src/TestFloorGrid.cpp similarity index 100% rename from tests/gpu-test/src/TestFloorGrid.cpp rename to tests-manual/gpu/src/TestFloorGrid.cpp diff --git a/tests/gpu-test/src/TestFloorGrid.h b/tests-manual/gpu/src/TestFloorGrid.h similarity index 100% rename from tests/gpu-test/src/TestFloorGrid.h rename to tests-manual/gpu/src/TestFloorGrid.h diff --git a/tests/gpu-test/src/TestFloorTexture.cpp b/tests-manual/gpu/src/TestFloorTexture.cpp similarity index 100% rename from tests/gpu-test/src/TestFloorTexture.cpp rename to tests-manual/gpu/src/TestFloorTexture.cpp diff --git a/tests/gpu-test/src/TestFloorTexture.h b/tests-manual/gpu/src/TestFloorTexture.h similarity index 100% rename from tests/gpu-test/src/TestFloorTexture.h rename to tests-manual/gpu/src/TestFloorTexture.h diff --git a/tests/gpu-test/src/TestHelpers.cpp b/tests-manual/gpu/src/TestHelpers.cpp similarity index 100% rename from tests/gpu-test/src/TestHelpers.cpp rename to tests-manual/gpu/src/TestHelpers.cpp diff --git a/tests/gpu-test/src/TestHelpers.h b/tests-manual/gpu/src/TestHelpers.h similarity index 100% rename from tests/gpu-test/src/TestHelpers.h rename to tests-manual/gpu/src/TestHelpers.h diff --git a/tests/gpu-test/src/TestInstancedShapes.cpp b/tests-manual/gpu/src/TestInstancedShapes.cpp similarity index 100% rename from tests/gpu-test/src/TestInstancedShapes.cpp rename to tests-manual/gpu/src/TestInstancedShapes.cpp diff --git a/tests/gpu-test/src/TestInstancedShapes.h b/tests-manual/gpu/src/TestInstancedShapes.h similarity index 100% rename from tests/gpu-test/src/TestInstancedShapes.h rename to tests-manual/gpu/src/TestInstancedShapes.h diff --git a/tests/gpu-test/src/TestShapes.cpp b/tests-manual/gpu/src/TestShapes.cpp similarity index 100% rename from tests/gpu-test/src/TestShapes.cpp rename to tests-manual/gpu/src/TestShapes.cpp diff --git a/tests/gpu-test/src/TestShapes.h b/tests-manual/gpu/src/TestShapes.h similarity index 100% rename from tests/gpu-test/src/TestShapes.h rename to tests-manual/gpu/src/TestShapes.h diff --git a/tests/gpu-test/src/TestWindow.cpp b/tests-manual/gpu/src/TestWindow.cpp similarity index 100% rename from tests/gpu-test/src/TestWindow.cpp rename to tests-manual/gpu/src/TestWindow.cpp diff --git a/tests/gpu-test/src/TestWindow.h b/tests-manual/gpu/src/TestWindow.h similarity index 100% rename from tests/gpu-test/src/TestWindow.h rename to tests-manual/gpu/src/TestWindow.h diff --git a/tests/gpu-test/src/main.cpp b/tests-manual/gpu/src/main.cpp similarity index 100% rename from tests/gpu-test/src/main.cpp rename to tests-manual/gpu/src/main.cpp diff --git a/tests/qml/CMakeLists.txt b/tests-manual/qml/CMakeLists.txt similarity index 100% rename from tests/qml/CMakeLists.txt rename to tests-manual/qml/CMakeLists.txt diff --git a/tests/qml/qml/controls/WebEntityView.qml b/tests-manual/qml/qml/controls/WebEntityView.qml similarity index 100% rename from tests/qml/qml/controls/WebEntityView.qml rename to tests-manual/qml/qml/controls/WebEntityView.qml diff --git a/tests/qml/qml/main.qml b/tests-manual/qml/qml/main.qml similarity index 100% rename from tests/qml/qml/main.qml rename to tests-manual/qml/qml/main.qml diff --git a/tests/qml/qml/qml/+android/UI.js b/tests-manual/qml/qml/qml/+android/UI.js similarity index 100% rename from tests/qml/qml/qml/+android/UI.js rename to tests-manual/qml/qml/qml/+android/UI.js diff --git a/tests/qml/qml/qml/+ios/UI.js b/tests-manual/qml/qml/qml/+ios/UI.js similarity index 100% rename from tests/qml/qml/qml/+ios/UI.js rename to tests-manual/qml/qml/qml/+ios/UI.js diff --git a/tests/qml/qml/qml/+osx/UI.js b/tests-manual/qml/qml/qml/+osx/UI.js similarity index 100% rename from tests/qml/qml/qml/+osx/UI.js rename to tests-manual/qml/qml/qml/+osx/UI.js diff --git a/tests/qml/qml/qml/ButtonPage.qml b/tests-manual/qml/qml/qml/ButtonPage.qml similarity index 100% rename from tests/qml/qml/qml/ButtonPage.qml rename to tests-manual/qml/qml/qml/ButtonPage.qml diff --git a/tests/qml/qml/qml/InputPage.qml b/tests-manual/qml/qml/qml/InputPage.qml similarity index 100% rename from tests/qml/qml/qml/InputPage.qml rename to tests-manual/qml/qml/qml/InputPage.qml diff --git a/tests/qml/qml/qml/ProgressPage.qml b/tests-manual/qml/qml/qml/ProgressPage.qml similarity index 100% rename from tests/qml/qml/qml/ProgressPage.qml rename to tests-manual/qml/qml/qml/ProgressPage.qml diff --git a/tests/qml/qml/qml/UI.js b/tests-manual/qml/qml/qml/UI.js similarity index 100% rename from tests/qml/qml/qml/UI.js rename to tests-manual/qml/qml/qml/UI.js diff --git a/tests/qml/src/main.cpp b/tests-manual/qml/src/main.cpp similarity index 100% rename from tests/qml/src/main.cpp rename to tests-manual/qml/src/main.cpp diff --git a/tests/qt59/CMakeLists.txt b/tests-manual/qt59/CMakeLists.txt similarity index 100% rename from tests/qt59/CMakeLists.txt rename to tests-manual/qt59/CMakeLists.txt diff --git a/tests/qt59/src/main.cpp b/tests-manual/qt59/src/main.cpp similarity index 100% rename from tests/qt59/src/main.cpp rename to tests-manual/qt59/src/main.cpp diff --git a/tests/render-perf/CMakeLists.txt b/tests-manual/render-perf/CMakeLists.txt similarity index 100% rename from tests/render-perf/CMakeLists.txt rename to tests-manual/render-perf/CMakeLists.txt diff --git a/tests/render-perf/src/Camera.hpp b/tests-manual/render-perf/src/Camera.hpp similarity index 100% rename from tests/render-perf/src/Camera.hpp rename to tests-manual/render-perf/src/Camera.hpp diff --git a/tests/render-perf/src/main.cpp b/tests-manual/render-perf/src/main.cpp similarity index 100% rename from tests/render-perf/src/main.cpp rename to tests-manual/render-perf/src/main.cpp diff --git a/tests/render-texture-load/CMakeLists.txt b/tests-manual/render-texture-load/CMakeLists.txt similarity index 100% rename from tests/render-texture-load/CMakeLists.txt rename to tests-manual/render-texture-load/CMakeLists.txt diff --git a/tests/render-texture-load/src/GLIHelpers.cpp b/tests-manual/render-texture-load/src/GLIHelpers.cpp similarity index 100% rename from tests/render-texture-load/src/GLIHelpers.cpp rename to tests-manual/render-texture-load/src/GLIHelpers.cpp diff --git a/tests/render-texture-load/src/GLIHelpers.h b/tests-manual/render-texture-load/src/GLIHelpers.h similarity index 100% rename from tests/render-texture-load/src/GLIHelpers.h rename to tests-manual/render-texture-load/src/GLIHelpers.h diff --git a/tests/render-texture-load/src/main.cpp b/tests-manual/render-texture-load/src/main.cpp similarity index 100% rename from tests/render-texture-load/src/main.cpp rename to tests-manual/render-texture-load/src/main.cpp diff --git a/tests/render-utils/CMakeLists.txt b/tests-manual/render-utils/CMakeLists.txt similarity index 100% rename from tests/render-utils/CMakeLists.txt rename to tests-manual/render-utils/CMakeLists.txt diff --git a/tests/render-utils/src/main.cpp b/tests-manual/render-utils/src/main.cpp similarity index 100% rename from tests/render-utils/src/main.cpp rename to tests-manual/render-utils/src/main.cpp diff --git a/tests/shaders/CMakeLists.txt b/tests-manual/shaders/CMakeLists.txt similarity index 100% rename from tests/shaders/CMakeLists.txt rename to tests-manual/shaders/CMakeLists.txt diff --git a/tests/shaders/src/main.cpp b/tests-manual/shaders/src/main.cpp similarity index 100% rename from tests/shaders/src/main.cpp rename to tests-manual/shaders/src/main.cpp diff --git a/tests/ui/CMakeLists.txt b/tests-manual/ui/CMakeLists.txt similarity index 100% rename from tests/ui/CMakeLists.txt rename to tests-manual/ui/CMakeLists.txt diff --git a/tests/ui/qml/Palettes.qml b/tests-manual/ui/qml/Palettes.qml similarity index 100% rename from tests/ui/qml/Palettes.qml rename to tests-manual/ui/qml/Palettes.qml diff --git a/tests/ui/qml/ScrollingGraph.qml b/tests-manual/ui/qml/ScrollingGraph.qml similarity index 100% rename from tests/ui/qml/ScrollingGraph.qml rename to tests-manual/ui/qml/ScrollingGraph.qml diff --git a/tests/ui/qml/StubMenu.qml b/tests-manual/ui/qml/StubMenu.qml similarity index 100% rename from tests/ui/qml/StubMenu.qml rename to tests-manual/ui/qml/StubMenu.qml diff --git a/tests/ui/qml/Stubs.qml b/tests-manual/ui/qml/Stubs.qml similarity index 100% rename from tests/ui/qml/Stubs.qml rename to tests-manual/ui/qml/Stubs.qml diff --git a/tests/ui/qml/TestControllers.qml b/tests-manual/ui/qml/TestControllers.qml similarity index 100% rename from tests/ui/qml/TestControllers.qml rename to tests-manual/ui/qml/TestControllers.qml diff --git a/tests/ui/qml/TestDialog.qml b/tests-manual/ui/qml/TestDialog.qml similarity index 100% rename from tests/ui/qml/TestDialog.qml rename to tests-manual/ui/qml/TestDialog.qml diff --git a/tests/ui/qml/TestMenu.qml b/tests-manual/ui/qml/TestMenu.qml similarity index 100% rename from tests/ui/qml/TestMenu.qml rename to tests-manual/ui/qml/TestMenu.qml diff --git a/tests/ui/qml/TestRoot.qml b/tests-manual/ui/qml/TestRoot.qml similarity index 100% rename from tests/ui/qml/TestRoot.qml rename to tests-manual/ui/qml/TestRoot.qml diff --git a/tests/ui/qml/controlDemo/ButtonPage.qml b/tests-manual/ui/qml/controlDemo/ButtonPage.qml similarity index 100% rename from tests/ui/qml/controlDemo/ButtonPage.qml rename to tests-manual/ui/qml/controlDemo/ButtonPage.qml diff --git a/tests/ui/qml/controlDemo/InputPage.qml b/tests-manual/ui/qml/controlDemo/InputPage.qml similarity index 100% rename from tests/ui/qml/controlDemo/InputPage.qml rename to tests-manual/ui/qml/controlDemo/InputPage.qml diff --git a/tests/ui/qml/controlDemo/ProgressPage.qml b/tests-manual/ui/qml/controlDemo/ProgressPage.qml similarity index 100% rename from tests/ui/qml/controlDemo/ProgressPage.qml rename to tests-manual/ui/qml/controlDemo/ProgressPage.qml diff --git a/tests/ui/qml/controlDemo/main.qml b/tests-manual/ui/qml/controlDemo/main.qml similarity index 100% rename from tests/ui/qml/controlDemo/main.qml rename to tests-manual/ui/qml/controlDemo/main.qml diff --git a/tests/ui/qml/main.qml b/tests-manual/ui/qml/main.qml similarity index 100% rename from tests/ui/qml/main.qml rename to tests-manual/ui/qml/main.qml diff --git a/tests/ui/qmlscratch.pro b/tests-manual/ui/qmlscratch.pro similarity index 100% rename from tests/ui/qmlscratch.pro rename to tests-manual/ui/qmlscratch.pro diff --git a/tests/ui/src/main.cpp b/tests-manual/ui/src/main.cpp similarity index 100% rename from tests/ui/src/main.cpp rename to tests-manual/ui/src/main.cpp From 6e16109fa45dfc5821bc59d9dac624ebab478321 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 09:11:13 -0700 Subject: [PATCH 170/192] Fix unit test compile failures and crashes --- tests/animation/src/AnimTests.cpp | 1 + tests/ktx/src/KtxTests.cpp | 4 +++- tests/networking/src/ResourceTests.cpp | 21 ++++++++++++++++----- tests/networking/src/ResourceTests.h | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/animation/src/AnimTests.cpp b/tests/animation/src/AnimTests.cpp index fe54ac3781..432129594a 100644 --- a/tests/animation/src/AnimTests.cpp +++ b/tests/animation/src/AnimTests.cpp @@ -39,6 +39,7 @@ void AnimTests::initTestCase() { void AnimTests::cleanupTestCase() { //DependencyManager::destroy(); + DependencyManager::get()->cleanup(); } void AnimTests::testClipInternalState() { diff --git a/tests/ktx/src/KtxTests.cpp b/tests/ktx/src/KtxTests.cpp index 65d9cbec3d..5158ad2fd4 100644 --- a/tests/ktx/src/KtxTests.cpp +++ b/tests/ktx/src/KtxTests.cpp @@ -76,7 +76,9 @@ void KtxTests::testKtxEvalFunctions() { void KtxTests::testKtxSerialization() { const QString TEST_IMAGE = getRootPath() + "/scripts/developer/tests/cube_texture.png"; QImage image(TEST_IMAGE); - gpu::TexturePointer testTexture = image::TextureUsage::process2DTextureColorFromImage(image, TEST_IMAGE.toStdString(), true); + std::atomic abortSignal; + gpu::TexturePointer testTexture = + image::TextureUsage::process2DTextureColorFromImage(std::move(image), TEST_IMAGE.toStdString(), true, abortSignal); auto ktxMemory = gpu::Texture::serialize(*testTexture); QVERIFY(ktxMemory.get()); diff --git a/tests/networking/src/ResourceTests.cpp b/tests/networking/src/ResourceTests.cpp index 864d7c9939..6af3629bc7 100644 --- a/tests/networking/src/ResourceTests.cpp +++ b/tests/networking/src/ResourceTests.cpp @@ -11,16 +11,23 @@ #include -#include "ResourceCache.h" -#include "NetworkAccessManager.h" -#include "DependencyManager.h" +#include +#include +#include +#include +#include +#include QTEST_MAIN(ResourceTests) void ResourceTests::initTestCase() { - auto resourceCacheSharedItems = DependencyManager::set(); - + //DependencyManager::set(); + DependencyManager::set(); + DependencyManager::registerInheritance(); + DependencyManager::set(NodeType::Agent, INVALID_PORT); + DependencyManager::set(); + DependencyManager::set(); const qint64 MAXIMUM_CACHE_SIZE = 1024 * 1024 * 1024; // 1GB // set up the file cache @@ -34,6 +41,10 @@ void ResourceTests::initTestCase() { networkAccessManager.setCache(cache); } +void ResourceTests::cleanupTestCase() { + DependencyManager::get()->cleanup(); +} + static QSharedPointer resource; diff --git a/tests/networking/src/ResourceTests.h b/tests/networking/src/ResourceTests.h index 32fc151982..59675816ba 100644 --- a/tests/networking/src/ResourceTests.h +++ b/tests/networking/src/ResourceTests.h @@ -18,6 +18,7 @@ private slots: void initTestCase(); void downloadFirst(); void downloadAgain(); + void cleanupTestCase(); }; #endif // hifi_ResourceTests_h From f206456cddfd93f063632ed0e1c2e92dddcfa419 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 10:18:08 -0700 Subject: [PATCH 171/192] Restoring manual tests to solution, removing dead tests --- CMakeLists.txt | 1 + tests-manual/CMakeLists.txt | 8 ++++ tests-manual/qt59/CMakeLists.txt | 22 ---------- tests-manual/qt59/src/main.cpp | 73 -------------------------------- tests-manual/ui/CMakeLists.txt | 1 - 5 files changed, 9 insertions(+), 96 deletions(-) create mode 100644 tests-manual/CMakeLists.txt delete mode 100644 tests-manual/qt59/CMakeLists.txt delete mode 100644 tests-manual/qt59/src/main.cpp delete mode 100644 tests-manual/ui/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 93b784b462..69ea0b7fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,7 @@ add_subdirectory(tools) if (BUILD_TESTS) add_subdirectory(tests) + add_subdirectory(tests-manual) endif() if (BUILD_INSTALLER) diff --git a/tests-manual/CMakeLists.txt b/tests-manual/CMakeLists.txt new file mode 100644 index 0000000000..bc64183298 --- /dev/null +++ b/tests-manual/CMakeLists.txt @@ -0,0 +1,8 @@ +# add the manual test directories +file(GLOB TEST_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*") +foreach(DIR ${TEST_SUBDIRS}) + if((IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}") AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}/CMakeLists.txt")) + set(TEST_PROJ_NAME ${DIR}) + add_subdirectory(${DIR}) + endif() +endforeach() diff --git a/tests-manual/qt59/CMakeLists.txt b/tests-manual/qt59/CMakeLists.txt deleted file mode 100644 index e3450ae069..0000000000 --- a/tests-manual/qt59/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -set(TARGET_NAME qt59) - -if (WIN32) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049 /ignore:4217") -endif() - -setup_memory_debugger() - -# This is not a testcase -- just set it up as a regular hifi project -setup_hifi_project(Gui) -set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") - - -# link in the shared libraries -link_hifi_libraries(shared networking) - -if (WIN32) - add_dependency_external_projects(wasapi) -endif() - -package_libraries_for_deployment() diff --git a/tests-manual/qt59/src/main.cpp b/tests-manual/qt59/src/main.cpp deleted file mode 100644 index 19b922de9f..0000000000 --- a/tests-manual/qt59/src/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Created by Bradley Austin Davis on 2017/06/06 -// Copyright 2013-2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include - -#include - -#include -#include -#include -#include - -#include - - -class Qt59TestApp : public QCoreApplication { - Q_OBJECT -public: - Qt59TestApp(int argc, char* argv[]); - ~Qt59TestApp(); - -private: - void finish(int exitCode); -}; - - - -Qt59TestApp::Qt59TestApp(int argc, char* argv[]) : - QCoreApplication(argc, argv) -{ - DependencyManager::registerInheritance(); - DependencyManager::set([&] { return QString("Mozilla/5.0 (HighFidelityACClient)"); }); - DependencyManager::set(); - DependencyManager::set(NodeType::Agent, 0); - auto nodeList = DependencyManager::get(); - nodeList->startThread(); - auto messagesClient = DependencyManager::set(); - messagesClient->startThread(); - QTimer::singleShot(1000, [this] { finish(0); }); -} - -Qt59TestApp::~Qt59TestApp() { -} - - -void Qt59TestApp::finish(int exitCode) { - auto nodeList = DependencyManager::get(); - - // send the domain a disconnect packet, force stoppage of domain-server check-ins - nodeList->getDomainHandler().disconnect(); - nodeList->setIsShuttingDown(true); - nodeList->getPacketReceiver().setShouldDropPackets(true); - - // remove the NodeList from the DependencyManager - DependencyManager::destroy(); - QCoreApplication::exit(exitCode); -} - - -int main(int argc, char * argv[]) { - setupHifiApplication("Qt59Test"); - - Qt59TestApp app(argc, argv); - - return app.exec(); -} - -#include "main.moc" diff --git a/tests-manual/ui/CMakeLists.txt b/tests-manual/ui/CMakeLists.txt deleted file mode 100644 index 0a5d6796e0..0000000000 --- a/tests-manual/ui/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -# This folder contains code for testing the QML UI using Qt Creator. It is not intended to be included in the CMake project From e9dc3c650b57e1610e95b4e7d72b2c022c5e7cbb Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 15:31:17 -0700 Subject: [PATCH 172/192] Breakup building and testing --- cmake/macros/SetupHifiTestCase.cmake | 5 ++--- tests/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/macros/SetupHifiTestCase.cmake b/cmake/macros/SetupHifiTestCase.cmake index 6c7d38e19c..b0edb41e36 100644 --- a/cmake/macros/SetupHifiTestCase.cmake +++ b/cmake/macros/SetupHifiTestCase.cmake @@ -124,15 +124,14 @@ macro(SETUP_HIFI_TESTCASE) # This target will also build + run the other test targets using ctest when built. add_custom_target(${TEST_TARGET} - COMMAND ctest . SOURCES ${TEST_PROJ_SRC_FILES} # display source files under the testcase target DEPENDS ${${TEST_PROJ_NAME}_TARGETS}) + set_target_properties(${TEST_TARGET} PROPERTIES + FOLDER "Tests" EXCLUDE_FROM_DEFAULT_BUILD TRUE EXCLUDE_FROM_ALL TRUE) - set_target_properties(${TEST_TARGET} PROPERTIES FOLDER "Tests") - list (APPEND ALL_TEST_TARGETS ${TEST_TARGET}) set(ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE) else () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a8b0727e3d..bc11580979 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,9 +27,9 @@ set_target_properties("test-extensions" PROPERTIES FOLDER "Tests") # set (ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE) # copies this back to parent scope # add_custom_target("all-tests" - COMMAND ctest . DEPENDS "${ALL_TEST_TARGETS}") -set_target_properties("all-tests" PROPERTIES FOLDER "hidden/test-targets") + set_target_properties("all-tests" PROPERTIES + FOLDER "hidden/test-targets" EXCLUDE_FROM_DEFAULT_BUILD TRUE EXCLUDE_FROM_ALL TRUE) From 12ae44c14f4424503ab5562a2b0706431173cc68 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 15:34:51 -0700 Subject: [PATCH 173/192] Remove debugging pragma --- tests-manual/gpu-textures/src/TestTextures.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests-manual/gpu-textures/src/TestTextures.cpp b/tests-manual/gpu-textures/src/TestTextures.cpp index 57cf1bccbf..7aedb506da 100644 --- a/tests-manual/gpu-textures/src/TestTextures.cpp +++ b/tests-manual/gpu-textures/src/TestTextures.cpp @@ -19,8 +19,6 @@ #include "TestHelpers.h" -#pragma optimize("", off) - std::string vertexShaderSource = R"SHADER( #line 14 layout(location = 0) out vec2 outTexCoord0; @@ -165,4 +163,4 @@ void TexturesTest::onPrevTexture() { void TexturesTest::onMaxTextureMemory(int maxTextureMemory) { gpu::Texture::setAllowedGPUMemoryUsage(MB_TO_BYTES(maxTextureMemory)); -} \ No newline at end of file +} From 1d403b4d6781b5c728d29fb46d8634c10f714d0f Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 8 May 2018 19:41:07 -0700 Subject: [PATCH 174/192] Add texture transfer testing --- libraries/gl/src/gl/OffscreenGLCanvas.cpp | 15 +- tests/gpu/CMakeLists.txt | 9 + tests/gpu/src/TextureTest.cpp | 208 ++++++++++++++++++++++ tests/gpu/src/TextureTest.h | 37 ++++ 4 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 tests/gpu/CMakeLists.txt create mode 100644 tests/gpu/src/TextureTest.cpp create mode 100644 tests/gpu/src/TextureTest.h diff --git a/libraries/gl/src/gl/OffscreenGLCanvas.cpp b/libraries/gl/src/gl/OffscreenGLCanvas.cpp index 91f7954943..6598a26c99 100644 --- a/libraries/gl/src/gl/OffscreenGLCanvas.cpp +++ b/libraries/gl/src/gl/OffscreenGLCanvas.cpp @@ -103,12 +103,15 @@ void OffscreenGLCanvas::onMessageLogged(const QOpenGLDebugMessage& debugMessage) bool OffscreenGLCanvas::makeCurrent() { bool result = _context->makeCurrent(_offscreenSurface); - std::call_once(_reportOnce, []{ - qCDebug(glLogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); - qCDebug(glLogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); - qCDebug(glLogging) << "GL Vendor: " << QString((const char*) glGetString(GL_VENDOR)); - qCDebug(glLogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER)); - }); + if (glGetString) { + std::call_once(_reportOnce, [] { + qCDebug(glLogging) << "GL Version: " << QString((const char*)glGetString(GL_VERSION)); + qCDebug(glLogging) << "GL Shader Language Version: " + << QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)); + qCDebug(glLogging) << "GL Vendor: " << QString((const char*)glGetString(GL_VENDOR)); + qCDebug(glLogging) << "GL Renderer: " << QString((const char*)glGetString(GL_RENDERER)); + }); + } return result; } diff --git a/tests/gpu/CMakeLists.txt b/tests/gpu/CMakeLists.txt new file mode 100644 index 0000000000..6974953b40 --- /dev/null +++ b/tests/gpu/CMakeLists.txt @@ -0,0 +1,9 @@ +# Declare dependencies +macro (setup_testcase_dependencies) + # link in the shared libraries + link_hifi_libraries(shared ktx gpu gl ${PLATFORM_GL_BACKEND}) + package_libraries_for_deployment() + target_opengl() +endmacro () + +setup_hifi_testcase() diff --git a/tests/gpu/src/TextureTest.cpp b/tests/gpu/src/TextureTest.cpp new file mode 100644 index 0000000000..9377a18244 --- /dev/null +++ b/tests/gpu/src/TextureTest.cpp @@ -0,0 +1,208 @@ +// +// Created by Bradley Austin Davis on 2018/01/11 +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "TextureTest.h" + +#include +#include +#include +#include +#include + +QTEST_MAIN(TextureTest) +#pragma optimize("", off) +#define LOAD_TEXTURE_COUNT 40 +static const QDir TEST_DIR("D:/ktx_texture_test"); + +std::string vertexShaderSource = R"SHADER( +#line 14 +layout(location = 0) out vec2 outTexCoord0; + +const vec4 VERTICES[] = vec4[]( + vec4(-1.0, -1.0, 0.0, 1.0), + vec4( 1.0, -1.0, 0.0, 1.0), + vec4(-1.0, 1.0, 0.0, 1.0), + vec4( 1.0, 1.0, 0.0, 1.0) +); + +void main() { + outTexCoord0 = VERTICES[gl_VertexID].xy; + outTexCoord0 += 1.0; + outTexCoord0 /= 2.0; + gl_Position = VERTICES[gl_VertexID]; +} +)SHADER"; + +std::string fragmentShaderSource = R"SHADER( +#line 28 + +uniform sampler2D tex; + +layout(location = 0) in vec2 inTexCoord0; +layout(location = 0) out vec4 outFragColor; + +void main() { + outFragColor = texture(tex, inTexCoord0); + outFragColor.a = 1.0; + //outFragColor.rb = inTexCoord0; +} + +)SHADER"; + +void TextureTest::initTestCase() { + getDefaultOpenGLSurfaceFormat(); + _canvas.create(); + if (!_canvas.makeCurrent()) { + qFatal("Unable to make test GL context current"); + } + gl::initModuleGl(); + gpu::Context::init(); + _gpuContext = std::make_shared(); + gpu::Texture::setAllowedGPUMemoryUsage(MB_TO_BYTES(4096)); + + _canvas.makeCurrent(); + { + auto VS = gpu::Shader::createVertex(vertexShaderSource); + auto PS = gpu::Shader::createPixel(fragmentShaderSource); + auto program = gpu::Shader::createProgram(VS, PS); + gpu::Shader::BindingSet slotBindings; + gpu::Shader::makeProgram(*program, slotBindings); + // If the pipeline did not exist, make it + auto state = std::make_shared(); + state->setCullMode(gpu::State::CULL_NONE); + state->setDepthTest({}); + state->setBlendFunction({ false }); + _pipeline = gpu::Pipeline::create(program, state); + } + + { _framebuffer.reset(gpu::Framebuffer::create("cached", gpu::Element::COLOR_SRGBA_32, _size.x, _size.y)); } + + { + auto entryList = TEST_DIR.entryList({ "*.ktx" }, QDir::Filter::Files); + _textureFiles.reserve(entryList.size()); + for (auto entry : entryList) { + auto textureFile = TEST_DIR.absoluteFilePath(entry).toStdString(); + _textureFiles.push_back(textureFile); + } + } + + { + std::shuffle(_textureFiles.begin(), _textureFiles.end(), std::default_random_engine()); + size_t newTextureCount = std::min(_textureFiles.size(), LOAD_TEXTURE_COUNT); + for (size_t i = 0; i < newTextureCount; ++i) { + const auto& textureFile = _textureFiles[i]; + auto texture = gpu::Texture::unserialize(textureFile); + _textures.push_back(texture); + } + } +} + +void TextureTest::cleanupTestCase() { + _gpuContext.reset(); +} + +void TextureTest::beginFrame() { + _gpuContext->recycle(); + _gpuContext->beginFrame(); + gpu::doInBatch("TestWindow::beginFrame", _gpuContext, [&](gpu::Batch& batch) { + batch.setFramebuffer(_framebuffer); + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLORS, { 0.0f, 0.1f, 0.2f, 1.0f }); + batch.clearDepthFramebuffer(1e4); + batch.setViewportTransform({ 0, 0, _size.x, _size.y }); + }); +} + +void TextureTest::endFrame() { + gpu::doInBatch("TestWindow::endFrame::finish", _gpuContext, [&](gpu::Batch& batch) { batch.resetStages(); }); + auto framePointer = _gpuContext->endFrame(); + _gpuContext->consumeFrameUpdates(framePointer); + _gpuContext->executeFrame(framePointer); + // Simulate swapbuffers with a finish + glFinish(); + QThread::msleep(10); +} + +void TextureTest::renderFrame(const std::function& renderLambda) { + beginFrame(); + gpu::doInBatch("Test::body", _gpuContext, renderLambda); + endFrame(); +} + + +inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { + auto now = usecTimestampNow(); + auto interval = now - startUsecs; + if (interval > maxIntervalUecs) { + startUsecs = now; + return true; + } + return false; +} + +inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) { + return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND); +} + +template +void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) { + if (afterSecs(lastReportUsecs, secs)) { + lamdba(); + } +} + +inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) { + if (afterSecs(startUsecs, secs)) { + qFatal(message); + } +} + +void TextureTest::testTextureLoading() { + auto renderTexturesLamdba = [this](gpu::Batch& batch) { + batch.setPipeline(_pipeline); + for (const auto& texture : _textures) { + batch.setResourceTexture(0, texture); + batch.draw(gpu::TRIANGLE_STRIP, 4, 0); + } + }; + + size_t totalSize = 0; + for (const auto& texture : _textures) { + totalSize += texture->evalTotalSize(); + } + + auto reportLambda = [=] { + qDebug() << "Expected" << totalSize; + qDebug() << "Allowed " << gpu::Texture::getAllowedGPUMemoryUsage(); + qDebug() << "Allocated " << gpu::Context::getTextureResourceGPUMemSize(); + qDebug() << "Populated " << gpu::Context::getTextureResourcePopulatedGPUMemSize(); + qDebug() << "Pending " << gpu::Context::getTexturePendingGPUTransferMemSize(); + }; + + auto lastReport = usecTimestampNow(); + auto start = usecTimestampNow(); + while (totalSize != gpu::Context::getTextureResourceGPUMemSize()) { + reportEvery(lastReport, 4, reportLambda); + failAfter(start, 10, "Failed to allocate texture memory after 10 seconds"); + renderFrame(renderTexturesLamdba); + } + + // Restart the timer + start = usecTimestampNow(); + auto allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + auto populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + while (allocatedMemory != populatedMemory && 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) { + reportEvery(lastReport, 4, reportLambda); + failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); + renderFrame(); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + } + QCOMPARE(allocatedMemory, totalSize); + QCOMPARE(populatedMemory, totalSize); +} + diff --git a/tests/gpu/src/TextureTest.h b/tests/gpu/src/TextureTest.h new file mode 100644 index 0000000000..f3753f5e9b --- /dev/null +++ b/tests/gpu/src/TextureTest.h @@ -0,0 +1,37 @@ +// +// Created by Bradley Austin Davis on 2018/05/08 +// Copyright 2013-2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once + +#include +#include +#include + +class TextureTest : public QObject { + Q_OBJECT + +private: + void beginFrame(); + void endFrame(); + void renderFrame(const std::function& = [](gpu::Batch&){}); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testTextureLoading(); + +private: + OffscreenGLCanvas _canvas; + gpu::ContextPointer _gpuContext; + gpu::PipelinePointer _pipeline; + gpu::FramebufferPointer _framebuffer; + gpu::TexturePointer _colorBuffer, _depthBuffer; + const glm::uvec2 _size{ 640, 480 }; + std::vector _textureFiles; + std::vector _textures; +}; From 7fbad47351f472c65030a59c128069eef8cf06a0 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 9 May 2018 09:52:00 -0700 Subject: [PATCH 175/192] Working on texture test --- libraries/test-utils/CMakeLists.txt | 3 + .../src/test-utils/FileDownloader.cpp | 21 +++ .../src/test-utils/FileDownloader.h | 23 +++ tests/QTestExtensions.h | 43 ++++- tests/gpu/CMakeLists.txt | 10 +- tests/gpu/src/TextureTest.cpp | 157 +++++++++++++----- tests/gpu/src/TextureTest.h | 6 +- 7 files changed, 214 insertions(+), 49 deletions(-) create mode 100644 libraries/test-utils/CMakeLists.txt create mode 100644 libraries/test-utils/src/test-utils/FileDownloader.cpp create mode 100644 libraries/test-utils/src/test-utils/FileDownloader.h diff --git a/libraries/test-utils/CMakeLists.txt b/libraries/test-utils/CMakeLists.txt new file mode 100644 index 0000000000..2c23e96c1e --- /dev/null +++ b/libraries/test-utils/CMakeLists.txt @@ -0,0 +1,3 @@ +set(TARGET_NAME test-utils) +setup_hifi_library(Network Gui) + diff --git a/libraries/test-utils/src/test-utils/FileDownloader.cpp b/libraries/test-utils/src/test-utils/FileDownloader.cpp new file mode 100644 index 0000000000..09049e3e0c --- /dev/null +++ b/libraries/test-utils/src/test-utils/FileDownloader.cpp @@ -0,0 +1,21 @@ +#include "FileDownloader.h" + +#include +#include + +FileDownloader::FileDownloader(QUrl url, const Handler& handler, QObject* parent) : QObject(parent), _handler(handler) { + connect(&_accessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(fileDownloaded(QNetworkReply*))); + _accessManager.get(QNetworkRequest(url)); +} + +void FileDownloader::waitForDownload() { + while (!_complete) { + QCoreApplication::processEvents(); + } +} + +void FileDownloader::fileDownloaded(QNetworkReply* pReply) { + _handler(pReply->readAll()); + pReply->deleteLater(); + _complete = true; +} diff --git a/libraries/test-utils/src/test-utils/FileDownloader.h b/libraries/test-utils/src/test-utils/FileDownloader.h new file mode 100644 index 0000000000..5a618fcf45 --- /dev/null +++ b/libraries/test-utils/src/test-utils/FileDownloader.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +class FileDownloader : public QObject { + Q_OBJECT + +public: + using Handler = std::function; + + FileDownloader(QUrl url, const Handler& handler, QObject* parent = 0); + + void waitForDownload(); + +private slots: + void fileDownloaded(QNetworkReply* pReply); + +private: + QNetworkAccessManager _accessManager; + Handler _handler; + bool _complete { false }; +}; diff --git a/tests/QTestExtensions.h b/tests/QTestExtensions.h index b7b9795a9a..c43ef3f73e 100644 --- a/tests/QTestExtensions.h +++ b/tests/QTestExtensions.h @@ -13,8 +13,9 @@ #define hifi_QTestExtensions_hpp #include +#include #include - +#include #include "GLMTestUtils.h" // Implements several extensions to QtTest. @@ -302,3 +303,43 @@ inline auto errorTest (float actual, float expected, float acceptableRelativeErr QCOMPARE_WITH_LAMBDA(actual, expected, errorTest(actual, expected, relativeError)) + +inline QString getTestResource(const QString& relativePath) { + static QDir dir; + static std::once_flag once; + std::call_once(once, []{ + QFileInfo fileInfo(__FILE__); + auto parentDir = fileInfo.absoluteDir(); + auto rootDir = parentDir.absoluteFilePath(".."); + dir = QDir::cleanPath(rootDir); + }); + + return QDir::cleanPath(dir.absoluteFilePath(relativePath)); +} + +inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { + auto now = usecTimestampNow(); + auto interval = now - startUsecs; + if (interval > maxIntervalUecs) { + startUsecs = now; + return true; + } + return false; +} + +inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) { + return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND); +} + +template +void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) { + if (afterSecs(lastReportUsecs, secs)) { + lamdba(); + } +} + +inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) { + if (afterSecs(startUsecs, secs)) { + QFAIL(message); + } +} diff --git a/tests/gpu/CMakeLists.txt b/tests/gpu/CMakeLists.txt index 6974953b40..ad0eac5822 100644 --- a/tests/gpu/CMakeLists.txt +++ b/tests/gpu/CMakeLists.txt @@ -1,9 +1,17 @@ # Declare dependencies macro (setup_testcase_dependencies) # link in the shared libraries - link_hifi_libraries(shared ktx gpu gl ${PLATFORM_GL_BACKEND}) + link_hifi_libraries(shared test-utils ktx gpu gl ${PLATFORM_GL_BACKEND}) package_libraries_for_deployment() target_opengl() + target_zlib() + find_package(QuaZip REQUIRED) + target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${QUAZIP_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${QUAZIP_LIBRARIES}) + if (WIN32) + add_paths_to_fixup_libs(${QUAZIP_DLL_PATH}) + add_dependency_external_projects(wasapi) + endif () endmacro () setup_hifi_testcase() diff --git a/tests/gpu/src/TextureTest.cpp b/tests/gpu/src/TextureTest.cpp index 9377a18244..f896914579 100644 --- a/tests/gpu/src/TextureTest.cpp +++ b/tests/gpu/src/TextureTest.cpp @@ -8,16 +8,27 @@ #include "TextureTest.h" +#include + #include #include #include #include #include +#include + +#include +#include + +#include "../../QTestExtensions.h" + +#pragma optimize("", off) QTEST_MAIN(TextureTest) -#pragma optimize("", off) + #define LOAD_TEXTURE_COUNT 40 -static const QDir TEST_DIR("D:/ktx_texture_test"); + +static const QString TEST_DATA("https://hifi-public.s3.amazonaws.com/austin/test_data/test_ktx.zip"); std::string vertexShaderSource = R"SHADER( #line 14 @@ -54,7 +65,10 @@ void main() { )SHADER"; +#define USE_SERVER_DATA 1 + void TextureTest::initTestCase() { + _resourcesPath = getTestResource("interface/resources"); getDefaultOpenGLSurfaceFormat(); _canvas.create(); if (!_canvas.makeCurrent()) { @@ -63,7 +77,32 @@ void TextureTest::initTestCase() { gl::initModuleGl(); gpu::Context::init(); _gpuContext = std::make_shared(); - gpu::Texture::setAllowedGPUMemoryUsage(MB_TO_BYTES(4096)); +#if USE_SERVER_DATA + if (!_testDataDir.isValid()) { + qFatal("Unable to create temp directory"); + } + + QString path = _testDataDir.path(); + FileDownloader(TEST_DATA, + [&](const QByteArray& data) { + QTemporaryFile zipFile; + if (zipFile.open()) { + zipFile.write(data); + zipFile.close(); + } + if (!_testDataDir.isValid()) { + qFatal("Unable to create temp dir"); + } + auto files = JlCompress::extractDir(zipFile.fileName(), _testDataDir.path()); + for (const auto& file : files) { + qDebug() << file; + } + }) + .waitForDownload(); + _resourcesPath = _testDataDir.path(); +#else + _resourcesPath = "D:/test_ktx"; +#endif _canvas.makeCurrent(); { @@ -80,19 +119,21 @@ void TextureTest::initTestCase() { _pipeline = gpu::Pipeline::create(program, state); } - { _framebuffer.reset(gpu::Framebuffer::create("cached", gpu::Element::COLOR_SRGBA_32, _size.x, _size.y)); } + _framebuffer.reset(gpu::Framebuffer::create("cached", gpu::Element::COLOR_SRGBA_32, _size.x, _size.y)); + // Find the test textures { - auto entryList = TEST_DIR.entryList({ "*.ktx" }, QDir::Filter::Files); + QDir resourcesDir(_resourcesPath); + auto entryList = resourcesDir.entryList({ "*.ktx" }, QDir::Filter::Files); _textureFiles.reserve(entryList.size()); for (auto entry : entryList) { - auto textureFile = TEST_DIR.absoluteFilePath(entry).toStdString(); + auto textureFile = resourcesDir.absoluteFilePath(entry).toStdString(); _textureFiles.push_back(textureFile); } } + // Load the test textures { - std::shuffle(_textureFiles.begin(), _textureFiles.end(), std::default_random_engine()); size_t newTextureCount = std::min(_textureFiles.size(), LOAD_TEXTURE_COUNT); for (size_t i = 0; i < newTextureCount; ++i) { const auto& textureFile = _textureFiles[i]; @@ -103,6 +144,9 @@ void TextureTest::initTestCase() { } void TextureTest::cleanupTestCase() { + _framebuffer.reset(); + _pipeline.reset(); + _gpuContext->recycle(); _gpuContext.reset(); } @@ -133,35 +177,8 @@ void TextureTest::renderFrame(const std::function& renderLamb endFrame(); } - -inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { - auto now = usecTimestampNow(); - auto interval = now - startUsecs; - if (interval > maxIntervalUecs) { - startUsecs = now; - return true; - } - return false; -} - -inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) { - return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND); -} - -template -void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) { - if (afterSecs(lastReportUsecs, secs)) { - lamdba(); - } -} - -inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) { - if (afterSecs(startUsecs, secs)) { - qFatal(message); - } -} - void TextureTest::testTextureLoading() { + QVERIFY(_textures.size() > 0); auto renderTexturesLamdba = [this](gpu::Batch& batch) { batch.setPipeline(_pipeline); for (const auto& texture : _textures) { @@ -170,39 +187,87 @@ void TextureTest::testTextureLoading() { } }; - size_t totalSize = 0; + size_t expectedAllocation = 0; for (const auto& texture : _textures) { - totalSize += texture->evalTotalSize(); + expectedAllocation += texture->evalTotalSize(); } + QVERIFY(_textures.size() > 0); auto reportLambda = [=] { - qDebug() << "Expected" << totalSize; - qDebug() << "Allowed " << gpu::Texture::getAllowedGPUMemoryUsage(); + qDebug() << "Allowed " << gpu::Texture::getAllowedGPUMemoryUsage(); qDebug() << "Allocated " << gpu::Context::getTextureResourceGPUMemSize(); qDebug() << "Populated " << gpu::Context::getTextureResourcePopulatedGPUMemSize(); qDebug() << "Pending " << gpu::Context::getTexturePendingGPUTransferMemSize(); }; + auto allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + auto populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + + // Cycle frames we're fully allocated + // We need to use the texture rendering lambda auto lastReport = usecTimestampNow(); auto start = usecTimestampNow(); - while (totalSize != gpu::Context::getTextureResourceGPUMemSize()) { + while (expectedAllocation != allocatedMemory) { reportEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to allocate texture memory after 10 seconds"); renderFrame(renderTexturesLamdba); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); } + QCOMPARE(allocatedMemory, expectedAllocation); // Restart the timer start = usecTimestampNow(); - auto allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); - auto populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); - while (allocatedMemory != populatedMemory && 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) { + // Cycle frames we're fully populated + while (allocatedMemory != populatedMemory || 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) { reportEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); renderFrame(); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); } - QCOMPARE(allocatedMemory, totalSize); - QCOMPARE(populatedMemory, totalSize); -} + reportLambda(); + QCOMPARE(populatedMemory, allocatedMemory); + // FIXME workaround a race condition in the difference between populated size and the actual _populatedMip value in the texture + for (size_t i = 0; i < _textures.size(); ++i) { + renderFrame(); + } + + // Test on-demand deallocation of memory + auto maxMemory = allocatedMemory / 2; + gpu::Texture::setAllowedGPUMemoryUsage(maxMemory); + + // Restart the timer + start = usecTimestampNow(); + // Cycle frames until the allocated memory is below the max memory + while (allocatedMemory > maxMemory || allocatedMemory != populatedMemory) { + reportEvery(lastReport, 4, reportLambda); + failAfter(start, 10, "Failed to deallocate texture memory after 10 seconds"); + renderFrame(renderTexturesLamdba); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + } + reportLambda(); + + // Verify that the allocation is now below the target + QVERIFY(allocatedMemory <= maxMemory); + // Verify that populated memory is the same as allocated memory + QCOMPARE(populatedMemory, allocatedMemory); + + // Restart the timer + start = usecTimestampNow(); + // Reset the max memory to automatic + gpu::Texture::setAllowedGPUMemoryUsage(0); + // Cycle frames we're fully populated + while (allocatedMemory != expectedAllocation || allocatedMemory != populatedMemory) { + reportEvery(lastReport, 4, reportLambda); + failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); + renderFrame(); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + } + reportLambda(); + QCOMPARE(allocatedMemory, expectedAllocation); + QCOMPARE(populatedMemory, allocatedMemory); +} diff --git a/tests/gpu/src/TextureTest.h b/tests/gpu/src/TextureTest.h index f3753f5e9b..9d3dc4ab81 100644 --- a/tests/gpu/src/TextureTest.h +++ b/tests/gpu/src/TextureTest.h @@ -9,6 +9,8 @@ #pragma once #include +#include + #include #include @@ -18,7 +20,7 @@ class TextureTest : public QObject { private: void beginFrame(); void endFrame(); - void renderFrame(const std::function& = [](gpu::Batch&){}); + void renderFrame(const std::function& = [](gpu::Batch&) {}); private slots: void initTestCase(); @@ -26,6 +28,8 @@ private slots: void testTextureLoading(); private: + QString _resourcesPath; + QTemporaryDir _testDataDir; OffscreenGLCanvas _canvas; gpu::ContextPointer _gpuContext; gpu::PipelinePointer _pipeline; From 57691d5d66cafb7cf55216f96f3b32426fee3a20 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 9 May 2018 12:36:26 -0700 Subject: [PATCH 176/192] Cache downloaded assets --- tests/gpu/src/TextureTest.cpp | 54 +++++++++++++++++------------------ tests/gpu/src/TextureTest.h | 1 - 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/tests/gpu/src/TextureTest.cpp b/tests/gpu/src/TextureTest.cpp index f896914579..65d0933302 100644 --- a/tests/gpu/src/TextureTest.cpp +++ b/tests/gpu/src/TextureTest.cpp @@ -8,6 +8,7 @@ #include "TextureTest.h" +#include #include #include @@ -22,13 +23,12 @@ #include "../../QTestExtensions.h" -#pragma optimize("", off) - QTEST_MAIN(TextureTest) #define LOAD_TEXTURE_COUNT 40 static const QString TEST_DATA("https://hifi-public.s3.amazonaws.com/austin/test_data/test_ktx.zip"); +static const QString TEST_DIR_NAME("{630b8f02-52af-4cdf-a896-24e472b94b28}"); std::string vertexShaderSource = R"SHADER( #line 14 @@ -65,9 +65,18 @@ void main() { )SHADER"; -#define USE_SERVER_DATA 1 +QtMessageHandler originalHandler; + +void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { +#if defined(Q_OS_WIN) + OutputDebugStringA(message.toStdString().c_str()); + OutputDebugStringA("\n"); +#endif + originalHandler(type, context, message); +} void TextureTest::initTestCase() { + originalHandler = qInstallMessageHandler(messageHandler); _resourcesPath = getTestResource("interface/resources"); getDefaultOpenGLSurfaceFormat(); _canvas.create(); @@ -77,32 +86,21 @@ void TextureTest::initTestCase() { gl::initModuleGl(); gpu::Context::init(); _gpuContext = std::make_shared(); -#if USE_SERVER_DATA - if (!_testDataDir.isValid()) { - qFatal("Unable to create temp directory"); - } - QString path = _testDataDir.path(); - FileDownloader(TEST_DATA, - [&](const QByteArray& data) { - QTemporaryFile zipFile; - if (zipFile.open()) { - zipFile.write(data); - zipFile.close(); - } - if (!_testDataDir.isValid()) { - qFatal("Unable to create temp dir"); - } - auto files = JlCompress::extractDir(zipFile.fileName(), _testDataDir.path()); - for (const auto& file : files) { - qDebug() << file; - } - }) - .waitForDownload(); - _resourcesPath = _testDataDir.path(); -#else - _resourcesPath = "D:/test_ktx"; -#endif + _resourcesPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + TEST_DIR_NAME; + if (!QFileInfo(_resourcesPath).exists()) { + QDir(_resourcesPath).mkpath("."); + FileDownloader(TEST_DATA, + [&](const QByteArray& data) { + QTemporaryFile zipFile; + if (zipFile.open()) { + zipFile.write(data); + zipFile.close(); + } + JlCompress::extractDir(zipFile.fileName(), _resourcesPath); + }) + .waitForDownload(); + } _canvas.makeCurrent(); { diff --git a/tests/gpu/src/TextureTest.h b/tests/gpu/src/TextureTest.h index 9d3dc4ab81..91f8a358ea 100644 --- a/tests/gpu/src/TextureTest.h +++ b/tests/gpu/src/TextureTest.h @@ -29,7 +29,6 @@ private slots: private: QString _resourcesPath; - QTemporaryDir _testDataDir; OffscreenGLCanvas _canvas; gpu::ContextPointer _gpuContext; gpu::PipelinePointer _pipeline; From e0b57a22286207c86c31f24cfc4582c212d26139 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Wed, 9 May 2018 18:20:19 -0300 Subject: [PATCH 177/192] Code review in radar.js --- scripts/system/+android/radar.js | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 67ba896207..5d93ed4db1 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -346,9 +346,9 @@ function pinchUpdate(event) { } Camera.position = { - x: Camera.position.x, - y:radarHeight, - z:Camera.position.z + x : Camera.position.x, + y : radarHeight, + z : Camera.position.z }; if (!draggingCamera) { @@ -360,7 +360,7 @@ function pinchUpdate(event) { } function isInsideSquare(coords0, coords1, halfside) { - return coords0 != undefined && coords1!= undefined && + return coords0 != undefined && coords1 != undefined && Math.abs(coords0.x - coords1.x) <= halfside && Math.abs(coords0.y - coords1.y) <= halfside; } @@ -372,7 +372,7 @@ function dragScrollUpdate(event) { // drag management var pickRay = Camera.computePickRay(event.x, event.y); var dragAt = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, - radarHeight-MyAvatar.position.y)); + radarHeight - MyAvatar.position.y)); if (lastDragAt === undefined || lastDragAt === null) { lastDragAt = dragAt; @@ -1082,29 +1082,20 @@ function renderAllOthersAvatarIcons() { } } -/******************************************************************************* - * Entities (to remark) cache structure for showing entities markers - ******************************************************************************/ - var ICON_ENTITY_DEFAULT_DIMENSIONS = { x : 0.10, y : 0.00001, z : 0.10 }; -var entityIconModelDimensionsVal = { - x : 0, - y : 0.00001, - z : 0 -}; + function teleportIconModelDimensions(y) { - // given the current height, give a size - // TODO: receive entity.position.y and substract to radarHeight + var teleportModelDimensions = ICON_ENTITY_DEFAULT_DIMENSIONS; var xz = -0.002831 * (radarHeight - y) + 0.1; - entityIconModelDimensionsVal.x = xz; - entityIconModelDimensionsVal.z = xz; + teleportModelDimensions.x = xz; + teleportModelDimensions.z = xz; // reuse object - return entityIconModelDimensionsVal; + return teleportModelDimensions; } /******************************************************************************* From 9b6225db40bfa1f69707e2a1507a007f2eed9b4f Mon Sep 17 00:00:00 2001 From: Simon Walton Date: Wed, 9 May 2018 14:29:10 -0700 Subject: [PATCH 178/192] Bump default packet version 20 -> 21 --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 98b0e1d892..e7a793d267 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -91,7 +91,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::Ping: return static_cast(PingVersion::IncludeConnectionID); default: - return 20; + return 21; } } From cb336bdeab4b0400af37fdf62073566f8106bd35 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 10 May 2018 10:55:50 -0700 Subject: [PATCH 179/192] Fix linux build problems --- tests/QTestExtensions.h | 8 ++++---- tests/gpu/src/TextureTest.cpp | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/QTestExtensions.h b/tests/QTestExtensions.h index c43ef3f73e..ac037d831b 100644 --- a/tests/QTestExtensions.h +++ b/tests/QTestExtensions.h @@ -317,7 +317,7 @@ inline QString getTestResource(const QString& relativePath) { return QDir::cleanPath(dir.absoluteFilePath(relativePath)); } -inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { +inline bool afterUsecs(quint64& startUsecs, quint64 maxIntervalUecs) { auto now = usecTimestampNow(); auto interval = now - startUsecs; if (interval > maxIntervalUecs) { @@ -327,18 +327,18 @@ inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { return false; } -inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) { +inline bool afterSecs(quint64& startUsecs, quint64 maxIntervalSecs) { return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND); } template -void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) { +void doEvery(quint64& lastReportUsecs, quint64 secs, F lamdba) { if (afterSecs(lastReportUsecs, secs)) { lamdba(); } } -inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) { +inline void failAfter(quint64 startUsecs, quint64 secs, const char* message) { if (afterSecs(startUsecs, secs)) { QFAIL(message); } diff --git a/tests/gpu/src/TextureTest.cpp b/tests/gpu/src/TextureTest.cpp index 65d0933302..18361af791 100644 --- a/tests/gpu/src/TextureTest.cpp +++ b/tests/gpu/src/TextureTest.cpp @@ -206,7 +206,7 @@ void TextureTest::testTextureLoading() { auto lastReport = usecTimestampNow(); auto start = usecTimestampNow(); while (expectedAllocation != allocatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to allocate texture memory after 10 seconds"); renderFrame(renderTexturesLamdba); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -218,7 +218,7 @@ void TextureTest::testTextureLoading() { start = usecTimestampNow(); // Cycle frames we're fully populated while (allocatedMemory != populatedMemory || 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); renderFrame(); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -240,7 +240,7 @@ void TextureTest::testTextureLoading() { start = usecTimestampNow(); // Cycle frames until the allocated memory is below the max memory while (allocatedMemory > maxMemory || allocatedMemory != populatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to deallocate texture memory after 10 seconds"); renderFrame(renderTexturesLamdba); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -259,7 +259,7 @@ void TextureTest::testTextureLoading() { gpu::Texture::setAllowedGPUMemoryUsage(0); // Cycle frames we're fully populated while (allocatedMemory != expectedAllocation || allocatedMemory != populatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); renderFrame(); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -268,4 +268,17 @@ void TextureTest::testTextureLoading() { reportLambda(); QCOMPARE(allocatedMemory, expectedAllocation); QCOMPARE(populatedMemory, allocatedMemory); + + _textures.clear(); + // Cycle frames we're fully populated + while (allocatedMemory != 0) { + failAfter(start, 10, "Failed to clear texture memory after 10 seconds"); + renderFrame(); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + } + QCOMPARE(allocatedMemory, 0); + QCOMPARE(populatedMemory, 0); + qDebug() << "Done"; + } From a061e84ad7028d59dc7a8db72c070df6a9fba999 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Thu, 10 May 2018 19:40:02 +0100 Subject: [PATCH 180/192] remove unused commented code --- .../qml/dialogs/assetDialog/AssetDialogContent.qml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml index ed442aa191..914fe139ab 100644 --- a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml +++ b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml @@ -20,14 +20,8 @@ Item { // Set from OffscreenUi::assetDialog() property alias dir: assetTableModel.folder property alias filter: selectionType.filtersString - property int options // Not used. property bool selectDirectory: false - - // Not implemented. - // property bool saveDialog: false; - // property bool multiSelect: false; - property bool singleClickNavigate: false HifiConstants { id: hifi } @@ -84,7 +78,6 @@ Item { size: 28 width: height enabled: destination !== "" - // onClicked: d.navigateHome(); onClicked: assetTableModel.folder = destination; } } From 32d10641dc44861e9c22b3505cc579ce02648845 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 10 May 2018 14:41:35 -0700 Subject: [PATCH 181/192] don't enable so much logging when 'verbose logging' is turned on --- interface/src/Application.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 20efe73f08..6810621093 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2253,8 +2253,12 @@ void Application::updateVerboseLogging() { } bool enable = menu->isOptionChecked(MenuOption::VerboseLogging); - QString rules = "*.debug=%1\n" - "*.info=%1"; + QString rules = + "hifi.*.debug=%1\n" + "hifi.*.info=%1\n" + "hifi.audio-stream.warning=false\n" + "hifi.audio-stream.debug=false\n" + "hifi.audio-stream.info=false"; rules = rules.arg(enable ? "true" : "false"); QLoggingCategory::setFilterRules(rules); } From fab85c3f6d433940d7c503d3a103317447300593 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 11 May 2018 09:52:48 +1200 Subject: [PATCH 182/192] Fix JSDoc function definitions specifying properties instead of params --- .../entities/src/EntityScriptingInterface.h | 4 +- .../src/AssetScriptingInterface.h | 58 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 8adb5138f2..7e47d9e2d4 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -481,8 +481,8 @@ public slots: /**jsdoc * Gets the status of server entity script attached to an entity * @function Entities.getServerScriptStatus - * @property {Uuid} entityID - The ID of the entity to get the server entity script status for. - * @property {Entities~getServerScriptStatusCallback} callback - The function to call upon completion. + * @param {Uuid} entityID - The ID of the entity to get the server entity script status for. + * @param {Entities~getServerScriptStatusCallback} callback - The function to call upon completion. * @returns {boolean} true always. */ /**jsdoc diff --git a/libraries/script-engine/src/AssetScriptingInterface.h b/libraries/script-engine/src/AssetScriptingInterface.h index eb9a628ae3..7f7a3a68b0 100644 --- a/libraries/script-engine/src/AssetScriptingInterface.h +++ b/libraries/script-engine/src/AssetScriptingInterface.h @@ -186,36 +186,36 @@ public: /**jsdoc * @function Assets.deleteAsset - * @property {} options - * @property {} scope - * @property {} [callback = ""] + * @param {} options + * @param {} scope + * @param {} [callback = ""] */ Q_INVOKABLE void deleteAsset(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.resolveAsset - * @property {} options - * @property {} scope - * @property {} [callback = ""] + * @param {} options + * @param {} scope + * @param {} [callback = ""] */ Q_INVOKABLE void resolveAsset(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.decompressData - * @property {} options - * @property {} scope - * @property {} [callback = ""] + * @param {} options + * @param {} scope + * @param {} [callback = ""] */ Q_INVOKABLE void decompressData(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.compressData - * @property {} options - * @property {} scope - * @property {} [callback = ""] + * @param {} options + * @param {} scope + * @param {} [callback = ""] */ Q_INVOKABLE void compressData(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); @@ -229,7 +229,7 @@ public: /**jsdoc * @function Assets.canWriteCacheValue - * @property {string} url + * @param {string} url * @returns {boolean} */ @@ -237,8 +237,8 @@ public: /**jsdoc * @function Assets.getCacheStatus - * @property {} scope - * @property {} [callback=undefined] + * @param {} scope + * @param {} [callback=undefined] */ Q_INVOKABLE void getCacheStatus(QScriptValue scope, QScriptValue callback = QScriptValue()) { @@ -247,38 +247,38 @@ public: /**jsdoc * @function Assets.queryCacheMeta - * @property {} options - * @property {} scope - * @property {} [callback=undefined] + * @param {} options + * @param {} scope + * @param {} [callback=undefined] */ Q_INVOKABLE void queryCacheMeta(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.loadFromCache - * @property {} options - * @property {} scope - * @property {} [callback=undefined] + * @param {} options + * @param {} scope + * @param {} [callback=undefined] */ Q_INVOKABLE void loadFromCache(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.saveToCache - * @property {} options - * @property {} scope - * @property {} [callback=undefined] + * @param {} options + * @param {} scope + * @param {} [callback=undefined] */ Q_INVOKABLE void saveToCache(QScriptValue options, QScriptValue scope, QScriptValue callback = QScriptValue()); /**jsdoc * @function Assets.saveToCache - * @property {} url - * @property {} data - * @property {} metadata - * @property {} scope - * @property {} [callback=undefined] + * @param {} url + * @param {} data + * @param {} metadata + * @param {} scope + * @param {} [callback=undefined] */ Q_INVOKABLE void saveToCache(const QUrl& url, const QByteArray& data, const QVariantMap& metadata, From 826c427e2a0d12bfd2e72dc166a7e66b6db33c61 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 10 May 2018 15:42:59 -0700 Subject: [PATCH 183/192] trying to sort-out audio-stream logging --- interface/src/Application.cpp | 1 - libraries/audio/src/AudioLogging.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6810621093..ff8b545c57 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2256,7 +2256,6 @@ void Application::updateVerboseLogging() { QString rules = "hifi.*.debug=%1\n" "hifi.*.info=%1\n" - "hifi.audio-stream.warning=false\n" "hifi.audio-stream.debug=false\n" "hifi.audio-stream.info=false"; rules = rules.arg(enable ? "true" : "false"); diff --git a/libraries/audio/src/AudioLogging.cpp b/libraries/audio/src/AudioLogging.cpp index 8a668a4bcb..73091885cb 100644 --- a/libraries/audio/src/AudioLogging.cpp +++ b/libraries/audio/src/AudioLogging.cpp @@ -12,5 +12,4 @@ #include "AudioLogging.h" Q_LOGGING_CATEGORY(audio, "hifi.audio") -Q_LOGGING_CATEGORY(audiostream, "hifi.audio-stream", QtWarningMsg) - +Q_LOGGING_CATEGORY(audiostream, "hifi.audio-stream") From 50a53a5174bd3dc2a29131d0e316266c060a5d66 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 10 May 2018 16:00:01 -0700 Subject: [PATCH 184/192] fix lastEdited vs pal --- scripts/system/pal.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 0a01007ee9..84328001e1 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -251,6 +251,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See }); } break; + case 'refresh': // old name for refreshNearby case 'refreshNearby': data = {}; ExtendedOverlay.some(function (overlay) { // capture the audio data @@ -743,10 +744,13 @@ function receiveMessage(channel, messageString, senderID) { var message = JSON.parse(messageString); switch (message.method) { case 'select': - sendToQml(message); // Accepts objects, not just strings. + if (!onPalScreen) { + tablet.loadQMLSource(PAL_QML_SOURCE); + Script.setTimeout(function () { sendToQml(message); }, 1000); + } else { + sendToQml(message); // Accepts objects, not just strings. + } break; - default: - print('Unrecognized PAL message', messageString); } } From bf26aec260fe661b2391d1a92157c80c5c29b6cc Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 10 May 2018 16:39:56 -0700 Subject: [PATCH 185/192] untabify --- scripts/system/pal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 84328001e1..c70c2729f5 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -744,12 +744,12 @@ function receiveMessage(channel, messageString, senderID) { var message = JSON.parse(messageString); switch (message.method) { case 'select': - if (!onPalScreen) { - tablet.loadQMLSource(PAL_QML_SOURCE); - Script.setTimeout(function () { sendToQml(message); }, 1000); - } else { + if (!onPalScreen) { + tablet.loadQMLSource(PAL_QML_SOURCE); + Script.setTimeout(function () { sendToQml(message); }, 1000); + } else { sendToQml(message); // Accepts objects, not just strings. - } + } break; } } From 4eba727849e4294625e31bdec2a8312b2c1445fd Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 11 May 2018 10:47:41 -0700 Subject: [PATCH 186/192] fix qml crash on start up --- .../resources/qml/dialogs/assetDialog/AssetDialogContent.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml index 31e013638e..c3e842bc2f 100644 --- a/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml +++ b/interface/resources/qml/dialogs/assetDialog/AssetDialogContent.qml @@ -21,6 +21,7 @@ Item { // Set from OffscreenUi::assetDialog() property alias dir: assetTableModel.folder property alias filter: selectionType.filtersString + property int options property bool selectDirectory: false property bool singleClickNavigate: false From 85a6e2555fcec45ce812fd898088913b1e206089 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 11 May 2018 13:55:29 -0700 Subject: [PATCH 187/192] don't assert when unserializing a 'spring' action --- libraries/physics/src/ObjectActionTractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectActionTractor.cpp b/libraries/physics/src/ObjectActionTractor.cpp index a48989be33..4235bbd616 100644 --- a/libraries/physics/src/ObjectActionTractor.cpp +++ b/libraries/physics/src/ObjectActionTractor.cpp @@ -397,7 +397,7 @@ void ObjectActionTractor::deserialize(QByteArray serializedArguments) { EntityDynamicType type; dataStream >> type; - assert(type == getType()); + assert(type == getType() || type == DYNAMIC_TYPE_SPRING); QUuid id; dataStream >> id; From a9a783588bae2dca4f048fd257253f4cca9dfe71 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 14 May 2018 09:25:17 -0700 Subject: [PATCH 188/192] Fixed typo. --- tools/auto-tester/src/Test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index c7ce5f8893..0fb957d309 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -89,7 +89,7 @@ private: const int NUM_DIGITS { 5 }; const QString EXPECTED_IMAGE_PREFIX { "ExpectedImage_" }; - // We have to directories to work with. + // We have two directories to work with. // The first is the directory containing the test we are working with // The second contains the snapshots taken for test runs that need to be evaluated QString testDirectory; From 81ebb681bb185ff5ec5430e981333425b79f7be8 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 14 May 2018 09:35:34 -0700 Subject: [PATCH 189/192] Show invalidated items in My Purchases --- .../resources/qml/hifi/commerce/purchases/Purchases.qml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index d79b8d09fa..0b95f26f55 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -995,10 +995,6 @@ Rectangle { for (var i = 0; i < purchasesModel.count; i++) { if (purchasesModel.get(i).title.toLowerCase().indexOf(filterBar.text.toLowerCase()) !== -1) { - if (!purchasesModel.get(i).valid) { - continue; - } - if (purchasesModel.get(i).status !== "confirmed" && !root.isShowingMyItems) { tempPurchasesModel.insert(0, purchasesModel.get(i)); } else if ((root.isShowingMyItems && purchasesModel.get(i).edition_number === "0") || @@ -1055,10 +1051,6 @@ Rectangle { var currentId; for (var i = 0; i < tempPurchasesModel.count; i++) { currentId = tempPurchasesModel.get(i).id; - - if (!purchasesModel.get(i).valid) { - continue; - } filteredPurchasesModel.append(tempPurchasesModel.get(i)); filteredPurchasesModel.setProperty(i, 'cardBackVisible', false); filteredPurchasesModel.setProperty(i, 'isInstalled', ((root.installedApps).indexOf(currentId) > -1)); From 2a1c2ba7b1ce7fe3e583117f4d2a3c2f18f0f2d4 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 14 May 2018 09:54:05 -0700 Subject: [PATCH 190/192] PurchasedItem logic --- .../resources/qml/hifi/commerce/purchases/PurchasedItem.qml | 5 ++++- .../resources/qml/hifi/commerce/purchases/Purchases.qml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index 4db98091c1..17c42d1b08 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -49,6 +49,7 @@ Item { property string upgradeTitle; property bool updateAvailable: root.upgradeUrl !== "" && !root.isShowingMyItems; property bool isShowingMyItems; + property bool valid; property string originalStatusText; property string originalStatusColor; @@ -239,6 +240,7 @@ Item { width: 62; onLoaded: { + item.enabled = root.valid; item.buttonGlyphText = hifi.glyphs.gift; item.buttonText = "Gift"; item.buttonClicked = function() { @@ -646,7 +648,8 @@ Item { height: 40; enabled: root.hasPermissionToRezThis && root.purchaseStatus !== "invalidated" && - MyAvatar.skeletonModelURL !== root.itemHref; + MyAvatar.skeletonModelURL !== root.itemHref && + root.valid; onHoveredChanged: { if (hovered) { diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 0b95f26f55..8fe1ebe6c9 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -616,6 +616,7 @@ Rectangle { upgradeTitle: model.upgrade_title; itemType: model.itemType; isShowingMyItems: root.isShowingMyItems; + valid: model.valid; anchors.topMargin: 10; anchors.bottomMargin: 10; From a881d07e59f72e7de90f19478f011f0aa0c10fe3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 14 May 2018 13:12:58 -0700 Subject: [PATCH 191/192] MS15090: Fix gifting when running marketplaces.js separately --- scripts/system/marketplaces/marketplaces.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index c3edee264f..dc4d5aa844 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -19,6 +19,7 @@ var selectionDisplay = null; // for gridTool.js to ignore Script.include("/~/system/libraries/WebTablet.js"); Script.include("/~/system/libraries/gridTool.js"); + Script.include("/~/system/libraries/connectionUtils.js"); var METAVERSE_SERVER_URL = Account.metaverseServerURL; var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace"; From 83cae5460101cae5f8f5c3c76d3e76a24790ce3a Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 14 May 2018 13:34:20 -0700 Subject: [PATCH 192/192] Show 'invalidated' label for valid = false --- .../hifi/commerce/purchases/PurchasedItem.qml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index 17c42d1b08..19b57354dc 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -465,7 +465,7 @@ Item { Item { id: statusContainer; - visible: root.purchaseStatus === "pending" || root.purchaseStatus === "invalidated" || root.numberSold > -1; + visible: root.purchaseStatus === "pending" || !root.valid || root.numberSold > -1; anchors.left: itemName.left; anchors.right: itemName.right; anchors.top: itemName.bottom; @@ -482,7 +482,7 @@ Item { text: { if (root.purchaseStatus === "pending") { "PENDING..." - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { "INVALIDATED" } else if (root.numberSold > -1) { ("Sales: " + root.numberSold + "/" + (root.limitedRun === -1 ? "\u221e" : root.limitedRun)) @@ -494,7 +494,7 @@ Item { color: { if (root.purchaseStatus === "pending") { hifi.colors.blueAccent - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { hifi.colors.redAccent } else { hifi.colors.baseGray @@ -508,7 +508,7 @@ Item { text: { if (root.purchaseStatus === "pending") { hifi.glyphs.question - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { hifi.glyphs.question } else { "" @@ -525,7 +525,7 @@ Item { color: { if (root.purchaseStatus === "pending") { hifi.colors.blueAccent - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { hifi.colors.redAccent } else { hifi.colors.baseGray @@ -540,7 +540,7 @@ Item { onClicked: { if (root.purchaseStatus === "pending") { sendToPurchases({method: 'showPendingLightbox'}); - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { sendToPurchases({method: 'showInvalidatedLightbox'}); } } @@ -548,7 +548,7 @@ Item { if (root.purchaseStatus === "pending") { statusText.color = hifi.colors.blueHighlight; statusIcon.color = hifi.colors.blueHighlight; - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { statusText.color = hifi.colors.redAccent; statusIcon.color = hifi.colors.redAccent; } @@ -557,7 +557,7 @@ Item { if (root.purchaseStatus === "pending") { statusText.color = hifi.colors.blueAccent; statusIcon.color = hifi.colors.blueAccent; - } else if (root.purchaseStatus === "invalidated") { + } else if (!root.valid) { statusText.color = hifi.colors.redHighlight; statusIcon.color = hifi.colors.redHighlight; } @@ -647,7 +647,6 @@ Item { width: 160; height: 40; enabled: root.hasPermissionToRezThis && - root.purchaseStatus !== "invalidated" && MyAvatar.skeletonModelURL !== root.itemHref && root.valid;