Avoid setting null texs on uncaching models

This commit is contained in:
Zach Pomerantz 2016-04-03 06:05:16 -07:00
parent d899d7d696
commit fc19b60f8a
2 changed files with 3 additions and 2 deletions

View file

@ -232,7 +232,7 @@ std::shared_ptr<NetworkGeometry> ModelCache::getGeometry(const QUrl& url, const
GeometryExtra geometryExtra = { mapping, textureBaseUrl };
GeometryResource::Pointer resource = getResource(url, QUrl(), true, &geometryExtra).staticCast<GeometryResource>();
if (resource) {
if (resource->isLoaded() && !resource->hasTextures()) {
if (resource->isLoaded() && resource->shouldSetTextures()) {
resource->setTextures();
}
return std::make_shared<NetworkGeometry>(resource);

View file

@ -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();