From a10abe0283787c369cb59426be6b1bf641911cfa Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Fri, 8 Jul 2022 18:11:06 +0200 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 684909a69168a898f4609aa048c153f0c1a18eef Mon Sep 17 00:00:00 2001 From: Engin Manap Date: Sat, 9 Jul 2022 17:23:40 +0200 Subject: [PATCH 7/7] 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