From eb26d9b4e38de4dcced40cf18a051577d84bd64a Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Fri, 3 Apr 2020 14:28:33 -0700 Subject: [PATCH 01/32] working on parenting fixes --- .../qml/+android_interface/Stats.qml | 4 +++ interface/resources/qml/Stats.qml | 4 +++ interface/src/ui/Stats.cpp | 2 ++ interface/src/ui/Stats.h | 18 ++++++++++++ .../src/EntityTreeRenderer.cpp | 7 +++-- .../src/EntityTreeRenderer.h | 5 ++++ .../src/RenderableEntityItem.cpp | 20 ++++--------- .../src/RenderableEntityItem.h | 7 +---- .../src/RenderableGizmoEntityItem.cpp | 19 +++++++------ .../src/RenderableGizmoEntityItem.h | 1 + .../src/RenderableGridEntityItem.cpp | 3 +- .../src/RenderableImageEntityItem.cpp | 16 +++++------ .../RenderableParticleEffectEntityItem.cpp | 28 ++++++++++++++++--- .../src/RenderableParticleEffectEntityItem.h | 2 ++ .../src/RenderablePolyLineEntityItem.cpp | 3 +- .../src/RenderableShapeEntityItem.cpp | 7 ++--- .../src/RenderableTextEntityItem.cpp | 3 +- .../src/RenderableWebEntityItem.cpp | 3 +- .../src/RenderableZoneEntityItem.cpp | 10 ------- .../src/RenderableZoneEntityItem.h | 1 - libraries/entities/src/EntityItem.cpp | 20 ++++++++----- libraries/entities/src/EntityItem.h | 4 +-- libraries/entities/src/GizmoEntityItem.cpp | 1 + libraries/entities/src/GridEntityItem.cpp | 1 + libraries/entities/src/ImageEntityItem.cpp | 1 + libraries/entities/src/LightEntityItem.cpp | 16 +---------- libraries/entities/src/LightEntityItem.h | 3 -- libraries/entities/src/LineEntityItem.cpp | 1 + libraries/entities/src/MaterialEntityItem.cpp | 1 + libraries/entities/src/ModelEntityItem.cpp | 1 + .../entities/src/ParticleEffectEntityItem.cpp | 1 + libraries/entities/src/PolyLineEntityItem.cpp | 1 + libraries/entities/src/PolyVoxEntityItem.cpp | 1 + libraries/entities/src/ShapeEntityItem.cpp | 1 + libraries/entities/src/TextEntityItem.cpp | 1 + libraries/entities/src/WebEntityItem.cpp | 1 + libraries/entities/src/ZoneEntityItem.cpp | 1 + libraries/render-utils/src/Model.cpp | 12 ++++---- libraries/render-utils/src/Model.h | 6 ++-- 39 files changed, 134 insertions(+), 103 deletions(-) diff --git a/interface/resources/qml/+android_interface/Stats.qml b/interface/resources/qml/+android_interface/Stats.qml index 1f07af786f..b44b95c5ca 100644 --- a/interface/resources/qml/+android_interface/Stats.qml +++ b/interface/resources/qml/+android_interface/Stats.qml @@ -386,6 +386,10 @@ Item { visible: root.expanded text: "LOD: " + root.lodStatus; } + StatText { + visible: root.expanded + text: "Entity Updates: " + root.numEntityUpdates + " / " + root.numNeededEntityUpdates; + } } } } diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 23aa256cdc..9e4fdffaee 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -437,6 +437,10 @@ Item { visible: root.expanded text: "LOD: " + root.lodStatus; } + StatText { + visible: root.expanded + text: "Entity Updates: " + root.numEntityUpdates + " / " + root.numNeededEntityUpdates; + } } } } diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 8b9b9743f0..a9e2e4d8e3 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -456,6 +456,8 @@ void Stats::updateStats(bool force) { STAT_UPDATE(localLeaves, (int)OctreeElement::getLeafNodeCount()); // LOD Details STAT_UPDATE(lodStatus, "You can see " + DependencyManager::get()->getLODFeedbackText()); + STAT_UPDATE(numEntityUpdates, DependencyManager::get()->getPrevNumEntityUpdates()); + STAT_UPDATE(numNeededEntityUpdates, DependencyManager::get()->getPrevTotalNeededEntityUpdates()); } diff --git a/interface/src/ui/Stats.h b/interface/src/ui/Stats.h index b87e3a3dbc..96f0ea725a 100644 --- a/interface/src/ui/Stats.h +++ b/interface/src/ui/Stats.h @@ -112,6 +112,8 @@ private: \ * @property {number} lodAngle - Read-only. * @property {number} lodTargetFramerate - Read-only. * @property {string} lodStatus - Read-only. + * @property {string} numEntityUpdates - Read-only. + * @property {string} numNeededEntityUpdates - Read-only. * @property {string} timingStats - Read-only. * @property {string} gameUpdateStats - Read-only. * @property {number} serverElements - Read-only. @@ -277,6 +279,8 @@ class Stats : public QQuickItem { STATS_PROPERTY(int, lodAngle, 0) STATS_PROPERTY(int, lodTargetFramerate, 0) STATS_PROPERTY(QString, lodStatus, QString()) + STATS_PROPERTY(int, numEntityUpdates, 0) + STATS_PROPERTY(int, numNeededEntityUpdates, 0) STATS_PROPERTY(QString, timingStats, QString()) STATS_PROPERTY(QString, gameUpdateStats, QString()) STATS_PROPERTY(int, serverElements, 0) @@ -883,6 +887,20 @@ signals: */ void lodStatusChanged(); + /**jsdoc + * Triggered when the value of the numEntityUpdates property changes. + * @function Stats.numEntityUpdatesChanged + * @returns {Signal} + */ + void numEntityUpdatesChanged(); + + /**jsdoc + * Triggered when the value of the numNeededEntityUpdates property changes. + * @function Stats.numNeededEntityUpdatesChanged + * @returns {Signal} + */ + void numNeededEntityUpdatesChanged(); + /**jsdoc * Triggered when the value of the serverElements property changes. * @function Stats.serverElementsChanged diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index ab3f4c5243..5e05ebf5c9 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -426,6 +426,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene } float expectedUpdateCost = _avgRenderableUpdateCost * _renderablesToUpdate.size(); + _prevTotalNeededEntityUpdates = _renderablesToUpdate.size(); if (expectedUpdateCost < MAX_UPDATE_RENDERABLES_TIME_BUDGET) { // we expect to update all renderables within available time budget PROFILE_RANGE_EX(simulation_physics, "UpdateRenderables", 0xffff00ff, (uint64_t)_renderablesToUpdate.size()); @@ -434,7 +435,8 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene assert(renderable); // only valid renderables are added to _renderablesToUpdate renderable->updateInScene(scene, transaction); } - size_t numRenderables = _renderablesToUpdate.size() + 1; // add one to avoid divide by zero + _prevNumEntityUpdates = _renderablesToUpdate.size(); + size_t numRenderables = _prevNumEntityUpdates + 1; // add one to avoid divide by zero _renderablesToUpdate.clear(); // compute average per-renderable update cost @@ -495,7 +497,8 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene } // compute average per-renderable update cost - size_t numUpdated = sortedRenderables.size() - _renderablesToUpdate.size() + 1; // add one to avoid divide by zero + _prevNumEntityUpdates = sortedRenderables.size() - _renderablesToUpdate.size(); + size_t numUpdated = _prevNumEntityUpdates + 1; // add one to avoid divide by zero float cost = (float)(usecTimestampNow() - updateStart) / (float)(numUpdated); const float BLEND = 0.1f; _avgRenderableUpdateCost = (1.0f - BLEND) * _avgRenderableUpdateCost + BLEND * cost; diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 6dbaedc123..36ec94c464 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -135,6 +135,9 @@ public: static bool addMaterialToAvatar(const QUuid& avatarID, graphics::MaterialLayer material, const std::string& parentMaterialName); static bool removeMaterialFromAvatar(const QUuid& avatarID, graphics::MaterialPointer material, const std::string& parentMaterialName); + int getPrevNumEntityUpdates() const { return _prevNumEntityUpdates; } + int getPrevTotalNeededEntityUpdates() const { return _prevTotalNeededEntityUpdates; } + signals: void enterEntity(const EntityItemID& entityItemID); void leaveEntity(const EntityItemID& entityItemID); @@ -248,6 +251,8 @@ private: ReadWriteLockable _changedEntitiesGuard; std::unordered_set _changedEntities; + int _prevNumEntityUpdates { 0 }; + int _prevTotalNeededEntityUpdates { 0 }; std::unordered_set _renderablesToUpdate; std::unordered_map _entitiesInScene; diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index ae56a8fc47..79ee861c95 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -201,13 +201,6 @@ void EntityRenderer::render(RenderArgs* args) { return; } - if (!_renderUpdateQueued && needsRenderUpdate()) { - // FIXME find a way to spread out the calls to needsRenderUpdate so that only a given subset of the - // items checks every frame, like 1/N of the tree ever N frames - _renderUpdateQueued = true; - emit requestRenderUpdate(); - } - if (_visible && (args->_renderMode != RenderArgs::RenderMode::DEFAULT_RENDER_MODE || !_cauterized)) { doRender(args); } @@ -326,11 +319,6 @@ void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& trans } _updateTime = usecTimestampNow(); - // FIXME is this excessive? - if (!needsRenderUpdate()) { - return; - } - doRenderUpdateSynchronous(scene, transaction, _entity); transaction.updateItem(_renderItemID, [this](PayloadProxyInterface& self) { if (!isValidRenderItem()) { @@ -338,7 +326,6 @@ void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& trans } // Happens on the render thread. Classes should use doRenderUpdateAsynchronous(_entity); - _renderUpdateQueued = false; }); } @@ -431,7 +418,7 @@ void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transa } void EntityRenderer::onAddToScene(const EntityItemPointer& entity) { - QObject::connect(this, &EntityRenderer::requestRenderUpdate, this, [this] { + QObject::connect(this, &EntityRenderer::requestRenderUpdate, this, [this] { auto renderer = DependencyManager::get(); if (renderer) { renderer->onEntityChanged(_entity->getID()); @@ -440,7 +427,10 @@ void EntityRenderer::onAddToScene(const EntityItemPointer& entity) { _changeHandlerId = entity->registerChangeHandler([](const EntityItemID& changedEntity) { auto renderer = DependencyManager::get(); if (renderer) { - renderer->onEntityChanged(changedEntity); + auto renderable = renderer->renderableForEntityId(changedEntity); + if (renderable && renderable->needsRenderUpdate()) { + renderer->onEntityChanged(changedEntity); + } } }); } diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index 227eb6a018..d52ccf4a99 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -145,8 +145,6 @@ protected: PrimitiveMode _primitiveMode { PrimitiveMode::SOLID }; bool _cauterized { false }; bool _moving { false }; - // Only touched on the rendering thread - bool _renderUpdateQueued{ false }; Transform _renderTransform; std::unordered_map _materials; @@ -187,10 +185,7 @@ protected: using Parent::needsRenderUpdateFromEntity; // Returns true if the item in question needs to have updateInScene called because of changes in the entity virtual bool needsRenderUpdateFromEntity(const EntityItemPointer& entity) const override final { - if (Parent::needsRenderUpdateFromEntity(entity)) { - return true; - } - return needsRenderUpdateFromTypedEntity(_typedEntity); + return Parent::needsRenderUpdateFromEntity(entity) || needsRenderUpdateFromTypedEntity(_typedEntity); } virtual void doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) override final { diff --git a/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp b/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp index 9081d0727f..7a36ae2707 100644 --- a/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp @@ -39,6 +39,16 @@ bool GizmoEntityRenderer::isTransparent() const { return Parent::isTransparent() || ringTransparent; } +void GizmoEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { + void* key = (void*)this; + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { + withWriteLock([&] { + _renderTransform = getModelTransform(); + _renderTransform.postScale(entity->getScaledDimensions()); + }); + }); +} + void GizmoEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { bool dirty = false; RingGizmoPropertyGroup ringProperties = entity->getRingProperties(); @@ -186,15 +196,6 @@ void GizmoEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint } } } - - void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() { - withWriteLock([&] { - updateModelTransformAndBound(); - _renderTransform = getModelTransform(); - _renderTransform.postScale(entity->getScaledDimensions()); - }); - }); } Item::Bound GizmoEntityRenderer::getBound() { diff --git a/libraries/entities-renderer/src/RenderableGizmoEntityItem.h b/libraries/entities-renderer/src/RenderableGizmoEntityItem.h index c072f482cd..e3d84a0201 100644 --- a/libraries/entities-renderer/src/RenderableGizmoEntityItem.h +++ b/libraries/entities-renderer/src/RenderableGizmoEntityItem.h @@ -29,6 +29,7 @@ protected: bool isTransparent() const override; private: + virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity); virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; virtual void doRender(RenderArgs* args) override; diff --git a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp index 0b074f7a81..52900d0798 100644 --- a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp @@ -41,10 +41,9 @@ void GridEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen }); void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { withWriteLock([&] { _dimensions = entity->getScaledDimensions(); - updateModelTransformAndBound(); _renderTransform = getModelTransform(); }); }); diff --git a/libraries/entities-renderer/src/RenderableImageEntityItem.cpp b/libraries/entities-renderer/src/RenderableImageEntityItem.cpp index acdf5a35de..4d19a83ae6 100644 --- a/libraries/entities-renderer/src/RenderableImageEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableImageEntityItem.cpp @@ -30,11 +30,9 @@ bool ImageEntityRenderer::isTransparent() const { } bool ImageEntityRenderer::needsRenderUpdate() const { - bool textureLoadedChanged = resultWithReadLock([&] { - return (!_textureIsLoaded && _texture && _texture->isLoaded()); - }); - - if (textureLoadedChanged) { + if (resultWithReadLock([&] { + return !_textureIsLoaded; + })) { return true; } @@ -63,15 +61,15 @@ void ImageEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce _pulseProperties = entity->getPulseProperties(); _billboardMode = entity->getBillboardMode(); - if (!_textureIsLoaded && _texture && _texture->isLoaded()) { - _textureIsLoaded = true; + if (!_textureIsLoaded) { + emit requestRenderUpdate(); } + _textureIsLoaded = _texture && (_texture->isLoaded() || _texture->isFailed()); }); void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { withWriteLock([&] { - updateModelTransformAndBound(); _renderTransform = getModelTransform(); _renderTransform.postScale(entity->getScaledDimensions()); }); diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index f34eb85230..5ffb395302 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -64,6 +64,16 @@ ParticleEffectEntityRenderer::ParticleEffectEntityRenderer(const EntityItemPoint }); } +bool ParticleEffectEntityRenderer::needsRenderUpdate() const { + if (resultWithReadLock([&] { + return !_textureLoaded; + })) { + return true; + } + + return Parent::needsRenderUpdate(); +} + void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { auto newParticleProperties = entity->getParticleProperties(); if (!newParticleProperties.valid()) { @@ -102,6 +112,7 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi } withWriteLock([&] { + _textureLoaded = true; entity->setVisuallyReady(true); }); } else { @@ -111,20 +122,29 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi if (textureNeedsUpdate) { withWriteLock([&] { _networkTexture = DependencyManager::get()->getTexture(_particleProperties.textures); + _textureLoaded = false; + entity->setVisuallyReady(false); }); } - if (_networkTexture) { + if (!_textureLoaded) { + emit requestRenderUpdate(); + } + + bool textureLoaded = resultWithReadLock([&] { + return _networkTexture && (_networkTexture->isLoaded() || _networkTexture->isFailed()); + }); + if (textureLoaded) { withWriteLock([&] { - entity->setVisuallyReady(_networkTexture->isFailed() || _networkTexture->isLoaded()); + entity->setVisuallyReady(true); + _textureLoaded = true; }); } } void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] { withWriteLock([&] { - updateModelTransformAndBound(); _renderTransform = getModelTransform(); }); }); diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index cc907f2b1d..a89ab804fc 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -25,6 +25,7 @@ public: ParticleEffectEntityRenderer(const EntityItemPointer& entity); protected: + virtual bool needsRenderUpdate() const override; virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override; virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; @@ -111,6 +112,7 @@ private: GeometryResource::Pointer _geometryResource; NetworkTexturePointer _networkTexture; + bool _textureLoaded { false }; ScenePointer _scene; }; diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index e75f8593d6..a843083831 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -204,9 +204,8 @@ void PolyLineEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& bool geometryChanged = uvModeStretchChanged || pointsChanged || widthsChanged || normalsChanged || colorsChanged || textureChanged || faceCameraChanged; void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, geometryChanged] () { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, geometryChanged] { withWriteLock([&] { - updateModelTransformAndBound(); _renderTransform = getModelTransform(); if (geometryChanged) { diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index d5a0e22199..222b833be2 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -70,20 +70,18 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce }); void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { withWriteLock([&] { - auto entity = getEntity(); _position = entity->getWorldPosition(); _dimensions = entity->getUnscaledDimensions(); // get unscaled to avoid scaling twice _orientation = entity->getWorldOrientation(); - updateModelTransformAndBound(); _renderTransform = getModelTransform(); // contains parent scale, if this entity scales with its parent if (_shape == entity::Sphere) { _renderTransform.postScale(SPHERE_ENTITY_SCALE); } _renderTransform.postScale(_dimensions); - });; + }); }); } @@ -125,6 +123,7 @@ void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint auto materials = _materials.find("0"); if (materials != _materials.end()) { materials->second.setNeedsUpdate(true); + emit requestRenderUpdate(); } } }); diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index fbd10e2f5b..a5baad4841 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -102,10 +102,9 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { withWriteLock([&] { _dimensions = entity->getScaledDimensions(); - updateModelTransformAndBound(); _renderTransform = getModelTransform(); _renderTransform.postScale(_dimensions); }); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 1da4999bad..c818eaf237 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -236,11 +236,10 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene } void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] { withWriteLock([&] { glm::vec2 windowSize = getWindowSize(entity); _webSurface->resize(QSize(windowSize.x, windowSize.y)); - updateModelTransformAndBound(); _renderTransform = getModelTransform(); _renderTransform.setScale(1.0f); _renderTransform.postScale(entity->getScaledDimensions()); diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index bbb8c67ad1..d6c675e88c 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -255,14 +255,6 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen entity->setVisuallyReady(visuallyReady); } -void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { - if (entity->getShapeType() == SHAPE_TYPE_SPHERE) { - _renderTransform = getModelTransform(); - _renderTransform.postScale(SPHERE_ENTITY_SCALE); - } -} - - ItemKey ZoneEntityRenderer::getKey() { return ItemKey::Builder().withTypeMeta().withTagBits(getTagMask()).build(); } @@ -299,8 +291,6 @@ bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint return true; } - // FIXME: do we need to trigger an update when shapeType changes? see doRenderUpdateAsynchronousTyped - return false; } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 5fd9b87408..d4e3d16408 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -39,7 +39,6 @@ protected: virtual void doRender(RenderArgs* args) override; virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override; virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override; - virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; private: void updateKeyZoneItemFromEntity(const TypedEntityPointer& entity); diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 856468f2ec..a48b7377df 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -615,10 +615,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef _lastEdited = lastEditedFromBufferAdjusted; _lastEditedFromRemote = now; _lastEditedFromRemoteInRemoteTime = lastEditedFromBuffer; - - // TODO: only send this notification if something ACTUALLY changed (hint, we haven't yet parsed - // the properties out of the bitstream (see below)) - somethingChangedNotification(); // notify derived classes that something has changed } // last updated is stored as ByteCountCoded delta from lastEdited @@ -1569,7 +1565,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); #endif setLastEdited(now); - somethingChangedNotification(); // notify derived classes that something has changed if (getDirtyFlags() & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES)) { // anything that sets the transform or velocity must update _lastSimulated which is used // for kinematic extrapolation (e.g. we want to extrapolate forward from this moment @@ -1827,6 +1822,7 @@ void EntityItem::setPosition(const glm::vec3& value) { void EntityItem::setParentID(const QUuid& value) { QUuid oldParentID = getParentID(); if (oldParentID != value) { + _needsRenderUpdate = true; EntityTreePointer tree = getTree(); if (tree && !oldParentID.isNull()) { tree->removeFromChildrenOfAvatars(getThisPointer()); @@ -2993,10 +2989,15 @@ bool EntityItem::getCauterized() const { } void EntityItem::setCauterized(bool value) { + bool needsRenderUpdate = false; withWriteLock([&] { - _needsRenderUpdate |= _cauterized != value; + needsRenderUpdate = _cauterized != value; + _needsRenderUpdate |= needsRenderUpdate; _cauterized = value; }); + if (needsRenderUpdate) { + somethingChangedNotification(); + } } bool EntityItem::getIgnorePickIntersection() const { @@ -3031,10 +3032,15 @@ bool EntityItem::getCullWithParent() const { } void EntityItem::setCullWithParent(bool value) { + bool needsRenderUpdate = false; withWriteLock([&] { - _needsRenderUpdate |= _cullWithParent != value; + needsRenderUpdate = _cullWithParent != value; + _needsRenderUpdate |= needsRenderUpdate; _cullWithParent = value; }); + if (needsRenderUpdate) { + somethingChangedNotification(); + } } bool EntityItem::isChildOfMyAvatar() const { diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 14b8b259cc..5b0f1ad44c 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -574,8 +574,8 @@ public: bool stillHasMyGrab() const; - bool needsRenderUpdate() const { return resultWithReadLock([&] { return _needsRenderUpdate; }); } - void setNeedsRenderUpdate(bool needsRenderUpdate) { withWriteLock([&] { _needsRenderUpdate = needsRenderUpdate; }); } + bool needsRenderUpdate() const { return _needsRenderUpdate; } + void setNeedsRenderUpdate(bool needsRenderUpdate) { _needsRenderUpdate = needsRenderUpdate; } signals: void spaceUpdate(std::pair data); diff --git a/libraries/entities/src/GizmoEntityItem.cpp b/libraries/entities/src/GizmoEntityItem.cpp index a2fc691387..9d79e06534 100644 --- a/libraries/entities/src/GizmoEntityItem.cpp +++ b/libraries/entities/src/GizmoEntityItem.cpp @@ -58,6 +58,7 @@ bool GizmoEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/GridEntityItem.cpp b/libraries/entities/src/GridEntityItem.cpp index e45ab89b69..a1147b21df 100644 --- a/libraries/entities/src/GridEntityItem.cpp +++ b/libraries/entities/src/GridEntityItem.cpp @@ -70,6 +70,7 @@ bool GridEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/ImageEntityItem.cpp b/libraries/entities/src/ImageEntityItem.cpp index 2d942cc25d..c538ce619d 100644 --- a/libraries/entities/src/ImageEntityItem.cpp +++ b/libraries/entities/src/ImageEntityItem.cpp @@ -71,6 +71,7 @@ bool ImageEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index 2df2136639..11864f59da 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -55,21 +55,6 @@ void LightEntityItem::setUnscaledDimensions(const glm::vec3& value) { } } -void LightEntityItem::locationChanged(bool tellPhysics, bool tellChildren) { - EntityItem::locationChanged(tellPhysics, tellChildren); - withWriteLock([&] { - _needsRenderUpdate = true; - }); -} - -void LightEntityItem::dimensionsChanged() { - EntityItem::dimensionsChanged(); - withWriteLock([&] { - _needsRenderUpdate = true; - }); -} - - EntityItemProperties LightEntityItem::getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const { EntityItemProperties properties = EntityItem::getProperties(desiredProperties, allowEmptyDesiredProperties); // get the properties from our base class @@ -145,6 +130,7 @@ bool LightEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/LightEntityItem.h b/libraries/entities/src/LightEntityItem.h index 8194ff8308..533d2994d6 100644 --- a/libraries/entities/src/LightEntityItem.h +++ b/libraries/entities/src/LightEntityItem.h @@ -73,9 +73,6 @@ public: static bool getLightsArePickable() { return _lightsArePickable; } static void setLightsArePickable(bool value) { _lightsArePickable = value; } - - virtual void locationChanged(bool tellPhysics, bool tellChildren) override; - virtual void dimensionsChanged() override; virtual bool supportsDetailedIntersection() const override { return true; } virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, diff --git a/libraries/entities/src/LineEntityItem.cpp b/libraries/entities/src/LineEntityItem.cpp index 1cd09c1a0c..45cdf980a1 100644 --- a/libraries/entities/src/LineEntityItem.cpp +++ b/libraries/entities/src/LineEntityItem.cpp @@ -61,6 +61,7 @@ bool LineEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/MaterialEntityItem.cpp b/libraries/entities/src/MaterialEntityItem.cpp index 73bebfc403..11745c29ce 100644 --- a/libraries/entities/src/MaterialEntityItem.cpp +++ b/libraries/entities/src/MaterialEntityItem.cpp @@ -60,6 +60,7 @@ bool MaterialEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 0b6e62e89e..aa0c7304a7 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -111,6 +111,7 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index c20ae87276..082c4efb17 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -759,6 +759,7 @@ bool ParticleEffectEntityItem::setProperties(const EntityItemProperties& propert "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/PolyLineEntityItem.cpp b/libraries/entities/src/PolyLineEntityItem.cpp index fe14ba6925..fcd4b6d89d 100644 --- a/libraries/entities/src/PolyLineEntityItem.cpp +++ b/libraries/entities/src/PolyLineEntityItem.cpp @@ -77,6 +77,7 @@ bool PolyLineEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index b424ba137f..c31d0b81b3 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -130,6 +130,7 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 882ab26901..5b9c3e6881 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -186,6 +186,7 @@ bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties.getLastEdited()); + somethingChangedNotification(); } return somethingChanged; } diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index bcc2c0efed..9c53196247 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -109,6 +109,7 @@ bool TextEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index a62f599e4c..d8b2c8fc3d 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -92,6 +92,7 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 0771d9ad54..dc18c05ef3 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -88,6 +88,7 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) { "now=" << now << " getLastEdited()=" << getLastEdited(); } setLastEdited(properties._lastEdited); + somethingChangedNotification(); } return somethingChanged; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index d8172112ff..d3f2a04d24 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -282,11 +282,6 @@ void Model::setRenderItemsNeedUpdate() { emit requestRenderUpdate(); } -void Model::setPrimitiveMode(PrimitiveMode primitiveMode) { - _primitiveMode = primitiveMode; - setRenderItemsNeedUpdate(); -} - void Model::reset() { if (isLoaded()) { const HFMModel& hfmModel = getHFMModel(); @@ -888,6 +883,13 @@ void Model::updateRenderItemsKey(const render::ScenePointer& scene) { scene->enqueueTransaction(transaction); } +void Model::setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene) { + if (_primitiveMode != primitiveMode) { + _primitiveMode = primitiveMode; + updateRenderItemsKey(scene); + } +} + void Model::setVisibleInScene(bool visible, const render::ScenePointer& scene) { if (Model::isVisible() != visible) { auto keyBuilder = render::ItemKey::Builder(_renderItemKeyGlobalFlags); diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index b677861e9f..85aaa33bcb 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -129,6 +129,9 @@ public: bool isCauterized() const { return _cauterized; } void setCauterized(bool value, const render::ScenePointer& scene); + void setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene = nullptr); + PrimitiveMode getPrimitiveMode() const { return _primitiveMode; } + void setCullWithParent(bool value); // Access the current RenderItemKey Global Flags used by the model and applied to the render items representing the parts of the model. @@ -168,9 +171,6 @@ public: bool isLoaded() const { return (bool)_renderGeometry && _renderGeometry->isHFMModelLoaded(); } bool isAddedToScene() const { return _addedToScene; } - void setPrimitiveMode(PrimitiveMode primitiveMode); - PrimitiveMode getPrimitiveMode() const { return _primitiveMode; } - void reset(); void setSnapModelToRegistrationPoint(bool snapModelToRegistrationPoint, const glm::vec3& registrationPoint); From a8c8c775f3a6415bd4876e1ed5512664757b6186 Mon Sep 17 00:00:00 2001 From: Marcus Llewellyn Date: Sat, 18 Apr 2020 12:32:08 -0500 Subject: [PATCH 02/32] Re-enable and update code signing in installer template --- cmake/templates/NSIS.template.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index 0e4c2f3579..ded90494bf 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -204,13 +204,13 @@ ; The Inner invocation has written an uninstaller binary for us. ; We need to sign it if it's a production or PR build. - ; !if @PRODUCTION_BUILD@ == 1 - ; !if @BYPASS_SIGNING@ == 1 - ; !warning "BYPASS_SIGNING set - installer will not be signed" - ; !else - ; !system '"@SIGNTOOL_EXECUTABLE@" sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 $%TEMP%\@UNINSTALLER_NAME@' = 0 - ; !endif - ; !endif + !if @PRODUCTION_BUILD@ == 1 + !if @BYPASS_SIGNING@ == 1 + !warning "BYPASS_SIGNING set - installer will not be signed" + !else + !system '"@SIGNTOOL_EXECUTABLE@" sign /fd sha256 /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://timestamp.comodoca.com?td=sha256 /td SHA256 $%TEMP%\@UNINSTALLER_NAME@' = 0 + !endif + !endif ; Good. Now we can carry on writing the real installer. From 7c264e7d852e58d52e389bf15a630c5f2757c956 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Mon, 15 Jun 2020 22:51:51 -0400 Subject: [PATCH 03/32] First pass at adding domain metadata exporter. --- .../resources/describe-settings.json | 26 +++++++++++++++- .../resources/metadata_exporter/index.html | 14 +++++++++ domain-server/src/DomainMetadata.cpp | 19 ++++++++++++ domain-server/src/DomainMetadata.h | 4 +++ domain-server/src/DomainServer.cpp | 31 +++++++++++++++++-- domain-server/src/DomainServer.h | 4 ++- libraries/networking/src/DomainHandler.h | 9 +++++- 7 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 domain-server/resources/metadata_exporter/index.html diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 284dd344e7..6dd8e64981 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -54,7 +54,23 @@ "default": true, "type": "checkbox", "advanced": true - } + }, + { + "name": "enable_metadata_exporter", + "label": "Enable Metadata HTTP Availability", + "help": "Allows your domain's metadata to be accessible on the public internet via direct HTTP connection to the domain server.", + "default": true, + "type": "checkbox", + "advanced": true + }, + { + "name": "metadata_exporter_port", + "label": "Metadata Exporter HTTP Port", + "help": "This is the port where the Metaverse exporter accepts connections. It listens both on IPv4 and IPv6 and can be accessed remotely, so you should make sure to restrict access with a firewall as needed.", + "default": "9704", + "type": "int", + "advanced": true + }, ] }, { @@ -210,6 +226,14 @@ "help": "Must match the password entered above for change to be saved.", "value-hidden": true }, + { + "name": "approved_safe_urls", + "label": "Approved Script and QML URLs", + "help": "These URLs will be sent to the Interface as safe URLs to allow through the whitelist if the Interface has this security option enabled.", + "placeholder": "0", + "default": "1", + "advanced": false + }, { "name": "maximum_user_capacity", "label": "Maximum User Capacity", diff --git a/domain-server/resources/metadata_exporter/index.html b/domain-server/resources/metadata_exporter/index.html new file mode 100644 index 0000000000..acc7aae23a --- /dev/null +++ b/domain-server/resources/metadata_exporter/index.html @@ -0,0 +1,14 @@ + + + Vircadia Metadata exporter + + + +

Vircadia Metadata exporter

+ +

If you can see this page, this means that your domain's metadata is available to be exported.

+

+ Metadata +

+ + diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 2540858742..26dbc16184 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -4,6 +4,7 @@ // // Created by Zach Pomerantz on 5/25/2016. // Copyright 2016 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -14,10 +15,13 @@ #include #include #include +#include #include "DomainServer.h" #include "DomainServerNodeData.h" +Q_LOGGING_CATEGORY(domain_metadata_exporter, "hifi.domain_server.metadata_exporter") + const QString DomainMetadata::USERS = "users"; const QString DomainMetadata::Users::NUM_TOTAL = "num_users"; const QString DomainMetadata::Users::NUM_ANON = "num_anon_users"; @@ -215,3 +219,18 @@ void DomainMetadata::sendDescriptors() { #endif } } + +bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { + const QString URI_METADATA = "/metadata"; + const QString EXPORTER_MIME_TYPE = "text/plain"; + + qCDebug(domain_metadata_exporter) << "Request on URL " << url; + + if (url.path() == URI_METADATA) { + QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); + connection->respond(HTTPConnection::StatusCode200, domainMetadataJSON.toUtf8(), qPrintable(EXPORTER_MIME_TYPE)); + return true; + } + + return false; +} diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index ed4e324464..85422692b9 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -15,6 +15,7 @@ #include #include +#include "HTTPManager.h" class DomainMetadata : public QObject { Q_OBJECT @@ -43,6 +44,9 @@ public: DomainMetadata(QObject* domainServer); DomainMetadata() = delete; + + bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override; + bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) override; // Get cached metadata QJsonObject get(); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 49b319e31d..1f7df37fc6 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -70,7 +70,6 @@ const QString DomainServer::REPLACEMENT_FILE_EXTENSION = ".replace"; const int MIN_PORT = 1; const int MAX_PORT = 65535; - int const DomainServer::EXIT_CODE_REBOOT = 234923; #if USE_STABLE_GLOBAL_SERVICES @@ -334,6 +333,7 @@ DomainServer::DomainServer(int argc, char* argv[]) : _nodePingMonitorTimer->start(NODE_PING_MONITOR_INTERVAL_MSECS); initializeExporter(); + initializeMetadataExporter(); } void DomainServer::parseCommandLine(int argc, char* argv[]) { @@ -427,6 +427,11 @@ DomainServer::~DomainServer() { _contentManager->aboutToFinish(); _contentManager->terminate(); } + + if (_httpMetadataExporterManager) { + _httpMetadataExporterManager->close(); + delete _httpMetadataExporterManager; + } if (_httpExporterManager) { _httpExporterManager->close(); @@ -3045,8 +3050,7 @@ void DomainServer::updateUpstreamNodes() { updateReplicationNodes(Upstream); } -void DomainServer::initializeExporter() -{ +void DomainServer::initializeExporter() { static const QString ENABLE_EXPORTER = "monitoring.enable_prometheus_exporter"; static const QString EXPORTER_PORT = "monitoring.prometheus_exporter_port"; @@ -3066,6 +3070,27 @@ void DomainServer::initializeExporter() } } +void DomainServer::initializeMetadataExporter() +{ + static const QString ENABLE_EXPORTER = "metaverse.enable_metadata_exporter"; + static const QString EXPORTER_PORT = "metaverse.metadata_exporter_port"; + + bool isMetadataExporterEnabled = _settingsManager.valueOrDefaultValueForKeyPath(ENABLE_EXPORTER).toBool(); + int metadataExporterPort = _settingsManager.valueOrDefaultValueForKeyPath(EXPORTER_PORT).toInt(); + + if (exporterPort < MIN_PORT || exporterPort > MAX_PORT) { + qCWarning(domain_server) << "Metadata exporter port " << metadataExporterPort << " is out of range."; + isMetadataExporterEnabled = false; + } + + qCDebug(domain_server) << "Setting up Metadata exporter."; + + if (isMetadataExporterEnabled && !_httpMetadataExporterManager) { + qCInfo(domain_server) << "Starting Metadata exporter on port " << metadataExporterPort; + _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), &_metadata); + } +} + void DomainServer::updateReplicatedNodes() { // Make sure we have downstream nodes in our list static const QString REPLICATED_USERS_KEY = "users"; diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 7c0fa5fb15..0334404863 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -73,7 +73,6 @@ public: static int const EXIT_CODE_REBOOT; bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override; - bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) override; static const QString REPLACEMENT_FILE_EXTENSION; @@ -140,6 +139,7 @@ private slots: void updateDownstreamNodes(); void updateUpstreamNodes(); void initializeExporter(); + void initializeMetadataExporter(); void tokenGrantFinished(); void profileRequestFinished(); @@ -240,6 +240,8 @@ private: HTTPManager _httpManager; HTTPManager* _httpExporterManager { nullptr }; + HTTPManager* _httpMetadataExporterManager; + std::unique_ptr _httpsManager; QHash _allAssignments; diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index 178c56c34a..50ebc1edbc 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -72,7 +72,14 @@ const quint16 DOMAIN_SERVER_EXPORTER_PORT = .value("VIRCADIA_DOMAIN_SERVER_EXPORTER_PORT") .toUInt() : 9703; - + +const quint16 DOMAIN_SERVER_METADATA_EXPORTER_PORT = + QProcessEnvironment::systemEnvironment() + .contains("DOMAIN_SERVER_METADATA_EXPORTER_PORT") + ? QProcessEnvironment::systemEnvironment() + .value("DOMAIN_SERVER_METADATA_EXPORTER_PORT") + .toUInt() + : 9704; const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5; From 269f0ac6002cd0933d9b9973285b3449982fcb31 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Mon, 15 Jun 2020 23:49:54 -0400 Subject: [PATCH 04/32] Latest condition. --- domain-server/src/DomainMetadata.cpp | 5 +++-- domain-server/src/DomainMetadata.h | 7 ++++--- domain-server/src/DomainServer.cpp | 7 +++---- domain-server/src/DomainServer.h | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 26dbc16184..f9f79d0846 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -10,6 +10,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html #include "DomainMetadata.h" +#include "HTTPConnection.h" #include #include @@ -220,14 +221,14 @@ void DomainMetadata::sendDescriptors() { } } -bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { +bool DomainMetadataExporter::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { + QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; const QString EXPORTER_MIME_TYPE = "text/plain"; qCDebug(domain_metadata_exporter) << "Request on URL " << url; if (url.path() == URI_METADATA) { - QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); connection->respond(HTTPConnection::StatusCode200, domainMetadataJSON.toUtf8(), qPrintable(EXPORTER_MIME_TYPE)); return true; } diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index 85422692b9..eade025a0a 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -17,6 +17,10 @@ #include #include "HTTPManager.h" +class DomainMetadataExporter : public HTTPRequestHandler { + bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); +}; + class DomainMetadata : public QObject { Q_OBJECT @@ -45,9 +49,6 @@ public: DomainMetadata(QObject* domainServer); DomainMetadata() = delete; - bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override; - bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) override; - // Get cached metadata QJsonObject get(); QJsonObject get(const QString& group); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 1f7df37fc6..d244fc99c6 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -3070,15 +3070,14 @@ void DomainServer::initializeExporter() { } } -void DomainServer::initializeMetadataExporter() -{ +void DomainServer::initializeMetadataExporter() { static const QString ENABLE_EXPORTER = "metaverse.enable_metadata_exporter"; static const QString EXPORTER_PORT = "metaverse.metadata_exporter_port"; bool isMetadataExporterEnabled = _settingsManager.valueOrDefaultValueForKeyPath(ENABLE_EXPORTER).toBool(); int metadataExporterPort = _settingsManager.valueOrDefaultValueForKeyPath(EXPORTER_PORT).toInt(); - if (exporterPort < MIN_PORT || exporterPort > MAX_PORT) { + if (metadataExporterPort < MIN_PORT || metadataExporterPort > MAX_PORT) { qCWarning(domain_server) << "Metadata exporter port " << metadataExporterPort << " is out of range."; isMetadataExporterEnabled = false; } @@ -3087,7 +3086,7 @@ void DomainServer::initializeMetadataExporter() if (isMetadataExporterEnabled && !_httpMetadataExporterManager) { qCInfo(domain_server) << "Starting Metadata exporter on port " << metadataExporterPort; - _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), &_metadata); + _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), &_metadataExporter); } } diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 0334404863..34555861af 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -73,6 +73,7 @@ public: static int const EXIT_CODE_REBOOT; bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override; + bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) override; static const QString REPLACEMENT_FILE_EXTENSION; @@ -237,6 +238,7 @@ private: DomainGatekeeper _gatekeeper; DomainServerExporter _exporter; + DomainMetadata _metadataExporter; HTTPManager _httpManager; HTTPManager* _httpExporterManager { nullptr }; From 19ff5bfd4f6ffa817bf64e0f477b247f50a630d7 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 16 Jun 2020 00:53:06 -0400 Subject: [PATCH 05/32] uno error. --- domain-server/src/DomainMetadata.cpp | 2 +- domain-server/src/DomainMetadata.h | 8 +++----- domain-server/src/DomainServer.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index f9f79d0846..b920ab022b 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -221,7 +221,7 @@ void DomainMetadata::sendDescriptors() { } } -bool DomainMetadataExporter::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { +bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; const QString EXPORTER_MIME_TYPE = "text/plain"; diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index eade025a0a..4c4f8ecf3c 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -17,11 +17,7 @@ #include #include "HTTPManager.h" -class DomainMetadataExporter : public HTTPRequestHandler { - bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); -}; - -class DomainMetadata : public QObject { +class DomainMetadata : public QObject, public HTTPRequestHandler { Q_OBJECT public: @@ -53,6 +49,8 @@ public: QJsonObject get(); QJsonObject get(const QString& group); + bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); + public slots: void descriptorsChanged(); void securityChanged(bool send); diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 34555861af..a4a47f5f46 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -242,7 +242,7 @@ private: HTTPManager _httpManager; HTTPManager* _httpExporterManager { nullptr }; - HTTPManager* _httpMetadataExporterManager; + HTTPManager* _httpMetadataExporterManager { nullptr }; std::unique_ptr _httpsManager; From 8052259489d3a3df6af899f4397d058f70ea2b50 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 17 Jun 2020 17:47:50 -0700 Subject: [PATCH 06/32] get domainmetadata stuff compiling --- domain-server/src/DomainMetadata.cpp | 13 +------------ domain-server/src/DomainMetadata.h | 5 ++--- domain-server/src/DomainServer.cpp | 11 +++++++++-- domain-server/src/DomainServer.h | 1 - 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index b920ab022b..262d4ea0f1 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -54,22 +54,11 @@ const QString DomainMetadata::Descriptors::TAGS = "tags"; // // it is meant to be sent to and consumed by an external API -DomainMetadata::DomainMetadata(QObject* domainServer) : QObject(domainServer) { +DomainMetadata::DomainMetadata() { // set up the structure necessary for casting during parsing _metadata[USERS] = QVariantMap {}; _metadata[DESCRIPTORS] = QVariantMap {}; - assert(dynamic_cast(domainServer)); - DomainServer* server = static_cast(domainServer); - - // update the metadata when a user (dis)connects - connect(server, &DomainServer::userConnected, this, &DomainMetadata::usersChanged); - connect(server, &DomainServer::userDisconnected, this, &DomainMetadata::usersChanged); - - // update the metadata when security changes - connect(&server->_settingsManager, &DomainServerSettingsManager::updateNodePermissions, - this, static_cast(&DomainMetadata::securityChanged)); - // initialize the descriptors securityChanged(false); descriptorsChanged(); diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index 4c4f8ecf3c..ba6b1b88a6 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -42,8 +42,8 @@ public: static const QString TAGS; }; - DomainMetadata(QObject* domainServer); - DomainMetadata() = delete; + DomainMetadata(); + ~DomainMetadata() = default; // Get cached metadata QJsonObject get(); @@ -54,7 +54,6 @@ public: public slots: void descriptorsChanged(); void securityChanged(bool send); - void securityChanged() { securityChanged(true); } void usersChanged(); protected: diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index d244fc99c6..7ff0459f21 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -268,10 +268,17 @@ DomainServer::DomainServer(int argc, char* argv[]) : } // send signal to DomainMetadata when descriptors changed - _metadata = new DomainMetadata(this); + _metadata = new DomainMetadata(); connect(&_settingsManager, &DomainServerSettingsManager::settingsUpdated, _metadata, &DomainMetadata::descriptorsChanged); + // update the metadata when a user (dis)connects + connect(this, &DomainServer::userConnected, _metadata, &DomainMetadata::usersChanged); + connect(this, &DomainServer::userDisconnected, _metadata, &DomainMetadata::usersChanged); + + // update the metadata when security changes + connect(&_settingsManager, &DomainServerSettingsManager::updateNodePermissions, [this] { _metadata->securityChanged(true); }); + qDebug() << "domain-server is running"; static const QString AC_SUBNET_WHITELIST_SETTING_PATH = "security.ac_subnet_whitelist"; @@ -3086,7 +3093,7 @@ void DomainServer::initializeMetadataExporter() { if (isMetadataExporterEnabled && !_httpMetadataExporterManager) { qCInfo(domain_server) << "Starting Metadata exporter on port " << metadataExporterPort; - _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), &_metadataExporter); + _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), _metadata); } } diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index a4a47f5f46..c27500d5ce 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -238,7 +238,6 @@ private: DomainGatekeeper _gatekeeper; DomainServerExporter _exporter; - DomainMetadata _metadataExporter; HTTPManager _httpManager; HTTPManager* _httpExporterManager { nullptr }; From 1da1dd20c383cbf28a53360b1a6301403e3285a4 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 17 Jun 2020 20:18:05 -0700 Subject: [PATCH 07/32] try to fix crash --- domain-server/src/DomainMetadata.cpp | 2 +- domain-server/src/DomainMetadata.h | 2 +- domain-server/src/DomainServer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 262d4ea0f1..755f3ec148 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -54,7 +54,7 @@ const QString DomainMetadata::Descriptors::TAGS = "tags"; // // it is meant to be sent to and consumed by an external API -DomainMetadata::DomainMetadata() { +DomainMetadata::DomainMetadata(QObject* domainServer) : QObject(domainServer) { // set up the structure necessary for casting during parsing _metadata[USERS] = QVariantMap {}; _metadata[DESCRIPTORS] = QVariantMap {}; diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index ba6b1b88a6..6fae29248d 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -42,7 +42,7 @@ public: static const QString TAGS; }; - DomainMetadata(); + DomainMetadata(QObject* domainServer); ~DomainMetadata() = default; // Get cached metadata diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 7ff0459f21..3f70d95421 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -268,7 +268,7 @@ DomainServer::DomainServer(int argc, char* argv[]) : } // send signal to DomainMetadata when descriptors changed - _metadata = new DomainMetadata(); + _metadata = new DomainMetadata(this); connect(&_settingsManager, &DomainServerSettingsManager::settingsUpdated, _metadata, &DomainMetadata::descriptorsChanged); From f712fc7735b7861851e0180463fd18203d669661 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Thu, 18 Jun 2020 16:43:59 -0400 Subject: [PATCH 08/32] Export to JSON, JSON formatting. --- domain-server/resources/describe-settings.json | 16 ++++++++-------- domain-server/src/DomainMetadata.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 6dd8e64981..be40611f14 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -54,7 +54,7 @@ "default": true, "type": "checkbox", "advanced": true - }, + }, { "name": "enable_metadata_exporter", "label": "Enable Metadata HTTP Availability", @@ -64,13 +64,13 @@ "advanced": true }, { - "name": "metadata_exporter_port", - "label": "Metadata Exporter HTTP Port", - "help": "This is the port where the Metaverse exporter accepts connections. It listens both on IPv4 and IPv6 and can be accessed remotely, so you should make sure to restrict access with a firewall as needed.", - "default": "9704", - "type": "int", - "advanced": true - }, + "name": "metadata_exporter_port", + "label": "Metadata Exporter HTTP Port", + "help": "This is the port where the Metaverse exporter accepts connections. It listens both on IPv4 and IPv6 and can be accessed remotely, so you should make sure to restrict access with a firewall as needed.", + "default": "9704", + "type": "int", + "advanced": true + } ] }, { diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 755f3ec148..e30cefa1db 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -213,7 +213,7 @@ void DomainMetadata::sendDescriptors() { bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; - const QString EXPORTER_MIME_TYPE = "text/plain"; + const QString EXPORTER_MIME_TYPE = "application/json"; qCDebug(domain_metadata_exporter) << "Request on URL " << url; From f1d731da11655f1b64b2950608e90d9c012afb5b Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 30 Jun 2020 00:25:27 -0400 Subject: [PATCH 09/32] Add users to the export. --- domain-server/src/DomainMetadata.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index e30cefa1db..f8d8d2d989 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -211,7 +211,10 @@ void DomainMetadata::sendDescriptors() { } bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { - QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); + QJsonArray metadataArray; + metadataArray << get(DESCRIPTORS); + metadataArray << get(USERS); + QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(metadataArray).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; const QString EXPORTER_MIME_TYPE = "application/json"; From a7861855a7428455cca39b5e783bad0b9ee41cea Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Thu, 16 Jul 2020 14:34:02 -0700 Subject: [PATCH 10/32] properties update over wire --- libraries/entities/src/EntityItem.cpp | 4 ++++ libraries/entities/src/GizmoEntityItem.cpp | 15 ++---------- libraries/entities/src/GizmoEntityItem.h | 2 +- libraries/entities/src/GridEntityItem.cpp | 15 ++---------- libraries/entities/src/GridEntityItem.h | 2 +- libraries/entities/src/ImageEntityItem.cpp | 15 ++---------- libraries/entities/src/ImageEntityItem.h | 2 +- libraries/entities/src/LightEntityItem.cpp | 19 +-------------- libraries/entities/src/LightEntityItem.h | 4 +--- libraries/entities/src/LineEntityItem.cpp | 14 +---------- libraries/entities/src/LineEntityItem.h | 2 +- libraries/entities/src/MaterialEntityItem.cpp | 15 ++---------- libraries/entities/src/MaterialEntityItem.h | 2 +- libraries/entities/src/ModelEntityItem.cpp | 15 +----------- libraries/entities/src/ModelEntityItem.h | 2 +- .../entities/src/ParticleEffectEntityItem.cpp | 15 ++---------- .../entities/src/ParticleEffectEntityItem.h | 2 +- libraries/entities/src/PolyLineEntityItem.cpp | 14 +---------- libraries/entities/src/PolyLineEntityItem.h | 2 +- libraries/entities/src/PolyVoxEntityItem.cpp | 16 +++---------- libraries/entities/src/PolyVoxEntityItem.h | 2 +- libraries/entities/src/ShapeEntityItem.cpp | 15 ++---------- libraries/entities/src/ShapeEntityItem.h | 2 +- libraries/entities/src/TextEntityItem.cpp | 15 +----------- libraries/entities/src/TextEntityItem.h | 2 +- libraries/entities/src/WebEntityItem.cpp | 15 +----------- libraries/entities/src/WebEntityItem.h | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 23 ++----------------- libraries/entities/src/ZoneEntityItem.h | 1 - 29 files changed, 40 insertions(+), 214 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 69f1ed2aee..faf29ec20b 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1001,6 +1001,9 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef element->getTree()->trackIncomingEntityLastEdited(lastEditedFromBufferAdjusted, bytesRead); } + if (somethingChanged) { + somethingChangedNotification(); + } return bytesRead; } @@ -1576,6 +1579,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { // when position and/or velocity was changed). _lastSimulated = now; } + somethingChangedNotification(); } // timestamps diff --git a/libraries/entities/src/GizmoEntityItem.cpp b/libraries/entities/src/GizmoEntityItem.cpp index 9d79e06534..47c9afd168 100644 --- a/libraries/entities/src/GizmoEntityItem.cpp +++ b/libraries/entities/src/GizmoEntityItem.cpp @@ -39,8 +39,8 @@ EntityItemProperties GizmoEntityItem::getProperties(const EntityPropertyFlags& d return properties; } -bool GizmoEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool GizmoEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(gizmoType, setGizmoType); withWriteLock([&] { @@ -49,17 +49,6 @@ bool GizmoEntityItem::setProperties(const EntityItemProperties& properties) { _needsRenderUpdate |= ringPropertiesChanged; }); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "GizmoEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/GizmoEntityItem.h b/libraries/entities/src/GizmoEntityItem.h index aa338355b8..37a802387d 100644 --- a/libraries/entities/src/GizmoEntityItem.h +++ b/libraries/entities/src/GizmoEntityItem.h @@ -26,7 +26,7 @@ public: // methods for getting/setting all properties of an entity EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - bool setProperties(const EntityItemProperties& properties) override; + bool setSubClassProperties(const EntityItemProperties& properties) override; EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/GridEntityItem.cpp b/libraries/entities/src/GridEntityItem.cpp index a1147b21df..e635511bfc 100644 --- a/libraries/entities/src/GridEntityItem.cpp +++ b/libraries/entities/src/GridEntityItem.cpp @@ -46,8 +46,8 @@ EntityItemProperties GridEntityItem::getProperties(const EntityPropertyFlags& de return properties; } -bool GridEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool GridEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha); @@ -61,17 +61,6 @@ bool GridEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(majorGridEvery, setMajorGridEvery); SET_ENTITY_PROPERTY_FROM_PROPERTIES(minorGridEvery, setMinorGridEvery); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "GridEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/GridEntityItem.h b/libraries/entities/src/GridEntityItem.h index 165d9b50f5..7dc7a475b2 100644 --- a/libraries/entities/src/GridEntityItem.h +++ b/libraries/entities/src/GridEntityItem.h @@ -26,7 +26,7 @@ public: // methods for getting/setting all properties of an entity EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - bool setProperties(const EntityItemProperties& properties) override; + bool setSubClassProperties(const EntityItemProperties& properties) override; EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/ImageEntityItem.cpp b/libraries/entities/src/ImageEntityItem.cpp index c538ce619d..6a8c457b0a 100644 --- a/libraries/entities/src/ImageEntityItem.cpp +++ b/libraries/entities/src/ImageEntityItem.cpp @@ -45,8 +45,8 @@ EntityItemProperties ImageEntityItem::getProperties(const EntityPropertyFlags& d return properties; } -bool ImageEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool ImageEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha); @@ -62,17 +62,6 @@ bool ImageEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(keepAspectRatio, setKeepAspectRatio); SET_ENTITY_PROPERTY_FROM_PROPERTIES(subImage, setSubImage); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "ImageEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/ImageEntityItem.h b/libraries/entities/src/ImageEntityItem.h index a1be5a0554..bca67dc738 100644 --- a/libraries/entities/src/ImageEntityItem.h +++ b/libraries/entities/src/ImageEntityItem.h @@ -26,7 +26,7 @@ public: // methods for getting/setting all properties of an entity EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - bool setProperties(const EntityItemProperties& properties) override; + bool setSubClassProperties(const EntityItemProperties& properties) override; EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index 11864f59da..715b457bde 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -119,24 +119,8 @@ void LightEntityItem::setCutoff(float value) { } } -bool LightEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "LightEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } - return somethingChanged; -} - bool LightEntityItem::setSubClassProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setSubClassProperties(properties); // set the properties in our base class + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight); @@ -148,7 +132,6 @@ bool LightEntityItem::setSubClassProperties(const EntityItemProperties& properti return somethingChanged; } - int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData, diff --git a/libraries/entities/src/LightEntityItem.h b/libraries/entities/src/LightEntityItem.h index 533d2994d6..5245770ec8 100644 --- a/libraries/entities/src/LightEntityItem.h +++ b/libraries/entities/src/LightEntityItem.h @@ -33,11 +33,9 @@ public: /// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately virtual void setUnscaledDimensions(const glm::vec3& value) override; - virtual bool setProperties(const EntityItemProperties& properties) override; - virtual bool setSubClassProperties(const EntityItemProperties& properties) override; - // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/LineEntityItem.cpp b/libraries/entities/src/LineEntityItem.cpp index 45cdf980a1..f3304e716f 100644 --- a/libraries/entities/src/LineEntityItem.cpp +++ b/libraries/entities/src/LineEntityItem.cpp @@ -45,24 +45,12 @@ EntityItemProperties LineEntityItem::getProperties(const EntityPropertyFlags& de return properties; } -bool LineEntityItem::setProperties(const EntityItemProperties& properties) { +bool LineEntityItem::setSubClassProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(linePoints, setLinePoints); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "LineEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/LineEntityItem.h b/libraries/entities/src/LineEntityItem.h index ee473225fe..38e526204e 100644 --- a/libraries/entities/src/LineEntityItem.h +++ b/libraries/entities/src/LineEntityItem.h @@ -24,7 +24,7 @@ class LineEntityItem : public EntityItem { // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/MaterialEntityItem.cpp b/libraries/entities/src/MaterialEntityItem.cpp index 11745c29ce..dcdd80cb48 100644 --- a/libraries/entities/src/MaterialEntityItem.cpp +++ b/libraries/entities/src/MaterialEntityItem.cpp @@ -38,8 +38,8 @@ EntityItemProperties MaterialEntityItem::getProperties(const EntityPropertyFlags return properties; } -bool MaterialEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool MaterialEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(materialURL, setMaterialURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(materialMappingMode, setMaterialMappingMode); @@ -51,17 +51,6 @@ bool MaterialEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(materialData, setMaterialData); SET_ENTITY_PROPERTY_FROM_PROPERTIES(materialRepeat, setMaterialRepeat); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "MaterialEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/MaterialEntityItem.h b/libraries/entities/src/MaterialEntityItem.h index d8de8c3bc6..76cfbfa9dc 100644 --- a/libraries/entities/src/MaterialEntityItem.h +++ b/libraries/entities/src/MaterialEntityItem.h @@ -24,7 +24,7 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 6818c5cb6a..38e7ad9c3a 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -79,9 +79,8 @@ EntityItemProperties ModelEntityItem::getProperties(const EntityPropertyFlags& d return properties; } -bool ModelEntityItem::setProperties(const EntityItemProperties& properties) { +bool ModelEntityItem::setSubClassProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType); SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); @@ -105,18 +104,6 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties) { somethingChanged = somethingChanged || somethingChangedInAnimations; }); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "ModelEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } - return somethingChanged; } diff --git a/libraries/entities/src/ModelEntityItem.h b/libraries/entities/src/ModelEntityItem.h index c331a94adf..795630a72a 100644 --- a/libraries/entities/src/ModelEntityItem.h +++ b/libraries/entities/src/ModelEntityItem.h @@ -29,7 +29,7 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 082c4efb17..5ccc209a54 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -696,8 +696,8 @@ EntityItemProperties ParticleEffectEntityItem::getProperties(const EntityPropert return properties; } -bool ParticleEffectEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool ParticleEffectEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType); SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); @@ -750,17 +750,6 @@ bool ParticleEffectEntityItem::setProperties(const EntityItemProperties& propert SET_ENTITY_PROPERTY_FROM_PROPERTIES(spinFinish, setSpinFinish); SET_ENTITY_PROPERTY_FROM_PROPERTIES(rotateWithEntity, setRotateWithEntity); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "ParticleEffectEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index 358e5a6b6d..c96323fc9a 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -214,7 +214,7 @@ public: // methods for getting/setting all properties of this entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/PolyLineEntityItem.cpp b/libraries/entities/src/PolyLineEntityItem.cpp index fcd4b6d89d..909bc132fb 100644 --- a/libraries/entities/src/PolyLineEntityItem.cpp +++ b/libraries/entities/src/PolyLineEntityItem.cpp @@ -53,9 +53,8 @@ EntityItemProperties PolyLineEntityItem::getProperties(const EntityPropertyFlags return properties; } -bool PolyLineEntityItem::setProperties(const EntityItemProperties& properties) { +bool PolyLineEntityItem::setSubClassProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures); @@ -68,17 +67,6 @@ bool PolyLineEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(glow, setGlow); SET_ENTITY_PROPERTY_FROM_PROPERTIES(faceCamera, setFaceCamera); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "PolyLineEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/PolyLineEntityItem.h b/libraries/entities/src/PolyLineEntityItem.h index e68666d75e..8fb7831c6a 100644 --- a/libraries/entities/src/PolyLineEntityItem.h +++ b/libraries/entities/src/PolyLineEntityItem.h @@ -24,7 +24,7 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index c31d0b81b3..dd55ca898b 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -106,8 +106,9 @@ EntityItemProperties PolyVoxEntityItem::getProperties(const EntityPropertyFlags& return properties; } -bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool PolyVoxEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; + SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelVolumeSize, setVoxelVolumeSize); SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelData, setVoxelData); SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelSurfaceStyle, setVoxelSurfaceStyle); @@ -121,17 +122,6 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(yPNeighborID, setYPNeighborID); SET_ENTITY_PROPERTY_FROM_PROPERTIES(zPNeighborID, setZPNeighborID); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "PolyVoxEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/PolyVoxEntityItem.h b/libraries/entities/src/PolyVoxEntityItem.h index 9d02cbcdad..f994fcd37c 100644 --- a/libraries/entities/src/PolyVoxEntityItem.h +++ b/libraries/entities/src/PolyVoxEntityItem.h @@ -24,7 +24,7 @@ class PolyVoxEntityItem : public EntityItem { // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/ShapeEntityItem.cpp b/libraries/entities/src/ShapeEntityItem.cpp index 5b9c3e6881..5e140665b3 100644 --- a/libraries/entities/src/ShapeEntityItem.cpp +++ b/libraries/entities/src/ShapeEntityItem.cpp @@ -165,8 +165,8 @@ entity::Shape ShapeEntityItem::getShape() const { }); } -bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class +bool ShapeEntityItem::setSubClassProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha); @@ -177,17 +177,6 @@ bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) { }); SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "ShapeEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties.getLastEdited()); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/ShapeEntityItem.h b/libraries/entities/src/ShapeEntityItem.h index 43c2ce2a1f..7320867430 100644 --- a/libraries/entities/src/ShapeEntityItem.h +++ b/libraries/entities/src/ShapeEntityItem.h @@ -55,7 +55,7 @@ public: // methods for getting/setting all properties of an entity EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - bool setProperties(const EntityItemProperties& properties) override; + bool setSubClassProperties(const EntityItemProperties& properties) override; EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 9c53196247..a996319463 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -73,9 +73,8 @@ EntityItemProperties TextEntityItem::getProperties(const EntityPropertyFlags& de return properties; } -bool TextEntityItem::setProperties(const EntityItemProperties& properties) { +bool TextEntityItem::setSubClassProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class withWriteLock([&] { bool pulsePropertiesChanged = _pulseProperties.setProperties(properties); @@ -99,18 +98,6 @@ bool TextEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(textEffect, setTextEffect); SET_ENTITY_PROPERTY_FROM_PROPERTIES(textEffectColor, setTextEffectColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(textEffectThickness, setTextEffectThickness); - - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "TextEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } return somethingChanged; } diff --git a/libraries/entities/src/TextEntityItem.h b/libraries/entities/src/TextEntityItem.h index 5e3f6d7c02..91496708f6 100644 --- a/libraries/entities/src/TextEntityItem.h +++ b/libraries/entities/src/TextEntityItem.h @@ -31,7 +31,7 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index d8b2c8fc3d..73e0096e76 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -63,9 +63,8 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des return properties; } -bool WebEntityItem::setProperties(const EntityItemProperties& properties) { +bool WebEntityItem::setSubClassProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha); @@ -83,18 +82,6 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight); - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "WebEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } - return somethingChanged; } diff --git a/libraries/entities/src/WebEntityItem.h b/libraries/entities/src/WebEntityItem.h index b61e2b124f..5ab53d6ef8 100644 --- a/libraries/entities/src/WebEntityItem.h +++ b/libraries/entities/src/WebEntityItem.h @@ -27,7 +27,7 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; + virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 842651fcac..88466caff0 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -76,27 +76,8 @@ EntityItemProperties ZoneEntityItem::getProperties(const EntityPropertyFlags& de return properties; } -bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) { - bool somethingChanged = false; - somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class - - if (somethingChanged) { - bool wantDebug = false; - if (wantDebug) { - uint64_t now = usecTimestampNow(); - int elapsed = now - getLastEdited(); - qCDebug(entities) << "ZoneEntityItem::setProperties() AFTER update... edited AGO=" << elapsed << - "now=" << now << " getLastEdited()=" << getLastEdited(); - } - setLastEdited(properties._lastEdited); - somethingChangedNotification(); - } - - return somethingChanged; -} - bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& properties) { - bool somethingChanged = EntityItem::setSubClassProperties(properties); // set the properties in our base class + bool somethingChanged = false; SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType); SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); @@ -122,7 +103,7 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(avatarPriority, setAvatarPriority); SET_ENTITY_PROPERTY_FROM_PROPERTIES(screenshare, setScreenshare); - somethingChanged = somethingChanged || _keyLightPropertiesChanged || _ambientLightPropertiesChanged || + somethingChanged |= _keyLightPropertiesChanged || _ambientLightPropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged || _bloomPropertiesChanged; return somethingChanged; diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 8ec3ea12b4..dda03f9115 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -33,7 +33,6 @@ public: // methods for getting/setting all properties of an entity virtual EntityItemProperties getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const override; - virtual bool setProperties(const EntityItemProperties& properties) override; virtual bool setSubClassProperties(const EntityItemProperties& properties) override; virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; From 1c545dffca5355bbc8f04524fe000bc4d5cf9967 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Mon, 20 Jul 2020 14:25:52 -0400 Subject: [PATCH 11/32] Apply suggestions from code review Co-authored-by: David Rowe --- domain-server/resources/metadata_exporter/index.html | 4 ++-- domain-server/src/DomainMetadata.h | 3 +-- domain-server/src/DomainServer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/domain-server/resources/metadata_exporter/index.html b/domain-server/resources/metadata_exporter/index.html index acc7aae23a..c75cc711e8 100644 --- a/domain-server/resources/metadata_exporter/index.html +++ b/domain-server/resources/metadata_exporter/index.html @@ -1,10 +1,10 @@ - Vircadia Metadata exporter + Vircadia Metadata Exporter -

Vircadia Metadata exporter

+

Vircadia Metadata Exporter

If you can see this page, this means that your domain's metadata is available to be exported.

diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index 6fae29248d..70f17348df 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -44,12 +44,11 @@ public: DomainMetadata(QObject* domainServer); ~DomainMetadata() = default; - // Get cached metadata QJsonObject get(); QJsonObject get(const QString& group); - bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false); + bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override; public slots: void descriptorsChanged(); diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 1d61449897..bad9c96e6b 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -3079,14 +3079,14 @@ void DomainServer::initializeMetadataExporter() { int metadataExporterPort = _settingsManager.valueOrDefaultValueForKeyPath(EXPORTER_PORT).toInt(); if (metadataExporterPort < MIN_PORT || metadataExporterPort > MAX_PORT) { - qCWarning(domain_server) << "Metadata exporter port " << metadataExporterPort << " is out of range."; + qCWarning(domain_server) << "Metadata exporter port" << metadataExporterPort << "is out of range."; isMetadataExporterEnabled = false; } qCDebug(domain_server) << "Setting up Metadata exporter."; if (isMetadataExporterEnabled && !_httpMetadataExporterManager) { - qCInfo(domain_server) << "Starting Metadata exporter on port " << metadataExporterPort; + qCInfo(domain_server) << "Starting Metadata exporter on port" << metadataExporterPort; _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), _metadata); } } From 8274ee3ca90c457aa82b83ac7004b171e611d770 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 20 Jul 2020 15:10:48 -0700 Subject: [PATCH 12/32] put back old last edited logic --- libraries/entities/src/EntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index faf29ec20b..ddedf0db18 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1572,7 +1572,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { qCDebug(entities) << "EntityItem::setProperties() AFTER update... edited AGO=" << elapsed << "now=" << now << " getLastEdited()=" << getLastEdited(); #endif - setLastEdited(now); + setLastEdited(properties._lastEdited); if (getDirtyFlags() & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES)) { // anything that sets the transform or velocity must update _lastSimulated which is used // for kinematic extrapolation (e.g. we want to extrapolate forward from this moment From e8d9fe852e5996168630c7c42dc22b7b82f30460 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 21 Jul 2020 00:49:14 -0400 Subject: [PATCH 13/32] Adjust lines for length. --- domain-server/src/DomainServer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index bad9c96e6b..d7b813dd7d 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -3067,7 +3067,13 @@ void DomainServer::initializeExporter() { if (isExporterEnabled && !_httpExporterManager) { qCInfo(domain_server) << "Starting Prometheus exporter on port " << exporterPort; - _httpExporterManager = new HTTPManager(QHostAddress::Any, (quint16)exporterPort, QString("%1/resources/prometheus_exporter/").arg(QCoreApplication::applicationDirPath()), &_exporter); + _httpExporterManager = new HTTPManager + ( + QHostAddress::Any, + (quint16)exporterPort, + QString("%1/resources/prometheus_exporter/").arg(QCoreApplication::applicationDirPath()), + &_exporter + ); } } @@ -3087,7 +3093,13 @@ void DomainServer::initializeMetadataExporter() { if (isMetadataExporterEnabled && !_httpMetadataExporterManager) { qCInfo(domain_server) << "Starting Metadata exporter on port" << metadataExporterPort; - _httpMetadataExporterManager = new HTTPManager(QHostAddress::Any, (quint16)metadataExporterPort, QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), _metadata); + _httpMetadataExporterManager = new HTTPManager + ( + QHostAddress::Any, + (quint16)metadataExporterPort, + QString("%1/resources/metadata_exporter/").arg(QCoreApplication::applicationDirPath()), + _metadata + ); } } From eef1e3b93e3d04af82f23eca3e59d62af6010d5a Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Tue, 21 Jul 2020 01:30:56 -0400 Subject: [PATCH 14/32] Update index.html --- domain-server/resources/metadata_exporter/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/domain-server/resources/metadata_exporter/index.html b/domain-server/resources/metadata_exporter/index.html index c75cc711e8..a22d50fe22 100644 --- a/domain-server/resources/metadata_exporter/index.html +++ b/domain-server/resources/metadata_exporter/index.html @@ -1,3 +1,15 @@ + + Vircadia Metadata Exporter From 3783c9897643095c5af7c34b5fab022309911bcd Mon Sep 17 00:00:00 2001 From: Maki Date: Tue, 4 Aug 2020 01:33:19 +0100 Subject: [PATCH 15/32] Allow resolving relative urls when importing entities json --- libraries/octree/src/Octree.cpp | 29 +++++--- libraries/octree/src/Octree.h | 4 +- .../octree/src/OctreeEntitiesFileParser.cpp | 70 ++++++++++++++++++- .../octree/src/OctreeEntitiesFileParser.h | 2 + 4 files changed, 93 insertions(+), 12 deletions(-) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 897ac142bf..96f2383181 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -685,8 +685,9 @@ bool Octree::readFromFile(const char* fileName) { QDataStream fileInputStream(&file); QFileInfo fileInfo(qFileName); uint64_t fileLength = fileInfo.size(); + QUrl relativeURL = QUrl::fromLocalFile(qFileName).adjusted(QUrl::RemoveFilename); - bool success = readFromStream(fileLength, fileInputStream); + bool success = readFromStream(fileLength, fileInputStream, "", false, relativeURL); file.close(); @@ -708,7 +709,9 @@ bool Octree::readJSONFromGzippedFile(QString qFileName) { } QDataStream jsonStream(jsonData); - return readJSONFromStream(-1, jsonStream); + QUrl relativeURL = QUrl::fromLocalFile(qFileName).adjusted(QUrl::RemoveFilename); + + return readJSONFromStream(-1, jsonStream, "", false, relativeURL); } // hack to get the marketplace id into the entities. We will create a way to get this from a hash of @@ -761,13 +764,15 @@ bool Octree::readFromURL( QByteArray uncompressedJsonData; bool wasCompressed = gunzip(data, uncompressedJsonData); + QUrl relativeURL = QUrl(urlString).adjusted(QUrl::RemoveFilename); + if (wasCompressed) { QDataStream inputStream(uncompressedJsonData); - return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID); + return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID, isImport, relativeURL); } QDataStream inputStream(data); - return readFromStream(data.size(), inputStream, marketplaceID, isImport); + return readFromStream(data.size(), inputStream, marketplaceID, isImport, relativeURL); } bool Octree::readFromByteArray( @@ -780,20 +785,23 @@ bool Octree::readFromByteArray( QByteArray uncompressedJsonData; bool wasCompressed = gunzip(data, uncompressedJsonData); + QUrl relativeURL = QUrl(urlString).adjusted(QUrl::RemoveFilename); + if (wasCompressed) { QDataStream inputStream(uncompressedJsonData); - return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID); + return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID, false, relativeURL); } QDataStream inputStream(data); - return readFromStream(data.size(), inputStream, marketplaceID); + return readFromStream(data.size(), inputStream, marketplaceID, false, relativeURL); } bool Octree::readFromStream( uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID, - const bool isImport + const bool isImport, + const QUrl& relativeURL ) { // decide if this is binary SVO or JSON-formatted SVO QIODevice *device = inputStream.device(); @@ -806,7 +814,7 @@ bool Octree::readFromStream( return false; } else { qCDebug(octree) << "Reading from JSON SVO Stream length:" << streamLength; - return readJSONFromStream(streamLength, inputStream, marketplaceID, isImport); + return readJSONFromStream(streamLength, inputStream, marketplaceID, isImport, relativeURL); } } @@ -837,7 +845,8 @@ bool Octree::readJSONFromStream( uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID, /*=""*/ - const bool isImport + const bool isImport, + const QUrl& relativeURL ) { // if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until // we get an eof. Leave streamLength parameter for consistency. @@ -858,7 +867,9 @@ bool Octree::readJSONFromStream( } OctreeEntitiesFileParser octreeParser; + octreeParser.relativeURL = relativeURL; octreeParser.setEntitiesString(jsonBuffer); + QVariantMap asMap; if (!octreeParser.parseEntities(asMap)) { qCritical() << "Couldn't parse Entities JSON:" << octreeParser.getErrorString().c_str(); diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index a7885801de..cb46d5151b 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -218,8 +218,8 @@ public: bool readFromFile(const char* filename); bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1, const bool isImport = false); // will support file urls as well... bool readFromByteArray(const QString& url, const QByteArray& byteArray); - bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false); - bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false); + bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false, const QUrl& urlString = QUrl()); + bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false, const QUrl& urlString = QUrl()); bool readJSONFromGzippedFile(QString qFileName); virtual bool readFromMap(QVariantMap& entityDescription, const bool isImport = false) = 0; diff --git a/libraries/octree/src/OctreeEntitiesFileParser.cpp b/libraries/octree/src/OctreeEntitiesFileParser.cpp index e82201adfd..72cfd30ef9 100644 --- a/libraries/octree/src/OctreeEntitiesFileParser.cpp +++ b/libraries/octree/src/OctreeEntitiesFileParser.cpp @@ -237,7 +237,75 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) { return false; } - entitiesArray.append(entity.object()); + QJsonObject entityObject = entity.object(); + + // resolve urls starting with ./ or ../ + if (relativeURL.isEmpty() == false) { + bool isDirty = false; + + const QStringList urlKeys { + // model + "modelURL", + "animation.url", + // image + "imageURL", + // web + "sourceUrl", + "scriptURL", + // zone + "ambientLight.ambientURL", + "skybox.url", + // particles + "textures", + // materials + "materialURL", + // ...shared + "href", + "script", + "serverScripts", + "collisionSoundURL", + "compoundShapeURL", + // TODO: deal with materialData and userData + }; + + for (const QString& key : urlKeys) { + if (key.contains('.')) { + // url is inside another object + const QStringList keyPair = key.split('.'); + const QString entityKey = keyPair[0]; + const QString childKey = keyPair[1]; + + if (entityObject.contains(entityKey) && entityObject[entityKey].isObject()) { + QJsonObject childObject = entityObject[entityKey].toObject(); + + if (childObject.contains(childKey) && childObject[childKey].isString()) { + const QString url = childObject[childKey].toString(); + + if (url.startsWith("./") || url.startsWith("../")) { + childObject[childKey] = relativeURL.resolved(url).toString(); + entityObject[entityKey] = childObject; + isDirty = true; + } + } + } + } else { + if (entityObject.contains(key) && entityObject[key].isString()) { + const QString url = entityObject[key].toString(); + + if (url.startsWith("./") || url.startsWith("../")) { + entityObject[key] = relativeURL.resolved(url).toString(); + isDirty = true; + } + } + } + } + + if (isDirty) { + entity.setObject(entityObject); + } + } + + entitiesArray.append(entityObject); _position = matchingBrace; char c = nextToken(); if (c == ']') { diff --git a/libraries/octree/src/OctreeEntitiesFileParser.h b/libraries/octree/src/OctreeEntitiesFileParser.h index bc51896b18..39560710db 100644 --- a/libraries/octree/src/OctreeEntitiesFileParser.h +++ b/libraries/octree/src/OctreeEntitiesFileParser.h @@ -16,12 +16,14 @@ #include #include +#include class OctreeEntitiesFileParser { public: void setEntitiesString(const QByteArray& entitiesContents); bool parseEntities(QVariantMap& parsedEntities); std::string getErrorString() const; + QUrl relativeURL; private: int nextToken(); From 87fd039f99632328d4029178e320a4c1eca646f6 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 4 Aug 2020 08:54:44 -0700 Subject: [PATCH 16/32] fix merge issue --- libraries/render-utils/src/Model.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 0956392944..92c9b4fafb 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -886,13 +886,6 @@ void Model::updateRenderItemsKey(const render::ScenePointer& scene) { scene->enqueueTransaction(transaction); } -void Model::setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene) { - if (_primitiveMode != primitiveMode) { - _primitiveMode = primitiveMode; - updateRenderItemsKey(scene); - } -} - void Model::setVisibleInScene(bool visible, const render::ScenePointer& scene) { if (Model::isVisible() != visible) { auto keyBuilder = render::ItemKey::Builder(_renderItemKeyGlobalFlags); @@ -965,10 +958,10 @@ void Model::setCauterized(bool cauterized, const render::ScenePointer& scene) { } } -void Model::setPrimitiveMode(PrimitiveMode primitiveMode) { +void Model::setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene) { if (_primitiveMode != primitiveMode) { _primitiveMode = primitiveMode; - setRenderItemsNeedUpdate(); + updateRenderItemsKey(scene); } } From c31ccc7a786ee19113d2572ae99cdcbc7f9cfefe Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 8 Aug 2020 00:04:44 -0400 Subject: [PATCH 17/32] Fix unit for localAngularVelocity and other things Revisiting the tooltips for: - colorSpread - localAngularVelocity (Set the correct unit 'deg/s'. This addresses issue #530 ) - damping - angularDamping --- .../system/create/assets/data/createAppTooltips.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/create/assets/data/createAppTooltips.json b/scripts/system/create/assets/data/createAppTooltips.json index 4efd0593fb..c247bc7cae 100644 --- a/scripts/system/create/assets/data/createAppTooltips.json +++ b/scripts/system/create/assets/data/createAppTooltips.json @@ -319,7 +319,7 @@ "tooltip": "The finish color of each particle." }, "colorSpread": { - "tooltip": "The spread in color that each particle is given, resulting in a variety of colors." + "tooltip": "The spread in color that each particle is given, resulting in a variety of colors. The variation range (-/+) on each RGB channel to use around the RGB values of the particle color." }, "particleAlphaTriple": { "tooltip": "The opacity of each particle between 0.0 fully transparent and 1.0 completely opaque.", @@ -531,7 +531,7 @@ "tooltip": "If enabled, grabbed entities will follow the movements of your hand controller instead of your avatar's hand." }, "canCastShadow": { - "tooltip": "If enabled, the geometry of this entity casts shadows when a shadow-casting light source shines on it. Note: Shadows are rendered only on high-profiled computers. This setting will have no effect on computers profiled to medium or low graphics.." + "tooltip": "If enabled, the geometry of this entity casts shadows when a shadow-casting light source shines on it. Note: Shadows are rendered only on high-profiled computers. This setting will have no effect on computers profiled to medium or low graphics." }, "ignorePickIntersection": { "tooltip": "If enabled, this entity will not be considered for ray picks, and will also not occlude other entities when picking." @@ -569,13 +569,13 @@ "tooltip": "The linear velocity vector of the entity. The velocity at which this entity moves forward in space." }, "damping": { - "tooltip": "The linear damping to slow down the linear velocity of an entity over time." + "tooltip": "The linear damping to slow down the linear velocity of an entity over time. A higher damping value slows down the entity more quickly. The default value is for an exponential decay timescale of 2.0s, where it takes 2.0s for the movement to slow to 1/e = 0.368 of its initial value." }, "localAngularVelocity": { - "tooltip": "The angular velocity of the entity in rad/s with respect to its axes, about its pivot point." + "tooltip": "The angular velocity of the entity in 'deg/s' with respect to its axes, about its pivot point." }, "angularDamping": { - "tooltip": "The angular damping to slow down the angular velocity of an entity over time." + "tooltip": "The angular damping to slow down the angular velocity of an entity over time. A higher damping value slows down the entity more quickly. The default value is for an exponential decay timescale of 2.0s, where it takes 2.0s for the movement to slow to 1/e = 0.368 of its initial value." }, "restitution": { "tooltip": "If enabled, the entity can bounce against other objects that also have Bounciness." From 797d18d59dd5b5341c4bb58d89fb90d68df27b47 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 8 Aug 2020 00:07:33 -0400 Subject: [PATCH 18/32] CSS adjustment for the new field type 'vec3rgb' CSS has been adjusted for the new field type 'vec3rgb'. Part of the fix for issue #593. --- scripts/system/html/css/edit-style.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index c72456d414..ada8116a0d 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -1688,17 +1688,17 @@ input.rename-entity { margin-left: 4px; margin-right: 10px; } -.fstuple label.red, .fstuple label.x, .fstuple label.w { +.fstuple label.red, .fstuple label.r, .fstuple label.x, .fstuple label.w { color: #C62147; } -.fstuple label.green, .fstuple label.y, .fstuple label.h { +.fstuple label.green, .fstuple label.g, .fstuple label.y, .fstuple label.h { color: #359D85; } -.fstuple label.blue, .fstuple label.z { +.fstuple label.blue, .fstuple label.b, .fstuple label.z { color: #0093C5; } -.xyz.fstuple, .pyr.fstuple { +.xyz.fstuple, .pyr.fstuple, .vec3rgb.fstuple { position: relative; left: -12px; min-width: 50px; From f3a6fa527b2825e3eb8fceaa4c4d607e4608c43d Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 8 Aug 2020 00:14:26 -0400 Subject: [PATCH 19/32] Replace the colorSpread color-picker by a vector Replace the color picker of the attribute particle.colorSpread by a color vec3 To do this, a new type of UI field has been added "vec3rgb" to support the "red, green, blue" vector (non-Color-picker). This addresses issue #593 Fix also the broken particle texture preview that, as for 'atp:/', doesn't support 'file:/'. This will be required for issue #534 --- .../html/js/entityProperties.js | 70 +++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 182dddf817..f8f7063828 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1133,7 +1133,13 @@ const GROUPS = [ }, { label: "Color Spread", - type: "color", + type: "vec3rgb", + vec3Type: "vec3rgb", + min: 0, + max: 255, + step: 1, + decimals: 0, + subLabels: [ "r", "g", "b" ], propertyID: "colorSpread", }, { @@ -1791,6 +1797,8 @@ function getPropertyInputElement(propertyID) { return { x: property.elNumberX.elInput, y: property.elNumberY.elInput, z: property.elNumberZ.elInput }; case 'color': return { red: property.elNumberR.elInput, green: property.elNumberG.elInput, blue: property.elNumberB.elInput }; + case 'vec3rgb': + return { red: property.elNumberR.elInput, green: property.elNumberG.elInput, blue: property.elNumberB.elInput }; case 'icon': return property.elLabel; case 'dynamic-multiselect': @@ -1889,6 +1897,12 @@ function resetProperties() { property.elNumberB.setValue("", false); break; } + case 'vec3rgb': { + property.elNumberR.setValue("", false); + property.elNumberG.setValue("", false); + property.elNumberB.setValue("", false); + break; + } case 'dropdown': { property.elInput.classList.remove('multi-diff'); property.elInput.value = ""; @@ -1995,7 +2009,7 @@ function isCurrentlyDraggingProperty(propertyName) { return properties[propertyName] && properties[propertyName].dragging === true; } -const SUPPORTED_FALLBACK_TYPES = ['number', 'number-draggable', 'rect', 'vec3', 'vec2', 'color']; +const SUPPORTED_FALLBACK_TYPES = ['number', 'number-draggable', 'rect', 'vec3', 'vec2', 'color', 'vec3rgb']; function getMultiplePropertyValue(originalPropertyName) { // if this is a compound property name (i.e. animation.running) @@ -2051,6 +2065,9 @@ function getMultiplePropertyValue(originalPropertyName) { case 'color': isPropertyNotNumber = isNaN(propertyValue.red) || propertyValue.red === null; break; + case 'vec3rgb': + isPropertyNotNumber = isNaN(propertyValue.red) || propertyValue.red === null; + break; } if (isPropertyNotNumber) { if (fallbackMultiValue === null) { @@ -2662,6 +2679,33 @@ function createVec3Property(property, elProperty) { return elResult; } +function createVec3rgbProperty(property, elProperty) { + let propertyData = property.data; + + elProperty.className = propertyData.vec3Type + " fstuple"; + + let elNumberR = createTupleNumberInput(property, propertyData.subLabels[VECTOR_ELEMENTS.X_NUMBER]); + let elNumberG = createTupleNumberInput(property, propertyData.subLabels[VECTOR_ELEMENTS.Y_NUMBER]); + let elNumberB = createTupleNumberInput(property, propertyData.subLabels[VECTOR_ELEMENTS.Z_NUMBER]); + elProperty.appendChild(elNumberR.elDiv); + elProperty.appendChild(elNumberG.elDiv); + elProperty.appendChild(elNumberB.elDiv); + + elNumberR.setValueChangeFunction(createEmitNumberPropertyComponentUpdateFunction(property, 'red')); + elNumberG.setValueChangeFunction(createEmitNumberPropertyComponentUpdateFunction(property, 'green')); + elNumberB.setValueChangeFunction(createEmitNumberPropertyComponentUpdateFunction(property, 'blue')); + + elNumberR.setMultiDiffStepFunction(createMultiDiffStepFunction(property, 'red')); + elNumberG.setMultiDiffStepFunction(createMultiDiffStepFunction(property, 'green')); + elNumberB.setMultiDiffStepFunction(createMultiDiffStepFunction(property, 'blue')); + + let elResult = []; + elResult[VECTOR_ELEMENTS.X_NUMBER] = elNumberR; + elResult[VECTOR_ELEMENTS.Y_NUMBER] = elNumberG; + elResult[VECTOR_ELEMENTS.Z_NUMBER] = elNumberB; + return elResult; +} + function createVec2Property(property, elProperty) { let propertyData = property.data; @@ -2856,7 +2900,7 @@ function createTextureProperty(property, elProperty) { let imageLoad = function(url) { elDiv.style.display = null; - if (url.slice(0, 5).toLowerCase() === "atp:/") { + if (url.slice(0, 5).toLowerCase() === "atp:/" || url.slice(0, 6).toLowerCase() === "file:/") { elImage.src = ""; elImage.style.display = "none"; elDiv.classList.remove("with-texture"); @@ -3048,6 +3092,13 @@ function createProperty(propertyData, propertyElementID, propertyName, propertyI property.elNumberB = elColor[COLOR_ELEMENTS.BLUE_NUMBER]; break; } + case 'vec3rgb': { + let elVec3 = createVec3rgbProperty(property, elProperty); + property.elNumberR = elVec3[VECTOR_ELEMENTS.X_NUMBER]; + property.elNumberG = elVec3[VECTOR_ELEMENTS.Y_NUMBER]; + property.elNumberB = elVec3[VECTOR_ELEMENTS.Z_NUMBER]; + break; + } case 'dropdown': { property.elInput = createDropdownProperty(property, propertyID, elProperty); break; @@ -4096,6 +4147,13 @@ function handleEntitySelectionUpdate(selections, isPropertiesToolUpdate) { property.elNumberB.setValue(displayColor.blue); break; } + case 'vec3rgb': { + let detailedNumberDiff = getDetailedNumberMPVDiff(propertyMultiValue, propertyData); + property.elNumberR.setValue(detailedNumberDiff.averagePerPropertyComponent.red, detailedNumberDiff.propertyComponentDiff.red); + property.elNumberG.setValue(detailedNumberDiff.averagePerPropertyComponent.green, detailedNumberDiff.propertyComponentDiff.green); + property.elNumberB.setValue(detailedNumberDiff.averagePerPropertyComponent.blue, detailedNumberDiff.propertyComponentDiff.blue); + break; + } case 'dropdown': { property.elInput.classList.toggle('multi-diff', isMultiDiffValue); property.elInput.value = isMultiDiffValue ? "" : propertyValue; @@ -4350,7 +4408,8 @@ function loaded() { properties[propertyID] = property; } if (propertyData.type === 'number' || propertyData.type === 'number-draggable' || - propertyData.type === 'vec2' || propertyData.type === 'vec3' || propertyData.type === 'rect') { + propertyData.type === 'vec2' || propertyData.type === 'vec3' || + propertyData.type === 'rect' || propertyData.type === 'vec3rgb') { propertyRangeRequests.push(propertyID); } @@ -4435,6 +4494,9 @@ function loaded() { case 'vec2': updateVectorMinMax(properties[property]); break; + case 'vec3rgb': + updateVectorMinMax(properties[property]); + break; case 'rect': updateRectMinMax(properties[property]); break; From d31f161d887aaf973c3854f4ea6fbc302d4e2cdd Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sun, 9 Aug 2020 00:10:40 -0400 Subject: [PATCH 20/32] Remove the deprecated "acceleration" attribute This removes the "acceleration" attribute from the Create App. (Physic section) because this attribute is deprecated. --- .../entityProperties/html/js/entityProperties.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index f8f7063828..0b0a3a286a 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -1657,16 +1657,6 @@ const GROUPS = [ decimals: 4, unit: "m/s2", propertyID: "gravity", - }, - { - label: "Acceleration", - type: "vec3", - vec3Type: "xyz", - subLabels: [ "x", "y", "z" ], - step: 0.1, - decimals: 4, - unit: "m/s2", - propertyID: "acceleration", } ] }, From e78ece7fc5e64ec225807924d39ebe070d72e3c6 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Mon, 17 Aug 2020 14:16:41 -0700 Subject: [PATCH 21/32] CR --- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 2 +- libraries/render-utils/src/Model.cpp | 4 ++-- libraries/render-utils/src/Model.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 51178fea1b..b5ed4b767d 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -496,7 +496,7 @@ void EntityTreeRenderer::updateChangedEntities(const render::ScenePointer& scene } // compute average per-renderable update cost - _prevNumEntityUpdates = sortedRenderables.size() - _renderablesToUpdate.size(); + _prevNumEntityUpdates = sortedRenderables.size() - _renderablesToUpdate.size(); size_t numUpdated = _prevNumEntityUpdates + 1; // add one to avoid divide by zero float cost = (float)(usecTimestampNow() - updateStart) / (float)(numUpdated); const float BLEND = 0.1f; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 92c9b4fafb..182b83762c 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -958,10 +958,10 @@ void Model::setCauterized(bool cauterized, const render::ScenePointer& scene) { } } -void Model::setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene) { +void Model::setPrimitiveMode(PrimitiveMode primitiveMode) { if (_primitiveMode != primitiveMode) { _primitiveMode = primitiveMode; - updateRenderItemsKey(scene); + updateRenderItemsKey(nullptr); } } diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 0f65b62194..4585ad0009 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -118,7 +118,7 @@ public: bool isCauterized() const { return _cauterized; } void setCauterized(bool value, const render::ScenePointer& scene); - void setPrimitiveMode(PrimitiveMode primitiveMode, const render::ScenePointer& scene = nullptr); + void setPrimitiveMode(PrimitiveMode primitiveMode); PrimitiveMode getPrimitiveMode() const { return _primitiveMode; } void setCullWithParent(bool value); From 8d217d215fe23a11390666326b1c8f3eeeb032a4 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Mon, 17 Aug 2020 21:58:42 -0400 Subject: [PATCH 22/32] Better code fix for preview being more specific on the validation for the unresolvable relative path. checking now if the path start with "file:///~" instead of only: "file:/" This was too much restrictive since those direct path works and wouldn't return a preview: Ex: "file://MYSERVER/folder/100_0057.jpg" --- .../system/create/entityProperties/html/js/entityProperties.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 0b0a3a286a..f6dcf10bc8 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -2890,7 +2890,7 @@ function createTextureProperty(property, elProperty) { let imageLoad = function(url) { elDiv.style.display = null; - if (url.slice(0, 5).toLowerCase() === "atp:/" || url.slice(0, 6).toLowerCase() === "file:/") { + if (url.slice(0, 5).toLowerCase() === "atp:/" || url.slice(0, 9).toLowerCase() === "file:///~") { elImage.src = ""; elImage.style.display = "none"; elDiv.classList.remove("with-texture"); From b7e4362553e6207694858e78ceb1acc5dab8ad54 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 19 Aug 2020 00:01:47 -0400 Subject: [PATCH 23/32] Make empty values no longer null, add name property, rename "Hosts" -> "Managers" --- .../resources/describe-settings.json | 14 ++++-- domain-server/src/DomainMetadata.cpp | 47 +++++++++++++------ domain-server/src/DomainMetadata.h | 3 +- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 9b3b716a4a..fbbeb391ba 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -162,6 +162,12 @@ "restart": false, "help": "This data will be queryable from your server. It may be collected by High Fidelity and used to share your domain with others.", "settings": [ + { + "name": "world_name", + "label": "Name", + "advanced": true, + "help": "The name of your domain (256 character limit)." + }, { "name": "description", "label": "Description", @@ -199,16 +205,16 @@ ] }, { - "name": "hosts", - "label": "Hosts", + "name": "managers", + "label": "Server Managers / Administrators", "advanced": true, "type": "table", "can_add_new_rows": true, - "help": "Usernames of hosts who can reliably show your domain to new visitors.", + "help": "Usernames of managers that administrate the domain.", "numbered": false, "columns": [ { - "name": "host", + "name": "manager", "label": "Username", "can_set": true } diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index f8d8d2d989..cfdbf249be 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -34,18 +34,21 @@ const QString DomainMetadata::Users::HOSTNAMES = "user_hostnames"; // } const QString DomainMetadata::DESCRIPTORS = "descriptors"; +const QString DomainMetadata::Descriptors::NAME = "world_name"; const QString DomainMetadata::Descriptors::DESCRIPTION = "description"; const QString DomainMetadata::Descriptors::CAPACITY = "capacity"; // parsed from security const QString DomainMetadata::Descriptors::RESTRICTION = "restriction"; // parsed from ACL const QString DomainMetadata::Descriptors::MATURITY = "maturity"; -const QString DomainMetadata::Descriptors::HOSTS = "hosts"; +const QString DomainMetadata::Descriptors::MANAGERS = "managers"; const QString DomainMetadata::Descriptors::TAGS = "tags"; // descriptors metadata will appear as (JSON): -// { "description": String, // capped description +// { +// "name": String, // capped name +// "description": String, // capped description // "capacity": Number, // "restriction": String, // enum of either open, hifi, or acl // "maturity": String, // enum corresponding to ESRB ratings -// "hosts": [ String ], // capped list of usernames +// "managers": [ String ], // capped list of usernames // "tags": [ String ], // capped list of tags // } @@ -82,12 +85,27 @@ void DomainMetadata::descriptorsChanged() { static const QString DESCRIPTORS_GROUP_KEYPATH = "descriptors"; auto descriptorsMap = static_cast(parent())->_settingsManager.valueForKeyPath(DESCRIPTORS).toMap(); - // copy simple descriptors (description/maturity) - state[Descriptors::DESCRIPTION] = descriptorsMap[Descriptors::DESCRIPTION]; - state[Descriptors::MATURITY] = descriptorsMap[Descriptors::MATURITY]; + // copy simple descriptors (name/description/maturity) + if (!descriptorsMap[Descriptors::NAME].isNull()) { + state[Descriptors::NAME] = descriptorsMap[Descriptors::NAME]; + } else { + state[Descriptors::NAME] = ""; + } - // copy array descriptors (hosts/tags) - state[Descriptors::HOSTS] = descriptorsMap[Descriptors::HOSTS].toList(); + if (!descriptorsMap[Descriptors::DESCRIPTION].isNull()) { + state[Descriptors::DESCRIPTION] = descriptorsMap[Descriptors::DESCRIPTION]; + } else { + state[Descriptors::DESCRIPTION] = ""; + } + + if (!descriptorsMap[Descriptors::MATURITY].isNull()) { + state[Descriptors::MATURITY] = descriptorsMap[Descriptors::MATURITY]; + } else { + state[Descriptors::MATURITY] = ""; + } + + // copy array descriptors (managers/tags) + state[Descriptors::MANAGERS] = descriptorsMap[Descriptors::MANAGERS].toList(); state[Descriptors::TAGS] = descriptorsMap[Descriptors::TAGS].toList(); // parse capacity @@ -211,19 +229,20 @@ void DomainMetadata::sendDescriptors() { } bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { - QJsonArray metadataArray; - metadataArray << get(DESCRIPTORS); - metadataArray << get(USERS); - QString domainMetadataJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(metadataArray).toJson(QJsonDocument::Compact))); + QString domainMetadataJSON = QString("{\"domain\":%1, \"users\":%2}") + .arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))) + .arg(QString(QJsonDocument(get(USERS)).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; const QString EXPORTER_MIME_TYPE = "application/json"; - qCDebug(domain_metadata_exporter) << "Request on URL " << url; - if (url.path() == URI_METADATA) { connection->respond(HTTPConnection::StatusCode200, domainMetadataJSON.toUtf8(), qPrintable(EXPORTER_MIME_TYPE)); return true; } +#if DEV_BUILD || PR_BUILD + qCDebug(domain_metadata_exporter) << "Metadata request on URL " << url; +#endif + return false; } diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index 70f17348df..d366bd2020 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -34,11 +34,12 @@ public: static const QString DESCRIPTORS; class Descriptors { public: + static const QString NAME; static const QString DESCRIPTION; static const QString CAPACITY; static const QString RESTRICTION; static const QString MATURITY; - static const QString HOSTS; + static const QString MANAGERS; static const QString TAGS; }; From af828607517c0f145aefee104e2b1ccf6676bdb1 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Wed, 19 Aug 2020 19:51:16 -0700 Subject: [PATCH 24/32] fix shape issue that alezia found --- .../src/RenderableShapeEntityItem.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index 222b833be2..683cc1359a 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -119,10 +119,14 @@ void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint materialChanged = true; } - if (materialChanged) { - auto materials = _materials.find("0"); - if (materials != _materials.end()) { + auto materials = _materials.find("0"); + if (materials != _materials.end()) { + if (materialChanged) { materials->second.setNeedsUpdate(true); + } + + if (materials->second.shouldUpdate()) { + RenderPipelines::updateMultiMaterial(materials->second); emit requestRenderUpdate(); } } From a079afbb73e44a8af56e301ebef3aac03cf9e5a5 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 21 Aug 2020 13:40:38 -0400 Subject: [PATCH 25/32] Update metadata exporting. --- .../resources/describe-settings.json | 30 ++++++++++++++++++- domain-server/src/DomainMetadata.cpp | 27 +++++++++++++++-- domain-server/src/DomainMetadata.h | 3 ++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index fbbeb391ba..3551104f75 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -174,6 +174,28 @@ "advanced": true, "help": "A description of your domain (256 character limit)." }, + { + "name": "thumbnail", + "label": "World Thumbnail", + "advanced": true, + "help": "A link to the thumbnail that is publicly accessible from the internet." + }, + { + "name": "images", + "label": "World Images", + "advanced": true, + "type": "table", + "can_add_new_rows": true, + "help": "URLs to images that visually describe your world to potential visitors.", + "numbered": false, + "columns": [ + { + "name": "image", + "label": "Image URL", + "can_set": true + } + ] + }, { "name": "maturity", "label": "Maturity", @@ -204,9 +226,15 @@ } ] }, + { + "name": "contact_info", + "label": "World Administrative Contact", + "advanced": true, + "help": "Contact information to reach server administrators for assistance (256 character limit)." + }, { "name": "managers", - "label": "Server Managers / Administrators", + "label": "World Managers / Administrators", "advanced": true, "type": "table", "can_add_new_rows": true, diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index cfdbf249be..53e3cce1ec 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -36,18 +36,25 @@ const QString DomainMetadata::Users::HOSTNAMES = "user_hostnames"; const QString DomainMetadata::DESCRIPTORS = "descriptors"; const QString DomainMetadata::Descriptors::NAME = "world_name"; const QString DomainMetadata::Descriptors::DESCRIPTION = "description"; +const QString DomainMetadata::Descriptors::THUMBNAIL = "thumbnail"; +const QString DomainMetadata::Descriptors::IMAGES = "images"; const QString DomainMetadata::Descriptors::CAPACITY = "capacity"; // parsed from security const QString DomainMetadata::Descriptors::RESTRICTION = "restriction"; // parsed from ACL const QString DomainMetadata::Descriptors::MATURITY = "maturity"; +const QString DomainMetadata::Descriptors::CONTACT = "contact_info"; const QString DomainMetadata::Descriptors::MANAGERS = "managers"; const QString DomainMetadata::Descriptors::TAGS = "tags"; + // descriptors metadata will appear as (JSON): // { -// "name": String, // capped name +// "world_name": String, // capped name // "description": String, // capped description +// "thumbnail": String, // capped thumbnail URL +// "images": [ String ], // capped list of image URLs // "capacity": Number, // "restriction": String, // enum of either open, hifi, or acl // "maturity": String, // enum corresponding to ESRB ratings +// "contact_info": [ String ], // capped list of usernames // "managers": [ String ], // capped list of usernames // "tags": [ String ], // capped list of tags // } @@ -85,7 +92,7 @@ void DomainMetadata::descriptorsChanged() { static const QString DESCRIPTORS_GROUP_KEYPATH = "descriptors"; auto descriptorsMap = static_cast(parent())->_settingsManager.valueForKeyPath(DESCRIPTORS).toMap(); - // copy simple descriptors (name/description/maturity) + // copy simple descriptors if (!descriptorsMap[Descriptors::NAME].isNull()) { state[Descriptors::NAME] = descriptorsMap[Descriptors::NAME]; } else { @@ -98,13 +105,27 @@ void DomainMetadata::descriptorsChanged() { state[Descriptors::DESCRIPTION] = ""; } + if (!descriptorsMap[Descriptors::THUMBNAIL].isNull()) { + state[Descriptors::THUMBNAIL] = descriptorsMap[Descriptors::THUMBNAIL]; + } else { + state[Descriptors::THUMBNAIL] = ""; + } + if (!descriptorsMap[Descriptors::MATURITY].isNull()) { state[Descriptors::MATURITY] = descriptorsMap[Descriptors::MATURITY]; } else { state[Descriptors::MATURITY] = ""; } + + if (!descriptorsMap[Descriptors::CONTACT].isNull()) { + state[Descriptors::CONTACT] = descriptorsMap[Descriptors::CONTACT]; + } else { + state[Descriptors::CONTACT] = ""; + } - // copy array descriptors (managers/tags) + // copy array descriptors + state[Descriptors::THUMBNAIL] = descriptorsMap[Descriptors::THUMBNAIL].toList(); + state[Descriptors::IMAGES] = descriptorsMap[Descriptors::IMAGES].toList(); state[Descriptors::MANAGERS] = descriptorsMap[Descriptors::MANAGERS].toList(); state[Descriptors::TAGS] = descriptorsMap[Descriptors::TAGS].toList(); diff --git a/domain-server/src/DomainMetadata.h b/domain-server/src/DomainMetadata.h index d366bd2020..24dcba909d 100644 --- a/domain-server/src/DomainMetadata.h +++ b/domain-server/src/DomainMetadata.h @@ -36,9 +36,12 @@ public: public: static const QString NAME; static const QString DESCRIPTION; + static const QString THUMBNAIL; + static const QString IMAGES; static const QString CAPACITY; static const QString RESTRICTION; static const QString MATURITY; + static const QString CONTACT; static const QString MANAGERS; static const QString TAGS; }; From c81365f4f0d925c81eac92446bef0a35a070b1a0 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 21 Aug 2020 13:47:59 -0400 Subject: [PATCH 26/32] Update description for Prometheus exporter. --- domain-server/resources/describe-settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 3551104f75..7c8783bb82 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -114,7 +114,7 @@ { "name": "enable_prometheus_exporter", "label": "Enable Prometheus Exporter", - "help": "Enable a Prometheus exporter to make it possible to gather the stats that are available at Nodes tab with a Prometheus server. This makes it possible to keep track of long-term domain statistics for graphing, troubleshooting, and performance monitoring.", + "help": "Enable a Prometheus exporter to make it possible to gather stats about the mixers that are available in the Nodes tab with a Prometheus server. This makes it possible to keep track of long-term domain statistics for graphing, troubleshooting, and performance monitoring.", "default": false, "type": "checkbox", "advanced": true From a24b8f0fc6004d6fca455cc89624985eb95b1215 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 21 Aug 2020 14:08:50 -0400 Subject: [PATCH 27/32] Missed a spot, was wiping thumbnail string and replacing with an array. --- domain-server/src/DomainMetadata.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 53e3cce1ec..981d82ee3b 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -124,7 +124,6 @@ void DomainMetadata::descriptorsChanged() { } // copy array descriptors - state[Descriptors::THUMBNAIL] = descriptorsMap[Descriptors::THUMBNAIL].toList(); state[Descriptors::IMAGES] = descriptorsMap[Descriptors::IMAGES].toList(); state[Descriptors::MANAGERS] = descriptorsMap[Descriptors::MANAGERS].toList(); state[Descriptors::TAGS] = descriptorsMap[Descriptors::TAGS].toList(); From ebecbcc7f70511b98b16d5da0a24eb40cf99d753 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 21 Aug 2020 22:00:06 -0400 Subject: [PATCH 28/32] Update JSON structure for metadata. --- domain-server/src/DomainMetadata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domain-server/src/DomainMetadata.cpp b/domain-server/src/DomainMetadata.cpp index 981d82ee3b..35bcd10c91 100644 --- a/domain-server/src/DomainMetadata.cpp +++ b/domain-server/src/DomainMetadata.cpp @@ -230,7 +230,7 @@ void DomainMetadata::maybeUpdateUsers() { } void DomainMetadata::sendDescriptors() { - QString domainUpdateJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); + QString domainUpdateJSON = QString("{\"domain\":{\"meta\":%1}").arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))); const QUuid& domainID = DependencyManager::get()->getSessionUUID(); if (!domainID.isNull()) { static const QString DOMAIN_UPDATE = "/api/v1/domains/%1"; @@ -249,7 +249,7 @@ void DomainMetadata::sendDescriptors() { } bool DomainMetadata::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { - QString domainMetadataJSON = QString("{\"domain\":%1, \"users\":%2}") + QString domainMetadataJSON = QString("{\"domain\":{\"meta\":%1}, \"users\":%2}") .arg(QString(QJsonDocument(get(DESCRIPTORS)).toJson(QJsonDocument::Compact))) .arg(QString(QJsonDocument(get(USERS)).toJson(QJsonDocument::Compact))); const QString URI_METADATA = "/metadata"; From 404e18296a34d381b7e7a14b1a94d0be59e0860e Mon Sep 17 00:00:00 2001 From: ArcadeFever Date: Sun, 23 Aug 2020 12:33:13 -0700 Subject: [PATCH 29/32] changed url for AC script examples from HiFi to Vircadia github --- domain-server/resources/web/assignment/placeholder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain-server/resources/web/assignment/placeholder.js b/domain-server/resources/web/assignment/placeholder.js index bf64539bea..95c9903e32 100644 --- a/domain-server/resources/web/assignment/placeholder.js +++ b/domain-server/resources/web/assignment/placeholder.js @@ -1,3 +1,3 @@ // Here you can put a script that will be run by an assignment-client (AC) -// For examples, please go to https://github.com/highfidelity/hifi/tree/master/script-archive/acScripts +// For examples, please go to https://github.com/kasenvr/project-athena/tree/master/script-archive/acScripts // The directory named acScripts contains assignment-client specific scripts you can try. From 7481925611c73849c5b12c31f3d76f61d72f226f Mon Sep 17 00:00:00 2001 From: Kalila L Date: Mon, 24 Aug 2020 22:54:16 -0400 Subject: [PATCH 30/32] Add default timestamp server, remove obsolete comment. --- CMakeLists.txt | 2 +- cmake/templates/NSIS.template.in | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eac12d5ae7..424fbdc940 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ else() endif() # Use default time server if none defined in environment -set_from_env(TIMESERVER_URL TIMESERVER_URL "http://sha256timestamp.ws.symantec.com/sha256/timestamp") +set_from_env(TIMESERVER_URL TIMESERVER_URL "http://timestamp.comodoca.com?td=sha256") set(HIFI_USE_OPTIMIZED_IK_OPTION OFF) set(BUILD_CLIENT_OPTION ON) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index a7b1ba91c8..f40141be32 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -199,9 +199,6 @@ !system "$%TEMP%\tempinstaller.exe" = 2 - ; NOTE: We're not code signing right now, so we're going to disable that. - ; TODO: Get a code signing certificate so we can re-enable code signing. - ; The Inner invocation has written an uninstaller binary for us. ; We need to sign it if it's a production or PR build. !if @PRODUCTION_BUILD@ == 1 From a4bea1ce30f610ef041dcf3c24764c095ff8dfc2 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Tue, 25 Aug 2020 01:11:12 -0400 Subject: [PATCH 31/32] Update BUILD.md --- BUILD.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/BUILD.md b/BUILD.md index db81ecb30d..1c42b3155c 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,6 +1,6 @@ # General Build Information -*Last Updated on June 27, 2020* +*Last Updated on August 25, 2020* ### OS Specific Build Guides @@ -80,12 +80,16 @@ Where /path/to/directory is the path to a directory where you wish the build fil // The type of release. RELEASE_TYPE=PRODUCTION|PR|DEV - // TODO: What do these do? + // Set one of these if you require only one to be packaged + CLIENT_ONLY=1 + SERVER_ONLY=1 + + // Determine the build type PRODUCTION_BUILD=0|1 PR_BUILD=0|1 STABLE_BUILD=0|1 - // TODO: What do these do? + // Determine if to utilize testing or stable Metaverse URLs USE_STABLE_GLOBAL_SERVICES=1 BUILD_GLOBAL_SERVICES=STABLE From 693416cd0d1239e79f5caf505071df954589df78 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Wed, 26 Aug 2020 04:07:57 -0400 Subject: [PATCH 32/32] Update BUILD.md --- BUILD.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/BUILD.md b/BUILD.md index 1c42b3155c..eea91e118b 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,6 +1,6 @@ # General Build Information -*Last Updated on August 25, 2020* +*Last Updated on August 26, 2020* ### OS Specific Build Guides @@ -80,10 +80,6 @@ Where /path/to/directory is the path to a directory where you wish the build fil // The type of release. RELEASE_TYPE=PRODUCTION|PR|DEV - // Set one of these if you require only one to be packaged - CLIENT_ONLY=1 - SERVER_ONLY=1 - // Determine the build type PRODUCTION_BUILD=0|1 PR_BUILD=0|1 @@ -145,6 +141,8 @@ The following build options can be used when running CMake * BUILD_SERVER * BUILD_TESTS * BUILD_TOOLS +* CLIENT_ONLY // Will package only the Interface +* SERVER_ONLY // Will package only the Server #### Developer Build Options