From e2daf37a39bda703a50d6e0e38b48f832285002b Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Thu, 11 Mar 2010 18:24:54 +0000 Subject: [PATCH] - Fix http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099. - Add unit test to avoid ppfx-related issue with re-use of Importer's in future. - X file loader now properly resets all of its members. - OptimizeMeshes step now properly resets all of its member. - Fix old (and already deprecated) makefile.mingw. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@593 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/OptimizeMeshes.cpp | 4 ++++ code/XFileImporter.cpp | 4 ++++ code/makefile.mingw | 4 +++- test/unit/utImporter.cpp | 28 +++++++++++++++++++++++++++- test/unit/utImporter.h | 3 +++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/code/OptimizeMeshes.cpp b/code/OptimizeMeshes.cpp index 8c1cc6202..9d5b0d5c0 100644 --- a/code/OptimizeMeshes.cpp +++ b/code/OptimizeMeshes.cpp @@ -103,6 +103,10 @@ void OptimizeMeshesProcess::Execute( aiScene* pScene) DefaultLogger::get()->debug("OptimizeMeshesProcess begin"); mScene = pScene; + // need to clear persistent members from previous runs + merge_list.clear(); + output.clear(); + merge_list.reserve(pScene->mNumMeshes); output.reserve(pScene->mNumMeshes); diff --git a/code/XFileImporter.cpp b/code/XFileImporter.cpp index 1dc14c714..473c36c89 100644 --- a/code/XFileImporter.cpp +++ b/code/XFileImporter.cpp @@ -96,6 +96,10 @@ void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, I if( fileSize < 16) throw new ImportErrorException( "XFile is too small."); + // need to clear members - this method might be called multiple + // times on a single XFileImporter instance. + mImportedMats.clear(); + // in the hope that binary files will never start with a BOM ... mBuffer.resize( fileSize); file->Read( &mBuffer.front(), 1, fileSize); diff --git a/code/makefile.mingw b/code/makefile.mingw index 5680fad23..4841201cb 100644 --- a/code/makefile.mingw +++ b/code/makefile.mingw @@ -45,12 +45,14 @@ CPPFLAGS=-Wall # Setup environment for noboost build ifeq ($(NOBOOST),1) SINGLETHREADED = 1 - INCLUDEFLAGS += -I../include/BoostWorkaround/ + INCLUDEFLAGS += -I/BoostWorkaround/ DEFINEFLAGS += -DASSIMP_BUILD_BOOST_WORKAROUND # NAMESUFFIX += -noboost else # adjust this manually if your boost is stored elsewhere INCLUDEFLAGS += -I"C:/Program Files/boost/boost_1_38" + #INCLUDEFLAGS += -I"$(BOOST_DIR)" + endif # Setup environment for st build diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index 307d05899..a00a31bce 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -171,5 +171,31 @@ void ImporterTest :: testExtensionCheck (void) std::string s; pImp->GetExtensionList(s); - // todo .. + // TODO +} + +void ImporterTest :: testMultipleReads (void) +{ + // see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099 + // Check whether reading and post-processing multiple times using + // the same objects is *generally* fine. + + const unsigned int flags = + aiProcess_Triangulate | + aiProcess_JoinIdenticalVertices | + aiProcess_GenSmoothNormals | + aiProcess_ValidateDataStructure | + aiProcess_RemoveRedundantMaterials | + aiProcess_SortByPType | + aiProcess_FindDegenerates | + aiProcess_FindInvalidData | + aiProcess_GenUVCoords | + aiProcess_OptimizeMeshes | + aiProcess_OptimizeGraph; + + CPPUNIT_ASSERT(pImp->ReadFile("../../test/models/X/test.x",flags)); + CPPUNIT_ASSERT(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); + CPPUNIT_ASSERT(pImp->ReadFile("../../test/models/X/Testwuson.x",flags)); + CPPUNIT_ASSERT(pImp->ReadFile("../../test/models/X/anim_test.x",flags)); + CPPUNIT_ASSERT(pImp->ReadFile("../../test/models/X/dwarf.x",flags)); } diff --git a/test/unit/utImporter.h b/test/unit/utImporter.h index b03660844..baec140b1 100644 --- a/test/unit/utImporter.h +++ b/test/unit/utImporter.h @@ -19,6 +19,7 @@ class ImporterTest : public CPPUNIT_NS :: TestFixture CPPUNIT_TEST (testPluginInterface); CPPUNIT_TEST (testExtensionCheck); CPPUNIT_TEST (testMemoryRead); + CPPUNIT_TEST (testMultipleReads); CPPUNIT_TEST_SUITE_END (); public: @@ -35,6 +36,8 @@ class ImporterTest : public CPPUNIT_NS :: TestFixture void testExtensionCheck (void); void testMemoryRead (void); + void testMultipleReads (void); + private: Importer* pImp;