From 3052f35824eb98f3a26ed89a9215622a41343025 Mon Sep 17 00:00:00 2001 From: johnmaf Date: Tue, 20 Sep 2016 14:15:42 -0400 Subject: [PATCH] glTF: move mesh splitting to constructor to cover GLB --- code/glTFExporter.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 45877c8a9..708570577 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -80,20 +80,9 @@ namespace Assimp { // Worker function for exporting a scene to GLTF. Prototyped and registered in Exporter.cpp void ExportSceneGLTF(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) { - aiScene* sceneCopy_tmp; - SceneCombiner::CopyScene(&sceneCopy_tmp, pScene); - std::unique_ptr sceneCopy(sceneCopy_tmp); - - SplitLargeMeshesProcess_Triangle tri_splitter; - tri_splitter.SetLimit(0xffff); - tri_splitter.Execute(sceneCopy.get()); - - SplitLargeMeshesProcess_Vertex vert_splitter; - vert_splitter.SetLimit(0xffff); - vert_splitter.Execute(sceneCopy.get()); // invoke the exporter - glTFExporter exporter(pFile, pIOSystem, sceneCopy.get(), pProperties, false); + glTFExporter exporter(pFile, pIOSystem, pScene, pProperties, false); } // ------------------------------------------------------------------------------------------------ @@ -112,9 +101,22 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc const ExportProperties* pProperties, bool isBinary) : mFilename(filename) , mIOSystem(pIOSystem) - , mScene(pScene) , mProperties(pProperties) { + aiScene* sceneCopy_tmp; + SceneCombiner::CopyScene(&sceneCopy_tmp, pScene); + std::unique_ptr sceneCopy(sceneCopy_tmp); + + SplitLargeMeshesProcess_Triangle tri_splitter; + tri_splitter.SetLimit(0xffff); + tri_splitter.Execute(sceneCopy.get()); + + SplitLargeMeshesProcess_Vertex vert_splitter; + vert_splitter.SetLimit(0xffff); + vert_splitter.Execute(sceneCopy.get()); + + mScene = sceneCopy.get(); + std::unique_ptr asset(); mAsset.reset( new glTF::Asset( pIOSystem ) );