diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp index 7dae2633c..67f1c3af2 100644 --- a/code/Common/Assimp.cpp +++ b/code/Common/Assimp.cpp @@ -44,15 +44,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Implementation of the Plain-C API */ +#include +#include +#include #include -#include -#include -#include #include #include -#include -#include -#include +#include +#include +#include #include "CApi/CInterfaceIOWrapper.h" #include "Importer.h" @@ -62,46 +62,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ------------------------------------------------------------------------------------------------ #ifndef ASSIMP_BUILD_SINGLETHREADED -# include -# include +#include +#include #endif // ------------------------------------------------------------------------------------------------ using namespace Assimp; namespace Assimp { - // underlying structure for aiPropertyStore - typedef BatchLoader::PropertyMap PropertyMap; +// underlying structure for aiPropertyStore +typedef BatchLoader::PropertyMap PropertyMap; - /** Stores the LogStream objects for all active C log streams */ - struct mpred { - bool operator () (const aiLogStream& s0, const aiLogStream& s1) const { - return s0.callback LogStreamMap; +/** Stores the LogStream objects for all active C log streams */ +struct mpred { + bool operator()(const aiLogStream &s0, const aiLogStream &s1) const { + return s0.callback < s1.callback && s0.user < s1.user; + } +}; +typedef std::map LogStreamMap; - /** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */ - typedef std::list PredefLogStreamMap; +/** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */ +typedef std::list PredefLogStreamMap; - /** Local storage of all active log streams */ - static LogStreamMap gActiveLogStreams; +/** Local storage of all active log streams */ +static LogStreamMap gActiveLogStreams; - /** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */ - static PredefLogStreamMap gPredefinedStreams; +/** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */ +static PredefLogStreamMap gPredefinedStreams; - /** Error message of the last failed import process */ - static std::string gLastErrorString; +/** Error message of the last failed import process */ +static std::string gLastErrorString; - /** Verbose logging active or not? */ - static aiBool gVerboseLogging = false; +/** Verbose logging active or not? */ +static aiBool gVerboseLogging = false; - /** will return all registered importers. */ - void GetImporterInstanceList(std::vector< BaseImporter* >& out); - - /** will delete all registered importers. */ - void DeleteImporterInstanceList(std::vector< BaseImporter* >& out); -} // namespace assimp +/** will return all registered importers. */ +void GetImporterInstanceList(std::vector &out); +/** will delete all registered importers. */ +void DeleteImporterInstanceList(std::vector &out); +} // namespace Assimp #ifndef ASSIMP_BUILD_SINGLETHREADED /** Global mutex to manage the access to the log-stream map */ @@ -112,12 +111,12 @@ static std::mutex gLogStreamMutex; // Custom LogStream implementation for the C-API class LogToCallbackRedirector : public LogStream { public: - explicit LogToCallbackRedirector(const aiLogStream& s) - : stream (s) { + explicit LogToCallbackRedirector(const aiLogStream &s) : + stream(s) { ai_assert(NULL != s.callback); } - ~LogToCallbackRedirector() { + ~LogToCallbackRedirector() { #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(gLogStreamMutex); #endif @@ -127,7 +126,7 @@ public: // might cause strange problems, but the chance is quite low. PredefLogStreamMap::iterator it = std::find(gPredefinedStreams.begin(), - gPredefinedStreams.end(), (Assimp::LogStream*)stream.user); + gPredefinedStreams.end(), (Assimp::LogStream *)stream.user); if (it != gPredefinedStreams.end()) { delete *it; @@ -136,8 +135,8 @@ public: } /** @copydoc LogStream::write */ - void write(const char* message) { - stream.callback(message,stream.user); + void write(const char *message) { + stream.callback(message, stream.user); } private: @@ -147,37 +146,37 @@ private: // ------------------------------------------------------------------------------------------------ void ReportSceneNotFoundError() { ASSIMP_LOG_ERROR("Unable to find the Assimp::Importer for this aiScene. " - "The C-API does not accept scenes produced by the C++ API and vice versa"); + "The C-API does not accept scenes produced by the C++ API and vice versa"); ai_assert(false); } // ------------------------------------------------------------------------------------------------ // Reads the given file and returns its content. -const aiScene* aiImportFile( const char* pFile, unsigned int pFlags) { - return aiImportFileEx(pFile,pFlags,NULL); +const aiScene *aiImportFile(const char *pFile, unsigned int pFlags) { + return aiImportFileEx(pFile, pFlags, NULL); } // ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags, aiFileIO* pFS) { +const aiScene *aiImportFileEx(const char *pFile, unsigned int pFlags, aiFileIO *pFS) { return aiImportFileExWithProperties(pFile, pFlags, pFS, NULL); } // ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags, - aiFileIO* pFS, const aiPropertyStore* props) { +const aiScene *aiImportFileExWithProperties(const char *pFile, unsigned int pFlags, + aiFileIO *pFS, const aiPropertyStore *props) { ai_assert(NULL != pFile); - const aiScene* scene = NULL; + const aiScene *scene = NULL; ASSIMP_BEGIN_EXCEPTION_REGION(); // create an Importer for this file - Assimp::Importer* imp = new Assimp::Importer(); + Assimp::Importer *imp = new Assimp::Importer(); // copy properties - if(props) { - const PropertyMap* pp = reinterpret_cast(props); - ImporterPimpl* pimpl = imp->Pimpl(); + if (props) { + const PropertyMap *pp = reinterpret_cast(props); + ImporterPimpl *pimpl = imp->Pimpl(); pimpl->mIntProperties = pp->ints; pimpl->mFloatProperties = pp->floats; pimpl->mStringProperties = pp->strings; @@ -185,15 +184,15 @@ const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFl } // setup a custom IO system if necessary if (pFS) { - imp->SetIOHandler( new CIOSystemWrapper (pFS) ); + imp->SetIOHandler(new CIOSystemWrapper(pFS)); } // and have it read the file - scene = imp->ReadFile( pFile, pFlags); + scene = imp->ReadFile(pFile, pFlags); // if succeeded, store the importer in the scene and keep it alive - if( scene) { - ScenePrivateData* priv = const_cast( ScenePriv(scene) ); + if (scene) { + ScenePrivateData *priv = const_cast(ScenePriv(scene)); priv->mOrigImporter = imp; } else { // if failed, extract error code and destroy the import @@ -202,42 +201,40 @@ const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFl } // return imported data. If the import failed the pointer is NULL anyways - ASSIMP_END_EXCEPTION_REGION(const aiScene*); - + ASSIMP_END_EXCEPTION_REGION(const aiScene *); + return scene; } // ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileFromMemory( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint) -{ +const aiScene *aiImportFileFromMemory( + const char *pBuffer, + unsigned int pLength, + unsigned int pFlags, + const char *pHint) { return aiImportFileFromMemoryWithProperties(pBuffer, pLength, pFlags, pHint, NULL); } // ------------------------------------------------------------------------------------------------ -const aiScene* aiImportFileFromMemoryWithProperties( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint, - const aiPropertyStore* props) -{ - ai_assert( NULL != pBuffer ); - ai_assert( 0 != pLength ); +const aiScene *aiImportFileFromMemoryWithProperties( + const char *pBuffer, + unsigned int pLength, + unsigned int pFlags, + const char *pHint, + const aiPropertyStore *props) { + ai_assert(NULL != pBuffer); + ai_assert(0 != pLength); - const aiScene* scene = NULL; + const aiScene *scene = NULL; ASSIMP_BEGIN_EXCEPTION_REGION(); // create an Importer for this file - Assimp::Importer* imp = new Assimp::Importer(); + Assimp::Importer *imp = new Assimp::Importer(); // copy properties - if(props) { - const PropertyMap* pp = reinterpret_cast(props); - ImporterPimpl* pimpl = imp->Pimpl(); + if (props) { + const PropertyMap *pp = reinterpret_cast(props); + ImporterPimpl *pimpl = imp->Pimpl(); pimpl->mIntProperties = pp->ints; pimpl->mFloatProperties = pp->floats; pimpl->mStringProperties = pp->strings; @@ -245,27 +242,25 @@ const aiScene* aiImportFileFromMemoryWithProperties( } // and have it read the file from the memory buffer - scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint); + scene = imp->ReadFileFromMemory(pBuffer, pLength, pFlags, pHint); // if succeeded, store the importer in the scene and keep it alive - if( scene) { - ScenePrivateData* priv = const_cast( ScenePriv(scene) ); - priv->mOrigImporter = imp; - } - else { + if (scene) { + ScenePrivateData *priv = const_cast(ScenePriv(scene)); + priv->mOrigImporter = 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 - ASSIMP_END_EXCEPTION_REGION(const aiScene*); + ASSIMP_END_EXCEPTION_REGION(const aiScene *); return scene; } // ------------------------------------------------------------------------------------------------ // Releases all resources associated with the given import process. -void aiReleaseImport( const aiScene* pScene) -{ +void aiReleaseImport(const aiScene *pScene) { if (!pScene) { return; } @@ -273,15 +268,14 @@ void aiReleaseImport( const aiScene* pScene) ASSIMP_BEGIN_EXCEPTION_REGION(); // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pScene); - if( !priv || !priv->mOrigImporter) { + const ScenePrivateData *priv = ScenePriv(pScene); + if (!priv || !priv->mOrigImporter) { delete pScene; - } - else { + } else { // deleting the Importer also deletes the scene // Note: the reason that this is not written as 'delete priv->mOrigImporter' // is a suspected bug in gcc 4.4+ (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339) - Importer* importer = priv->mOrigImporter; + Importer *importer = priv->mOrigImporter; delete importer; } @@ -289,17 +283,15 @@ void aiReleaseImport( const aiScene* pScene) } // ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene, - unsigned int pFlags) -{ - const aiScene* sc = NULL; - +ASSIMP_API const aiScene *aiApplyPostProcessing(const aiScene *pScene, + unsigned int pFlags) { + const aiScene *sc = NULL; ASSIMP_BEGIN_EXCEPTION_REGION(); // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pScene); - if( !priv || !priv->mOrigImporter) { + const ScenePrivateData *priv = ScenePriv(pScene); + if (!priv || !priv->mOrigImporter) { ReportSceneNotFoundError(); return NULL; } @@ -311,61 +303,58 @@ ASSIMP_API const aiScene* aiApplyPostProcessing(const aiScene* pScene, return NULL; } - ASSIMP_END_EXCEPTION_REGION(const aiScene*); + ASSIMP_END_EXCEPTION_REGION(const aiScene *); return sc; } // ------------------------------------------------------------------------------------------------ -ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing( const aiScene *scene, - BaseProcess* process, - bool requestValidation ) { - const aiScene* sc( NULL ); +ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing(const aiScene *scene, + BaseProcess *process, + bool requestValidation) { + const aiScene *sc(NULL); ASSIMP_BEGIN_EXCEPTION_REGION(); // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv( scene ); - if ( NULL == priv || NULL == priv->mOrigImporter ) { + const ScenePrivateData *priv = ScenePriv(scene); + if (NULL == priv || NULL == priv->mOrigImporter) { ReportSceneNotFoundError(); return NULL; } - sc = priv->mOrigImporter->ApplyCustomizedPostProcessing( process, requestValidation ); + sc = priv->mOrigImporter->ApplyCustomizedPostProcessing(process, requestValidation); - if ( !sc ) { - aiReleaseImport( scene ); + if (!sc) { + aiReleaseImport(scene); return NULL; } - ASSIMP_END_EXCEPTION_REGION( const aiScene* ); + ASSIMP_END_EXCEPTION_REGION(const aiScene *); return sc; } // ------------------------------------------------------------------------------------------------ -void CallbackToLogRedirector (const char* msg, char* dt) -{ - ai_assert( NULL != msg ); - ai_assert( NULL != dt ); - LogStream* s = (LogStream*)dt; +void CallbackToLogRedirector(const char *msg, char *dt) { + ai_assert(NULL != msg); + ai_assert(NULL != dt); + LogStream *s = (LogStream *)dt; s->write(msg); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const char* file) -{ +ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream, const char *file) { aiLogStream sout; ASSIMP_BEGIN_EXCEPTION_REGION(); - LogStream* stream = LogStream::createDefaultStream(pStream,file); + LogStream *stream = LogStream::createDefaultStream(pStream, file); if (!stream) { sout.callback = NULL; sout.user = NULL; - } - else { + } else { sout.callback = &CallbackToLogRedirector; - sout.user = (char*)stream; + sout.user = (char *)stream; } gPredefinedStreams.push_back(stream); ASSIMP_END_EXCEPTION_REGION(aiLogStream); @@ -373,42 +362,40 @@ ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiAttachLogStream( const aiLogStream* stream ) -{ +ASSIMP_API void aiAttachLogStream(const aiLogStream *stream) { ASSIMP_BEGIN_EXCEPTION_REGION(); #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(gLogStreamMutex); #endif - LogStream* lg = new LogToCallbackRedirector(*stream); + LogStream *lg = new LogToCallbackRedirector(*stream); gActiveLogStreams[*stream] = lg; if (DefaultLogger::isNullLogger()) { - DefaultLogger::create(NULL,(gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); + DefaultLogger::create(NULL, (gVerboseLogging == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); } DefaultLogger::get()->attachStream(lg); ASSIMP_END_EXCEPTION_REGION(void); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream) -{ +ASSIMP_API aiReturn aiDetachLogStream(const aiLogStream *stream) { ASSIMP_BEGIN_EXCEPTION_REGION(); #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(gLogStreamMutex); #endif // find the log-stream associated with this data - LogStreamMap::iterator it = gActiveLogStreams.find( *stream); + LogStreamMap::iterator it = gActiveLogStreams.find(*stream); // it should be there... else the user is playing fools with us - if( it == gActiveLogStreams.end()) { + if (it == gActiveLogStreams.end()) { return AI_FAILURE; } - DefaultLogger::get()->detatchStream( it->second ); + DefaultLogger::get()->detatchStream(it->second); delete it->second; - gActiveLogStreams.erase( it); + gActiveLogStreams.erase(it); if (gActiveLogStreams.empty()) { DefaultLogger::kill(); @@ -418,19 +405,18 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream) } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiDetachAllLogStreams(void) -{ +ASSIMP_API void aiDetachAllLogStreams(void) { ASSIMP_BEGIN_EXCEPTION_REGION(); #ifndef ASSIMP_BUILD_SINGLETHREADED std::lock_guard lock(gLogStreamMutex); #endif - Logger *logger( DefaultLogger::get() ); - if ( NULL == logger ) { + Logger *logger(DefaultLogger::get()); + if (NULL == logger) { return; } for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) { - logger->detatchStream( it->second ); + logger->detatchStream(it->second); delete it->second; } gActiveLogStreams.clear(); @@ -440,8 +426,7 @@ ASSIMP_API void aiDetachAllLogStreams(void) } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiEnableVerboseLogging(aiBool d) -{ +ASSIMP_API void aiEnableVerboseLogging(aiBool d) { if (!DefaultLogger::isNullLogger()) { DefaultLogger::get()->setLogSeverity((d == AI_TRUE ? Logger::VERBOSE : Logger::NORMAL)); } @@ -450,31 +435,27 @@ ASSIMP_API void aiEnableVerboseLogging(aiBool d) // ------------------------------------------------------------------------------------------------ // Returns the error text of the last failed import process. -const char* aiGetErrorString() -{ +const char *aiGetErrorString() { return gLastErrorString.c_str(); } // ----------------------------------------------------------------------------------------------- // Return the description of a importer given its index -const aiImporterDesc* aiGetImportFormatDescription( size_t pIndex) -{ +const aiImporterDesc *aiGetImportFormatDescription(size_t pIndex) { return Importer().GetImporterInfo(pIndex); } // ----------------------------------------------------------------------------------------------- // Return the number of importers -size_t aiGetImportFormatCount(void) -{ +size_t aiGetImportFormatCount(void) { return Importer().GetImporterCount(); } // ------------------------------------------------------------------------------------------------ // Returns the error text of the last failed import process. -aiBool aiIsExtensionSupported(const char* szExtension) -{ +aiBool aiIsExtensionSupported(const char *szExtension) { ai_assert(NULL != szExtension); - aiBool candoit=AI_FALSE; + aiBool candoit = AI_FALSE; ASSIMP_BEGIN_EXCEPTION_REGION(); // FIXME: no need to create a temporary Importer instance just for that .. @@ -487,8 +468,7 @@ aiBool aiIsExtensionSupported(const char* szExtension) // ------------------------------------------------------------------------------------------------ // Get a list of all file extensions supported by ASSIMP -void aiGetExtensionList(aiString* szOut) -{ +void aiGetExtensionList(aiString *szOut) { ai_assert(NULL != szOut); ASSIMP_BEGIN_EXCEPTION_REGION(); @@ -501,14 +481,13 @@ void aiGetExtensionList(aiString* szOut) // ------------------------------------------------------------------------------------------------ // Get the memory requirements for a particular import. -void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn, - C_STRUCT aiMemoryInfo* in) -{ +void aiGetMemoryRequirements(const C_STRUCT aiScene *pIn, + C_STRUCT aiMemoryInfo *in) { ASSIMP_BEGIN_EXCEPTION_REGION(); // find the importer associated with this data - const ScenePrivateData* priv = ScenePriv(pIn); - if( !priv || !priv->mOrigImporter) { + const ScenePrivateData *priv = ScenePriv(pIn); + if (!priv || !priv->mOrigImporter) { ReportSceneNotFoundError(); return; } @@ -518,118 +497,106 @@ void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn, } // ------------------------------------------------------------------------------------------------ -ASSIMP_API aiPropertyStore* aiCreatePropertyStore(void) -{ - return reinterpret_cast( new PropertyMap() ); +ASSIMP_API aiPropertyStore *aiCreatePropertyStore(void) { + return reinterpret_cast(new PropertyMap()); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiReleasePropertyStore(aiPropertyStore* p) -{ - delete reinterpret_cast(p); +ASSIMP_API void aiReleasePropertyStore(aiPropertyStore *p) { + delete reinterpret_cast(p); } // ------------------------------------------------------------------------------------------------ // Importer::SetPropertyInteger -ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szName, int value) -{ +ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore *p, const char *szName, int value) { ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->ints,szName,value); + PropertyMap *pp = reinterpret_cast(p); + SetGenericProperty(pp->ints, szName, value); ASSIMP_END_EXCEPTION_REGION(void); } // ------------------------------------------------------------------------------------------------ // Importer::SetPropertyFloat -ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, ai_real value) -{ +ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore *p, const char *szName, ai_real value) { ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->floats,szName,value); + PropertyMap *pp = reinterpret_cast(p); + SetGenericProperty(pp->floats, szName, value); ASSIMP_END_EXCEPTION_REGION(void); } // ------------------------------------------------------------------------------------------------ // Importer::SetPropertyString -ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName, - const C_STRUCT aiString* st) -{ +ASSIMP_API void aiSetImportPropertyString(aiPropertyStore *p, const char *szName, + const C_STRUCT aiString *st) { if (!st) { return; } ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->strings,szName,std::string(st->C_Str())); + PropertyMap *pp = reinterpret_cast(p); + SetGenericProperty(pp->strings, szName, std::string(st->C_Str())); ASSIMP_END_EXCEPTION_REGION(void); } // ------------------------------------------------------------------------------------------------ // Importer::SetPropertyMatrix -ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName, - const C_STRUCT aiMatrix4x4* mat) -{ +ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore *p, const char *szName, + const C_STRUCT aiMatrix4x4 *mat) { if (!mat) { return; } ASSIMP_BEGIN_EXCEPTION_REGION(); - PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->matrices,szName,*mat); + PropertyMap *pp = reinterpret_cast(p); + SetGenericProperty(pp->matrices, szName, *mat); ASSIMP_END_EXCEPTION_REGION(void); } // ------------------------------------------------------------------------------------------------ // Rotation matrix to quaternion -ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion* quat,const aiMatrix3x3* mat) -{ - ai_assert( NULL != quat ); - ai_assert( NULL != mat ); +ASSIMP_API void aiCreateQuaternionFromMatrix(aiQuaternion *quat, const aiMatrix3x3 *mat) { + ai_assert(NULL != quat); + ai_assert(NULL != mat); *quat = aiQuaternion(*mat); } // ------------------------------------------------------------------------------------------------ // Matrix decomposition -ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4* mat,aiVector3D* scaling, - aiQuaternion* rotation, - aiVector3D* position) -{ - ai_assert( NULL != rotation ); - ai_assert( NULL != position ); - ai_assert( NULL != scaling ); - ai_assert( NULL != mat ); - mat->Decompose(*scaling,*rotation,*position); +ASSIMP_API void aiDecomposeMatrix(const aiMatrix4x4 *mat, aiVector3D *scaling, + aiQuaternion *rotation, + aiVector3D *position) { + ai_assert(NULL != rotation); + ai_assert(NULL != position); + ai_assert(NULL != scaling); + ai_assert(NULL != mat); + mat->Decompose(*scaling, *rotation, *position); } // ------------------------------------------------------------------------------------------------ // Matrix transpose -ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3* mat) -{ +ASSIMP_API void aiTransposeMatrix3(aiMatrix3x3 *mat) { ai_assert(NULL != mat); mat->Transpose(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4* mat) -{ +ASSIMP_API void aiTransposeMatrix4(aiMatrix4x4 *mat) { ai_assert(NULL != mat); mat->Transpose(); } // ------------------------------------------------------------------------------------------------ // Vector transformation -ASSIMP_API void aiTransformVecByMatrix3(aiVector3D* vec, - const aiMatrix3x3* mat) -{ - ai_assert( NULL != mat ); - ai_assert( NULL != vec); +ASSIMP_API void aiTransformVecByMatrix3(aiVector3D *vec, + const aiMatrix3x3 *mat) { + ai_assert(NULL != mat); + ai_assert(NULL != vec); *vec *= (*mat); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec, - const aiMatrix4x4* mat) -{ - ai_assert( NULL != mat ); - ai_assert( NULL != vec ); +ASSIMP_API void aiTransformVecByMatrix4(aiVector3D *vec, + const aiMatrix4x4 *mat) { + ai_assert(NULL != mat); + ai_assert(NULL != vec); *vec *= (*mat); } @@ -637,52 +604,48 @@ ASSIMP_API void aiTransformVecByMatrix4(aiVector3D* vec, // ------------------------------------------------------------------------------------------------ // Matrix multiplication ASSIMP_API void aiMultiplyMatrix4( - aiMatrix4x4* dst, - const aiMatrix4x4* src) -{ - ai_assert( NULL != dst ); - ai_assert( NULL != src ); + aiMatrix4x4 *dst, + const aiMatrix4x4 *src) { + ai_assert(NULL != dst); + ai_assert(NULL != src); *dst = (*dst) * (*src); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMultiplyMatrix3( - aiMatrix3x3* dst, - const aiMatrix3x3* src) -{ - ai_assert( NULL != dst ); - ai_assert( NULL != src ); + aiMatrix3x3 *dst, + const aiMatrix3x3 *src) { + ai_assert(NULL != dst); + ai_assert(NULL != src); *dst = (*dst) * (*src); } // ------------------------------------------------------------------------------------------------ // Matrix identity ASSIMP_API void aiIdentityMatrix3( - aiMatrix3x3* mat) -{ + aiMatrix3x3 *mat) { ai_assert(NULL != mat); *mat = aiMatrix3x3(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiIdentityMatrix4( - aiMatrix4x4* mat) -{ + aiMatrix4x4 *mat) { ai_assert(NULL != mat); *mat = aiMatrix4x4(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension ) { - if( NULL == extension ) { +ASSIMP_API C_STRUCT const aiImporterDesc *aiGetImporterDesc(const char *extension) { + if (NULL == extension) { return NULL; } - const aiImporterDesc *desc( NULL ); - std::vector< BaseImporter* > out; - GetImporterInstanceList( out ); - for( size_t i = 0; i < out.size(); ++i ) { - if( 0 == strncmp( out[ i ]->GetInfo()->mFileExtensions, extension, strlen( extension ) ) ) { - desc = out[ i ]->GetInfo(); + const aiImporterDesc *desc(NULL); + std::vector out; + GetImporterInstanceList(out); + for (size_t i = 0; i < out.size(); ++i) { + if (0 == strncmp(out[i]->GetInfo()->mFileExtensions, extension, strlen(extension))) { + desc = out[i]->GetInfo(); break; } } @@ -694,8 +657,8 @@ ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extensi // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiVector2AreEqual( - const C_STRUCT aiVector2D* a, - const C_STRUCT aiVector2D* b) { + const C_STRUCT aiVector2D *a, + const C_STRUCT aiVector2D *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a == *b; @@ -703,9 +666,9 @@ ASSIMP_API int aiVector2AreEqual( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiVector2AreEqualEpsilon( - const C_STRUCT aiVector2D* a, - const C_STRUCT aiVector2D* b, - const float epsilon) { + const C_STRUCT aiVector2D *a, + const C_STRUCT aiVector2D *b, + const float epsilon) { ai_assert(NULL != a); ai_assert(NULL != b); return a->Equal(*b, epsilon); @@ -713,8 +676,8 @@ ASSIMP_API int aiVector2AreEqualEpsilon( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Add( - C_STRUCT aiVector2D* dst, - const C_STRUCT aiVector2D* src) { + C_STRUCT aiVector2D *dst, + const C_STRUCT aiVector2D *src) { ai_assert(NULL != dst); ai_assert(NULL != src); *dst = *dst + *src; @@ -722,8 +685,8 @@ ASSIMP_API void aiVector2Add( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Subtract( - C_STRUCT aiVector2D* dst, - const C_STRUCT aiVector2D* src) { + C_STRUCT aiVector2D *dst, + const C_STRUCT aiVector2D *src) { ai_assert(NULL != dst); ai_assert(NULL != src); *dst = *dst - *src; @@ -731,16 +694,16 @@ ASSIMP_API void aiVector2Subtract( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Scale( - C_STRUCT aiVector2D* dst, - const float s) { + C_STRUCT aiVector2D *dst, + const float s) { ai_assert(NULL != dst); *dst *= s; } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2SymMul( - C_STRUCT aiVector2D* dst, - const C_STRUCT aiVector2D* other) { + C_STRUCT aiVector2D *dst, + const C_STRUCT aiVector2D *other) { ai_assert(NULL != dst); ai_assert(NULL != other); *dst = dst->SymMul(*other); @@ -748,16 +711,16 @@ ASSIMP_API void aiVector2SymMul( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2DivideByScalar( - C_STRUCT aiVector2D* dst, - const float s) { + C_STRUCT aiVector2D *dst, + const float s) { ai_assert(NULL != dst); *dst /= s; } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2DivideByVector( - C_STRUCT aiVector2D* dst, - C_STRUCT aiVector2D* v) { + C_STRUCT aiVector2D *dst, + C_STRUCT aiVector2D *v) { ai_assert(NULL != dst); ai_assert(NULL != v); *dst = *dst / *v; @@ -765,29 +728,29 @@ ASSIMP_API void aiVector2DivideByVector( // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector2Length( - const C_STRUCT aiVector2D* v) { + const C_STRUCT aiVector2D *v) { ai_assert(NULL != v); return v->Length(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector2SquareLength( - const C_STRUCT aiVector2D* v) { + const C_STRUCT aiVector2D *v) { ai_assert(NULL != v); return v->SquareLength(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Negate( - C_STRUCT aiVector2D* dst) { + C_STRUCT aiVector2D *dst) { ai_assert(NULL != dst); *dst = -(*dst); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector2DotProduct( - const C_STRUCT aiVector2D* a, - const C_STRUCT aiVector2D* b) { + const C_STRUCT aiVector2D *a, + const C_STRUCT aiVector2D *b) { ai_assert(NULL != a); ai_assert(NULL != b); return (*a) * (*b); @@ -795,15 +758,15 @@ ASSIMP_API float aiVector2DotProduct( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector2Normalize( - C_STRUCT aiVector2D* v) { + C_STRUCT aiVector2D *v) { ai_assert(NULL != v); v->Normalize(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiVector3AreEqual( - const C_STRUCT aiVector3D* a, - const C_STRUCT aiVector3D* b) { + const C_STRUCT aiVector3D *a, + const C_STRUCT aiVector3D *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a == *b; @@ -811,9 +774,9 @@ ASSIMP_API int aiVector3AreEqual( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiVector3AreEqualEpsilon( - const C_STRUCT aiVector3D* a, - const C_STRUCT aiVector3D* b, - const float epsilon) { + const C_STRUCT aiVector3D *a, + const C_STRUCT aiVector3D *b, + const float epsilon) { ai_assert(NULL != a); ai_assert(NULL != b); return a->Equal(*b, epsilon); @@ -821,8 +784,8 @@ ASSIMP_API int aiVector3AreEqualEpsilon( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiVector3LessThan( - const C_STRUCT aiVector3D* a, - const C_STRUCT aiVector3D* b) { + const C_STRUCT aiVector3D *a, + const C_STRUCT aiVector3D *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a < *b; @@ -830,8 +793,8 @@ ASSIMP_API int aiVector3LessThan( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Add( - C_STRUCT aiVector3D* dst, - const C_STRUCT aiVector3D* src) { + C_STRUCT aiVector3D *dst, + const C_STRUCT aiVector3D *src) { ai_assert(NULL != dst); ai_assert(NULL != src); *dst = *dst + *src; @@ -839,8 +802,8 @@ ASSIMP_API void aiVector3Add( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Subtract( - C_STRUCT aiVector3D* dst, - const C_STRUCT aiVector3D* src) { + C_STRUCT aiVector3D *dst, + const C_STRUCT aiVector3D *src) { ai_assert(NULL != dst); ai_assert(NULL != src); *dst = *dst - *src; @@ -848,16 +811,16 @@ ASSIMP_API void aiVector3Subtract( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Scale( - C_STRUCT aiVector3D* dst, - const float s) { + C_STRUCT aiVector3D *dst, + const float s) { ai_assert(NULL != dst); *dst *= s; } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3SymMul( - C_STRUCT aiVector3D* dst, - const C_STRUCT aiVector3D* other) { + C_STRUCT aiVector3D *dst, + const C_STRUCT aiVector3D *other) { ai_assert(NULL != dst); ai_assert(NULL != other); *dst = dst->SymMul(*other); @@ -865,15 +828,15 @@ ASSIMP_API void aiVector3SymMul( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3DivideByScalar( - C_STRUCT aiVector3D* dst, const float s) { + C_STRUCT aiVector3D *dst, const float s) { ai_assert(NULL != dst); *dst /= s; } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3DivideByVector( - C_STRUCT aiVector3D* dst, - C_STRUCT aiVector3D* v) { + C_STRUCT aiVector3D *dst, + C_STRUCT aiVector3D *v) { ai_assert(NULL != dst); ai_assert(NULL != v); *dst = *dst / *v; @@ -881,29 +844,29 @@ ASSIMP_API void aiVector3DivideByVector( // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector3Length( - const C_STRUCT aiVector3D* v) { + const C_STRUCT aiVector3D *v) { ai_assert(NULL != v); return v->Length(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector3SquareLength( - const C_STRUCT aiVector3D* v) { + const C_STRUCT aiVector3D *v) { ai_assert(NULL != v); return v->SquareLength(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Negate( - C_STRUCT aiVector3D* dst) { + C_STRUCT aiVector3D *dst) { ai_assert(NULL != dst); *dst = -(*dst); } // ------------------------------------------------------------------------------------------------ ASSIMP_API float aiVector3DotProduct( - const C_STRUCT aiVector3D* a, - const C_STRUCT aiVector3D* b) { + const C_STRUCT aiVector3D *a, + const C_STRUCT aiVector3D *b) { ai_assert(NULL != a); ai_assert(NULL != b); return (*a) * (*b); @@ -911,9 +874,9 @@ ASSIMP_API float aiVector3DotProduct( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3CrossProduct( - C_STRUCT aiVector3D* dst, - const C_STRUCT aiVector3D* a, - const C_STRUCT aiVector3D* b) { + C_STRUCT aiVector3D *dst, + const C_STRUCT aiVector3D *a, + const C_STRUCT aiVector3D *b) { ai_assert(NULL != dst); ai_assert(NULL != a); ai_assert(NULL != b); @@ -922,22 +885,22 @@ ASSIMP_API void aiVector3CrossProduct( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3Normalize( - C_STRUCT aiVector3D* v) { + C_STRUCT aiVector3D *v) { ai_assert(NULL != v); v->Normalize(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3NormalizeSafe( - C_STRUCT aiVector3D* v) { + C_STRUCT aiVector3D *v) { ai_assert(NULL != v); v->NormalizeSafe(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiVector3RotateByQuaternion( - C_STRUCT aiVector3D* v, - const C_STRUCT aiQuaternion* q) { + C_STRUCT aiVector3D *v, + const C_STRUCT aiQuaternion *q) { ai_assert(NULL != v); ai_assert(NULL != q); *v = q->Rotate(*v); @@ -945,8 +908,8 @@ ASSIMP_API void aiVector3RotateByQuaternion( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3FromMatrix4( - C_STRUCT aiMatrix3x3* dst, - const C_STRUCT aiMatrix4x4* mat) { + C_STRUCT aiMatrix3x3 *dst, + const C_STRUCT aiMatrix4x4 *mat) { ai_assert(NULL != dst); ai_assert(NULL != mat); *dst = aiMatrix3x3(*mat); @@ -954,8 +917,8 @@ ASSIMP_API void aiMatrix3FromMatrix4( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3FromQuaternion( - C_STRUCT aiMatrix3x3* mat, - const C_STRUCT aiQuaternion* q) { + C_STRUCT aiMatrix3x3 *mat, + const C_STRUCT aiQuaternion *q) { ai_assert(NULL != mat); ai_assert(NULL != q); *mat = q->GetMatrix(); @@ -963,8 +926,8 @@ ASSIMP_API void aiMatrix3FromQuaternion( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiMatrix3AreEqual( - const C_STRUCT aiMatrix3x3* a, - const C_STRUCT aiMatrix3x3* b) { + const C_STRUCT aiMatrix3x3 *a, + const C_STRUCT aiMatrix3x3 *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a == *b; @@ -972,39 +935,39 @@ ASSIMP_API int aiMatrix3AreEqual( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiMatrix3AreEqualEpsilon( - const C_STRUCT aiMatrix3x3* a, - const C_STRUCT aiMatrix3x3* b, - const float epsilon) { + const C_STRUCT aiMatrix3x3 *a, + const C_STRUCT aiMatrix3x3 *b, + const float epsilon) { ai_assert(NULL != a); ai_assert(NULL != b); return a->Equal(*b, epsilon); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiMatrix3Inverse(C_STRUCT aiMatrix3x3* mat) { +ASSIMP_API void aiMatrix3Inverse(C_STRUCT aiMatrix3x3 *mat) { ai_assert(NULL != mat); mat->Inverse(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API float aiMatrix3Determinant(const C_STRUCT aiMatrix3x3* mat) { +ASSIMP_API float aiMatrix3Determinant(const C_STRUCT aiMatrix3x3 *mat) { ai_assert(NULL != mat); return mat->Determinant(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3RotationZ( - C_STRUCT aiMatrix3x3* mat, - const float angle) { + C_STRUCT aiMatrix3x3 *mat, + const float angle) { ai_assert(NULL != mat); aiMatrix3x3::RotationZ(angle, *mat); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3FromRotationAroundAxis( - C_STRUCT aiMatrix3x3* mat, - const C_STRUCT aiVector3D* axis, - const float angle) { + C_STRUCT aiMatrix3x3 *mat, + const C_STRUCT aiVector3D *axis, + const float angle) { ai_assert(NULL != mat); ai_assert(NULL != axis); aiMatrix3x3::Rotation(angle, *axis, *mat); @@ -1012,8 +975,8 @@ ASSIMP_API void aiMatrix3FromRotationAroundAxis( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3Translation( - C_STRUCT aiMatrix3x3* mat, - const C_STRUCT aiVector2D* translation) { + C_STRUCT aiMatrix3x3 *mat, + const C_STRUCT aiVector2D *translation) { ai_assert(NULL != mat); ai_assert(NULL != translation); aiMatrix3x3::Translation(*translation, *mat); @@ -1021,9 +984,9 @@ ASSIMP_API void aiMatrix3Translation( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix3FromTo( - C_STRUCT aiMatrix3x3* mat, - const C_STRUCT aiVector3D* from, - const C_STRUCT aiVector3D* to) { + C_STRUCT aiMatrix3x3 *mat, + const C_STRUCT aiVector3D *from, + const C_STRUCT aiVector3D *to) { ai_assert(NULL != mat); ai_assert(NULL != from); ai_assert(NULL != to); @@ -1032,8 +995,8 @@ ASSIMP_API void aiMatrix3FromTo( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4FromMatrix3( - C_STRUCT aiMatrix4x4* dst, - const C_STRUCT aiMatrix3x3* mat) { + C_STRUCT aiMatrix4x4 *dst, + const C_STRUCT aiMatrix3x3 *mat) { ai_assert(NULL != dst); ai_assert(NULL != mat); *dst = aiMatrix4x4(*mat); @@ -1041,10 +1004,10 @@ ASSIMP_API void aiMatrix4FromMatrix3( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4FromScalingQuaternionPosition( - C_STRUCT aiMatrix4x4* mat, - const C_STRUCT aiVector3D* scaling, - const C_STRUCT aiQuaternion* rotation, - const C_STRUCT aiVector3D* position) { + C_STRUCT aiMatrix4x4 *mat, + const C_STRUCT aiVector3D *scaling, + const C_STRUCT aiQuaternion *rotation, + const C_STRUCT aiVector3D *position) { ai_assert(NULL != mat); ai_assert(NULL != scaling); ai_assert(NULL != rotation); @@ -1054,8 +1017,8 @@ ASSIMP_API void aiMatrix4FromScalingQuaternionPosition( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4Add( - C_STRUCT aiMatrix4x4* dst, - const C_STRUCT aiMatrix4x4* src) { + C_STRUCT aiMatrix4x4 *dst, + const C_STRUCT aiMatrix4x4 *src) { ai_assert(NULL != dst); ai_assert(NULL != src); *dst = *dst + *src; @@ -1063,8 +1026,8 @@ ASSIMP_API void aiMatrix4Add( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiMatrix4AreEqual( - const C_STRUCT aiMatrix4x4* a, - const C_STRUCT aiMatrix4x4* b) { + const C_STRUCT aiMatrix4x4 *a, + const C_STRUCT aiMatrix4x4 *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a == *b; @@ -1072,38 +1035,38 @@ ASSIMP_API int aiMatrix4AreEqual( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiMatrix4AreEqualEpsilon( - const C_STRUCT aiMatrix4x4* a, - const C_STRUCT aiMatrix4x4* b, - const float epsilon) { + const C_STRUCT aiMatrix4x4 *a, + const C_STRUCT aiMatrix4x4 *b, + const float epsilon) { ai_assert(NULL != a); ai_assert(NULL != b); return a->Equal(*b, epsilon); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API void aiMatrix4Inverse(C_STRUCT aiMatrix4x4* mat) { +ASSIMP_API void aiMatrix4Inverse(C_STRUCT aiMatrix4x4 *mat) { ai_assert(NULL != mat); mat->Inverse(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API float aiMatrix4Determinant(const C_STRUCT aiMatrix4x4* mat) { +ASSIMP_API float aiMatrix4Determinant(const C_STRUCT aiMatrix4x4 *mat) { ai_assert(NULL != mat); return mat->Determinant(); } // ------------------------------------------------------------------------------------------------ -ASSIMP_API int aiMatrix4IsIdentity(const C_STRUCT aiMatrix4x4* mat) { +ASSIMP_API int aiMatrix4IsIdentity(const C_STRUCT aiMatrix4x4 *mat) { ai_assert(NULL != mat); return mat->IsIdentity(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4DecomposeIntoScalingEulerAnglesPosition( - const C_STRUCT aiMatrix4x4* mat, - C_STRUCT aiVector3D* scaling, - C_STRUCT aiVector3D* rotation, - C_STRUCT aiVector3D* position) { + const C_STRUCT aiMatrix4x4 *mat, + C_STRUCT aiVector3D *scaling, + C_STRUCT aiVector3D *rotation, + C_STRUCT aiVector3D *position) { ai_assert(NULL != mat); ai_assert(NULL != scaling); ai_assert(NULL != rotation); @@ -1113,11 +1076,11 @@ ASSIMP_API void aiMatrix4DecomposeIntoScalingEulerAnglesPosition( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition( - const C_STRUCT aiMatrix4x4* mat, - C_STRUCT aiVector3D* scaling, - C_STRUCT aiVector3D* axis, - float* angle, - C_STRUCT aiVector3D* position) { + const C_STRUCT aiMatrix4x4 *mat, + C_STRUCT aiVector3D *scaling, + C_STRUCT aiVector3D *axis, + float *angle, + C_STRUCT aiVector3D *position) { ai_assert(NULL != mat); ai_assert(NULL != scaling); ai_assert(NULL != axis); @@ -1128,9 +1091,9 @@ ASSIMP_API void aiMatrix4DecomposeIntoScalingAxisAnglePosition( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4DecomposeNoScaling( - const C_STRUCT aiMatrix4x4* mat, - C_STRUCT aiQuaternion* rotation, - C_STRUCT aiVector3D* position) { + const C_STRUCT aiMatrix4x4 *mat, + C_STRUCT aiQuaternion *rotation, + C_STRUCT aiVector3D *position) { ai_assert(NULL != mat); ai_assert(NULL != rotation); ai_assert(NULL != position); @@ -1139,41 +1102,41 @@ ASSIMP_API void aiMatrix4DecomposeNoScaling( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4FromEulerAngles( - C_STRUCT aiMatrix4x4* mat, - float x, float y, float z) { + C_STRUCT aiMatrix4x4 *mat, + float x, float y, float z) { ai_assert(NULL != mat); mat->FromEulerAnglesXYZ(x, y, z); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4RotationX( - C_STRUCT aiMatrix4x4* mat, - const float angle) { + C_STRUCT aiMatrix4x4 *mat, + const float angle) { ai_assert(NULL != mat); aiMatrix4x4::RotationX(angle, *mat); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4RotationY( - C_STRUCT aiMatrix4x4* mat, - const float angle) { + C_STRUCT aiMatrix4x4 *mat, + const float angle) { ai_assert(NULL != mat); aiMatrix4x4::RotationY(angle, *mat); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4RotationZ( - C_STRUCT aiMatrix4x4* mat, - const float angle) { + C_STRUCT aiMatrix4x4 *mat, + const float angle) { ai_assert(NULL != mat); aiMatrix4x4::RotationZ(angle, *mat); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4FromRotationAroundAxis( - C_STRUCT aiMatrix4x4* mat, - const C_STRUCT aiVector3D* axis, - const float angle) { + C_STRUCT aiMatrix4x4 *mat, + const C_STRUCT aiVector3D *axis, + const float angle) { ai_assert(NULL != mat); ai_assert(NULL != axis); aiMatrix4x4::Rotation(angle, *axis, *mat); @@ -1181,8 +1144,8 @@ ASSIMP_API void aiMatrix4FromRotationAroundAxis( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4Translation( - C_STRUCT aiMatrix4x4* mat, - const C_STRUCT aiVector3D* translation) { + C_STRUCT aiMatrix4x4 *mat, + const C_STRUCT aiVector3D *translation) { ai_assert(NULL != mat); ai_assert(NULL != translation); aiMatrix4x4::Translation(*translation, *mat); @@ -1190,8 +1153,8 @@ ASSIMP_API void aiMatrix4Translation( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4Scaling( - C_STRUCT aiMatrix4x4* mat, - const C_STRUCT aiVector3D* scaling) { + C_STRUCT aiMatrix4x4 *mat, + const C_STRUCT aiVector3D *scaling) { ai_assert(NULL != mat); ai_assert(NULL != scaling); aiMatrix4x4::Scaling(*scaling, *mat); @@ -1199,9 +1162,9 @@ ASSIMP_API void aiMatrix4Scaling( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiMatrix4FromTo( - C_STRUCT aiMatrix4x4* mat, - const C_STRUCT aiVector3D* from, - const C_STRUCT aiVector3D* to) { + C_STRUCT aiMatrix4x4 *mat, + const C_STRUCT aiVector3D *from, + const C_STRUCT aiVector3D *to) { ai_assert(NULL != mat); ai_assert(NULL != from); ai_assert(NULL != to); @@ -1210,17 +1173,17 @@ ASSIMP_API void aiMatrix4FromTo( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionFromEulerAngles( - C_STRUCT aiQuaternion* q, - float x, float y, float z) { + C_STRUCT aiQuaternion *q, + float x, float y, float z) { ai_assert(NULL != q); *q = aiQuaternion(x, y, z); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionFromAxisAngle( - C_STRUCT aiQuaternion* q, - const C_STRUCT aiVector3D* axis, - const float angle) { + C_STRUCT aiQuaternion *q, + const C_STRUCT aiVector3D *axis, + const float angle) { ai_assert(NULL != q); ai_assert(NULL != axis); *q = aiQuaternion(*axis, angle); @@ -1228,8 +1191,8 @@ ASSIMP_API void aiQuaternionFromAxisAngle( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionFromNormalizedQuaternion( - C_STRUCT aiQuaternion* q, - const C_STRUCT aiVector3D* normalized) { + C_STRUCT aiQuaternion *q, + const C_STRUCT aiVector3D *normalized) { ai_assert(NULL != q); ai_assert(NULL != normalized); *q = aiQuaternion(*normalized); @@ -1237,8 +1200,8 @@ ASSIMP_API void aiQuaternionFromNormalizedQuaternion( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiQuaternionAreEqual( - const C_STRUCT aiQuaternion* a, - const C_STRUCT aiQuaternion* b) { + const C_STRUCT aiQuaternion *a, + const C_STRUCT aiQuaternion *b) { ai_assert(NULL != a); ai_assert(NULL != b); return *a == *b; @@ -1246,9 +1209,9 @@ ASSIMP_API int aiQuaternionAreEqual( // ------------------------------------------------------------------------------------------------ ASSIMP_API int aiQuaternionAreEqualEpsilon( - const C_STRUCT aiQuaternion* a, - const C_STRUCT aiQuaternion* b, - const float epsilon) { + const C_STRUCT aiQuaternion *a, + const C_STRUCT aiQuaternion *b, + const float epsilon) { ai_assert(NULL != a); ai_assert(NULL != b); return a->Equal(*b, epsilon); @@ -1256,22 +1219,22 @@ ASSIMP_API int aiQuaternionAreEqualEpsilon( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionNormalize( - C_STRUCT aiQuaternion* q) { + C_STRUCT aiQuaternion *q) { ai_assert(NULL != q); q->Normalize(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionConjugate( - C_STRUCT aiQuaternion* q) { + C_STRUCT aiQuaternion *q) { ai_assert(NULL != q); q->Conjugate(); } // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionMultiply( - C_STRUCT aiQuaternion* dst, - const C_STRUCT aiQuaternion* q) { + C_STRUCT aiQuaternion *dst, + const C_STRUCT aiQuaternion *q) { ai_assert(NULL != dst); ai_assert(NULL != q); *dst = (*dst) * (*q); @@ -1279,10 +1242,10 @@ ASSIMP_API void aiQuaternionMultiply( // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiQuaternionInterpolate( - C_STRUCT aiQuaternion* dst, - const C_STRUCT aiQuaternion* start, - const C_STRUCT aiQuaternion* end, - const float factor) { + C_STRUCT aiQuaternion *dst, + const C_STRUCT aiQuaternion *start, + const C_STRUCT aiQuaternion *end, + const float factor) { ai_assert(NULL != dst); ai_assert(NULL != start); ai_assert(NULL != end); diff --git a/code/FBX/FBXImporter.cpp b/code/FBX/FBXImporter.cpp index 571f60883..11c1503d8 100644 --- a/code/FBX/FBXImporter.cpp +++ b/code/FBX/FBXImporter.cpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index bddd04b1e..28ddce567 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -49,29 +47,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_METADATA_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #if defined(_MSC_VER) && (_MSC_VER <= 1500) -# include "Compiler/pstdint.h" +#include "Compiler/pstdint.h" #else -# include +#include #endif // ------------------------------------------------------------------------------- /** * Enum used to distinguish data types */ - // ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- typedef enum aiMetadataType { - AI_BOOL = 0, - AI_INT32 = 1, - AI_UINT64 = 2, - AI_FLOAT = 3, - AI_DOUBLE = 4, - AI_AISTRING = 5, + AI_BOOL = 0, + AI_INT32 = 1, + AI_UINT64 = 2, + AI_FLOAT = 3, + AI_DOUBLE = 4, + AI_AISTRING = 5, AI_AIVECTOR3D = 6, - AI_META_MAX = 7, + AI_META_MAX = 7, #ifndef SWIG FORCE_32BIT = INT_MAX @@ -84,10 +82,10 @@ typedef enum aiMetadataType { * * The type field uniquely identifies the underlying type of the data field */ - // ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- struct aiMetadataEntry { aiMetadataType mType; - void* mData; + void *mData; }; #ifdef __cplusplus @@ -98,15 +96,29 @@ struct aiMetadataEntry { /** * Helper functions to get the aiType enum entry for a type */ - // ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- -inline aiMetadataType GetAiType( bool ) { return AI_BOOL; } -inline aiMetadataType GetAiType( int32_t ) { return AI_INT32; } -inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; } -inline aiMetadataType GetAiType( float ) { return AI_FLOAT; } -inline aiMetadataType GetAiType( double ) { return AI_DOUBLE; } -inline aiMetadataType GetAiType( const aiString & ) { return AI_AISTRING; } -inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; } +inline aiMetadataType GetAiType(bool) { + return AI_BOOL; +} +inline aiMetadataType GetAiType(int32_t) { + return AI_INT32; +} +inline aiMetadataType GetAiType(uint64_t) { + return AI_UINT64; +} +inline aiMetadataType GetAiType(float) { + return AI_FLOAT; +} +inline aiMetadataType GetAiType(double) { + return AI_DOUBLE; +} +inline aiMetadataType GetAiType(const aiString &) { + return AI_AISTRING; +} +inline aiMetadataType GetAiType(const aiVector3D &) { + return AI_AIVECTOR3D; +} #endif // __cplusplus @@ -116,17 +128,17 @@ inline aiMetadataType GetAiType( const aiVector3D & ) { return AI_AIVECTOR3D; } * * Metadata is a key-value store using string keys and values. */ - // ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- struct aiMetadata { /** Length of the mKeys and mValues arrays, respectively */ unsigned int mNumProperties; /** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */ - C_STRUCT aiString* mKeys; + C_STRUCT aiString *mKeys; /** Arrays of values, may not be NULL. Entries in this array may be NULL if the * corresponding property key has no assigned value. */ - C_STRUCT aiMetadataEntry* mValues; + C_STRUCT aiMetadataEntry *mValues; #ifdef __cplusplus @@ -134,71 +146,62 @@ struct aiMetadata { * @brief The default constructor, set all members to zero by default. */ aiMetadata() AI_NO_EXCEPT - : mNumProperties(0) - , mKeys(nullptr) - , mValues(nullptr) { + : mNumProperties(0), + mKeys(nullptr), + mValues(nullptr) { // empty } - aiMetadata( const aiMetadata &rhs ) - : mNumProperties( rhs.mNumProperties ) - , mKeys( nullptr ) - , mValues( nullptr ) { - mKeys = new aiString[ mNumProperties ]; - for ( size_t i = 0; i < static_cast( mNumProperties ); ++i ) { - mKeys[ i ] = rhs.mKeys[ i ]; + aiMetadata(const aiMetadata &rhs) : + mNumProperties(rhs.mNumProperties), mKeys(nullptr), mValues(nullptr) { + mKeys = new aiString[mNumProperties]; + for (size_t i = 0; i < static_cast(mNumProperties); ++i) { + mKeys[i] = rhs.mKeys[i]; } - mValues = new aiMetadataEntry[ mNumProperties ]; - for ( size_t i = 0; i < static_cast(mNumProperties); ++i ) { - mValues[ i ].mType = rhs.mValues[ i ].mType; - switch ( rhs.mValues[ i ].mType ) { + mValues = new aiMetadataEntry[mNumProperties]; + for (size_t i = 0; i < static_cast(mNumProperties); ++i) { + mValues[i].mType = rhs.mValues[i].mType; + switch (rhs.mValues[i].mType) { case AI_BOOL: - mValues[ i ].mData = new bool; - ::memcpy( mValues[ i ].mData, rhs.mValues[ i ].mData, sizeof(bool) ); + mValues[i].mData = new bool; + ::memcpy(mValues[i].mData, rhs.mValues[i].mData, sizeof(bool)); break; case AI_INT32: { int32_t v; - ::memcpy( &v, rhs.mValues[ i ].mData, sizeof( int32_t ) ); - mValues[ i ].mData = new int32_t( v ); - } - break; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(int32_t)); + mValues[i].mData = new int32_t(v); + } break; case AI_UINT64: { - uint64_t v; - ::memcpy( &v, rhs.mValues[ i ].mData, sizeof( uint64_t ) ); - mValues[ i ].mData = new uint64_t( v ); - } - break; + uint64_t v; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(uint64_t)); + mValues[i].mData = new uint64_t(v); + } break; case AI_FLOAT: { - float v; - ::memcpy( &v, rhs.mValues[ i ].mData, sizeof( float ) ); - mValues[ i ].mData = new float( v ); - } - break; + float v; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(float)); + mValues[i].mData = new float(v); + } break; case AI_DOUBLE: { - double v; - ::memcpy( &v, rhs.mValues[ i ].mData, sizeof( double ) ); - mValues[ i ].mData = new double( v ); - } - break; + double v; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(double)); + mValues[i].mData = new double(v); + } break; case AI_AISTRING: { - aiString v; - rhs.Get( mKeys[ i ], v ); - mValues[ i ].mData = new aiString( v ); - } - break; + aiString v; + rhs.Get(mKeys[i], v); + mValues[i].mData = new aiString(v); + } break; case AI_AIVECTOR3D: { - aiVector3D v; - rhs.Get( mKeys[ i ], v ); - mValues[ i ].mData = new aiVector3D( v ); - } - break; + aiVector3D v; + rhs.Get(mKeys[i], v); + mValues[i].mData = new aiVector3D(v); + } break; #ifndef SWIG case FORCE_32BIT: #endif default: break; } - } } @@ -206,33 +209,33 @@ struct aiMetadata { * @brief The destructor. */ ~aiMetadata() { - delete [] mKeys; + delete[] mKeys; mKeys = nullptr; if (mValues) { // Delete each metadata entry - for (unsigned i=0; i( data ); + delete static_cast(data); break; case AI_INT32: - delete static_cast< int32_t* >( data ); + delete static_cast(data); break; case AI_UINT64: - delete static_cast< uint64_t* >( data ); + delete static_cast(data); break; case AI_FLOAT: - delete static_cast< float* >( data ); + delete static_cast(data); break; case AI_DOUBLE: - delete static_cast< double* >( data ); + delete static_cast(data); break; case AI_AISTRING: - delete static_cast< aiString* >( data ); + delete static_cast(data); break; case AI_AIVECTOR3D: - delete static_cast< aiVector3D* >( data ); + delete static_cast(data); break; #ifndef SWIG case FORCE_32BIT: @@ -243,7 +246,7 @@ struct aiMetadata { } // Delete the metadata array - delete [] mValues; + delete[] mValues; mValues = nullptr; } } @@ -252,16 +255,15 @@ struct aiMetadata { * @brief Allocates property fields + keys. * @param numProperties Number of requested properties. */ - static inline - aiMetadata *Alloc( unsigned int numProperties ) { - if ( 0 == numProperties ) { + static inline aiMetadata *Alloc(unsigned int numProperties) { + if (0 == numProperties) { return nullptr; } aiMetadata *data = new aiMetadata; data->mNumProperties = numProperties; - data->mKeys = new aiString[ data->mNumProperties ](); - data->mValues = new aiMetadataEntry[ data->mNumProperties ](); + data->mKeys = new aiString[data->mNumProperties](); + data->mValues = new aiMetadataEntry[data->mNumProperties](); return data; } @@ -269,44 +271,40 @@ struct aiMetadata { /** * @brief Deallocates property fields + keys. */ - static inline - void Dealloc( aiMetadata *metadata ) { + static inline void Dealloc(aiMetadata *metadata) { delete metadata; } - template - inline - void Add(const std::string& key, const T& value) { - aiString* new_keys = new aiString[mNumProperties + 1]; - aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1]; + template + inline void Add(const std::string &key, const T &value) { + aiString *new_keys = new aiString[mNumProperties + 1]; + aiMetadataEntry *new_values = new aiMetadataEntry[mNumProperties + 1]; - for(unsigned int i = 0; i < mNumProperties; ++i) - { - new_keys[i] = mKeys[i]; - new_values[i] = mValues[i]; - } + for (unsigned int i = 0; i < mNumProperties; ++i) { + new_keys[i] = mKeys[i]; + new_values[i] = mValues[i]; + } - delete[] mKeys; - delete[] mValues; + delete[] mKeys; + delete[] mValues; - mKeys = new_keys; - mValues = new_values; + mKeys = new_keys; + mValues = new_values; - mNumProperties++; + mNumProperties++; - Set(mNumProperties - 1, key, value); - } + Set(mNumProperties - 1, key, value); + } - template - inline - bool Set( unsigned index, const std::string& key, const T& value ) { + template + inline bool Set(unsigned index, const std::string &key, const T &value) { // In range assertion - if ( index >= mNumProperties ) { + if (index >= mNumProperties) { return false; } // Ensure that we have a valid key. - if ( key.empty() ) { + if (key.empty()) { return false; } @@ -321,73 +319,86 @@ struct aiMetadata { return true; } - template - inline - bool Get( unsigned index, T& value ) const { + template + inline bool Set( const std::string &key, const T &value ) { + if (key.empty()) { + return false; + } + + bool result = false; + for (unsigned int i = 0; i < mNumProperties; ++i) { + if (key == mKeys[i].C_Str()) { + Set(i, key, value); + result = true; + break; + } + } + + return result; + } + + template + inline bool Get(unsigned index, T &value) const { // In range assertion - if ( index >= mNumProperties ) { + if (index >= mNumProperties) { return false; } // Return false if the output data type does // not match the found value's data type - if ( GetAiType( value ) != mValues[ index ].mType ) { + if (GetAiType(value) != mValues[index].mType) { return false; } // Otherwise, output the found value and // return true - value = *static_cast(mValues[index].mData); + value = *static_cast(mValues[index].mData); return true; } - template - inline - bool Get( const aiString& key, T& value ) const { + template + inline bool Get(const aiString &key, T &value) const { // Search for the given key - for ( unsigned int i = 0; i < mNumProperties; ++i ) { - if ( mKeys[ i ] == key ) { - return Get( i, value ); + for (unsigned int i = 0; i < mNumProperties; ++i) { + if (mKeys[i] == key) { + return Get(i, value); } } return false; } - template - inline - bool Get( const std::string& key, T& value ) const { + template + inline bool Get(const std::string &key, T &value) const { return Get(aiString(key), value); } - /// Return metadata entry for analyzing it by user. - /// \param [in] pIndex - index of the entry. - /// \param [out] pKey - pointer to the key value. - /// \param [out] pEntry - pointer to the entry: type and value. - /// \return false - if pIndex is out of range, else - true. - inline - bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const { - if ( index >= mNumProperties ) { + /// Return metadata entry for analyzing it by user. + /// \param [in] pIndex - index of the entry. + /// \param [out] pKey - pointer to the key value. + /// \param [out] pEntry - pointer to the entry: type and value. + /// \return false - if pIndex is out of range, else - true. + inline bool Get(size_t index, const aiString *&key, const aiMetadataEntry *&entry) const { + if (index >= mNumProperties) { return false; } - key = &mKeys[index]; - entry = &mValues[index]; + key = &mKeys[index]; + entry = &mValues[index]; - return true; - } + return true; + } /// Check whether there is a metadata entry for the given key. /// \param [in] Key - the key value value to check for. - inline - bool HasKey(const char* key) { - if ( nullptr == key ) { + inline bool HasKey(const char *key) { + if (nullptr == key) { return false; } - + // Search for the given key for (unsigned int i = 0; i < mNumProperties; ++i) { - if ( 0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length ) ) { + if (0 == strncmp(mKeys[i].C_Str(), key, mKeys[i].length)) { return true; } } @@ -395,7 +406,6 @@ struct aiMetadata { } #endif // __cplusplus - }; #endif // AI_METADATA_H_INC diff --git a/test/unit/utFBXImporterExporter.cpp b/test/unit/utFBXImporterExporter.cpp index 30a26d99d..88a3e067e 100644 --- a/test/unit/utFBXImporterExporter.cpp +++ b/test/unit/utFBXImporterExporter.cpp @@ -213,6 +213,10 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) { double factor(0.0); scene->mMetaData->Get("UnitScaleFactor", factor); EXPECT_DOUBLE_EQ(500.0, factor); + + scene->mMetaData->Set("UnitScaleFactor", factor * 2); + scene->mMetaData->Get("UnitScaleFactor", factor); + EXPECT_DOUBLE_EQ(1000.0, factor); } TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {