Hack to suppress the attempted loading of .mtllib files if the url has a query part that includes "hifiusemat".

This commit is contained in:
Howard Stearns 2016-03-15 21:11:54 -07:00
parent 76b5b6aeeb
commit 798a225573

View file

@ -251,16 +251,10 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
#endif #endif
break; break;
} }
if (isValidTexture(filename)) { if (token == "map_Kd") {
if (token == "map_Kd") { currentMaterial.diffuseTextureFilename = filename;
currentMaterial.diffuseTextureFilename = filename;
} else {
currentMaterial.specularTextureFilename = filename;
}
} else { } else {
#ifdef WANT_DEBUG currentMaterial.specularTextureFilename = filename;
qCDebug(modelformat) << "OBJ Reader WARNING: " << _url << " ignoring missing texture " << filename;
#endif
} }
} }
} }
@ -534,7 +528,12 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
qCDebug(modelformat) << "OBJ reader fail: " << e.what(); qCDebug(modelformat) << "OBJ reader fail: " << e.what();
} }
QString queryPart = _url.query();
bool suppressMaterialsHack = queryPart.contains("hifiusemat"); // If this appears in query string, don't fetch mtl even if used.
OBJMaterial& preDefinedMaterial = materials[SMART_DEFAULT_MATERIAL_NAME]; OBJMaterial& preDefinedMaterial = materials[SMART_DEFAULT_MATERIAL_NAME];
if (suppressMaterialsHack) {
needsMaterialLibrary = preDefinedMaterial.userSpecifiesUV = false; // I said it was a hack...
}
// Some .obj files use the convention that a group with uv coordinates that doesn't define a material, should use // Some .obj files use the convention that a group with uv coordinates that doesn't define a material, should use
// a texture with the same basename as the .obj file. // a texture with the same basename as the .obj file.
if (preDefinedMaterial.userSpecifiesUV && !url.isEmpty()) { if (preDefinedMaterial.userSpecifiesUV && !url.isEmpty()) {