mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 20:58:30 +02:00
make getCollisionGeometryResource a separate call from getGeometryResource rather than passing a bool
This commit is contained in:
parent
6bd841857f
commit
8a3a52cbcf
4 changed files with 24 additions and 6 deletions
|
@ -612,7 +612,7 @@ void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
|||
ModelEntityItem::setShapeType(type);
|
||||
if (getShapeType() == SHAPE_TYPE_COMPOUND) {
|
||||
if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
|
||||
_compoundShapeResource = DependencyManager::get<ModelCache>()->getGeometryResource(getCompoundShapeURL(), false);
|
||||
_compoundShapeResource = DependencyManager::get<ModelCache>()->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<ModelCache>()->getGeometryResource(hullURL, false);
|
||||
_compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(hullURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -670,7 +670,8 @@ bool RenderableModelEntityItem::isReadyToComputeShape() {
|
|||
}
|
||||
return true;
|
||||
} else if (!getCompoundShapeURL().isEmpty()) {
|
||||
_compoundShapeResource = DependencyManager::get<ModelCache>()->getGeometryResource(getCompoundShapeURL(), false);
|
||||
_compoundShapeResource =
|
||||
DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,8 +283,22 @@ QSharedPointer<Resource> ModelCache::createResource(const QUrl& url, const QShar
|
|||
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) {
|
||||
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 };
|
||||
GeometryResource::Pointer resource = getResource(url, QUrl(), &geometryExtra).staticCast<GeometryResource>();
|
||||
if (resource) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -811,7 +811,7 @@ void Model::setURL(const QUrl& url) {
|
|||
invalidCalculatedMeshBoxes();
|
||||
deleteGeometry();
|
||||
|
||||
auto resource = DependencyManager::get<ModelCache>()->getGeometryResource(url, true);
|
||||
auto resource = DependencyManager::get<ModelCache>()->getGeometryResource(url);
|
||||
resource->setLoadPriority(this, _loadingPriority);
|
||||
_renderWatcher.setResource(resource);
|
||||
onInvalidate();
|
||||
|
|
Loading…
Reference in a new issue