From 9d40f36f8740d07469c861eb8d88c739ed34382d Mon Sep 17 00:00:00 2001 From: Alexandr Arutjunov Date: Tue, 4 Oct 2016 23:58:51 +0300 Subject: [PATCH] [F] Fixed type in list. [+] Added function to metadata class for conveniance. [*] Enumeration AI_INT changed to AI_INT32. --- code/CMakeLists.txt | 2 ++ code/SceneCombiner.cpp | 4 ++-- include/assimp/metadata.h | 34 +++++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index d71a1893d..10979df5c 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -611,6 +611,8 @@ ADD_ASSIMP_IMPORTER( X ) ADD_ASSIMP_IMPORTER(X3D + X3DExporter.cpp + X3DExporter.hpp X3DImporter.cpp X3DImporter.hpp X3DImporter_Geometry2D.cpp diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index 68c595b26..e167a3600 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -1237,8 +1237,8 @@ void SceneCombiner::Copy (aiMetadata** _dest, const aiMetadata* src) case AI_BOOL: out.mData = new bool(*static_cast(in.mData)); break; - case AI_INT: - out.mData = new int(*static_cast(in.mData)); + case AI_INT32: + out.mData = new int32_t(*static_cast(in.mData)); break; case AI_UINT64: out.mData = new uint64_t(*static_cast(in.mData)); diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 258bf329c..068bbbe5e 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -64,12 +64,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ------------------------------------------------------------------------------- typedef enum aiMetadataType { - AI_BOOL = 0, - AI_INT = 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, #ifndef SWIG @@ -106,7 +106,7 @@ struct aiMetadataEntry */ // ------------------------------------------------------------------------------- inline aiMetadataType GetAiType( bool ) { return AI_BOOL; } -inline aiMetadataType GetAiType( int ) { return AI_INT; } +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; } @@ -165,8 +165,8 @@ struct aiMetadata case AI_BOOL: delete static_cast(data); break; - case AI_INT: - delete static_cast(data); + case AI_INT32: + delete static_cast(data); break; case AI_UINT64: delete static_cast(data); @@ -248,6 +248,22 @@ struct aiMetadata return Get(aiString(key), value); } + /// \fn inline bool Get(size_t pIndex, const aiString*& pKey, const aiMetadataEntry*& pEntry) + /// 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 pIndex, const aiString*& pKey, const aiMetadataEntry*& pEntry) + { + if(pIndex >= mNumProperties) return false; + + pKey = &mKeys[pIndex]; + pEntry = &mValues[pIndex]; + + return true; + } + #endif // __cplusplus };