diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 62c41615b..bb0bf9246 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -120,7 +121,7 @@ namespace Nz // Sort meshes by material and group using MatPair = std::pair; - std::unordered_map> meshesByName; + tsl::ordered_map> meshesByName; UInt32 faceReserve = 0; UInt32 vertexReserve = 0; @@ -132,14 +133,14 @@ namespace Nz if (it == map.end()) it = map.insert(std::make_pair(mat, MatPair(Mesh(), matCount++))).first; - Mesh& meshData = it->second.first; + Mesh& meshData = it.value().first; meshData.faces.reserve(faceReserve); meshData.vertices.reserve(vertexReserve); faceReserve = 0; vertexReserve = 0; - return &(it->second.first); + return &meshData; }; // On prépare le mesh par défaut @@ -448,22 +449,26 @@ namespace Nz std::unordered_map materials; m_materials.resize(matCount); - for (auto& meshPair : meshesByName) + for (auto meshIt = meshesByName.begin(); meshIt != meshesByName.end(); ++meshIt) { - for (auto& matPair : meshPair.second) + auto& matMap = meshIt.value(); + for (auto matIt = matMap.begin(); matIt != matMap.end(); ++matIt) { - Mesh& mesh = matPair.second.first; - unsigned int index = matPair.second.second; + MatPair& matPair = matIt.value(); + Mesh& mesh = matPair.first; + unsigned int index = matPair.second; + if (!mesh.faces.empty()) { - mesh.name = meshPair.first; + mesh.name = meshIt.key(); - auto it = materials.find(matPair.first); + const std::string& matName = matIt.key(); + auto it = materials.find(matName); if (it == materials.end()) { mesh.material = index; - materials[matPair.first] = index; - m_materials[index] = matPair.first; + materials[matName] = index; + m_materials[index] = matName; } else mesh.material = it->second;