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

pull/898/head
Turo Lamminen 2016-05-21 22:04:39 +03:00
parent f0ebb40f19
commit 52405bbe1b
1 changed files with 7 additions and 9 deletions

View File

@ -276,21 +276,20 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co
resolved.reserve(pNode->mNodeInstances.size()); resolved.reserve(pNode->mNodeInstances.size());
// ... and iterate through all nodes to be instanced as children of pNode // ... and iterate through all nodes to be instanced as children of pNode
for (std::vector<Collada::NodeInstance>::const_iterator it = pNode->mNodeInstances.begin(), for (const auto &nodeInst: pNode->mNodeInstances)
end = pNode->mNodeInstances.end(); it != end; ++it)
{ {
// find the corresponding node in the library // find the corresponding node in the library
const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode); const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode);
const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second; const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632 // FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
// need to check for both name and ID to catch all. To avoid breaking valid files, // need to check for both name and ID to catch all. To avoid breaking valid files,
// the workaround is only enabled when the first attempt to resolve the node has failed. // the workaround is only enabled when the first attempt to resolve the node has failed.
if (!nd) { if (!nd) {
nd = FindNode(pParser.mRootNode,(*it).mNode); nd = FindNode(pParser.mRootNode, nodeInst.mNode);
} }
if (!nd) if (!nd)
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode); DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode);
else { else {
// attach this node to the list of children // attach this node to the list of children
@ -1320,11 +1319,10 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
// Fills materials from the collada material definitions // Fills materials from the collada material definitions
void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/) void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/)
{ {
for (std::vector<std::pair<Collada::Effect*, aiMaterial*> >::iterator it = newMats.begin(), for (auto &elem : newMats)
end = newMats.end(); it != end; ++it)
{ {
aiMaterial& mat = (aiMaterial&)*it->second; aiMaterial& mat = (aiMaterial&)*elem.second;
Collada::Effect& effect = *it->first; Collada::Effect& effect = *elem.first;
// resolve shading mode // resolve shading mode
int shadeMode; int shadeMode;