From 209c12cb1ca3e3d619606339de5b5b0d85b63ab0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 27 Oct 2014 16:52:22 -0700 Subject: [PATCH] repairs for texture replacement by name --- interface/src/renderer/GeometryCache.cpp | 19 +++++++++++++------ interface/src/renderer/GeometryCache.h | 3 +++ interface/src/renderer/TextureCache.h | 4 ---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/interface/src/renderer/GeometryCache.cpp b/interface/src/renderer/GeometryCache.cpp index 35765c50b8..f1d4d712e5 100644 --- a/interface/src/renderer/GeometryCache.cpp +++ b/interface/src/renderer/GeometryCache.cpp @@ -620,12 +620,19 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u NetworkMeshPart& part = mesh.parts[j]; QSharedPointer matchingTexture = QSharedPointer(); - if (part.diffuseTexture->getName() == name) { + if (part.diffuseTextureName == name) { part.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, - _geometry.meshes[i].isEye, QByteArray()); - part.diffuseTexture->setName(name); + _geometry.meshes[i].isEye, QByteArray()); part.diffuseTexture->setLoadPriorities(_loadPriorities); + } else if (part.normalTextureName == name) { + part.normalTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, + false, QByteArray()); + part.normalTexture->setLoadPriorities(_loadPriorities); + } else if (part.specularTextureName == name) { + part.specularTexture = Application::getInstance()->getTextureCache()->getTexture(url, DEFAULT_TEXTURE, + false, QByteArray()); + part.specularTexture->setLoadPriorities(_loadPriorities); } } } @@ -746,21 +753,21 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { networkPart.diffuseTexture = Application::getInstance()->getTextureCache()->getTexture( _textureBase.resolved(QUrl(part.diffuseTexture.filename)), DEFAULT_TEXTURE, mesh.isEye, part.diffuseTexture.content); - networkPart.diffuseTexture->setName(part.diffuseTexture.name); + networkPart.diffuseTextureName = part.diffuseTexture.name; networkPart.diffuseTexture->setLoadPriorities(_loadPriorities); } if (!part.normalTexture.filename.isEmpty()) { networkPart.normalTexture = Application::getInstance()->getTextureCache()->getTexture( _textureBase.resolved(QUrl(part.normalTexture.filename)), NORMAL_TEXTURE, false, part.normalTexture.content); - networkPart.normalTexture->setName(part.normalTexture.name); + networkPart.normalTextureName = part.normalTexture.name; networkPart.normalTexture->setLoadPriorities(_loadPriorities); } if (!part.specularTexture.filename.isEmpty()) { networkPart.specularTexture = Application::getInstance()->getTextureCache()->getTexture( _textureBase.resolved(QUrl(part.specularTexture.filename)), SPECULAR_TEXTURE, false, part.specularTexture.content); - networkPart.specularTexture->setName(part.specularTexture.name); + networkPart.specularTextureName = part.specularTexture.name; networkPart.specularTexture->setLoadPriorities(_loadPriorities); } networkMesh.parts.append(networkPart); diff --git a/interface/src/renderer/GeometryCache.h b/interface/src/renderer/GeometryCache.h index 461d622a02..4ed6c9943d 100644 --- a/interface/src/renderer/GeometryCache.h +++ b/interface/src/renderer/GeometryCache.h @@ -140,8 +140,11 @@ private: class NetworkMeshPart { public: + QString diffuseTextureName; QSharedPointer diffuseTexture; + QString normalTextureName; QSharedPointer normalTexture; + QString specularTextureName; QSharedPointer specularTexture; bool isTranslucent() const; diff --git a/interface/src/renderer/TextureCache.h b/interface/src/renderer/TextureCache.h index 29740621e3..fd9131fe23 100644 --- a/interface/src/renderer/TextureCache.h +++ b/interface/src/renderer/TextureCache.h @@ -145,9 +145,6 @@ public: /// Returns the lazily-computed average texture color. const QColor& getAverageColor() const { return _averageColor; } - - const QString& getName() const { return _name; } - void setName(const QString& name) { _name = name; } protected: @@ -159,7 +156,6 @@ protected: virtual void imageLoaded(const QImage& image); private: - QString _name; TextureType _type; bool _translucent; QColor _averageColor;