Fix setting textures in model overlays

This commit is contained in:
Ryan Huffman 2016-09-08 14:55:51 -07:00
parent 4974c88880
commit c683c82817
2 changed files with 14 additions and 12 deletions

View file

@ -123,17 +123,19 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
auto texturesValue = properties["textures"];
if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) {
QVariantMap textureMap = texturesValue.toMap();
foreach(const QString& key, textureMap.keys()) {
QUrl newTextureURL = textureMap[key].toUrl();
qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL;
QMetaObject::invokeMethod(_model.get(), "setTextureWithNameToURL", Qt::AutoConnection,
Q_ARG(const QString&, key),
Q_ARG(const QUrl&, newTextureURL));
_modelTextures[key] = newTextureURL; // Keep local track of textures for getProperty()
}
QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection,
Q_ARG(const QVariantMap&, textureMap));
// foreach(const QString& key, textureMap.keys()) {
//
// QUrl newTextureURL = textureMap[key].toUrl();
// qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL;
//
// QMetaObject::invokeMethod(_model.get(), "setTextureWithNameToURL", Qt::AutoConnection,
// Q_ARG(const QString&, key),
// Q_ARG(const QUrl&, newTextureURL));
//
// _modelTextures[key] = newTextureURL; // Keep local track of textures for getProperty()
// }
}
}

View file

@ -131,7 +131,7 @@ public:
const Geometry::Pointer& getCollisionGeometry() const { return _collisionGeometry; }
const QVariantMap getTextures() const { assert(isLoaded()); return _renderGeometry->getTextures(); }
void setTextures(const QVariantMap& textures);
Q_INVOKABLE void setTextures(const QVariantMap& textures);
/// Provided as a convenience, will crash if !isLoaded()
// And so that getGeometry() isn't chained everywhere