- Change BaseImporter::GetExtensionList to add all known file extensions to a std::set, so uniqueness is guaranteed. Also rewrite all related functions in Importer. NOTE: This does *not* change the public interface.

- FIX build error on vc8/release-noboost x64, ConvertUTF.c had wrong PCH settings.
- ADD knowext and listext verbs to assimp_cmd, add some raw docs.
- Update unit tests to reflect these changes. Currently I keep getting failures in some tests, this needs to be resolved *urgently*.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@567 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2010-03-02 17:38:01 +00:00
parent 8ef1e5b4ba
commit 5738860990
72 changed files with 416 additions and 261 deletions
+5 -3
View File
@@ -109,9 +109,10 @@ bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandle
// ------------------------------------------------------------------------------------------------
// Get list of all extension supported by this loader
void Discreet3DSImporter::GetExtensionList(std::string& append)
void Discreet3DSImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.3ds;*.prj");
extensions.insert("3ds");
extensions.insert("prj");
}
// ------------------------------------------------------------------------------------------------
@@ -130,8 +131,9 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
this->stream = &stream;
// We should have at least one chunk
if (stream.GetRemainingSize() < 16)
if (stream.GetRemainingSize() < 16) {
throw new ImportErrorException("3DS file is either empty or corrupt: " + pFile);
}
// Allocate our temporary 3DS representation
mScene = new D3DS::Scene();
+1 -1
View File
@@ -92,7 +92,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+4 -2
View File
@@ -137,9 +137,11 @@ bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get list of file extensions handled by this loader
void AC3DImporter::GetExtensionList(std::string& append)
void AC3DImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ac;*.acc;*.ac3d");
extensions.insert("ac");
extensions.insert("acc");
extensions.insert("ac3d");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -189,7 +189,7 @@ protected:
// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details */
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -2
View File
@@ -87,9 +87,10 @@ bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void ASEImporter::GetExtensionList(std::string& append)
void ASEImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ase;*.ask");
extensions.insert("ase");
extensions.insert("ask");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -86,7 +86,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+1 -2
View File
@@ -524,8 +524,7 @@ void aiGetExtensionList(aiString* szOut)
boost::mutex::scoped_lock lock(gMutex);
#endif
if (!gActiveImports.empty())
{
if (!gActiveImports.empty()) {
(*(gActiveImports.begin())).second->GetExtensionList(*szOut);
return;
}
+2 -2
View File
@@ -74,8 +74,8 @@ bool B3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void B3DImporter::GetExtensionList( std::string& append ){
append.append("*.b3d");
void B3DImporter::GetExtensionList( std::set<std::string>& extensions ){
extensions.insert("b3d");
}
#ifdef DEBUG_B3D
+1 -1
View File
@@ -60,7 +60,7 @@ public:
protected:
virtual void GetExtensionList(std::string& append);
virtual void GetExtensionList(std::set<std::string>& extensions);
virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
private:
+2 -2
View File
@@ -101,9 +101,9 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList( std::string& append)
void GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.bvh");
extensions.insert("bvh");
}
/** Imports the given file into the given scene structure.
+60 -37
View File
@@ -63,8 +63,7 @@ class ASSIMP_API ImportErrorException
{
public:
/** Constructor with arguments */
ImportErrorException( const std::string& pErrorText)
{
ImportErrorException( const std::string& pErrorText) {
mErrorText = pErrorText;
}
@@ -164,7 +163,7 @@ public:
* the file extension is enough. If no suitable loader is found with
* this strategy, CanRead() is called again, the 'checkSig' parameter
* set to true this time. Now the implementation is expected to
* perform a full check of the file format, possibly searching the
* perform a full check of the file structure, possibly searching the
* first bytes of the file for magic identifiers or keywords.
*
* @param pFile Path and file name of the file to be examined.
@@ -174,14 +173,12 @@ public:
* contents of the file to be loaded for magic bytes, keywords, etc
* to be able to load files with unknown/not existent file extensions.
* @return true if the class can read this file, false if not.
*
* @note Sometimes ASSIMP uses this method to determine whether a
* a given file extension is generally supported. In this case the
* file extension is passed in the pFile parameter, pIOHandler is NULL
*/
virtual bool CanRead( const std::string& pFile,
IOSystem* pIOHandler, bool checkSig) const = 0;
virtual bool CanRead(
const std::string& pFile,
IOSystem* pIOHandler,
bool checkSig
) const = 0;
// -------------------------------------------------------------------
/** Imports the given file and returns the imported data.
@@ -201,7 +198,10 @@ public:
* in InternReadFile(), this function will catch it and transform it into
* a suitable response to the caller.
*/
aiScene* ReadFile( const std::string& pFile, IOSystem* pIOHandler);
aiScene* ReadFile(
const std::string& pFile,
IOSystem* pIOHandler
);
// -------------------------------------------------------------------
/** Returns the error description of the last error that occured.
@@ -218,18 +218,22 @@ public:
* basing on the Importer's configuration property list.
* @param pImp Importer instance
*/
virtual void SetupProperties(const Importer* pImp);
virtual void SetupProperties(
const Importer* pImp
);
protected:
// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
* Importer implementations should append all file extensions
* which they supported to the passed string.
* Example: "*.blabb;*.quak;*.gug;*.foo" (no delimiter after the last!)
* @param append Output string
*/
virtual void GetExtensionList(std::string& append) = 0;
* Implementations are expected to insert() all file extensions
* handled by them into the extension set. A loader capable of
* reading certain files with the extension BLA would place the
* string bla (lower-case!) in the output set.
* @param extensions Output set. */
virtual void GetExtensionList(
std::set<std::string>& extensions
) = 0;
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure. The
@@ -274,10 +278,12 @@ protected:
* @param pScene The scene object to hold the imported data.
* NULL is not a valid parameter.
* @param pIOHandler The IO handler to use for any file access.
* NULL is not a valid parameter.
*/
virtual void InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler) = 0;
* NULL is not a valid parameter. */
virtual void InternReadFile(
const std::string& pFile,
aiScene* pScene,
IOSystem* pIOHandler
) = 0;
public: // static utilities
@@ -295,11 +301,12 @@ public: // static utilities
* @param numTokens Size of the token array
* @param searchBytes Number of bytes to be searched for the tokens.
*/
static bool SearchFileHeaderForToken(IOSystem* pIOSystem,
static bool SearchFileHeaderForToken(
IOSystem* pIOSystem,
const std::string& file,
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes = 200);
const char** tokens,
unsigned int numTokens,
unsigned int searchBytes = 200);
// -------------------------------------------------------------------
@@ -310,7 +317,8 @@ public: // static utilities
* @param ext2 Optional third extension
* @note Case-insensitive
*/
static bool SimpleExtensionCheck (const std::string& pFile,
static bool SimpleExtensionCheck (
const std::string& pFile,
const char* ext0,
const char* ext1 = NULL,
const char* ext2 = NULL);
@@ -320,7 +328,8 @@ public: // static utilities
* @param pFile Input file
* @return Extension without trailing dot, all lowercase
*/
static std::string GetExtension (const std::string& pFile);
static std::string GetExtension (
const std::string& pFile);
// -------------------------------------------------------------------
/** @brief Check whether a file starts with one or more magic tokens
@@ -336,7 +345,9 @@ public: // static utilities
* byte-swapped variant of all tokens (big endian). Only for
* tokens of size 2,4.
*/
static bool CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
static bool CheckMagicToken(
IOSystem* pIOHandler,
const std::string& pFile,
const void* magic,
unsigned int num,
unsigned int offset = 0,
@@ -348,7 +359,8 @@ public: // static utilities
*
* @param data File buffer to be converted to UTF8 data. The buffer
* is resized as appropriate. */
static void ConvertToUTF8(std::vector<char>& data);
static void ConvertToUTF8(
std::vector<char>& data);
// -------------------------------------------------------------------
/** Utility for text file loaders which copies the contents of the
@@ -358,7 +370,8 @@ public: // static utilities
* @param data Output buffer to be resized and filled with the
* converted text file data. The buffer is terminated with
* a binary 0. */
static void TextFileToBuffer(IOStream* stream,
static void TextFileToBuffer(
IOStream* stream,
std::vector<char>& data);
protected:
@@ -377,7 +390,7 @@ struct BatchData;
* could, this has not yet been implemented at the moment).
*
* @note The class may not be used by more than one thread*/
class ASSIMP_API BatchLoader
class ASSIMP_API BatchLoader
{
// friend of Importer
@@ -408,10 +421,12 @@ public:
// -------------------------------------------------------------------
/** Construct a batch loader from a given IO system to be used to acess external files */
/** Construct a batch loader from a given IO system to be used
* to acess external files */
BatchLoader(IOSystem* pIO);
~BatchLoader();
// -------------------------------------------------------------------
/** Add a new file to the list of files to be loaded.
* @param file File to be loaded
@@ -420,8 +435,12 @@ public:
* @return 'Load request channel' - an unique ID that can later
* be used to access the imported file data.
* @see GetImport */
unsigned int AddLoadRequest (const std::string& file,
unsigned int steps = 0, const PropertyMap* map = NULL);
unsigned int AddLoadRequest (
const std::string& file,
unsigned int steps = 0,
const PropertyMap* map = NULL
);
// -------------------------------------------------------------------
/** Get an imported scene.
@@ -432,10 +451,14 @@ public:
* @param which LRWC returned by AddLoadRequest().
* @return NULL if there is no scene with this file name
* in the queue of the scene hasn't been loaded yet. */
aiScene* GetImport (unsigned int which);
aiScene* GetImport(
unsigned int which
);
// -------------------------------------------------------------------
/** Waits until all scenes have been loaded. */
/** Waits until all scenes have been loaded. This returns
* immediately if no scenes are queued.*/
void LoadAll();
private:
+2 -2
View File
@@ -83,9 +83,9 @@ bool CSMImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Build a string of all file extensions supported
void CSMImporter::GetExtensionList(std::string& append)
void CSMImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.csm");
extensions.insert("csm");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -76,7 +76,7 @@ public:
protected:
// -------------------------------------------------------------------
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
+2 -2
View File
@@ -91,9 +91,9 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo
// ------------------------------------------------------------------------------------------------
// Get file extension list
void ColladaLoader::GetExtensionList( std::string& append)
void ColladaLoader::GetExtensionList( std::set<std::string>& extensions )
{
append.append("*.dae");
extensions.insert("dae");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -96,7 +96,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList( std::string& append);
void GetExtensionList( std::set<std::string>& extensions);
/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details
+2 -2
View File
@@ -101,9 +101,9 @@ bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get a list of all supported file extensions
void DXFImporter::GetExtensionList(std::string& append)
void DXFImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.dxf");
extensions.insert("dxf");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -96,7 +96,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -86,9 +86,9 @@ bool HMPImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get list of all file extensions that are handled by this loader
void HMPImporter::GetExtensionList(std::string& append)
void HMPImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.hmp");
extensions.insert("hmp");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -87,7 +87,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -6
View File
@@ -103,13 +103,10 @@ bool IRRImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void IRRImporter::GetExtensionList(std::string& append)
void IRRImporter::GetExtensionList(std::set<std::string>& extensions)
{
/* NOTE: The file extenxsion .xml is too generic. We'll
* need to open the file in CanRead() and check whether it is
* a real irrlicht file
*/
append.append("*.xml;*.irr");
extensions.insert("irr");
extensions.insert("xml");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -84,7 +84,7 @@ protected:
// -------------------------------------------------------------------
/**
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/**
+3 -3
View File
@@ -88,10 +88,10 @@ bool IRRMeshImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, b
// ------------------------------------------------------------------------------------------------
// Get a list of all file extensions which are handled by this class
void IRRMeshImporter::GetExtensionList(std::string& append)
void IRRMeshImporter::GetExtensionList(std::set<std::string>& extensions)
{
// fixme: consider cleaner handling of xml extension
append.append("*.xml;*.irrmesh");
extensions.insert("xml");
extensions.insert("irrmesh");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -83,7 +83,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+76 -62
View File
@@ -530,24 +530,26 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp)
// --------------------------------------------------------------------
// Check whether we would have two loaders for the same file extension
// This is absolutely OK, but we should warn the developer of the new
// loader that his code will probably never be called.s
// loader that his code will probably never be called if the first
// loader is a bit too lazy in his file checking.
// --------------------------------------------------------------------
std::string st;
std::set<std::string> st;
std::string baked;
pImp->GetExtensionList(st);
for(std::set<std::string>::const_iterator it = st.begin(); it != st.end(); ++it) {
#ifdef _DEBUG
const char* sz = ::strtok(const_cast<char*>(st.c_str()),";"); // evil
while (sz) {
if (IsExtensionSupported(std::string(sz)))
DefaultLogger::get()->warn(std::string( "The file extension " ) + sz + " is already in use");
sz = ::strtok(NULL,";");
}
if (IsExtensionSupported(*it)) {
DefaultLogger::get()->warn("The file extension " + *it + " is already in use");
}
#endif
baked += *it;
}
// add the loader
pimpl->mImporter.push_back(pImp);
DefaultLogger::get()->info("Registering custom importer: " + st);
DefaultLogger::get()->info("Registering custom importer for these file extensions: " + baked);
return AI_SUCCESS;
}
@@ -555,14 +557,19 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp)
// Unregister a custom loader plugin
aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
{
ai_assert(NULL != pImp);
if(!pImp) {
// unregistering a NULL importer is no problem for us ... really!
return AI_SUCCESS;
}
std::vector<BaseImporter*>::iterator it = std::find(pimpl->mImporter.begin(),pimpl->mImporter.end(),pImp);
if (it != pimpl->mImporter.end()) {
pimpl->mImporter.erase(it);
std::string st;
std::set<std::string> st;
pImp->GetExtensionList(st);
DefaultLogger::get()->info("Unregistering custom importer: " + st);
DefaultLogger::get()->info("Unregistering custom importer: ");
return AI_SUCCESS;
}
DefaultLogger::get()->warn("Unable to remove custom importer: I can't find you ...");
@@ -573,7 +580,11 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
// Unregister a custom loader plugin
aiReturn Importer::UnregisterPPStep(BaseProcess* pImp)
{
ai_assert(NULL != pImp);
if(!pImp) {
// unregistering a NULL ppstep is no problem for us ... really!
return AI_SUCCESS;
}
std::vector<BaseProcess*>::iterator it = std::find(pimpl->mPostProcessingSteps.begin(),pimpl->mPostProcessingSteps.end(),pImp);
if (it != pimpl->mPostProcessingSteps.end()) {
pimpl->mPostProcessingSteps.erase(it);
@@ -949,22 +960,27 @@ bool Importer::IsExtensionSupported(const char* szExtension)
// ------------------------------------------------------------------------------------------------
// Find a loader plugin for a given file extension
BaseImporter* Importer::FindLoader (const char* _szExtension)
BaseImporter* Importer::FindLoader (const char* szExtension)
{
std::string ext(_szExtension);
ai_assert(szExtension);
// skip over wildcard and dot characters at string head --
for(;*szExtension == '*' || *szExtension == '.'; ++szExtension);
std::string ext(szExtension);
if (ext.length() <= 1)
return NULL;
if (ext[0] != '.') {
// trailing dot is explicitly requested in the doc but we don't care for now ..
ext.erase(0,1);
}
std::set<std::string> str;
for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
str.clear();
// pass the file extension to the CanRead(..,NULL)-method
if ((*i)->CanRead(ext,NULL,false))
return *i;
(*i)->GetExtensionList(str);
for (std::set<std::string>::const_iterator it = str.begin(); it != str.end(); ++it) {
if (ext == *it) {
return (*i);
}
}
}
return NULL;
}
@@ -973,20 +989,20 @@ BaseImporter* Importer::FindLoader (const char* _szExtension)
// Helper function to build a list of all file extensions supported by ASSIMP
void Importer::GetExtensionList(aiString& szOut)
{
unsigned int iNum = 0;
std::string tmp;
for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i,++iNum)
{
// Insert a comma as delimiter character
// FIX: to take lazy loader implementations into account, we are
// slightly more tolerant here than we'd need to be.
if (0 != iNum && ';' != *(tmp.end()-1))
tmp.append(";");
std::set<std::string> str;
for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
(*i)->GetExtensionList(str);
}
(*i)->GetExtensionList(tmp);
for (std::set<std::string>::const_iterator it = str.begin();; ) {
szOut.Append("*.");
szOut.Append((*it).c_str());
if (++it == str.end()) {
break;
}
szOut.Append(";");
}
szOut.Set(tmp);
return;
}
// ------------------------------------------------------------------------------------------------
@@ -1044,8 +1060,10 @@ inline void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode)
iScene += sizeof(aiNode);
iScene += sizeof(unsigned int) * pcNode->mNumMeshes;
iScene += sizeof(void*) * pcNode->mNumChildren;
for (unsigned int i = 0; i < pcNode->mNumChildren;++i)
for (unsigned int i = 0; i < pcNode->mNumChildren;++i) {
AddNodeWeight(iScene,pcNode->mChildren[i]);
}
}
// ------------------------------------------------------------------------------------------------
@@ -1066,32 +1084,33 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
for (unsigned int i = 0; i < mScene->mNumMeshes;++i)
{
in.meshes += sizeof(aiMesh);
if (mScene->mMeshes[i]->HasPositions())
if (mScene->mMeshes[i]->HasPositions()) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
}
if (mScene->mMeshes[i]->HasNormals())
if (mScene->mMeshes[i]->HasNormals()) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
}
if (mScene->mMeshes[i]->HasTangentsAndBitangents())
if (mScene->mMeshes[i]->HasTangentsAndBitangents()) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices * 2;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a)
{
if (mScene->mMeshes[i]->HasVertexColors(a))
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a) {
if (mScene->mMeshes[i]->HasVertexColors(a)) {
in.meshes += sizeof(aiColor4D) * mScene->mMeshes[i]->mNumVertices;
}
else break;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
{
if (mScene->mMeshes[i]->HasTextureCoords(a))
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) {
if (mScene->mMeshes[i]->HasTextureCoords(a)) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
}
else break;
}
if (mScene->mMeshes[i]->HasBones())
{
if (mScene->mMeshes[i]->HasBones()) {
in.meshes += sizeof(void*) * mScene->mMeshes[i]->mNumBones;
for (unsigned int p = 0; p < mScene->mMeshes[i]->mNumBones;++p)
{
for (unsigned int p = 0; p < mScene->mMeshes[i]->mNumBones;++p) {
in.meshes += sizeof(aiBone);
in.meshes += mScene->mMeshes[i]->mBones[p]->mNumWeights * sizeof(aiVertexWeight);
}
@@ -1101,12 +1120,10 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
in.total += in.meshes;
// add all embedded textures
for (unsigned int i = 0; i < mScene->mNumTextures;++i)
{
for (unsigned int i = 0; i < mScene->mNumTextures;++i) {
const aiTexture* pc = mScene->mTextures[i];
in.textures += sizeof(aiTexture);
if (pc->mHeight)
{
if (pc->mHeight) {
in.textures += 4 * pc->mHeight * pc->mWidth;
}
else in.textures += pc->mWidth;
@@ -1114,14 +1131,12 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
in.total += in.textures;
// add all animations
for (unsigned int i = 0; i < mScene->mNumAnimations;++i)
{
for (unsigned int i = 0; i < mScene->mNumAnimations;++i) {
const aiAnimation* pc = mScene->mAnimations[i];
in.animations += sizeof(aiAnimation);
// add all bone anims
for (unsigned int a = 0; a < pc->mNumChannels; ++a)
{
for (unsigned int a = 0; a < pc->mNumChannels; ++a) {
const aiNodeAnim* pc2 = pc->mChannels[i];
in.animations += sizeof(aiNodeAnim);
in.animations += pc2->mNumPositionKeys * sizeof(aiVectorKey);
@@ -1140,13 +1155,12 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
in.total += in.nodes;
// add all materials
for (unsigned int i = 0; i < mScene->mNumMaterials;++i)
{
for (unsigned int i = 0; i < mScene->mNumMaterials;++i) {
const aiMaterial* pc = mScene->mMaterials[i];
in.materials += sizeof(aiMaterial);
in.materials += pc->mNumAllocated * sizeof(void*);
for (unsigned int a = 0; a < pc->mNumProperties;++a)
{
for (unsigned int a = 0; a < pc->mNumProperties;++a) {
in.materials += pc->mProperties[a]->mDataLength;
}
}
+3 -2
View File
@@ -100,9 +100,10 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append)
void GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.lwo;*.lxo");
extensions.insert("lxo");
extensions.insert("lwo");
}
// -------------------------------------------------------------------
+3 -2
View File
@@ -140,9 +140,10 @@ bool LWSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,bool c
// ------------------------------------------------------------------------------------------------
// Get list of file extensions
void LWSImporter::GetExtensionList(std::string& append)
void LWSImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.lws;*.mot");
extensions.insert("lws");
extensions.insert("mot");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -186,7 +186,7 @@ protected:
// -------------------------------------------------------------------
// Get list of supported extensions
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
// Import file into given scene data structure
+2 -2
View File
@@ -99,9 +99,9 @@ bool MD2Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get a list of all extensions supported by this loader
void MD2Importer::GetExtensionList(std::string& append)
void MD2Importer::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.md2");
extensions.insert("md2");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -91,7 +91,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+13 -6
View File
@@ -401,20 +401,27 @@ void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface* pcSurf)
// Check whether all requirements for Q3 files are met. We don't
// care, but probably someone does.
if (pcSurf->NUM_TRIANGLES > AI_MD3_MAX_TRIANGLES)
if (pcSurf->NUM_TRIANGLES > AI_MD3_MAX_TRIANGLES) {
DefaultLogger::get()->warn("MD3: Quake III triangle limit exceeded");
if (pcSurf->NUM_SHADER > AI_MD3_MAX_SHADERS)
}
if (pcSurf->NUM_SHADER > AI_MD3_MAX_SHADERS) {
DefaultLogger::get()->warn("MD3: Quake III shader limit exceeded");
if (pcSurf->NUM_VERTICES > AI_MD3_MAX_VERTS)
}
if (pcSurf->NUM_VERTICES > AI_MD3_MAX_VERTS) {
DefaultLogger::get()->warn("MD3: Quake III vertex limit exceeded");
if (pcSurf->NUM_FRAMES > AI_MD3_MAX_FRAMES)
}
if (pcSurf->NUM_FRAMES > AI_MD3_MAX_FRAMES) {
DefaultLogger::get()->warn("MD3: Quake III frame limit exceeded");
}
}
// ------------------------------------------------------------------------------------------------
void MD3Importer::GetExtensionList(std::string& append)
void MD3Importer::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.md3");
extensions.insert("md3");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -242,7 +242,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+4 -2
View File
@@ -89,9 +89,11 @@ bool MD5Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get list of all supported extensions
void MD5Importer::GetExtensionList(std::string& append)
void MD5Importer::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.md5mesh;*.md5anim;*.md5camera");
extensions.insert("md5anim");
extensions.insert("md5mesh");
extensions.insert("md5camera");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -85,7 +85,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Called prior to ReadFile().
+2 -2
View File
@@ -103,9 +103,9 @@ bool MDCImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void MDCImporter::GetExtensionList(std::string& append)
void MDCImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.mdc");
extensions.insert("mdc");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -88,7 +88,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -117,9 +117,9 @@ void MDLImporter::SetupProperties(const Importer* pImp)
// ------------------------------------------------------------------------------------------------
// Get a list of all supported extensions
void MDLImporter::GetExtensionList(std::string& append)
void MDLImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append( ".mdl" );
extensions.insert( "mdl" );
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -114,7 +114,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -84,9 +84,9 @@ bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void MS3DImporter::GetExtensionList(std::string& append)
void MS3DImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ms3d");
extensions.insert("ms3d");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -73,7 +73,7 @@ protected:
// -------------------------------------------------------------------
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details */
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -2
View File
@@ -72,9 +72,10 @@ bool NFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get the list of all supported file extensions
void NFFImporter::GetExtensionList(std::string& append)
void NFFImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.nff;*.enff");
extensions.insert("enff");
extensions.insert("nff");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -84,7 +84,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -82,9 +82,9 @@ bool OFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void OFFImporter::GetExtensionList(std::string& append)
void OFFImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.off");
extensions.insert("off");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -78,7 +78,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -3
View File
@@ -81,7 +81,7 @@ public:
private:
//! \brief Appends the supported extention.
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
//! \brief File import implementation.
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
@@ -124,9 +124,9 @@ private:
// ------------------------------------------------------------------------------------------------
//
inline void ObjFileImporter::GetExtensionList(std::string& append)
inline void ObjFileImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.obj");
extensions.insert("obj");
}
// ------------------------------------------------------------------------------------------------
+2 -2
View File
@@ -129,9 +129,9 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
void OgreImporter::GetExtensionList(std::string &append)
void OgreImporter::GetExtensionList(std::set<std::string>& extensions)
{
append+="*.mesh.xml";
extensions.insert("mesh.xml");
}
+1 -1
View File
@@ -26,7 +26,7 @@ class OgreImporter : public BaseImporter
public:
virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
virtual void GetExtensionList(std::string& append);
virtual void GetExtensionList(std::set<std::string>& extensions);
virtual void SetupProperties(const Importer* pImp);
private:
+2 -2
View File
@@ -80,9 +80,9 @@ bool PLYImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void PLYImporter::GetExtensionList(std::string& append)
void PLYImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ply");
extensions.insert("ply");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -85,7 +85,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -2
View File
@@ -81,9 +81,10 @@ bool Q3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void Q3DImporter::GetExtensionList(std::string& append)
void Q3DImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.q3o;*.q3s");
extensions.insert("q3o");
extensions.insert("q3s");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -78,7 +78,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -72,9 +72,9 @@ bool RAWImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
// ------------------------------------------------------------------------------------------------
// Get the list of all supported file extensions
void RAWImporter::GetExtensionList(std::string& append)
void RAWImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.raw");
extensions.insert("raw");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -79,7 +79,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+3 -2
View File
@@ -73,9 +73,10 @@ bool SMDImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool)
// ------------------------------------------------------------------------------------------------
// Get a list of all supported file extensions
void SMDImporter::GetExtensionList(std::string& append)
void SMDImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.smd;*.vta");
extensions.insert("smd");
extensions.insert("vta");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -204,7 +204,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -80,9 +80,9 @@ bool STLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
// ------------------------------------------------------------------------------------------------
void STLImporter::GetExtensionList(std::string& append)
void STLImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.stl");
extensions.insert("stl");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -78,7 +78,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
+2 -2
View File
@@ -83,9 +83,9 @@ bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
// ------------------------------------------------------------------------------------------------
// Build a string of all file extensions supported
void TerragenImporter::GetExtensionList(std::string& append)
void TerragenImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.ter;");
extensions.insert("ter");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -87,7 +87,7 @@ public:
protected:
// -------------------------------------------------------------------
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
void InternReadFile( const std::string& pFile, aiScene* pScene,
+4 -3
View File
@@ -79,9 +79,10 @@ bool UnrealImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bo
// ------------------------------------------------------------------------------------------------
// Build a string of all file extensions supported
void UnrealImporter::GetExtensionList(std::string& append)
void UnrealImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.3d;*.uc");
extensions.insert("3d");
extensions.insert("uc");
}
// ------------------------------------------------------------------------------------------------
@@ -322,7 +323,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
++pScene->mNumMeshes;
}
else {
tri.matIndex = nt-materials.begin();
tri.matIndex = static_cast<unsigned int>(nt-materials.begin());
++nt->numFaces;
}
}
+1 -1
View File
@@ -171,7 +171,7 @@ protected:
*
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
+2 -2
View File
@@ -78,9 +78,9 @@ bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo
}
// ------------------------------------------------------------------------------------------------
void XFileImporter::GetExtensionList(std::string& append)
void XFileImporter::GetExtensionList(std::set<std::string>& extensions)
{
append.append("*.x");
extensions.insert("x");
}
// ------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -88,7 +88,7 @@ protected:
/** Called by Importer::GetExtensionList() for each loaded importer.
* See BaseImporter::GetExtensionList() for details
*/
void GetExtensionList(std::string& append);
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.