Browse Source

Implements ignore filter for assimp fbx dummy nodes.
Adds gltf binary to list of supported extensions.

OTHGMars 6 years ago
parent
commit
0be93d6cf5

+ 12 - 2
Engine/source/ts/assimp/assimpShapeLoader.cpp

@@ -103,7 +103,8 @@ MODULE_BEGIN( AssimpShapeLoader )
       TSShapeLoader::addFormat("3D GameStudio (3DGS)", "mdl");
       TSShapeLoader::addFormat("3D GameStudio (3DGS) Terrain", "hmp");
       TSShapeLoader::addFormat("Izware Nendo", "ndo");
-	  TSShapeLoader::addFormat("gltf", "gltf");
+      TSShapeLoader::addFormat("gltf", "gltf");
+      TSShapeLoader::addFormat("gltf binary", "glb");
    }
 MODULE_END;
 
@@ -146,7 +147,7 @@ void AssimpShapeLoader::enumerateScene()
        Con::getBoolVariable("$Assimp::OptimizeMeshes", false) ? aiProcess_OptimizeMeshes | aiProcess_OptimizeGraph : 0 |
        0;
 
-   if(Con::getBoolVariable("$Assimp::Triangulate", false))
+   if(Con::getBoolVariable("$Assimp::Triangulate", true))
       ppsteps |= aiProcess_Triangulate;
 
    if (Con::getBoolVariable("$Assimp::OptimizeMeshes", false))
@@ -276,6 +277,15 @@ bool AssimpShapeLoader::canLoadCachedDTS(const Torque::Path& path)
    return false;
 }
 
+bool AssimpShapeLoader::ignoreNode(const String& name)
+{
+   // Do not add AssimpFbx dummy nodes to the TSShape. See: Assimp::FBX::ImportSettings::preservePivots
+   // https://github.com/assimp/assimp/blob/master/code/FBXImportSettings.h#L116-L135
+   if (name.find("_$AssimpFbx$_") != String::NPos)
+      return true;
+   return false;
+}
+
 //-----------------------------------------------------------------------------
 /// This function is invoked by the resource manager based on file extension.
 TSShape* assimpLoadShape(const Torque::Path &path)

+ 3 - 1
Engine/source/ts/assimp/assimpShapeLoader.h

@@ -34,7 +34,9 @@ class AssimpShapeLoader : public TSShapeLoader
 
 protected:
    const struct aiScene* mScene;
-  
+
+   virtual bool ignoreNode(const String& name);
+
 public:
    AssimpShapeLoader();
    ~AssimpShapeLoader();