Merge pull request #7470 from zzmp/fix/tex-json

Accept textures as list or json
This commit is contained in:
Chris Collins 2016-03-25 10:05:12 -07:00
commit 2a85170a46

View file

@ -113,14 +113,18 @@ QVariantMap RenderableModelEntityItem::parseTexturesToMap(QString textures) {
return _originalTexturesMap;
}
QString jsonTextures = "{\"" + textures.replace(":\"", "\":\"").replace(",\n", ",\"") + "}";
// Legacy: a ,\n-delimited list of filename:"texturepath"
if (*textures.cbegin() != '{') {
textures = "{\"" + textures.replace(":\"", "\":\"").replace(",\n", ",\"") + "}";
}
QJsonParseError error;
QJsonDocument texturesAsJson = QJsonDocument::fromJson(jsonTextures.toUtf8(), &error);
QJsonDocument texturesJson = QJsonDocument::fromJson(textures.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(entitiesrenderer) << "Could not evaluate textures property value:" << _textures;
return _originalTexturesMap;
}
QJsonObject texturesAsJsonObject = texturesAsJson.object();
return texturesAsJsonObject.toVariantMap();
return texturesJson.object().toVariantMap();
}
void RenderableModelEntityItem::remapTextures() {