Pārlūkot izejas kodu

Merge pull request #297 from gjaegy/master

fixed collada import bug + added obj importer '\' newline feature
Alexander Gessler 11 gadi atpakaļ
vecāks
revīzija
69570f675e
2 mainītis faili ar 20 papildinājumiem un 1 dzēšanām
  1. 3 0
      code/ColladaLoader.cpp
  2. 17 1
      code/ObjFileImporter.cpp

+ 3 - 0
code/ColladaLoader.cpp

@@ -133,6 +133,7 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I
 	mLights.clear();
 	mLights.clear();
 	mCameras.clear();
 	mCameras.clear();
 	mTextures.clear();
 	mTextures.clear();
+	mAnims.clear();
 
 
 	// parse the input file
 	// parse the input file
 	ColladaParser parser( pIOHandler, pFile);
 	ColladaParser parser( pIOHandler, pFile);
@@ -904,6 +905,8 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
 		pScene->mAnimations = new aiAnimation*[mAnims.size()];
 		pScene->mAnimations = new aiAnimation*[mAnims.size()];
 		std::copy( mAnims.begin(), mAnims.end(), pScene->mAnimations);
 		std::copy( mAnims.begin(), mAnims.end(), pScene->mAnimations);
 	}
 	}
+
+	mAnims.clear();
 }
 }
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------

+ 17 - 1
code/ObjFileImporter.cpp

@@ -139,7 +139,23 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
 	{
 	{
 		strModelName = pFile;
 		strModelName = pFile;
 	}
 	}
-	
+
+	// process all '\'
+	std::vector<char> ::iterator iter = m_Buffer.begin();
+	while (iter != m_Buffer.end())
+	{
+		if (*iter == '\\')
+		{
+			// remove '\'
+			iter = m_Buffer.erase(iter);
+			// remove next character
+			while (*iter == '\r' || *iter == '\n')
+				iter = m_Buffer.erase(iter);
+		}
+		else
+			++iter;
+	}
+
 	// parse the file into a temporary representation
 	// parse the file into a temporary representation
 	ObjFileParser parser(m_Buffer, strModelName, pIOHandler);
 	ObjFileParser parser(m_Buffer, strModelName, pIOHandler);