From c5628b615c7939e40a0d108b2d5edfd1482cec80 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 24 Aug 2016 16:05:22 -0700 Subject: [PATCH 1/2] Make sure we start fade in once an item becomes ready --- libraries/render-utils/src/MeshPartPayload.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 63082a8995..1c8c89d6db 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -533,10 +533,21 @@ void ModelMeshPartPayload::startFade() { void ModelMeshPartPayload::render(RenderArgs* args) const { PerformanceTimer perfTimer("ModelMeshPartPayload::render"); - if (!_model->_readyWhenAdded || !_model->_isVisible || !_hasStartedFade) { + if (!_model->_readyWhenAdded || !_model->_isVisible) { return; // bail asap } + // If we didn't start the fade in, check if we are ready to now.... + if (!_hasStartedFade && _model->isLoaded() && _model->getGeometry()->areTexturesLoaded()) { + const_cast(*this).startFade(); + } + + // If we still didn't start the fade in, bail + if (!_hasStartedFade) { + return; + } + + // When an individual mesh parts like this finishes its fade, we will mark the Model as // having render items that need updating bool nextIsFading = _isFading ? isStillFading() : false; From 5cdb30357f180f6b9fd7bbb66d1fa81cc3fe969c Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 24 Aug 2016 18:03:56 -0700 Subject: [PATCH 2/2] Add checking for failed downloads in the textures --- .../src/model-networking/ModelCache.cpp | 17 +++++++++++++++-- libraries/networking/src/ResourceCache.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 3b7092ce8d..306a19c308 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -330,9 +330,22 @@ bool Geometry::areTexturesLoaded() const { if (!_areTexturesLoaded) { for (auto& material : _materials) { // Check if material textures are loaded - if (std::any_of(material->_textures.cbegin(), material->_textures.cend(), - [](const NetworkMaterial::Textures::value_type& it) { return it.texture && !it.texture->isLoaded(); })) { + bool materialMissingTexture = std::any_of(material->_textures.cbegin(), material->_textures.cend(), + [](const NetworkMaterial::Textures::value_type& it) { + auto texture = it.texture; + if (!texture) { + return false; + } + // Failed texture downloads need to be considered as 'loaded' + // or the object will never fade in + bool finished = texture->isLoaded() || texture->isFailed(); + if (!finished) { + return true; + } + return false; + }); + if (materialMissingTexture) { return false; } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 11b80ca349..a2a5b4cbbe 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -282,6 +282,9 @@ public: /// Checks whether the resource has loaded. virtual bool isLoaded() const { return _loaded; } + /// Checks whether the resource has failed to download. + virtual bool isFailed() const { return _failedToLoad; } + /// For loading resources, returns the number of bytes received. qint64 getBytesReceived() const { return _bytesReceived; }