Browse Source

MaterialTools: fix silly typos in enum values.

As usual, the old names are still present, but deprecated.
pull/168/head
Vladimír Vondruš 2 years ago
parent
commit
98581c86c8
  1. 16
      src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp
  2. 34
      src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h
  3. 30
      src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp
  4. 4
      src/Magnum/SceneTools/Test/SceneConverterTest.cpp
  5. 2
      src/Magnum/SceneTools/sceneconverter.cpp

16
src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp

@ -63,13 +63,13 @@ Containers::Optional<Trade::MaterialData> phongToPbrMetallicRoughness(const Trad
const Containers::Optional<UnsignedInt> id = material.findAttributeId(attribute); const Containers::Optional<UnsignedInt> id = material.findAttributeId(attribute);
if(!id) continue; if(!id) continue;
if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes) { if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) {
Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute"; Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute";
return {}; return {};
} }
Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute, skipping"; Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute, skipping";
if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes) if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes)
attributesToKeep.reset(*id); attributesToKeep.reset(*id);
} }
for(const Trade::MaterialAttribute attribute: { for(const Trade::MaterialAttribute attribute: {
@ -79,8 +79,8 @@ Containers::Optional<Trade::MaterialData> phongToPbrMetallicRoughness(const Trad
const Containers::Optional<UnsignedInt> id = material.findAttributeId(attribute); const Containers::Optional<UnsignedInt> id = material.findAttributeId(attribute);
if(!id) continue; if(!id) continue;
if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes) { if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) {
Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute"; Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute";
return {}; return {};
} }
@ -88,8 +88,8 @@ Containers::Optional<Trade::MaterialData> phongToPbrMetallicRoughness(const Trad
const Containers::Optional<UnsignedInt> coordinatesId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Coordinates"_s); const Containers::Optional<UnsignedInt> coordinatesId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Coordinates"_s);
const Containers::Optional<UnsignedInt> layerId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Layer"_s); const Containers::Optional<UnsignedInt> layerId = material.findAttributeId(Trade::materialAttributeName(attribute) + "Layer"_s);
Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertable" << attribute << "attribute, skipping"; Warning{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute, skipping";
if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes) { if(flags >= PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes) {
attributesToKeep.reset(*id); attributesToKeep.reset(*id);
if(matrixId) if(matrixId)
attributesToKeep.reset(*matrixId); attributesToKeep.reset(*matrixId);

34
src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.h

@ -36,6 +36,10 @@
#include "Magnum/MaterialTools/visibility.h" #include "Magnum/MaterialTools/visibility.h"
#include "Magnum/Trade/Trade.h" #include "Magnum/Trade/Trade.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
#endif
namespace Magnum { namespace MaterialTools { namespace Magnum { namespace MaterialTools {
/** /**
@ -53,17 +57,35 @@ enum class PhongToPbrMetallicRoughnessFlag {
/** /**
* Drop attributes that can't be converted instead of keeping them in the * Drop attributes that can't be converted instead of keeping them in the
* output. If * output. If
* @relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertableAttributes} * @relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertibleAttributes}
* is specified as well, it has a priority. * 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 * Fail if any attributes can't be converted instead of keeping them in the
* output. Has a priority over * 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 */ /** @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 The following attributes currently aren't converted. If they are present in the
input material, a message is printed to @relativeref{Magnum,Warning}. The input material, a message is printed to @relativeref{Magnum,Warning}. The
attributes are passed through unchanged unless attributes are passed through unchanged unless
@ref PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes is set; if @ref PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes is set; if
@relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertableAttributes} is @relativeref{PhongToPbrMetallicRoughnessFlag,FailOnUnconvertibleAttributes} is
set instead, a message is printed to @relativeref{Magnum,Error} and the set instead, a message is printed to @relativeref{Magnum,Error} and the
function returns @relativeref{Corrade,Containers::NullOpt}. function returns @relativeref{Corrade,Containers::NullOpt}.

30
src/Magnum/MaterialTools/Test/PhongToPbrMetallicRoughnessTest.cpp

@ -177,7 +177,7 @@ const struct {
{Trade::MaterialAttribute::DiffuseTextureCoordinates, 2u}, {Trade::MaterialAttribute::DiffuseTextureCoordinates, 2u},
{Trade::MaterialAttribute::DiffuseTextureLayer, 155u}, {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::MaterialData{{}, {
{Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf},
{Trade::MaterialAttribute::AmbientTextureMatrix, Matrix3::scaling(Vector2{0.5f})}, {Trade::MaterialAttribute::AmbientTextureMatrix, Matrix3::scaling(Vector2{0.5f})},
@ -212,9 +212,9 @@ const struct {
{Trade::MaterialAttribute::SpecularTexture, 3u}, {Trade::MaterialAttribute::SpecularTexture, 3u},
{Trade::MaterialAttribute::SpecularTextureCoordinates, 2u}, {Trade::MaterialAttribute::SpecularTextureCoordinates, 2u},
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute, skipping\n" "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute, skipping\n"
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"},
{"specular color, texture + matrix + layer, ambient texture + coordinates; drop unconvertable", PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes, {"specular color, texture + matrix + layer, ambient texture + coordinates; drop unconvertible", PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes,
Trade::MaterialData{{}, { Trade::MaterialData{{}, {
{Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::DiffuseColor, 0xff3366cc_rgbaf},
{Trade::MaterialAttribute::SpecularColor, 0x3366ffff_rgbaf}, {Trade::MaterialAttribute::SpecularColor, 0x3366ffff_rgbaf},
@ -229,9 +229,9 @@ const struct {
{Trade::MaterialAttribute::BaseColor, 0xff3366cc_rgbaf}, {Trade::MaterialAttribute::BaseColor, 0xff3366cc_rgbaf},
{Trade::MaterialAttribute::DoubleSided, true} {Trade::MaterialAttribute::DoubleSided, true}
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularColor attribute, skipping\n" "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularColor attribute, skipping\n"
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientTexture attribute, skipping\n" "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientTexture attribute, skipping\n"
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute, skipping\n"},
}; };
const struct { const struct {
@ -240,26 +240,26 @@ const struct {
Trade::MaterialData material; Trade::MaterialData material;
const char* message; const char* message;
} FailData[]{ } FailData[]{
{"ambient color, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, {"ambient color, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes,
Trade::MaterialData{{}, { Trade::MaterialData{{}, {
{Trade::MaterialAttribute::AmbientColor, Color4{}}, {Trade::MaterialAttribute::AmbientColor, Color4{}},
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::AmbientColor attribute\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::AmbientColor attribute\n"},
{"specular texture, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, {"specular texture, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes,
Trade::MaterialData{{}, { Trade::MaterialData{{}, {
{Trade::MaterialAttribute::SpecularTexture, 0u}, {Trade::MaterialAttribute::SpecularTexture, 0u},
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute\n"},
{"shininess, fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes, {"shininess, fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes,
Trade::MaterialData{{}, { Trade::MaterialData{{}, {
{Trade::MaterialAttribute::Shininess, 0.5f}, {Trade::MaterialAttribute::Shininess, 0.5f},
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::Shininess attribute\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::Shininess attribute\n"},
{"specular color, both drop & fail on unconvertable", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertableAttributes|PhongToPbrMetallicRoughnessFlag::DropUnconvertableAttributes, {"specular color, both drop & fail on unconvertible", PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes|PhongToPbrMetallicRoughnessFlag::DropUnconvertibleAttributes,
Trade::MaterialData{{}, { Trade::MaterialData{{}, {
{Trade::MaterialAttribute::SpecularTexture, 0u}, {Trade::MaterialAttribute::SpecularTexture, 0u},
}}, }},
"MaterialTools::phongToPbrMetallicRoughness(): unconvertable Trade::MaterialAttribute::SpecularTexture attribute\n"}, "MaterialTools::phongToPbrMetallicRoughness(): unconvertible Trade::MaterialAttribute::SpecularTexture attribute\n"},
}; };
PhongToPbrMetallicRoughnessTest::PhongToPbrMetallicRoughnessTest() { PhongToPbrMetallicRoughnessTest::PhongToPbrMetallicRoughnessTest() {

4
src/Magnum/SceneTools/Test/SceneConverterTest.cpp

@ -770,7 +770,7 @@ const struct {
"UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr, "UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr,
/* The file should contain also material names and everything */ /* The file should contain also material names and everything */
"materials-pbr.gltf", nullptr, "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, { {"Phong to PBR, verbose", {InPlaceInit, {
/* Same as above, just with -v added */ /* Same as above, just with -v added */
"-I", "UfbxImporter", "-C", "GltfSceneConverter", "--phong-to-pbr", "-I", "UfbxImporter", "-C", "GltfSceneConverter", "--phong-to-pbr",
@ -780,7 +780,7 @@ const struct {
"UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr, "UfbxImporter", "PngImporter", "GltfSceneConverter", {"PngImageConverter", nullptr}, nullptr,
"materials-pbr.gltf", nullptr, "materials-pbr.gltf", nullptr,
"Converting material 0 to PBR\n" "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" "Converting material 1 to PBR\n"
"Trade::AbstractSceneConverter::addImporterContents(): adding 2D image 0 out of 2\n" "Trade::AbstractSceneConverter::addImporterContents(): adding 2D image 0 out of 2\n"
"Trade::AnyImageImporter::openFile(): using PngImporter\n" "Trade::AnyImageImporter::openFile(): using PngImporter\n"

2
src/Magnum/SceneTools/sceneconverter.cpp

@ -1152,7 +1152,7 @@ well, the IDs reference attributes of the first mesh.)")
Trade::Implementation::Duration d{conversionTime}; Trade::Implementation::Duration d{conversionTime};
/** @todo make the flags configurable as well? then the below /** @todo make the flags configurable as well? then the below
assert can actually fire, convert to a runtime error */ 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); CORRADE_INTERNAL_ASSERT(material);
} }

Loading…
Cancel
Save