make getCollisionGeometryResource a separate call from getGeometryResource rather than passing a bool

This commit is contained in:
Seth Alves 2017-04-10 13:54:24 -07:00
parent 6bd841857f
commit 8a3a52cbcf
4 changed files with 24 additions and 6 deletions

View file

@ -612,7 +612,7 @@ void RenderableModelEntityItem::setShapeType(ShapeType type) {
ModelEntityItem::setShapeType(type); ModelEntityItem::setShapeType(type);
if (getShapeType() == SHAPE_TYPE_COMPOUND) { if (getShapeType() == SHAPE_TYPE_COMPOUND) {
if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) { if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
_compoundShapeResource = DependencyManager::get<ModelCache>()->getGeometryResource(getCompoundShapeURL(), false); _compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
} }
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) { } else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
// the compoundURL has been set but the shapeType does not agree // 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())); QMetaObject::invokeMethod(tree.get(), "callLoader", Qt::QueuedConnection, Q_ARG(EntityItemID, getID()));
} }
if (getShapeType() == SHAPE_TYPE_COMPOUND) { if (getShapeType() == SHAPE_TYPE_COMPOUND) {
_compoundShapeResource = DependencyManager::get<ModelCache>()->getGeometryResource(hullURL, false); _compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(hullURL);
} }
} }
} }
@ -670,7 +670,8 @@ bool RenderableModelEntityItem::isReadyToComputeShape() {
} }
return true; return true;
} else if (!getCompoundShapeURL().isEmpty()) { } else if (!getCompoundShapeURL().isEmpty()) {
_compoundShapeResource = DependencyManager::get<ModelCache>()->getGeometryResource(getCompoundShapeURL(), false); _compoundShapeResource =
DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
} }
} }

View file

@ -283,8 +283,22 @@ QSharedPointer<Resource> ModelCache::createResource(const QUrl& url, const QShar
return QSharedPointer<Resource>(resource, &Resource::deleter); return QSharedPointer<Resource>(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) { const QVariantHash& mapping, const QUrl& textureBaseUrl) {
bool combineParts = true;
GeometryExtra geometryExtra = { mapping, textureBaseUrl, combineParts };
GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast<GeometryResource>();
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 }; GeometryExtra geometryExtra = { mapping, textureBaseUrl, combineParts };
GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast<GeometryResource>(); GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast<GeometryResource>();
if (resource) { if (resource) {

View file

@ -136,10 +136,13 @@ class ModelCache : public ResourceCache, public Dependency {
public: public:
GeometryResource::Pointer getGeometryResource(const QUrl& url, GeometryResource::Pointer getGeometryResource(const QUrl& url,
bool combineParts,
const QVariantHash& mapping = QVariantHash(), const QVariantHash& mapping = QVariantHash(),
const QUrl& textureBaseUrl = QUrl()); const QUrl& textureBaseUrl = QUrl());
GeometryResource::Pointer getCollisionGeometryResource(const QUrl& url,
const QVariantHash& mapping = QVariantHash(),
const QUrl& textureBaseUrl = QUrl());
protected: protected:
friend class GeometryMappingResource; friend class GeometryMappingResource;

View file

@ -811,7 +811,7 @@ void Model::setURL(const QUrl& url) {
invalidCalculatedMeshBoxes(); invalidCalculatedMeshBoxes();
deleteGeometry(); deleteGeometry();
auto resource = DependencyManager::get<ModelCache>()->getGeometryResource(url, true); auto resource = DependencyManager::get<ModelCache>()->getGeometryResource(url);
resource->setLoadPriority(this, _loadingPriority); resource->setLoadPriority(this, _loadingPriority);
_renderWatcher.setResource(resource); _renderWatcher.setResource(resource);
onInvalidate(); onInvalidate();