Merge pull request #10191 from sethalves/fix-collision-hull-munging

fix -- munge collision-hull at last minute rather than store munged url as a property
This commit is contained in:
druiz17 2017-04-11 09:09:54 -07:00 committed by GitHub
commit b7daf8c80b
2 changed files with 13 additions and 9 deletions

View file

@ -608,11 +608,19 @@ bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& ori
face, surfaceNormal, extraInfo, precisionPicking);
}
void RenderableModelEntityItem::getCollisionGeometryResource() {
QUrl hullURL(getCompoundShapeURL());
QUrlQuery queryArgs(hullURL);
queryArgs.addQueryItem("collision-hull", "");
hullURL.setQuery(queryArgs);
_compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(hullURL);
}
void RenderableModelEntityItem::setShapeType(ShapeType type) {
ModelEntityItem::setShapeType(type);
if (getShapeType() == SHAPE_TYPE_COMPOUND) {
if (!_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
_compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
getCollisionGeometryResource();
}
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
// the compoundURL has been set but the shapeType does not agree
@ -626,11 +634,7 @@ void RenderableModelEntityItem::setCompoundShapeURL(const QString& url) {
// will end up in a different hash-key in ResourceCache. TODO: It would be better to use the same URL and
// parse it twice.
auto currentCompoundShapeURL = getCompoundShapeURL();
QUrl hullURL(url);
QUrlQuery queryArgs(hullURL);
queryArgs.addQueryItem("collision-hull", "");
hullURL.setQuery(queryArgs);
ModelEntityItem::setCompoundShapeURL(hullURL.toString());
ModelEntityItem::setCompoundShapeURL(url);
if (getCompoundShapeURL() != currentCompoundShapeURL || !_model) {
EntityTreePointer tree = getTree();
@ -638,7 +642,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>()->getCollisionGeometryResource(hullURL);
getCollisionGeometryResource();
}
}
}
@ -670,8 +674,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() {
}
return true;
} else if (!getCompoundShapeURL().isEmpty()) {
_compoundShapeResource =
DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
getCollisionGeometryResource();
}
}

View file

@ -108,6 +108,7 @@ private:
QVariantMap parseTexturesToMap(QString textures);
void remapTextures();
void getCollisionGeometryResource();
GeometryResource::Pointer _compoundShapeResource;
ModelPointer _model = nullptr;
bool _needsInitialSimulation = true;