Browse Source

Merge branch 'master' into clang13

Kim Kulling 4 years ago
parent
commit
a486a698e8

+ 8 - 16
code/AssetLib/FBX/FBXParser.cpp

@@ -642,8 +642,7 @@ void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -733,8 +732,7 @@ void ParseVectorDataArray(std::vector<aiColor4D>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -816,8 +814,7 @@ void ParseVectorDataArray(std::vector<aiVector2D>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -892,8 +889,7 @@ void ParseVectorDataArray(std::vector<int>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * 4;
         uint64_t dataToRead = static_cast<uint64_t>(count) * 4;
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -954,8 +950,7 @@ void ParseVectorDataArray(std::vector<float>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
         uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -1019,8 +1014,7 @@ void ParseVectorDataArray(std::vector<unsigned int>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * 4;
         uint64_t dataToRead = static_cast<uint64_t>(count) * 4;
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -1088,8 +1082,7 @@ void ParseVectorDataArray(std::vector<uint64_t>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * 8;
         uint64_t dataToRead = static_cast<uint64_t>(count) * 8;
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 
@@ -1150,8 +1143,7 @@ void ParseVectorDataArray(std::vector<int64_t>& out, const Element& el)
 
 
         ai_assert(data == end);
         ai_assert(data == end);
         uint64_t dataToRead = static_cast<uint64_t>(count) * 8;
         uint64_t dataToRead = static_cast<uint64_t>(count) * 8;
-        ai_assert(buff.size() == dataToRead);
-        if (dataToRead > buff.size()) {
+        if (dataToRead != buff.size()) {
             ParseError("Invalid read size (binary)",&el);
             ParseError("Invalid read size (binary)",&el);
         }
         }
 
 

+ 1 - 1
code/AssetLib/Obj/ObjFileImporter.cpp

@@ -468,7 +468,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel,
             }
             }
 
 
             // Copy all vertex colors
             // Copy all vertex colors
-            if (!pModel->m_VertexColors.empty()) {
+            if (vertex < pModel->m_VertexColors.size()) {
                 const aiVector3D &color = pModel->m_VertexColors[vertex];
                 const aiVector3D &color = pModel->m_VertexColors[vertex];
                 pMesh->mColors[0][newIndex] = aiColor4D(color.x, color.y, color.z, 1.0);
                 pMesh->mColors[0][newIndex] = aiColor4D(color.x, color.y, color.z, 1.0);
             }
             }

+ 1 - 1
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) {
 inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
     Value *curName = FindMember(pJSON_Object, "name");
     Value *curName = FindMember(pJSON_Object, "name");
-    if (nullptr != curName) {
+    if (nullptr != curName && curName->IsString()) {
         name = curName->GetString();
         name = curName->GetString();
     }
     }
 
 

+ 6 - 0
code/AssetLib/glTF2/glTF2Importer.cpp

@@ -1336,6 +1336,12 @@ std::unordered_map<unsigned int, AnimationSamplers> GatherSamplers(Animation &an
             continue;
             continue;
         }
         }
 
 
+        auto& animsampler = anim.samplers[channel.sampler];
+        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;
+        }
+
         const unsigned int node_index = channel.target.node.GetIndex();
         const unsigned int node_index = channel.target.node.GetIndex();
 
 
         AnimationSamplers &sampler = samplers[node_index];
         AnimationSamplers &sampler = samplers[node_index];

+ 4 - 4
include/assimp/Logger.hpp

@@ -99,8 +99,8 @@ public:
     virtual ~Logger();
     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);
     void debug(const char* message);
 
 
     template<typename... T>
     template<typename... T>
@@ -109,7 +109,7 @@ public:
     }
     }
 
 
     // ----------------------------------------------------------------------
     // ----------------------------------------------------------------------
-	/** @brief  Writes a debug message
+    /** @brief  Writes a debug message
      *   @param message Debug message*/
      *   @param message Debug message*/
     void verboseDebug(const char* message);
     void verboseDebug(const char* message);
 
 
@@ -140,7 +140,7 @@ public:
 
 
     // ----------------------------------------------------------------------
     // ----------------------------------------------------------------------
     /** @brief  Writes an error message
     /** @brief  Writes an error message
-     *  @param  message Info message*/
+     *  @param  message Error message*/
     void error(const char* message);
     void error(const char* message);
 
 
     template<typename... T>
     template<typename... T>