From 8a3a52cbcf3b922a26944df6da87bb0dedb23b53 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 10 Apr 2017 13:54:24 -0700 Subject: [PATCH] make getCollisionGeometryResource a separate call from getGeometryResource rather than passing a bool --- .../src/RenderableModelEntityItem.cpp | 7 ++++--- .../src/model-networking/ModelCache.cpp | 16 +++++++++++++++- .../src/model-networking/ModelCache.h | 5 ++++- libraries/render-utils/src/Model.cpp | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index d30baaa6eb..cb950e244a 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -612,7 +612,7 @@ void RenderableModelEntityItem::setShapeType(ShapeType type) { ModelEntityItem::setShapeType(type); if (getShapeType() == SHAPE_TYPE_COMPOUND) { if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) { - _compoundShapeResource = DependencyManager::get()->getGeometryResource(getCompoundShapeURL(), false); + _compoundShapeResource = DependencyManager::get()->getCollisionGeometryResource(getCompoundShapeURL()); } } else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) { // the compoundURL has been set but the shapeType does not agree @@ -638,7 +638,7 @@ void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) { QMetaObject::invokeMethod(tree.get(), "callLoader", Qt::QueuedConnection, Q_ARG(EntityItemID, getID())); } if (getShapeType() == SHAPE_TYPE_COMPOUND) { - _compoundShapeResource = DependencyManager::get()->getGeometryResource(hullURL, false); + _compoundShapeResource = DependencyManager::get()->getCollisionGeometryResource(hullURL); } } } @@ -670,7 +670,8 @@ bool RenderableModelEntityItem::isReadyToComputeShape() { } return true; } else if (!getCompoundShapeURL().isEmpty()) { - _compoundShapeResource = DependencyManager::get()->getGeometryResource(getCompoundShapeURL(), false); + _compoundShapeResource = + DependencyManager::get()->getCollisionGeometryResource(getCompoundShapeURL()); } } diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index b701c9ae3b..d9c5294be2 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -283,8 +283,22 @@ QSharedPointer ModelCache::createResource(const QUrl& url, const QShar return QSharedPointer(resource, &Resource::deleter); } -GeometryResource::Pointer ModelCache::getGeometryResource(const QUrl& url, bool combineParts, +GeometryResource::Pointer ModelCache::getGeometryResource(const QUrl& url, const QVariantHash& mapping, const QUrl& textureBaseUrl) { + bool combineParts = true; + GeometryExtra geometryExtra = { mapping, textureBaseUrl, combineParts }; + GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast(); + if (resource) { + if (resource->isLoaded() && resource->shouldSetTextures()) { + resource->setTextures(); + } + } + return resource; +} + +GeometryResource::Pointer ModelCache::getCollisionGeometryResource(const QUrl& url, + const QVariantHash& mapping, const QUrl& textureBaseUrl) { + bool combineParts = false; GeometryExtra geometryExtra = { mapping, textureBaseUrl, combineParts }; GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast(); if (resource) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index b48249ec42..967897477d 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -136,10 +136,13 @@ class ModelCache : public ResourceCache, public Dependency { public: GeometryResource::Pointer getGeometryResource(const QUrl& url, - bool combineParts, const QVariantHash& mapping = QVariantHash(), const QUrl& textureBaseUrl = QUrl()); + GeometryResource::Pointer getCollisionGeometryResource(const QUrl& url, + const QVariantHash& mapping = QVariantHash(), + const QUrl& textureBaseUrl = QUrl()); + protected: friend class GeometryMappingResource; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index f452f7c37e..c274d69af6 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -811,7 +811,7 @@ void Model::setURL(const QUrl& url) { invalidCalculatedMeshBoxes(); deleteGeometry(); - auto resource = DependencyManager::get()->getGeometryResource(url, true); + auto resource = DependencyManager::get()->getGeometryResource(url); resource->setLoadPriority(this, _loadingPriority); _renderWatcher.setResource(resource); onInvalidate();