mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 15:23:56 +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;
|
||||
}
|
||||
materials[groupMaterialName] = material;
|
||||
materialNamePerShape.push_back(groupMaterialName);
|
||||
}
|
||||
materialNamePerShape.push_back(groupMaterialName);
|
||||
|
||||
|
||||
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
|
||||
for (uint32_t i = 0; i < (uint32_t)hfmModel.shapes.size(); ++i) {
|
||||
auto foundMaterialIndex = materialNameToIndex.find(materialNamePerShape[i]);
|
||||
if (foundMaterialIndex != materialNameToIndex.end()) {
|
||||
hfmModel.shapes[i].material = foundMaterialIndex.value();
|
||||
const auto& materialName = materialNamePerShape[i];
|
||||
if (!materialName.isEmpty()) {
|
||||
auto foundMaterialIndex = materialNameToIndex.find(materialName);
|
||||
if (foundMaterialIndex != materialNameToIndex.end()) {
|
||||
hfmModel.shapes[i].material = foundMaterialIndex.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue