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); 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) { 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>()->getCollisionGeometryResource(getCompoundShapeURL()); getCollisionGeometryResource();
} }
} 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
@ -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 // will end up in a different hash-key in ResourceCache. TODO: It would be better to use the same URL and
// parse it twice. // parse it twice.
auto currentCompoundShapeURL = getCompoundShapeURL(); auto currentCompoundShapeURL = getCompoundShapeURL();
QUrl hullURL(url); ModelEntityItem::setCompoundShapeURL(url);
QUrlQuery queryArgs(hullURL);
queryArgs.addQueryItem("collision-hull", "");
hullURL.setQuery(queryArgs);
ModelEntityItem::setCompoundShapeURL(hullURL.toString());
if (getCompoundShapeURL() != currentCompoundShapeURL || !_model) { if (getCompoundShapeURL() != currentCompoundShapeURL || !_model) {
EntityTreePointer tree = getTree(); EntityTreePointer tree = getTree();
@ -638,7 +642,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>()->getCollisionGeometryResource(hullURL); getCollisionGeometryResource();
} }
} }
} }
@ -670,8 +674,7 @@ bool RenderableModelEntityItem::isReadyToComputeShape() {
} }
return true; return true;
} else if (!getCompoundShapeURL().isEmpty()) { } else if (!getCompoundShapeURL().isEmpty()) {
_compoundShapeResource = getCollisionGeometryResource();
DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCompoundShapeURL());
} }
} }

View file

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