From 896ab8eee2bf864740ed5d722fbde9c5bc3303cd Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 22 May 2016 13:50:29 +0300 Subject: [PATCH] Unreal: Use C++11 range-based for loop --- code/UnrealLoader.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/code/UnrealLoader.cpp b/code/UnrealLoader.cpp index d7accacea..ad839fb25 100644 --- a/code/UnrealLoader.cpp +++ b/code/UnrealLoader.cpp @@ -171,9 +171,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, // collect triangles std::vector triangles(numTris); - for (std::vector::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) { - Unreal::Triangle& tri = *it; - + for (auto & tri : triangles) { for (unsigned int i = 0; i < 3;++i) { tri.mVertex[i] = d_reader.GetI2(); @@ -222,9 +220,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile, // collect vertices std::vector vertices(numVert); - for (std::vector::iterator it = vertices.begin(), end = vertices.end(); it != end; ++it) { + for (auto &vertex : vertices) { int32_t val = a_reader.GetI4(); - Unreal::DecompressVertex(*it,val); + Unreal::DecompressVertex(vertex ,val); } // list of textures. @@ -330,8 +328,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, materials.reserve(textures.size()*2+5); // find out how many output meshes and materials we'll have and build material indices - for (std::vector::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) { - Unreal::Triangle& tri = *it; + for (Unreal::Triangle &tri : triangles) { Unreal::TempMat mat(tri); std::vector::iterator nt = std::find(materials.begin(),materials.end(),mat); if (nt == materials.end()) { @@ -418,8 +415,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, } // fill them. - for (std::vector::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) { - Unreal::Triangle& tri = *it; + for (const Unreal::Triangle &tri : triangles) { Unreal::TempMat mat(tri); std::vector::iterator nt = std::find(materials.begin(),materials.end(),mat);