Skip to content

Commit

Permalink
Workaround assimp exporting empty 3mfs (#454)
Browse files Browse the repository at this point in the history
 Workaround assimp producing meshless 3mf files by nesting the node holding the mesh into a child of the root node if the extension is .3mf
  • Loading branch information
geoffder authored Jun 15, 2023
1 parent 79daba1 commit 6ae9dee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions meshIO/src/meshIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ void ExportScene(aiScene* scene, const std::string& filename) {
// std::cout << i << ", id = " << desc->id << ", " << desc->description
// << std::endl;
// }
auto ext = filename.substr(filename.length() - 4, 4);
if (ext == ".3mf") {
// Workaround https://github.com/assimp/assimp/issues/3816
aiNode* old_root = scene->mRootNode;
scene->mRootNode = new aiNode();
scene->mRootNode->addChildren(1, &old_root);
}

auto result = exporter.Export(scene, GetType(filename), filename);

Expand Down

0 comments on commit 6ae9dee

Please sign in to comment.