From e440fb276904a60dd819dc5703ae4570b6fd98fd Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sat, 11 Sep 2010 19:44:06 +0000 Subject: [PATCH] NDOLoader: improve reusability of some temporary vectors. ColladaLoader: fix http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632, thanks to Adario for the report. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@814 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ColladaLoader.cpp | 11 ++++++++--- code/NDOLoader.cpp | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index ff0c6e2ab..5dffd34d7 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -229,13 +229,18 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co end = pNode->mNodeInstances.end(); it != end; ++it) { // find the corresponding node in the library - ColladaParser::NodeLibrary::const_iterator fnd = pParser.mNodeLibrary.find((*it).mNode); - if (fnd == pParser.mNodeLibrary.end()) + + // 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. The const_cast is legal + // because we won't attempt to modify the instanced node although it is kept + // non-const. + Collada::Node* nd = const_cast(FindNode(pParser.mRootNode,(*it).mNode)); + if (!nd) DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode); else { // attach this node to the list of children - resolved.push_back((*fnd).second); + resolved.push_back(nd); } } } diff --git a/code/NDOLoader.cpp b/code/NDOLoader.cpp index fc2da4862..3c2020150 100644 --- a/code/NDOLoader.cpp +++ b/code/NDOLoader.cpp @@ -220,6 +220,9 @@ void NDOImporter::InternReadFile( const std::string& pFile, aiNode** cc = root->mChildren = new aiNode* [ root->mNumChildren = static_cast( objects.size()) ] (); pScene->mMeshes = new aiMesh* [ root->mNumChildren] (); + std::vector vertices; + std::vector indices; + for_each(const Object& obj,objects) { aiNode* nd = *cc++ = new aiNode(obj.name); nd->mParent = root; @@ -240,9 +243,7 @@ void NDOImporter::InternReadFile( const std::string& pFile, aiMesh* mesh = new aiMesh(); aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces=face_table.size()]; - std::vector vertices; - std::vector indices; - + vertices.clear(); vertices.reserve(4 * face_table.size()); // arbitrarily choosen for_each(FaceTable::value_type& v, face_table) { indices.clear();