From bd4a4fd6080930688aa8bf479c15b0925488a552 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Mon, 13 Sep 2010 14:40:25 +0000 Subject: [PATCH] further work on http://sourceforge.net/tracker/index.php?func=detail&aid=3054873&group_id=226462&atid=1067632 - first try the old node resolving algorithm (which checks for node IDs), if this fails switch to a workaround which takes both node names and IDs into account. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@815 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ColladaLoader.cpp | 15 ++++++----- code/ColladaLoader.h | 2 +- workspaces/vc8_deprecated/assimp.sln | 37 +++++----------------------- 3 files changed, 16 insertions(+), 38 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 5dffd34d7..7ed31819a 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -185,7 +185,7 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla node->mTransformation = pParser.CalculateResultTransform( pNode->mTransforms); // now resolve node instances - std::vector instances; + std::vector instances; ResolveNodeInstances(pParser,pNode,instances); // add children. first the *real* ones @@ -219,7 +219,7 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla // ------------------------------------------------------------------------------------------------ // Resolve node instances void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Collada::Node* pNode, - std::vector& resolved) + std::vector& resolved) { // reserve enough storage resolved.reserve(pNode->mNodeInstances.size()); @@ -229,12 +229,15 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co end = pNode->mNodeInstances.end(); it != end; ++it) { // find the corresponding node in the library + const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode); + 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 - // 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)); + // 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. + if (!nd) { + nd = const_cast(FindNode(pParser.mRootNode,(*it).mNode)); + } if (!nd) DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode); diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index cc245b91b..f33a6c167 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -108,7 +108,7 @@ protected: /** Resolve node instances */ void ResolveNodeInstances( const ColladaParser& pParser, const Collada::Node* pNode, - std::vector& resolved); + std::vector& resolved); /** Builds meshes for the given node and references them */ void BuildMeshesForNode( const ColladaParser& pParser, const Collada::Node* pNode, diff --git a/workspaces/vc8_deprecated/assimp.sln b/workspaces/vc8_deprecated/assimp.sln index f5f312aab..efd6eddfd 100644 --- a/workspaces/vc8_deprecated/assimp.sln +++ b/workspaces/vc8_deprecated/assimp.sln @@ -1,38 +1,13 @@  -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimpview", "assimp_view.vcproj", "{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimpview", "assimp_view.vcxproj", "{B17B959B-BB8A-4596-AF0F-A8C8DBBC3C5E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp", "assimp.vcproj", "{5691E159-2D9B-407F-971F-EA5C592DC524}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp", "assimp.vcxproj", "{5691E159-2D9B-407F-971F-EA5C592DC524}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit", "UnitTest.vcproj", "{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit", "UnitTest.vcxproj", "{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimp_cmd", "assimp_cmd.vcproj", "{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimpcmd", "assimp_cmd.vcxproj", "{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution