From 3796675123214960ed569f7f83c2788a3005a942 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 24 Aug 2018 15:46:39 -0700 Subject: [PATCH] script update and visuallyReady entities --- interface/src/Application.cpp | 5 ++- .../src/octree/OctreePacketProcessor.cpp | 4 +++ interface/src/octree/OctreePacketProcessor.h | 1 + interface/src/octree/SafeLanding.cpp | 33 +++++++++++++++---- interface/src/octree/SafeLanding.h | 3 ++ .../src/RenderableModelEntityItem.cpp | 10 +++++- .../src/RenderableModelEntityItem.h | 6 +++- .../src/RenderableZoneEntityItem.cpp | 10 ++++++ libraries/entities/src/EntityItem.h | 3 ++ libraries/entities/src/ModelEntityItem.cpp | 1 + libraries/entities/src/ZoneEntityItem.cpp | 1 + scripts/system/interstitialPage.js | 19 ++++++++--- 12 files changed, 83 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6b2781417d..a4ced55a2d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5519,6 +5519,7 @@ void Application::update(float deltaTime) { return; } + if (!_physicsEnabled) { if (!domainLoadingInProgress) { PROFILE_ASYNC_BEGIN(app, "Scene Loading", ""); @@ -5528,7 +5529,9 @@ void Application::update(float deltaTime) { // we haven't yet enabled physics. we wait until we think we have all the collision information // for nearby entities before starting bullet up. quint64 now = usecTimestampNow(); - if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) { + bool renderReady = _octreeProcessor.isEntitiesRenderReady(); + qDebug() << "--> render ready: " << renderReady; + if (isServerlessMode() || (_octreeProcessor.isLoadSequenceComplete() && renderReady)) { // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway _lastPhysicsCheckTime = now; _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter; diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index 11f6bbae13..e02c603415 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -138,6 +138,10 @@ bool OctreePacketProcessor::isLoadSequenceComplete() const { return _safeLanding->isLoadSequenceComplete(); } +bool OctreePacketProcessor::isEntitiesRenderReady() const { + return _safeLanding->entitiesRenderReady(); +} + float OctreePacketProcessor::domainLoadProgress() { return _safeLanding->loadingProgressPercentage(); } diff --git a/interface/src/octree/OctreePacketProcessor.h b/interface/src/octree/OctreePacketProcessor.h index fb8f0b581a..8e771de556 100644 --- a/interface/src/octree/OctreePacketProcessor.h +++ b/interface/src/octree/OctreePacketProcessor.h @@ -27,6 +27,7 @@ public: void startEntitySequence(); bool isLoadSequenceComplete() const; + bool isEntitiesRenderReady() const; float domainLoadProgress(); signals: diff --git a/interface/src/octree/SafeLanding.cpp b/interface/src/octree/SafeLanding.cpp index 4b8edd5934..bdaaa58fcc 100644 --- a/interface/src/octree/SafeLanding.cpp +++ b/interface/src/octree/SafeLanding.cpp @@ -36,6 +36,7 @@ void SafeLanding::startEntitySequence(QSharedPointer entityT if (entityTree) { Locker lock(_lock); _entityTree = entityTree; + _trackedEntitiesRenderStatus.clear(); _trackedEntities.clear(); _trackingEntities = true; connect(std::const_pointer_cast(_entityTree).get(), @@ -76,22 +77,24 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) { if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) { // Only track entities with downloaded collision bodies. _trackedEntities.emplace(entityID, entity); - - float trackedEntityCount = (float)_trackedEntities.size(); - - if (trackedEntityCount > _maxTrackedEntityCount) { - _maxTrackedEntityCount = trackedEntityCount; - } qCDebug(interfaceapp) << "Safe Landing: Tracking entity " << entity->getItemName(); } } } + + _trackedEntitiesRenderStatus.emplace(entityID, entity); + float trackedEntityCount = (float)_trackedEntitiesRenderStatus.size(); + + if (trackedEntityCount > _maxTrackedEntityCount) { + _maxTrackedEntityCount = trackedEntityCount; + } } } void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) { Locker lock(_lock); _trackedEntities.erase(entityID); + _trackedEntitiesRenderStatus.erase(entityID); } void SafeLanding::setCompletionSequenceNumbers(int first, int last) { @@ -165,6 +168,24 @@ bool SafeLanding::isEntityPhysicsComplete() { return _trackedEntities.empty(); } +bool SafeLanding::entitiesRenderReady() { + Locker lock(_lock); + + for (auto entityMapIter = _trackedEntitiesRenderStatus.begin(); entityMapIter != _trackedEntitiesRenderStatus.end(); ++entityMapIter) { + auto entity = entityMapIter->second; + bool visuallyReady = entity->isVisuallyReady(); + qDebug() << "is entityType: " << EntityTypes::getEntityTypeName(entity->getType()) << " " << visuallyReady; + if (visuallyReady) { + entityMapIter = _trackedEntitiesRenderStatus.erase(entityMapIter); + if (entityMapIter == _trackedEntitiesRenderStatus.end()) { + break; + } + } + } + qDebug() << "list size: -> " << _trackedEntitiesRenderStatus.size(); + return _trackedEntitiesRenderStatus.empty(); +} + float SafeLanding::ElevatedPriority(const EntityItem& entityItem) { return entityItem.getCollisionless() ? 0.0f : 10.0f; } diff --git a/interface/src/octree/SafeLanding.h b/interface/src/octree/SafeLanding.h index 4bede579dc..611b75ab79 100644 --- a/interface/src/octree/SafeLanding.h +++ b/interface/src/octree/SafeLanding.h @@ -18,6 +18,7 @@ #include #include "EntityItem.h" +#include "EntityDynamicInterface.h" class EntityTreeRenderer; class EntityItemID; @@ -29,6 +30,7 @@ public: void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive. void noteReceivedsequenceNumber(int sequenceNumber); bool isLoadSequenceComplete(); + bool entitiesRenderReady(); float loadingProgressPercentage(); private slots: @@ -46,6 +48,7 @@ private: EntityTreePointer _entityTree; using EntityMap = std::map; EntityMap _trackedEntities; + EntityMap _trackedEntitiesRenderStatus; static constexpr int INVALID_SEQUENCE = -1; int _initialStart { INVALID_SEQUENCE }; diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 34936c2c48..c3cc634236 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1441,7 +1441,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce // That is where _currentFrame and _lastAnimated were updated. if (_animating) { DETAILED_PROFILE_RANGE(simulation_physics, "Animate"); - + if (!jointsMapped()) { mapJoints(entity, model->getJointNames()); //else the joint have been mapped before but we have a new animation to load @@ -1457,6 +1457,14 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce } } + +void ModelEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { + withWriteLock([&] { + bool visuallyReady = (_prevModelLoaded && _texturesLoaded); + entity->setVisuallyReady(visuallyReady); + }); +} + void ModelEntityRenderer::setIsVisibleInSecondaryCamera(bool value) { Parent::setIsVisibleInSecondaryCamera(value); setKey(_didLastVisualGeometryRequestSucceed); diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index 45892fdd7f..bcf7296456 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -38,11 +38,13 @@ class ModelEntityWrapper : public ModelEntityItem { using Parent = ModelEntityItem; friend class render::entities::ModelEntityRenderer; +public: + bool isModelLoaded() const; + protected: ModelEntityWrapper(const EntityItemID& entityItemID) : Parent(entityItemID) {} void setModel(const ModelPointer& model); ModelPointer getModel() const; - bool isModelLoaded() const; bool _needsInitialSimulation{ true }; private: @@ -162,6 +164,8 @@ protected: virtual void doRender(RenderArgs* args) override; virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override; + virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; + render::hifi::Tag getTagMask() const override; void setIsVisibleInSecondaryCamera(bool value) override; diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index c5035431f6..598b3d1449 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -258,6 +258,16 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen if (hazeChanged) { updateHazeFromEntity(entity); } + + bool visuallyReady = true; + uint32_t skyboxMode = entity->getSkyboxMode(); + if (skyboxMode == COMPONENT_MODE_ENABLED) { + bool skyboxLoadedOrFailed = (_skyboxTexture && (_skyboxTexture->isLoaded() || _skyboxTexture->isFailed())); + qDebug() << "------> " << skyboxLoadedOrFailed; + visuallyReady = (!_skyboxTextureURL.isEmpty() || skyboxLoadedOrFailed); + } + + entity->setVisuallyReady(visuallyReady); } void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 47ae8de9ad..490f9b9e6b 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -305,6 +305,7 @@ public: void setDynamic(bool value); virtual bool shouldBePhysical() const { return false; } + bool isVisuallyReady() const { return _visuallyReady; } bool getLocked() const; void setLocked(bool value); @@ -527,6 +528,7 @@ public: void removeCloneID(const QUuid& cloneID); const QVector getCloneIDs() const; void setCloneIDs(const QVector& cloneIDs); + void setVisuallyReady(bool visuallyReady) { _visuallyReady = visuallyReady; } signals: void requestRenderUpdate(); @@ -639,6 +641,7 @@ protected: EntityTreeElementPointer _element; // set by EntityTreeElement void* _physicsInfo { nullptr }; // set by EntitySimulation bool _simulated { false }; // set by EntitySimulation + bool _visuallyReady { true }; bool addActionInternal(EntitySimulationPointer simulation, EntityDynamicPointer action); bool removeActionInternal(const QUuid& actionID, EntitySimulationPointer simulation = nullptr); diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 5d5344c9c8..774559a628 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -40,6 +40,7 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID) : EntityItem( _type = EntityTypes::Model; _lastKnownCurrentFrame = -1; _color[0] = _color[1] = _color[2] = 0; + _visuallyReady = false; } const QString ModelEntityItem::getTextures() const { diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index f2550e5d3c..58d5ba79c9 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -42,6 +42,7 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en _shapeType = DEFAULT_SHAPE_TYPE; _compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL; + _visuallyReady = false; } EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const { diff --git a/scripts/system/interstitialPage.js b/scripts/system/interstitialPage.js index 1507c7bd9a..a5e5e7c0a2 100644 --- a/scripts/system/interstitialPage.js +++ b/scripts/system/interstitialPage.js @@ -32,6 +32,7 @@ var BUTTON_PROPERTIES = { text: "Interstitial" }; + var tablet = null; var button = null; @@ -336,11 +337,12 @@ Overlays.editOverlay(loadingBarPlacard, properties); Overlays.editOverlay(loadingBarProgress, loadingBarProperties); - if (physicsEnabled) { + if (physicsEnabled && !HMD.active) { toolbar.writeProperty("visible", true); - resetValues(); } + resetValues(); + Camera.mode = "first person"; } @@ -356,7 +358,13 @@ Overlays.editOverlay(anchorOverlay, { localPosition: localPosition }); } + + Window.interstitialStatusChanged.connect(function(interstitialMode) { + print("------> insterstitial mode changed " + interstitialMode + " <------"); + }); + function update() { + var downloadInfo = GlobalServices.getDownloadInfo(); var physicsEnabled = Window.isPhysicsEnabled(); var thisInterval = Date.now(); var deltaTime = (thisInterval - lastInterval); @@ -365,7 +373,7 @@ var domainLoadingProgressPercentage = Window.domainLoadingProgress(); var progress = MAX_X_SIZE * domainLoadingProgressPercentage; - print(progress); + //print(progress); if (progress >= target) { target = progress; } @@ -383,6 +391,7 @@ }; Overlays.editOverlay(loadingBarProgress, properties); + print(JSON.stringify(downloadInfo)); if ((physicsEnabled && (currentProgress >= (MAX_X_SIZE - EPSILON)))) { updateOverlays((physicsEnabled || connectionToDomainFailed)); endAudio(); @@ -431,7 +440,9 @@ renderViewTask.getConfig("LightingModel")["enableAmbientLight"] = true; renderViewTask.getConfig("LightingModel")["enableDirectionalLight"] = true; renderViewTask.getConfig("LightingModel")["enablePointLight"] = true; - toolbar.writeProperty("visible", true); + if (!HMD.active) { + toolbar.writeProperty("visible", true); + } } Script.scriptEnding.connect(cleanup);