From 237ef9981ad9b2bb9a6221da527236f1aa4dfb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 6 May 2022 13:38:48 +0200 Subject: [PATCH] [wip] sceneconverter: work with whole scenes, not just meshes. TODO: needs rework to still be able to perform ops on the meshes as well --- src/Magnum/SceneTools/sceneconverter.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index e3ea15e91..8ec857167 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -52,6 +52,7 @@ #include "Magnum/Trade/SceneData.h" #include "Magnum/Trade/SkinData.h" #include "Magnum/Trade/TextureData.h" +#include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/AbstractSceneConverter.h" #include "Magnum/Trade/Implementation/converterUtilities.h" @@ -1385,10 +1386,18 @@ is specified as well, the IDs reference attributes of the first mesh.)") Debug{} << "Fuzzy duplicate removal:" << beforeVertexCount << "->" << mesh->vertexCount() << "vertices"; } - /* Load converter plugin */ + /* Image converter manager for potential dependencies. Needs to be + constructed before the scene converter manager for proper destruction + order. */ + PluginManager::Manager imageConverterManager{ + args.value("plugin-dir").empty() ? Containers::String{} : + Utility::Path::join(args.value("plugin-dir"), Trade::AbstractImageConverter::pluginSearchPaths().back())}; + + /* Scene converter manager, register the image converter manager with it */ PluginManager::Manager converterManager{ args.value("plugin-dir").empty() ? Containers::String{} : Utility::Path::join(args.value("plugin-dir"), Trade::AbstractSceneConverter::pluginSearchPaths().back())}; + converterManager.registerExternalManager(imageConverterManager); /* Assume there's always one passed --converter option less, and the last is implicitly AnySceneConverter. All converters except the last one are @@ -1411,13 +1420,20 @@ is specified as well, the IDs reference attributes of the first mesh.)") /* This is the last --converter (or the implicit AnySceneConverter at the end), output to a file and exit the loop */ - if(i + 1 >= converterCount && (converter->features() & Trade::SceneConverterFeature::ConvertMeshToFile)) { + if(i + 1 >= converterCount && (converter->features() & (Trade::SceneConverterFeature::ConvertMeshToFile|Trade::SceneConverterFeature::ConvertMultipleToFile))) { // TODO fuck, the flags should be implicitly inheriting, this is fucked /* No verbose output for just one converter */ if(converterCount > 1 && args.isSet("verbose")) Debug{} << "Saving output with" << converterName << Debug::nospace << "..."; + // TODO F, here the import and conversion time will conflate Trade::Implementation::Duration d{conversionTime}; - if(!converter->convertToFile(*mesh, args.value("output"))) { +// if(!converter->convertToFile(*mesh, args.value("output"))) { +// Error{} << "Cannot save file" << args.value("output"); +// return 5; +// } + + converter->beginFile(args.value("output")); + if(!converter->addSupportedImporterContents(*importer) || !converter->endFile()) { Error{} << "Cannot save file" << args.value("output"); return 5; }