Adding Importer::ReadFileFromMemory to make Chromanoid happy.

Updating unit test suite to verify the newly added stuff for correctness.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@444 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2009-06-21 19:44:48 +00:00
parent a4d7871096
commit adb4ab602e
12 changed files with 456 additions and 66 deletions

View File

@@ -264,7 +264,7 @@ const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
{
ai_assert(NULL != pFile);
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer;
Assimp::Importer* imp = new Assimp::Importer();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
@@ -303,6 +303,49 @@ const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
return scene;
}
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileFromMemory(
const char* pBuffer,
unsigned int pLength,
unsigned int pFlags,
const char* pHint)
{
ai_assert(NULL != pBuffer && 0 != pLength);
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
// copy the global property lists to the Importer instance
imp->pimpl->mIntProperties = gIntProperties;
imp->pimpl->mFloatProperties = gFloatProperties;
imp->pimpl->mStringProperties = gStringProperties;
#ifdef AI_C_THREADSAFE
lock.unlock();
#endif
// and have it read the file from the memory buffer
const aiScene* scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint);
// if succeeded, place it in the collection of active processes
if( scene) {
#ifdef AI_C_THREADSAFE
lock.lock();
#endif
gActiveImports[scene] = imp;
}
else {
// if failed, extract error code and destroy the import
gLastErrorString = imp->GetErrorString();
delete imp;
}
// return imported data. If the import failed the pointer is NULL anyways
return scene;
}
// ------------------------------------------------------------------------------------------------
// Releases all resources associated with the given import process.
void aiReleaseImport( const aiScene* pScene)