From 6b0a7a21a436cfff9368742a85e65b3f94930926 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Mon, 23 May 2022 14:24:56 +0800 Subject: [PATCH 01/11] Store SID in SID field Signed-off-by: Luca Della Vedova --- code/AssetLib/Collada/ColladaParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 922d1f6b2..9b3af0848 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -2057,7 +2057,7 @@ void ColladaParser::ReadSceneNode(XmlNode &node, Node *pNode) { XmlParser::getStdStrAttribute(currentNode, "id", child->mID); } if (XmlParser::hasAttribute(currentNode, "sid")) { - XmlParser::getStdStrAttribute(currentNode, "id", child->mSID); + XmlParser::getStdStrAttribute(currentNode, "sid", child->mSID); } if (XmlParser::hasAttribute(currentNode, "name")) { XmlParser::getStdStrAttribute(currentNode, "name", child->mName); From a10abe0283787c369cb59426be6b1bf641911cfa Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 18:11:06 +0200 Subject: [PATCH 02/11] Add fallthrough comment to switch case This allows gcc to identify intentional fallthroughs, which are part all -Wall. Specifically -Werror=implicit-fallthrough --- code/AssetLib/3DS/3DSConverter.cpp | 2 +- code/AssetLib/3DS/3DSLoader.cpp | 3 ++- code/AssetLib/ASE/ASELoader.cpp | 1 + code/AssetLib/LWO/LWOLoader.cpp | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp index 5a01429e4..2421d5460 100644 --- a/code/AssetLib/3DS/3DSConverter.cpp +++ b/code/AssetLib/3DS/3DSConverter.cpp @@ -262,7 +262,7 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material &oldMat, unsigned int iWire = 1; mat.AddProperty((int *)&iWire, 1, AI_MATKEY_ENABLE_WIREFRAME); } - +// fallthrough case D3DS::Discreet3DS::Gouraud: eShading = aiShadingMode_Gouraud; break; diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index 0ec8b872a..b76640218 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -1284,7 +1284,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) { switch (chunk.Flag) { case Discreet3DS::CHUNK_LINRGBF: bGamma = true; - + // fallthrough case Discreet3DS::CHUNK_RGBF: if (sizeof(float) * 3 > diff) { *out = clrError; @@ -1297,6 +1297,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) { case Discreet3DS::CHUNK_LINRGBB: bGamma = true; + // fallthrough case Discreet3DS::CHUNK_RGBB: { if (sizeof(char) * 3 > diff) { *out = clrError; diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index caa708961..7caac24ce 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -870,6 +870,7 @@ void ASEImporter::ConvertMaterial(ASE::Material &mat) { unsigned int iWire = 1; mat.pcInstance->AddProperty((int *)&iWire, 1, AI_MATKEY_ENABLE_WIREFRAME); } + // fallthrough case D3DS::Discreet3DS::Gouraud: eShading = aiShadingMode_Gouraud; break; diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index 44517a1a6..77589d63c 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -1540,6 +1540,7 @@ void LWOImporter::LoadLWO2File() { break; } // --- intentionally no break here + // fallthrough case AI_LWO_VMAP: { if (skip) break; From ae276987a02b919df742904175d67ed25e20b725 Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 18:12:41 +0200 Subject: [PATCH 03/11] Remove unnecessary const qualifiers These changes are part of enable -Wall, this specific changes are for -Werror=ignored-qualifiers --- code/AssetLib/Blender/BlenderDNA.cpp | 8 ++++---- code/AssetLib/Blender/BlenderLoader.cpp | 2 +- code/AssetLib/glTF/glTFAsset.inl | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/AssetLib/Blender/BlenderDNA.cpp b/code/AssetLib/Blender/BlenderDNA.cpp index 2910904ba..fbb61ab4f 100644 --- a/code/AssetLib/Blender/BlenderDNA.cpp +++ b/code/AssetLib/Blender/BlenderDNA.cpp @@ -325,10 +325,10 @@ void SectionParser ::Next() { stream.SetCurrentPos(current.start + current.size); const char tmp[] = { - (const char)stream.GetI1(), - (const char)stream.GetI1(), - (const char)stream.GetI1(), - (const char)stream.GetI1() + (char)stream.GetI1(), + (char)stream.GetI1(), + (char)stream.GetI1(), + (char)stream.GetI1() }; current.id = std::string(tmp, tmp[3] ? 4 : tmp[2] ? 3 : tmp[1] ? 2 : 1); diff --git a/code/AssetLib/Blender/BlenderLoader.cpp b/code/AssetLib/Blender/BlenderLoader.cpp index 2ed0d6b8a..9322369eb 100644 --- a/code/AssetLib/Blender/BlenderLoader.cpp +++ b/code/AssetLib/Blender/BlenderLoader.cpp @@ -986,7 +986,7 @@ void BlenderImporter::ConvertMesh(const Scene & /*in*/, const Object * /*obj*/, // key is material number, value is the TextureUVMapping for the material typedef std::map MaterialTextureUVMappings; MaterialTextureUVMappings matTexUvMappings; - const uint32_t maxMat = static_cast(mesh->mat.size()); + const uint32_t maxMat = static_cast(mesh->mat.size()); for (uint32_t m = 0; m < maxMat; ++m) { // get material by index const std::shared_ptr pMat = mesh->mat[m]; diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl index 1f4544156..86fba95b7 100644 --- a/code/AssetLib/glTF/glTFAsset.inl +++ b/code/AssetLib/glTF/glTFAsset.inl @@ -891,12 +891,12 @@ inline void Mesh::Decode_O3DGC(const SCompression_Open3DGC &pCompression_Open3DG auto get_buf_offset = [](Ref &pAccessor) -> size_t { return pAccessor->byteOffset + pAccessor->bufferView->byteOffset; }; // Indices - ifs.SetCoordIndex((IndicesType *const)(decoded_data + get_buf_offset(primitives[0].indices))); + ifs.SetCoordIndex((IndicesType *)(decoded_data + get_buf_offset(primitives[0].indices))); // Coordinates - ifs.SetCoord((o3dgc::Real *const)(decoded_data + get_buf_offset(primitives[0].attributes.position[0]))); + ifs.SetCoord((o3dgc::Real *)(decoded_data + get_buf_offset(primitives[0].attributes.position[0]))); // Normals if (size_normal) { - ifs.SetNormal((o3dgc::Real *const)(decoded_data + get_buf_offset(primitives[0].attributes.normal[0]))); + ifs.SetNormal((o3dgc::Real *)(decoded_data + get_buf_offset(primitives[0].attributes.normal[0]))); } for (size_t idx = 0, idx_end = size_floatattr.size(), idx_texcoord = 0; idx < idx_end; idx++) { @@ -904,7 +904,7 @@ inline void Mesh::Decode_O3DGC(const SCompression_Open3DGC &pCompression_Open3DG case o3dgc::O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_TEXCOORD: if (idx_texcoord < primitives[0].attributes.texcoord.size()) { // See above about absent attributes. - ifs.SetFloatAttribute(static_cast(idx), (o3dgc::Real *const)(decoded_data + get_buf_offset(primitives[0].attributes.texcoord[idx]))); + ifs.SetFloatAttribute(static_cast(idx), (o3dgc::Real *)(decoded_data + get_buf_offset(primitives[0].attributes.texcoord[idx]))); idx_texcoord++; } From c3a89fd2d007e3bacf257f7764d4888b037c5104 Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 18:13:25 +0200 Subject: [PATCH 04/11] Fix non virtual destructor use --- code/AssetLib/MMD/MMDPmxParser.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h index 08f57f6f0..4b3968dec 100644 --- a/code/AssetLib/MMD/MMDPmxParser.h +++ b/code/AssetLib/MMD/MMDPmxParser.h @@ -357,6 +357,10 @@ namespace pmx { public: void virtual Read(std::istream *stream, PmxSetting *setting) = 0; + + virtual ~PmxMorphOffset() { + + } }; class PmxMorphVertexOffset : public PmxMorphOffset From 3890b5dff5f62c95ba44255e224800e5b9d29255 Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 18:15:49 +0200 Subject: [PATCH 05/11] Add missing = operator implicit assignment operator is depricated, these classes were missing explicit definitions of this operator. It is causing warnings, specifically -Werror=deprecated-copy --- code/AssetLib/glTF2/glTF2Asset.h | 2 ++ contrib/clipper/clipper.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index c597fc951..44ab6c9c8 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -374,6 +374,8 @@ struct CustomExtension { mValues(other.mValues) { // empty } + + CustomExtension& operator=(const CustomExtension&) = default; }; //! Base class for all glTF top-level objects diff --git a/contrib/clipper/clipper.cpp b/contrib/clipper/clipper.cpp index 857cd1c3e..2d02aff67 100644 --- a/contrib/clipper/clipper.cpp +++ b/contrib/clipper/clipper.cpp @@ -86,6 +86,13 @@ class Int128 Int128(const Int128 &val): hi(val.hi), lo(val.lo){} + Int128 operator = (const Int128 &val) + { + lo = val.lo; + hi = val.hi; + return val; + } + long64 operator = (const long64 &val) { lo = val; From 8a90ba8a399f5c62ccf5266039e187964ecefaa6 Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 23:42:16 +0200 Subject: [PATCH 06/11] Don't optimize on debug builds --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4f711528..8a56f2250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -302,8 +302,12 @@ ELSEIF( MINGW ) SET(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}") SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") ENDIF() - SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}") - SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") + IF (CMAKE_BUILD_TYPE STREQUAL "Debug") + SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -g ${CMAKE_CXX_FLAGS}") + ELSE() + SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}") + ENDIF() + SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") ENDIF() IF ( IOS AND NOT ASSIMP_HUNTER_ENABLED) From e63426b89c97e9f9c9f0ced64de55813a43d4402 Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 23:42:41 +0200 Subject: [PATCH 07/11] Fix collada parser fails on Mixamo exports --- code/AssetLib/Collada/ColladaParser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 922d1f6b2..25034defb 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -1616,12 +1616,17 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) { XmlParser::getValueAsString(currentNode, v); const char *content = v.c_str(); vcount.reserve(numPrimitives); + SkipSpacesAndLineEnd(&content); for (unsigned int a = 0; a < numPrimitives; a++) { if (*content == 0) { throw DeadlyImportError("Expected more values while reading contents."); } // read a number - vcount.push_back((size_t)strtoul10(content, &content)); + size_t valueRead = (size_t)strtoul10(content, &content); + if(valueRead == 0) { + printf("wohoo"); + } + vcount.push_back(valueRead); // skip whitespace after it SkipSpacesAndLineEnd(&content); } From d109db152c1bcd9d4d5c5bf8115feb95811d199e Mon Sep 17 00:00:00 2001 From: Koekto-code <97475827+Koekto-code@users.noreply.github.com> Date: Sat, 9 Jul 2022 15:32:24 +0300 Subject: [PATCH 08/11] Use winresrc.h for mingw --- tools/assimp_cmd/assimp_cmd.rc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/assimp_cmd/assimp_cmd.rc b/tools/assimp_cmd/assimp_cmd.rc index 94572b7e0..2ead81bcb 100644 --- a/tools/assimp_cmd/assimp_cmd.rc +++ b/tools/assimp_cmd/assimp_cmd.rc @@ -1,5 +1,9 @@ #include "revision.h" -#include "winres.h" +#if defined(__GNUC__) && defined(_WIN32) + #include "winresrc.h" +#else + #include "winres.h" +#endif LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) From 684909a69168a898f4609aa048c153f0c1a18eef Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Sat, 9 Jul 2022 17:23:40 +0200 Subject: [PATCH 09/11] Fix comments on PR 1) Use default instead of empty destructor 2) Remove debug code --- code/AssetLib/Collada/ColladaParser.cpp | 6 +----- code/AssetLib/MMD/MMDPmxParser.h | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 25034defb..47d96ff94 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -1622,11 +1622,7 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) { throw DeadlyImportError("Expected more values while reading contents."); } // read a number - size_t valueRead = (size_t)strtoul10(content, &content); - if(valueRead == 0) { - printf("wohoo"); - } - vcount.push_back(valueRead); + vcount.push_back((size_t)strtoul10(content, &content)); // skip whitespace after it SkipSpacesAndLineEnd(&content); } diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h index 4b3968dec..c9df37c68 100644 --- a/code/AssetLib/MMD/MMDPmxParser.h +++ b/code/AssetLib/MMD/MMDPmxParser.h @@ -358,9 +358,7 @@ namespace pmx public: void virtual Read(std::istream *stream, PmxSetting *setting) = 0; - virtual ~PmxMorphOffset() { - - } + virtual ~PmxMorphOffset() = default; }; class PmxMorphVertexOffset : public PmxMorphOffset From 0c07ea7c7117a8831289f843c5bae2ad628e9579 Mon Sep 17 00:00:00 2001 From: sashashura <93376818+sashashura@users.noreply.github.com> Date: Sat, 16 Jul 2022 13:44:46 +0100 Subject: [PATCH 10/11] Fixes Heap-buffer-overflow in SuperFastHash --- code/AssetLib/LWS/LWSLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index 951dbe180..abaaaa305 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -313,6 +313,9 @@ void LWSImporter::SetupNodeName(aiNode *nd, LWS::NodeDesc &src) { std::string::size_type t = src.path.substr(s).find_last_of('.'); nd->mName.length = ::ai_snprintf(nd->mName.data, MAXLEN, "%s_(%08X)", src.path.substr(s).substr(0, t).c_str(), combined); + if (nd->mName.length > MAXLEN) { + nd->mName.length = MAXLEN; + } return; } } From fb653e83812d1d10256581944eb0636e67fc1dc4 Mon Sep 17 00:00:00 2001 From: Bernd Waibel Date: Sun, 24 Jul 2022 16:42:13 +0200 Subject: [PATCH 11/11] Update version tag Closes: https://github.com/assimp/assimp/issues/4655 Signed-off-by: Bernd Waibel --- CMakeLists.txt | 2 +- test/unit/utVersion.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a56f2250..2c55fce0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ IF(ASSIMP_HUNTER_ENABLED) add_definitions(-DASSIMP_USE_HUNTER) ENDIF() -PROJECT(Assimp VERSION 5.2.0) +PROJECT(Assimp VERSION 5.2.4) # All supported options ############################################### diff --git a/test/unit/utVersion.cpp b/test/unit/utVersion.cpp index 7548417e7..5826b280d 100644 --- a/test/unit/utVersion.cpp +++ b/test/unit/utVersion.cpp @@ -61,7 +61,7 @@ TEST_F( utVersion, aiGetVersionMajorTest ) { } TEST_F( utVersion, aiGetVersionPatchTest ) { - EXPECT_EQ(aiGetVersionPatch(), 0U ); + EXPECT_EQ(aiGetVersionPatch(), 4U ); } TEST_F( utVersion, aiGetCompileFlagsTest ) {