From 2daf0c4da4c23bd4da39c4fb3307a3e3928bc016 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 1 Apr 2016 11:32:13 -0700 Subject: [PATCH 1/2] Init tex base url in Geometry ctor --- libraries/model-networking/src/model-networking/ModelCache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 45f78f4f19..81883d972d 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -95,7 +95,8 @@ class GeometryResource : public Resource, public Geometry { public: using Pointer = QSharedPointer; - GeometryResource(const QUrl& url, const QUrl& textureBaseUrl = QUrl()) : Resource(url) {} + GeometryResource(const QUrl& url, const QUrl& textureBaseUrl = QUrl()) : + Resource(url), _textureBaseUrl(textureBaseUrl) {} virtual bool areTexturesLoaded() const { return isLoaded() && Geometry::areTexturesLoaded(); } From 489a2fd0b97303def20b8fcbca6c8f7f02088099 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 1 Apr 2016 11:32:29 -0700 Subject: [PATCH 2/2] Persist tex base url across caching --- .../src/model-networking/ModelCache.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 4120062308..41c2a2e194 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -29,6 +29,10 @@ public: const QUrl& textureBaseUrl; }; +QUrl resolveTextureBaseUrl(const QUrl& url, const QUrl& textureBaseUrl) { + return textureBaseUrl.isValid() ? textureBaseUrl : url; +} + class GeometryMappingResource : public GeometryResource { Q_OBJECT public: @@ -52,18 +56,17 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { finishedLoading(false); } else { QUrl url = _url.resolved(filename); - QUrl textureBaseUrl; QString texdir = mapping.value("texdir").toString(); if (!texdir.isNull()) { if (!texdir.endsWith('/')) { texdir += '/'; } - textureBaseUrl = _url.resolved(texdir); + _textureBaseUrl = resolveTextureBaseUrl(url, _url.resolved(texdir)); } auto modelCache = DependencyManager::get(); - GeometryExtra extra{ mapping, textureBaseUrl }; + GeometryExtra extra{ mapping, _textureBaseUrl }; // Get the raw GeometryResource, not the wrapped NetworkGeometry _geometryResource = modelCache->getResource(url, QUrl(), false, &extra).staticCast(); @@ -160,7 +163,7 @@ class GeometryDefinitionResource : public GeometryResource { Q_OBJECT public: GeometryDefinitionResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl) : - GeometryResource(url, textureBaseUrl.isValid() ? textureBaseUrl : url), _mapping(mapping) {} + GeometryResource(url, resolveTextureBaseUrl(url, textureBaseUrl)), _mapping(mapping) {} virtual void downloadFinished(const QByteArray& data) override;