From 11c972cf6abb7a60db7c7a47f8da1f02a966ebe3 Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Wed, 11 Sep 2024 11:02:45 +0200 Subject: [PATCH] WIP2 --- src/io_assimp/io_assimp_writer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/io_assimp/io_assimp_writer.cpp b/src/io_assimp/io_assimp_writer.cpp index 71bedb0f..1c2a81ed 100644 --- a/src/io_assimp/io_assimp_writer.cpp +++ b/src/io_assimp/io_assimp_writer.cpp @@ -23,7 +23,9 @@ namespace Mayo::IO { namespace { -aiMesh* createAssimpMesh(const IMeshAccess& mesh) +using ai_MeshPtr = aiMesh*; + +ai_MeshPtr createAssimpMesh(const IMeshAccess& mesh) { auto ai_mesh = new aiMesh; ai_mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; @@ -94,7 +96,7 @@ bool AssimpWriter::transfer(Span appItems, TaskProgress* // Find meshes std::unordered_set setOfPartLabels; - std::vector vecMesh; + std::vector vecMesh; System::traverseUniqueItems(appItems, [&](const DocumentTreeNode& treeNode) { TDF_Label partLabel; if (treeNode.isLeaf()) { @@ -117,6 +119,12 @@ bool AssimpWriter::transfer(Span appItems, TaskProgress* delete m_scene; m_scene = new aiScene; + + m_scene->mNumMeshes = static_cast(vecMesh.size()); + m_scene->mMeshes = new ai_MeshPtr[vecMesh.size()]; + for (unsigned i = 0; i < vecMesh.size(); ++i) + m_scene->mMeshes[i] = vecMesh[i]; + m_scene->mRootNode = new aiNode("Root Node"); return false;