From 98581c86c8723673595d792e6ef38a0f9dc5944d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 7 Dec 2023 12:33:56 +0100 Subject: [PATCH] MaterialTools: fix silly typos in enum values. As usual, the old names are still present, but deprecated. --- .../PhongToPbrMetallicRoughness.cpp | 16 ++++----- .../PhongToPbrMetallicRoughness.h | 34 +++++++++++++++---- .../Test/PhongToPbrMetallicRoughnessTest.cpp | 30 ++++++++-------- .../SceneTools/Test/SceneConverterTest.cpp | 4 +-- src/Magnum/SceneTools/sceneconverter.cpp | 2 +- 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp index baf94e234..3776a344d 100644 --- a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp +++ b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp @@ -63,13 +63,13 @@ Containers::Optional phongToPbrMetallicRoughness(const Trad const Containers::Optional id = material.findAttributeId(attribute); if(!id) continue; - if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes) { - Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute"; + if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) { + Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute"; return {}; } - Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute, skipping"; - if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes) + Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute, skipping"; + if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes) attributesToKeep.reset(*id); } for(const Trade::MaterialAttribute attribute: { @@ -79,8 +79,8 @@ Containers::Optional phongToPbrMetallicRoughness(const Trad const Containers::Optional id = material.findAttributeId(attribute); if(!id) continue; - if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes) { - Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute"; + if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) { + Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute"; return {}; } @@ -88,8 +88,8 @@ Containers::Optional phongToPbrMetallicRoughness(const Trad const Containers::Optional coordinatesId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Coordinates"_s); const Containers::Optional layerId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Layer"_s); - Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute, skipping"; - if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes) { + Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute, skipping"; + if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes) { attributesToKeep.reset(*id); if(matrixId) attributesToKeep.reset(*matrixId); diff --git a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h index a6b447cc1..1f757300f 100644 --- a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h +++ b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h @@ -36,6 +36,10 @@ #include "Magnum/MaterialTools/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace MaterialTools { /** @@ -53,17 +57,35 @@ enum class PhongToPbrMetallicRoughnessFlag { /** * Drop attributes that can't be converted instead of keeping them in the * output. If - * @relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertableAttributes} + * @relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertibleAttributes} * is specified as well, it has a priority. */ - DropUnconvertableAttributes = 1 << 1, + DropUnconvertibleAttributes = 1 << 1, + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copydoc PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes + * @m_deprecated_since_latest Use @ref PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes + * instead. + */ + DropUnconvertableAttributes CORRADE_DEPRECATED_ENUM("use DropUnconvertibleAttributes instead") = DropUnconvertibleAttributes, + #endif /** * Fail if any attributes can't be converted instead of keeping them in the * output. Has a priority over - * @relativeref{PhongToPbrMetallicRoughnessFlag,DropUnconvertableAttributes}. + * @relativeref{PhongToPbrMetallicRoughnessFlag,DropUnconvertibleAttributes}. + */ + FailOnUnconvertibleAttributes = (1 << 2)|DropUnconvertibleAttributes, + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copydoc PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes + * @m_deprecated_since_latest Use @ref PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes + * instead. */ - FailOnUnconvertableAttributes = (1 << 2)|DropUnconvertableAttributes, + FailOnUnconvertableAttributes CORRADE_DEPRECATED_ENUM("use FailOnUnconvertibleAttributes instead") = FailOnUnconvertibleAttributes, + #endif /** @todo flags to pick various shininess conversion alternatives */ }; @@ -97,8 +119,8 @@ set. The following attributes currently aren't converted. If they are present in the input material, a message is printed to @relativeref{Magnum,Warning}. The attributes are passed through unchanged unless -@ref PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes is set; if -@relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertableAttributes} is +@ref PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes is set; if +@relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertibleAttributes} is set instead, a message is printed to @relativeref{Magnum,Error} and the function returns @relativeref{Corrade,Containers::NullOpt}. diff --git a/src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp b/src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp index e4a094753..5227ad613 100644 --- a/src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp +++ b/src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp @@ -177,7 +177,7 @@ const struct { {Trade::MaterialAttribute::DiffuseTextureCoordinates, 2u}, {Trade::MaterialAttribute::DiffuseTextureLayer, 155u}, }}}, - {"ambient texture properties without texture, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, + {"ambient texture properties without texture, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::AmbientTextureMatrix, Matrix3::scaling(Vector2{0.5f})}, @@ -212,9 +212,9 @@ const struct { {Trade::MaterialAttribute::SpecularTexture, 3u}, {Trade::MaterialAttribute::SpecularTextureCoordinates, 2u}, }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute, skipping\n" - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, - {"specular color, texture + matrix + layer, ambient texture + coordinates; drop unconvertable", PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute, skipping\n" + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, + {"specular color, texture + matrix + layer, ambient texture + coordinates; drop unconvertible", PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::SpecularColor, 0x3366ffff_rgbaf}, @@ -229,9 +229,9 @@ const struct { {Trade::MaterialAttribute::BaseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::DoubleSided, true} }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularColor attribute, skipping\n" - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientTexture attribute, skipping\n" - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularColor attribute, skipping\n" + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientTexture attribute, skipping\n" + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, }; const struct { @@ -240,26 +240,26 @@ const struct { Trade::MaterialData material; const char* message; } FailData[]{ - {"ambient color, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, + {"ambient color, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::AmbientColor, Color4{}}, }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute\n"}, - {"specular texture, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute\n"}, + {"specular texture, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::SpecularTexture, 0u}, }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute\n"}, - {"shininess, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute\n"}, + {"shininess, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::Shininess, 0.5f}, }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::Shininess attribute\n"}, - {"specular color, both drop & fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes|PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::Shininess attribute\n"}, + {"specular color, both drop & fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes|PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes, Trade::MaterialData{{}, { {Trade::MaterialAttribute::SpecularTexture, 0u}, }}, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute\n"}, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute\n"}, }; PhongToPbrMetallicRoughnessTest::PhongToPbrMetallicRoughnessTest() { diff --git a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp index 5b6050102..8c7d40697 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterTest.cpp @@ -770,7 +770,7 @@ const struct { "UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr, /* The file should contain also material names and everything */ "materials-pbr.gltf", nullptr, - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute, skipping\n"}, + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute, skipping\n"}, {"Phong to PBR, verbose", {InPlaceInit, { /* Same as above, just with -v added */ "-I", "UfbxImporter", "-C", "GltfSceneConverter", "--phong-to-pbr", @@ -780,7 +780,7 @@ const struct { "UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr, "materials-pbr.gltf", nullptr, "Converting material 0 to PBR\n" - "MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute, skipping\n" + "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute, skipping\n" "Converting material 1 to PBR\n" "Trade::AbstractSceneConverter::addImporterContents(): adding 2D image 0 out of 2\n" "Trade::AnyImageImporter::openFile(): using PngImporter\n" diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index 06730b69e..fc225b607 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -1152,7 +1152,7 @@ well, the IDs reference attributes of the first mesh.)") Trade::Implementation::Duration d{conversionTime}; /** @todo make the flags configurable as well? then the below assert can actually fire, convert to a runtime error */ - material = MaterialTools::phongToPbrMetallicRoughness(*material, MaterialTools::PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes); + material = MaterialTools::phongToPbrMetallicRoughness(*material, MaterialTools::PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes); CORRADE_INTERNAL_ASSERT(material); }