From a1eaaaa0e398ce860c0ecfe42d61f98222f57208 Mon Sep 17 00:00:00 2001 From: Krishty Date: Thu, 29 Jul 2021 14:45:39 +0200 Subject: [PATCH 1/7] fix comments fixes some copy-paste errors in logger comments introduced with 89584c167aaf341a6d717083bb9a52a4c1b0ace1 --- include/assimp/Logger.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index 3ca4a6cb2..18e913953 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -99,8 +99,8 @@ public: virtual ~Logger(); // ---------------------------------------------------------------------- - /** @brief Writes a info message - * @param message Info message*/ + /** @brief Writes a debug message + * @param message Debug message*/ void debug(const char* message); template @@ -109,7 +109,7 @@ public: } // ---------------------------------------------------------------------- - /** @brief Writes a debug message + /** @brief Writes a debug message * @param message Debug message*/ void verboseDebug(const char* message); @@ -140,7 +140,7 @@ public: // ---------------------------------------------------------------------- /** @brief Writes an error message - * @param message Info message*/ + * @param message Error message*/ void error(const char* message); template From 8d6d6b48c3dad5bb244c0bb7bb6097be4ff083eb Mon Sep 17 00:00:00 2001 From: Hill Ma Date: Mon, 2 Aug 2021 11:58:46 -0700 Subject: [PATCH 2/7] Obj: make a predicate more robust. Since we might encounter invalid input it is a good idea to check the actual size of the array. --- code/AssetLib/Obj/ObjFileImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Obj/ObjFileImporter.cpp b/code/AssetLib/Obj/ObjFileImporter.cpp index d6232be81..5e2b48e24 100644 --- a/code/AssetLib/Obj/ObjFileImporter.cpp +++ b/code/AssetLib/Obj/ObjFileImporter.cpp @@ -468,7 +468,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel, } // Copy all vertex colors - if (!pModel->m_VertexColors.empty()) { + if (vertex < pModel->m_VertexColors.size()) { const aiVector3D &color = pModel->m_VertexColors[vertex]; pMesh->mColors[0][newIndex] = aiColor4D(color.x, color.y, color.z, 1.0); } From 69c152d7c130e96287eada4467611322f8bd64ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ubi=C3=B1as?= Date: Wed, 11 Aug 2021 18:57:21 -0400 Subject: [PATCH 3/7] Add missing diagnostic push --- code/AssetLib/glTF/glTFExporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 810263f52..10943905c 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -526,6 +526,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref Date: Wed, 11 Aug 2021 19:32:26 -0400 Subject: [PATCH 4/7] Disable diagnostic for LogStream comparator --- code/Common/Assimp.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp index ca0912979..3a0ec7d60 100644 --- a/code/Common/Assimp.cpp +++ b/code/Common/Assimp.cpp @@ -72,12 +72,25 @@ namespace Assimp { // underlying structure for aiPropertyStore typedef BatchLoader::PropertyMap PropertyMap; +#if defined(__has_warning) +#if __has_warning("-Wordered-compare-function-pointers") +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wordered-compare-function-pointers" +#endif +#endif + /** 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; } }; + +#if defined(__has_warning) +#if __has_warning("-Wordered-compare-function-pointers") +#pragma GCC diagnostic pop +#endif +#endif typedef std::map LogStreamMap; /** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */ From b95df54225c0406290143d0d4ed08d7439420652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ubi=C3=B1as?= Date: Wed, 11 Aug 2021 19:33:10 -0400 Subject: [PATCH 5/7] Remove unused code --- contrib/openddlparser/code/OpenDDLExport.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLExport.cpp b/contrib/openddlparser/code/OpenDDLExport.cpp index 6d6f2458d..d235b553b 100644 --- a/contrib/openddlparser/code/OpenDDLExport.cpp +++ b/contrib/openddlparser/code/OpenDDLExport.cpp @@ -134,10 +134,9 @@ bool OpenDDLExport::writeToStream(const std::string &statement) { } bool OpenDDLExport::writeNode(DDLNode *node, std::string &statement) { - bool success(true); writeNodeHeader(node, statement); if (node->hasProperties()) { - success |= writeProperties(node, statement); + writeProperties(node, statement); } writeLineEnd(statement); From de2f5cf0213ffb575c5b1381e39a2660cde13fba Mon Sep 17 00:00:00 2001 From: "Max Vollmer (Microsoft Havok)" <60260460+ms-maxvollmer@users.noreply.github.com> Date: Fri, 13 Aug 2021 16:14:28 +0100 Subject: [PATCH 6/7] Crash fixes --- code/AssetLib/FBX/FBXParser.cpp | 24 ++++++++---------------- code/AssetLib/glTF2/glTF2Asset.inl | 2 +- code/AssetLib/glTF2/glTF2Importer.cpp | 6 ++++++ 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp index 37cf83cf9..61e53c2d0 100644 --- a/code/AssetLib/FBX/FBXParser.cpp +++ b/code/AssetLib/FBX/FBXParser.cpp @@ -642,8 +642,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * (type == 'd' ? 8 : 4); - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -733,8 +732,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * (type == 'd' ? 8 : 4); - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -816,8 +814,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * (type == 'd' ? 8 : 4); - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -892,8 +889,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * 4; - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -954,8 +950,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * (type == 'd' ? 8 : 4); - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -1019,8 +1014,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * 4; - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -1088,8 +1082,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * 8; - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } @@ -1150,8 +1143,7 @@ void ParseVectorDataArray(std::vector& out, const Element& el) ai_assert(data == end); uint64_t dataToRead = static_cast(count) * 8; - ai_assert(buff.size() == dataToRead); - if (dataToRead > buff.size()) { + if (dataToRead != buff.size()) { ParseError("Invalid read size (binary)",&el); } diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index d5f5b5cd0..9f793d7c0 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -1522,7 +1522,7 @@ inline bool GetAttribTargetVector(Mesh::Primitive &p, const int targetIndex, con inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { Value *curName = FindMember(pJSON_Object, "name"); - if (nullptr != curName) { + if (nullptr != curName && curName->IsString()) { name = curName->GetString(); } diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 921aaad9e..a4f3f0ba1 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1336,6 +1336,12 @@ std::unordered_map GatherSamplers(Animation &an continue; } + auto& animsampler = anim.samplers[channel.sampler]; + if (animsampler.input->count != animsampler.output->count) { + ASSIMP_LOG_WARN("Animation ", anim.name, ": Sampler input size ", animsampler.input->count, " doesn't match output size ", animsampler.output->count); + continue; + } + const unsigned int node_index = channel.target.node.GetIndex(); AnimationSamplers &sampler = samplers[node_index]; From c1e830cf3b62de1f0fcc7ec14dcd374392e2e393 Mon Sep 17 00:00:00 2001 From: "Max Vollmer (Microsoft Havok)" <60260460+ms-maxvollmer@users.noreply.github.com> Date: Fri, 13 Aug 2021 17:46:10 +0100 Subject: [PATCH 7/7] The GLTF2 specs aren't very specific about the restrictions of the number of keyframes in sampler input and output. It seems logical that they should be the same, but there is an official sample model from Khronos where output has more keyframes. I thus assume that the GLTF2 standard allows more keyframes in output, but not in input. Fixed the check accordingly. --- code/AssetLib/glTF2/glTF2Importer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index a4f3f0ba1..7a781ba04 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1337,8 +1337,8 @@ std::unordered_map GatherSamplers(Animation &an } auto& animsampler = anim.samplers[channel.sampler]; - if (animsampler.input->count != animsampler.output->count) { - ASSIMP_LOG_WARN("Animation ", anim.name, ": Sampler input size ", animsampler.input->count, " doesn't match output size ", animsampler.output->count); + if (animsampler.input->count > animsampler.output->count) { + ASSIMP_LOG_WARN("Animation ", anim.name, ": Number of keyframes in sampler input ", animsampler.input->count, " exceeds number of keyframes in sampler output ", animsampler.output->count); continue; }