瀏覽代碼

Merge pull request #53 from hu-xd/skip-empty-animations

Skip empty animations, fixes #44
K. S. Ernest (iFire) Lee 1 年之前
父節點
當前提交
61543913dd
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/gltf/Raw2Gltf.cpp

+ 8 - 0
src/gltf/Raw2Gltf.cpp

@@ -155,6 +155,14 @@ ModelData* Raw2Gltf(
 
     for (int i = 0; i < raw.GetAnimationCount(); i++) {
       const RawAnimation& animation = raw.GetAnimation(i);
+      
+      if (animation.channels.empty()) {
+        fmt::printf(
+          "Animation '%s' has no channels, skipped\n",
+          animation.name.c_str()
+        );
+        continue;
+      }
 
       auto accessor = gltf->AddAccessorAndView(buffer, GLT_FLOAT, animation.times);
       accessor->min = {*std::min_element(std::begin(animation.times), std::end(animation.times))};