Merge remote-tracking branch 'upstream/stable'

This commit is contained in:
Brad Davis 2016-08-24 19:31:11 -07:00
commit 479d90a462
3 changed files with 30 additions and 3 deletions

View file

@ -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;
}

View file

@ -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; }

View file

@ -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<ModelMeshPartPayload&>(*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;