From 86db988a0c68db5c8de47117455125acf4c7885d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Dec 2021 21:25:27 +0100 Subject: [PATCH] sceneconverter: skip refcounting in --info when there's no refeeree. Should have been done in f10d74041be2134bfc45868967f47331b1ff7f46 already, but somehow I failed to test for this case -- if there are no scenes (materials/textures), it doesn't make sense to print reference count for cameras/meshes/lights (textures/images). --- src/Magnum/SceneTools/sceneconverter.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index 8526f9440..2a4cc55f4 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -396,14 +396,15 @@ used.)") /* Scene properties, together with counting how much is each mesh / light / material / skin shared (which gets used only if both - --info-scenes and --info-{lights,materials,skins} is passed). - Texture reference count is calculated when parsing materials. */ + --info-scenes and --info-{lights,materials,skins} is passed and + the file has at least one scene). Texture reference count is + calculated when parsing materials. */ Containers::Array sceneInfos; Containers::Array materialReferenceCount; Containers::Array lightReferenceCount; Containers::Array meshReferenceCount; Containers::Array skinReferenceCount; - if(args.isSet("info") || args.isSet("info-scenes")) { + if((args.isSet("info") || args.isSet("info-scenes")) && importer->sceneCount()) { materialReferenceCount = Containers::Array{importer->materialCount()}; lightReferenceCount = Containers::Array{importer->lightCount()}; meshReferenceCount = Containers::Array{importer->meshCount()}; @@ -517,10 +518,10 @@ used.)") /* Material properties, together with how much is each texture shared (which gets used only if both --info-materials and --info-textures - is passed). */ + is passed and the file has at least one material). */ Containers::Array materialInfos; Containers::Array textureReferenceCount; - if(args.isSet("info") || args.isSet("info-materials")) { + if((args.isSet("info") || args.isSet("info-materials")) && importer->materialCount()) { textureReferenceCount = Containers::Array{importer->textureCount()}; for(UnsignedInt i = 0; i != importer->materialCount(); ++i) { @@ -643,12 +644,12 @@ used.)") /* Texture properties, together with how much is each image shared (which gets used only if both --info-textures and --info-images is - passed). */ + passed and the file has at least one texture). */ Containers::Array textureInfos; Containers::Array image1DReferenceCount; Containers::Array image2DReferenceCount; Containers::Array image3DReferenceCount; - if(args.isSet("info") || args.isSet("info-textures")) { + if((args.isSet("info") || args.isSet("info-textures")) && importer->textureCount()) { image1DReferenceCount = Containers::Array{importer->image1DCount()}; image2DReferenceCount = Containers::Array{importer->image2DCount()}; image3DReferenceCount = Containers::Array{importer->image3DCount()};