From fc19b60f8a247decb9f469717f7dd53046ae57e6 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Sun, 3 Apr 2016 06:05:16 -0700 Subject: [PATCH] Avoid setting null texs on uncaching models --- libraries/model-networking/src/model-networking/ModelCache.cpp | 2 +- libraries/model-networking/src/model-networking/ModelCache.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 41c2a2e194..68606dbc7d 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -232,7 +232,7 @@ std::shared_ptr ModelCache::getGeometry(const QUrl& url, const GeometryExtra geometryExtra = { mapping, textureBaseUrl }; GeometryResource::Pointer resource = getResource(url, QUrl(), true, &geometryExtra).staticCast(); if (resource) { - if (resource->isLoaded() && !resource->hasTextures()) { + if (resource->isLoaded() && resource->shouldSetTextures()) { resource->setTextures(); } return std::make_shared(resource); diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 81883d972d..f479dc9ce2 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -107,7 +107,8 @@ protected: friend class GeometryMappingResource; // Geometries may not hold onto textures while cached - that is for the texture cache - bool hasTextures() const { return !_materials.empty(); } + // Instead, these methods clear and reset textures from the geometry when caching/loading + bool shouldSetTextures() const { return _geometry && _materials.empty(); } void setTextures(); void resetTextures();