From 085b3dcabc253c04357b5e9a12eec74adb10823f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 19 Sep 2022 21:57:36 +0200 Subject: [PATCH] sceneconverter: profile also the --concatenate-meshes option. Bah, this is way too brittle (and impossible to test / verify). --- src/Magnum/SceneTools/sceneconverter.cpp | 36 +++++++++++++++--------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index 990d1d016..63478800e 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -392,6 +392,9 @@ the first mesh.)") return 1; } + /* Wow, C++, you suck. This implicitly initializes to random shit?! */ + std::chrono::high_resolution_clock::duration conversionTime{}; + Containers::Optional mesh; /* Concatenate input meshes, if requested */ @@ -399,6 +402,7 @@ the first mesh.)") Containers::Array meshes; arrayReserve(meshes, importer->meshCount()); for(std::size_t i = 0, iMax = importer->meshCount(); i != iMax; ++i) { + Trade::Implementation::Duration d{importTime}; Containers::Optional meshToConcatenate = importer->mesh(i); if(!meshToConcatenate) { Error{} << "Cannot import mesh" << i; @@ -413,23 +417,32 @@ the first mesh.)") /** @todo make it possible to choose the scene */ if(importer->defaultScene() != -1) { Containers::Optional scene; - if(!(scene = importer->scene(importer->defaultScene()))) { - Error{} << "Cannot import scene" << importer->defaultScene() << "for mesh concatenation"; - return 1; + { + Trade::Implementation::Duration d{importTime}; + if(!(scene = importer->scene(importer->defaultScene()))) { + Error{} << "Cannot import scene" << importer->defaultScene() << "for mesh concatenation"; + return 1; + } } - /** @todo once there are 2D scenes, check the scene is 3D */ Containers::Array flattenedMeshes; - for(const Containers::Triple& meshTransformation: SceneTools::flattenMeshHierarchy3D(*scene)) - arrayAppend(flattenedMeshes, MeshTools::transform3D(meshes[meshTransformation.first()], meshTransformation.third())); + { + Trade::Implementation::Duration d{conversionTime}; + /** @todo once there are 2D scenes, check the scene is 3D */ + for(const Containers::Triple& meshTransformation: SceneTools::flattenMeshHierarchy3D(*scene)) + arrayAppend(flattenedMeshes, MeshTools::transform3D(meshes[meshTransformation.first()], meshTransformation.third())); + } meshes = std::move(flattenedMeshes); } /* Concatenate all meshes together */ - /** @todo this will assert if the meshes have incompatible primitives - (such as some triangles, some lines), or if they have - loops/strips/fans -- handle that explicitly */ - mesh = MeshTools::concatenate(meshes); + { + Trade::Implementation::Duration d{conversionTime}; + /** @todo this will assert if the meshes have incompatible primitives + (such as some triangles, some lines), or if they have + loops/strips/fans -- handle that explicitly */ + mesh = MeshTools::concatenate(meshes); + } /* Otherwise import just one */ } else { @@ -440,9 +453,6 @@ the first mesh.)") } } - /* Wow, C++, you suck. This implicitly initializes to random shit?! */ - std::chrono::high_resolution_clock::duration conversionTime{}; - /* Filter mesh attributes, if requested */ if(const Containers::StringView onlyMeshAttributes = args.value("only-mesh-attributes")) { const Containers::Optional> only = Utility::String::parseNumberSequence(onlyMeshAttributes, 0, mesh->attributeCount());