Browse Source

In model mode with no animations, optimize nodes away to be able to merge submeshes with same material.

Lasse Öörni 12 năm trước cách đây
mục cha
commit
28d4ebeb14
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      Tools/AssetImporter/AssetImporter.cpp

+ 9 - 2
Tools/AssetImporter/AssetImporter.cpp

@@ -327,6 +327,15 @@ void Run(const Vector<String>& arguments)
         if (!scene_)
             ErrorExit("Could not open or parse input file " + inFile);
         
+        // In model mode, if scene has no animations, can flatten the hierarchy to combine submeshes with same material
+        /// \todo It is slow to load scene twice just to know whether there are animations
+        if (command == "model" && (!scene_->HasAnimations() || noAnimations_))
+        {
+            aiReleaseImport(scene_);
+            flags |= aiProcess_OptimizeGraph | aiProcess_PreTransformVertices;
+            scene_ = aiImportFile(GetNativePath(inFile).CString(), flags);
+        }
+
         rootNode_ = scene_->mRootNode;
         if (!rootNodeName.Empty())
         {
@@ -639,8 +648,6 @@ void BuildAndSaveModel(OutModel& model)
             combineBuffers = false;
     }
     
-    /// \todo Skip empty submeshes (if no valid faces)
-    
     SharedPtr<IndexBuffer> ib;
     SharedPtr<VertexBuffer> vb;
     Vector<SharedPtr<VertexBuffer> > vbVector;