mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:24:24 +02:00
Persist tex base url across caching
This commit is contained in:
parent
2daf0c4da4
commit
489a2fd0b9
1 changed files with 7 additions and 4 deletions
|
@ -29,6 +29,10 @@ public:
|
||||||
const QUrl& textureBaseUrl;
|
const QUrl& textureBaseUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QUrl resolveTextureBaseUrl(const QUrl& url, const QUrl& textureBaseUrl) {
|
||||||
|
return textureBaseUrl.isValid() ? textureBaseUrl : url;
|
||||||
|
}
|
||||||
|
|
||||||
class GeometryMappingResource : public GeometryResource {
|
class GeometryMappingResource : public GeometryResource {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -52,18 +56,17 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) {
|
||||||
finishedLoading(false);
|
finishedLoading(false);
|
||||||
} else {
|
} else {
|
||||||
QUrl url = _url.resolved(filename);
|
QUrl url = _url.resolved(filename);
|
||||||
QUrl textureBaseUrl;
|
|
||||||
|
|
||||||
QString texdir = mapping.value("texdir").toString();
|
QString texdir = mapping.value("texdir").toString();
|
||||||
if (!texdir.isNull()) {
|
if (!texdir.isNull()) {
|
||||||
if (!texdir.endsWith('/')) {
|
if (!texdir.endsWith('/')) {
|
||||||
texdir += '/';
|
texdir += '/';
|
||||||
}
|
}
|
||||||
textureBaseUrl = _url.resolved(texdir);
|
_textureBaseUrl = resolveTextureBaseUrl(url, _url.resolved(texdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto modelCache = DependencyManager::get<ModelCache>();
|
auto modelCache = DependencyManager::get<ModelCache>();
|
||||||
GeometryExtra extra{ mapping, textureBaseUrl };
|
GeometryExtra extra{ mapping, _textureBaseUrl };
|
||||||
|
|
||||||
// Get the raw GeometryResource, not the wrapped NetworkGeometry
|
// Get the raw GeometryResource, not the wrapped NetworkGeometry
|
||||||
_geometryResource = modelCache->getResource(url, QUrl(), false, &extra).staticCast<GeometryResource>();
|
_geometryResource = modelCache->getResource(url, QUrl(), false, &extra).staticCast<GeometryResource>();
|
||||||
|
@ -160,7 +163,7 @@ class GeometryDefinitionResource : public GeometryResource {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GeometryDefinitionResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl) :
|
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;
|
virtual void downloadFinished(const QByteArray& data) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue