diff --git a/CMakeLists.txt b/CMakeLists.txt index e859986b7..0f0e5a793 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,10 +84,6 @@ OPTION( ASSIMP_NO_EXPORT "Disable Assimp's export functionality." OFF ) -OPTION( ASSIMP_BUILD_ZLIB - "Build your own zlib" - OFF -) OPTION( ASSIMP_BUILD_ASSIMP_TOOLS "If the supplementary tools for Assimp are built in addition to the library." OFF @@ -134,6 +130,18 @@ OPTION ( ASSIMP_IGNORE_GIT_HASH OFF ) +IF (WIN32) + OPTION( ASSIMP_BUILD_ZLIB + "Build your own zlib" + ON + ) +ELSE() + OPTION( ASSIMP_BUILD_ZLIB + "Build your own zlib" + OFF + ) +ENDIF() + IF (WIN32) # Use subset of Windows.h ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN ) diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index b60657805..76b61cda5 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -975,7 +975,7 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones) } // store the name of the bone - pcOutBone->mName.length = (size_t)iMaxLen; + pcOutBone->mName.length = static_cast(iMaxLen); ::memcpy(pcOutBone->mName.data, pcBone->name, pcOutBone->mName.length); pcOutBone->mName.data[pcOutBone->mName.length] = '\0'; } diff --git a/code/AssetLib/SMD/SMDLoader.cpp b/code/AssetLib/SMD/SMDLoader.cpp index dd1f56dc3..1c73c7e66 100644 --- a/code/AssetLib/SMD/SMDLoader.cpp +++ b/code/AssetLib/SMD/SMDLoader.cpp @@ -590,7 +590,7 @@ void SMDImporter::CreateOutputMaterials() { pScene->mMaterials[iMat] = pcMat; aiString szName; - szName.length = (size_t)ai_snprintf(szName.data,MAXLEN,"Texture_%u",iMat); + szName.length = static_cast(ai_snprintf(szName.data,MAXLEN,"Texture_%u",iMat)); pcMat->AddProperty(&szName,AI_MATKEY_NAME); if (aszTextures[iMat].length()) diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl index 868d9cbdf..6f6eda502 100644 --- a/code/AssetLib/glTF2/glTF2AssetWriter.inl +++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl @@ -836,7 +836,7 @@ namespace glTF2 { throw DeadlyExportError("Failed to write scene data!"); } - uint32_t jsonChunkLength = (docBuffer.GetSize() + 3) & ~3; // Round up to next multiple of 4 + uint32_t jsonChunkLength = static_cast((docBuffer.GetSize() + 3) & ~3); // Round up to next multiple of 4 auto paddingLength = jsonChunkLength - docBuffer.GetSize(); GLB_Chunk jsonChunk; @@ -862,7 +862,7 @@ namespace glTF2 { int GLB_Chunk_count = 1; uint32_t binaryChunkLength = 0; if (bodyBuffer->byteLength > 0) { - binaryChunkLength = (bodyBuffer->byteLength + 3) & ~3; // Round up to next multiple of 4 + binaryChunkLength = static_cast((bodyBuffer->byteLength + 3) & ~3); // Round up to next multiple of 4 auto curPaddingLength = binaryChunkLength - bodyBuffer->byteLength; ++GLB_Chunk_count; diff --git a/contrib/zip/src/miniz.h b/contrib/zip/src/miniz.h index 0a5560b24..7a6ff8d1a 100644 --- a/contrib/zip/src/miniz.h +++ b/contrib/zip/src/miniz.h @@ -6092,8 +6092,8 @@ mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) { if (!pZip->m_file_offset_alignment) return 0; n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); - return (pZip->m_file_offset_alignment - n) & - (pZip->m_file_offset_alignment - 1); + return (mz_uint)((pZip->m_file_offset_alignment - n) & + (pZip->m_file_offset_alignment - 1)); } static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index d2ec837e9..c766d0ae2 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -56,6 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif +#include + // ------------------------------------------------------------------------------- /** * Enum used to distinguish data types @@ -70,7 +72,9 @@ typedef enum aiMetadataType { AI_AISTRING = 5, AI_AIVECTOR3D = 6, AI_AIMETADATA = 7, - AI_META_MAX = 8, + AI_INT64 = 8, + AI_UINT32 = 9, + AI_META_MAX = 10, #ifndef SWIG FORCE_32BIT = INT_MAX @@ -133,6 +137,12 @@ inline aiMetadataType GetAiType(const aiVector3D &) { inline aiMetadataType GetAiType(const aiMetadata &) { return AI_AIMETADATA; } +inline aiMetadataType GetAiType(int64_t) { + return AI_INT64; +} +inline aiMetadataType GetAiType(uint32_t) { + return AI_UINT32; +} #endif // __cplusplus @@ -215,6 +225,16 @@ struct aiMetadata { rhs.Get(static_cast(i), v); mValues[i].mData = new aiMetadata(v); } break; + case AI_INT64: { + int64_t v; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(int64_t)); + mValues[i].mData = new int64_t(v); + } break; + case AI_UINT32: { + uint32_t v; + ::memcpy(&v, rhs.mValues[i].mData, sizeof(uint32_t)); + mValues[i].mData = new uint32_t(v); + } break; #ifndef SWIG case FORCE_32BIT: #endif @@ -267,6 +287,12 @@ struct aiMetadata { case AI_AIMETADATA: delete static_cast(data); break; + case AI_INT64: + delete static_cast(data); + break; + case AI_UINT32: + delete static_cast(data); + break; #ifndef SWIG case FORCE_32BIT: #endif @@ -510,6 +536,16 @@ struct aiMetadata { return false; } } break; + case AI_INT64: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; + case AI_UINT32: { + if (*static_cast(lhs.mValues[i].mData) != *static_cast(rhs.mValues[i].mData)) { + return false; + } + } break; #ifndef SWIG case FORCE_32BIT: #endif diff --git a/port/PyAssimp/README.md b/port/PyAssimp/README.md index c9944f717..900003be4 100644 --- a/port/PyAssimp/README.md +++ b/port/PyAssimp/README.md @@ -76,7 +76,7 @@ $ python setup.py install ``` PyAssimp requires a assimp dynamic library (`DLL` on windows, -`.so` on linux, `.dynlib` on macOS) in order to work. The default search directories are: +`.so` on linux, `.dylib` on macOS) in order to work. The default search directories are: - the current directory - on linux additionally: `/usr/lib`, `/usr/local/lib`, `/usr/lib/x86_64-linux-gnu` diff --git a/port/PyAssimp/README.rst b/port/PyAssimp/README.rst index 03b7968f1..45624145f 100644 --- a/port/PyAssimp/README.rst +++ b/port/PyAssimp/README.rst @@ -81,7 +81,7 @@ Install ``pyassimp`` by running: $ python setup.py install PyAssimp requires a assimp dynamic library (``DLL`` on windows, ``.so`` -on linux, ``.dynlib`` on macOS) in order to work. The default search +on linux, ``.dylib`` on macOS) in order to work. The default search directories are: - the current directory diff --git a/test/unit/utMetadata.cpp b/test/unit/utMetadata.cpp index 514b1a4a4..676404c3c 100644 --- a/test/unit/utMetadata.cpp +++ b/test/unit/utMetadata.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2022, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -84,7 +82,7 @@ TEST_F( utMetadata, allocTest ) { } TEST_F( utMetadata, get_set_pod_Test ) { - m_data = aiMetadata::Alloc( 5 ); + m_data = aiMetadata::Alloc( 7 ); // int, 32 bit unsigned int index( 0 ); @@ -137,6 +135,28 @@ TEST_F( utMetadata, get_set_pod_Test ) { EXPECT_TRUE( success ); EXPECT_DOUBLE_EQ( 3.0, result_double ); + // int64_t + index++; + const std::string key_int64 = "test_int64"; + int64_t val_int64 = 64; + success = m_data->Set(index, key_int64, val_int64); + EXPECT_TRUE(success); + int64_t result_int64(0); + success = m_data->Get(key_int64, result_int64); + EXPECT_TRUE(success); + EXPECT_EQ(result_int64, val_int64); + + // uint32 + index++; + const std::string key_uint32 = "test_uint32"; + int64_t val_uint32 = 32; + success = m_data->Set(index, key_uint32, val_uint32); + EXPECT_TRUE(success); + int64_t result_uint32(0); + success = m_data->Get(key_uint32, result_uint32); + EXPECT_TRUE(success); + EXPECT_EQ(result_uint32, val_uint32); + // error int result; success = m_data->Get( "bla", result ); @@ -181,6 +201,7 @@ TEST_F( utMetadata, get_set_aiVector3D_Test ) { EXPECT_TRUE( success ); } + TEST_F( utMetadata, copy_test ) { m_data = aiMetadata::Alloc( AI_META_MAX ); bool bv = true; @@ -199,9 +220,12 @@ TEST_F( utMetadata, copy_test ) { m_data->Set( 6, "aiVector3D", vecVal ); aiMetadata metaVal; m_data->Set( 7, "aiMetadata", metaVal ); - - aiMetadata copy( *m_data ); - EXPECT_EQ( 8u, copy.mNumProperties ); + int64_t i64 = 64; + m_data->Set(8, "int64_t", i64); + uint32_t ui32 = 32; + m_data->Set(9, "uint32_t", ui32); + aiMetadata copy(*m_data); + EXPECT_EQ( 10u, copy.mNumProperties ); // bool test {