mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:28:46 +02:00
Fix OBJSerializer crash with empty groupMaterialName
This commit is contained in:
parent
fa51ec3daf
commit
77dcad21db
1 changed files with 7 additions and 4 deletions
|
@ -741,8 +741,8 @@ HFMModel::Pointer OBJSerializer::read(const hifi::ByteArray& data, const hifi::V
|
||||||
needsMaterialLibrary = groupMaterialName != SMART_DEFAULT_MATERIAL_NAME;
|
needsMaterialLibrary = groupMaterialName != SMART_DEFAULT_MATERIAL_NAME;
|
||||||
}
|
}
|
||||||
materials[groupMaterialName] = material;
|
materials[groupMaterialName] = material;
|
||||||
materialNamePerShape.push_back(groupMaterialName);
|
|
||||||
}
|
}
|
||||||
|
materialNamePerShape.push_back(groupMaterialName);
|
||||||
|
|
||||||
|
|
||||||
hfm::Shape shape;
|
hfm::Shape shape;
|
||||||
|
@ -1010,9 +1010,12 @@ HFMModel::Pointer OBJSerializer::read(const hifi::ByteArray& data, const hifi::V
|
||||||
|
|
||||||
// GO over the shapes once more to assign the material index correctly
|
// GO over the shapes once more to assign the material index correctly
|
||||||
for (uint32_t i = 0; i < (uint32_t)hfmModel.shapes.size(); ++i) {
|
for (uint32_t i = 0; i < (uint32_t)hfmModel.shapes.size(); ++i) {
|
||||||
auto foundMaterialIndex = materialNameToIndex.find(materialNamePerShape[i]);
|
const auto& materialName = materialNamePerShape[i];
|
||||||
if (foundMaterialIndex != materialNameToIndex.end()) {
|
if (!materialName.isEmpty()) {
|
||||||
hfmModel.shapes[i].material = foundMaterialIndex.value();
|
auto foundMaterialIndex = materialNameToIndex.find(materialName);
|
||||||
|
if (foundMaterialIndex != materialNameToIndex.end()) {
|
||||||
|
hfmModel.shapes[i].material = foundMaterialIndex.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue