Raw: Use C++11 range-based for loop

pull/898/head
Turo Lamminen 2016-05-22 13:45:50 +03:00
parent 6c9c040419
commit d238597459
1 changed files with 12 additions and 15 deletions

View File

@ -183,12 +183,11 @@ void RAWImporter::InternReadFile( const std::string& pFile,
} }
// search in the list of meshes whether we have one with this texture // search in the list of meshes whether we have one with this texture
for (std::vector< MeshInformation >::iterator it = (*curGroup).meshes.begin(), for (auto &mesh : (*curGroup).meshes)
end = (*curGroup).meshes.end(); it != end; ++it)
{ {
if (length == (*it).name.length() && (length ? !::strcmp(sz,(*it).name.c_str()) : true)) if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true))
{ {
output = &(*it); output = &mesh;
break; break;
} }
} }
@ -223,13 +222,12 @@ void RAWImporter::InternReadFile( const std::string& pFile,
// count the number of valid groups // count the number of valid groups
// (meshes can't be empty) // (meshes can't be empty)
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end(); for (auto & outGroup : outGroups)
it != end;++it)
{ {
if (!(*it).meshes.empty()) if (!outGroup.meshes.empty())
{ {
++pScene->mRootNode->mNumChildren; ++pScene->mRootNode->mNumChildren;
pScene->mNumMeshes += (unsigned int)(*it).meshes.size(); pScene->mNumMeshes += (unsigned int) outGroup.meshes.size();
} }
} }
@ -251,10 +249,9 @@ void RAWImporter::InternReadFile( const std::string& pFile,
aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
unsigned int meshIdx = 0; unsigned int meshIdx = 0;
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end(); for (auto & outGroup : outGroups)
it != end;++it)
{ {
if ((*it).meshes.empty())continue; if (outGroup.meshes.empty())continue;
aiNode* node; aiNode* node;
if (pScene->mRootNode->mNumChildren) if (pScene->mRootNode->mNumChildren)
@ -263,13 +260,13 @@ void RAWImporter::InternReadFile( const std::string& pFile,
node->mParent = pScene->mRootNode; node->mParent = pScene->mRootNode;
} }
else node = *cc;++cc; else node = *cc;++cc;
node->mName.Set((*it).name); node->mName.Set(outGroup.name);
// add all meshes // add all meshes
node->mNumMeshes = (unsigned int)(*it).meshes.size(); node->mNumMeshes = (unsigned int) outGroup.meshes.size();
unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ]; unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ];
for (std::vector< MeshInformation >::iterator it2 = (*it).meshes.begin(), for (std::vector< MeshInformation >::iterator it2 = outGroup.meshes.begin(),
end2 = (*it).meshes.end(); it2 != end2; ++it2) end2 = outGroup.meshes.end(); it2 != end2; ++it2)
{ {
ai_assert(!(*it2).vertices.empty()); ai_assert(!(*it2).vertices.empty());