From 509bad3462cbe22ce743314da70f28f650e38df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 13 May 2023 18:54:26 +0200 Subject: [PATCH] Trade: don't unwrap custom attribute/field names when passing to do*(). Originally I thought I'd save plugins some time if I just give them the custom indices directly, without being wrapped in a SceneField / MeshAttribute enum. But in practice that didn't really save anything, made the interfaces more error-prone due to there being no concrete type anymore, and all code that delegates to nested importers or converters had to re-wrap the IDs again, which is *again* error-prone. Bumping the interface strings because this is a breaking change for the implementations. Not for users tho, there nothing changes. --- .../Test/SceneConverterImplementationTest.cpp | 21 +++++++------- src/Magnum/SceneTools/sceneconverter.cpp | 8 +++--- src/Magnum/Trade/AbstractImporter.cpp | 12 ++++---- src/Magnum/Trade/AbstractImporter.h | 21 +++++++------- src/Magnum/Trade/AbstractSceneConverter.cpp | 8 +++--- src/Magnum/Trade/AbstractSceneConverter.h | 13 ++++----- .../Trade/Test/AbstractImporterTest.cpp | 18 ++++++------ .../Trade/Test/AbstractSceneConverterTest.cpp | 28 +++++++++---------- .../AnySceneConverter/AnySceneConverter.cpp | 8 +++--- .../AnySceneConverter/AnySceneConverter.h | 4 +-- .../AnySceneImporter/AnySceneImporter.cpp | 8 +++--- .../AnySceneImporter/AnySceneImporter.h | 4 +-- 12 files changed, 75 insertions(+), 78 deletions(-) diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index 52fc0c48a..37605d315 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -224,8 +224,8 @@ void SceneConverterImplementationTest::infoScenesObjects() { if(id == 8) return "Not in any scene"; return ""; } - Containers::String doSceneFieldName(UnsignedInt name) override { - if(name == 1337) return "DirectionVector"; + Containers::String doSceneFieldName(Trade::SceneField name) override { + if(name == Trade::sceneFieldCustom(1337)) return "DirectionVector"; return ""; } Containers::Optional doScene(UnsignedInt id) override { @@ -340,8 +340,8 @@ void SceneConverterImplementationTest::infoAnimations() { CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } - Containers::String doAnimationTrackTargetName(UnsignedShort name) override { - if(name == 333) + Containers::String doAnimationTrackTargetName(Trade::AnimationTrackTarget name) override { + if(name == Trade::animationTrackTargetCustom(333)) return "visibility"; return {}; } @@ -646,11 +646,11 @@ void SceneConverterImplementationTest::infoMeshes() { Containers::String doMeshName(UnsignedInt id) override { return id == 1 ? "LODs? No, meshets." : ""; } - Containers::String doMeshAttributeName(UnsignedShort name) override { - if(name == 25) return "vertices"; - if(name == 26) return "triangles"; + Containers::String doMeshAttributeName(Trade::MeshAttribute name) override { + if(name == Trade::meshAttributeCustom(25)) return "vertices"; + if(name == Trade::meshAttributeCustom(26)) return "triangles"; /* 37 (triangleCount) deliberately not named */ - if(name == 116) return "vertexCount"; + if(name == Trade::meshAttributeCustom(116)) return "vertexCount"; return ""; } @@ -755,8 +755,9 @@ void SceneConverterImplementationTest::infoMeshesBounds() { }}; } - Containers::String doMeshAttributeName(UnsignedShort name) override { - if(name == 25) return "NormalButCustomSoNoBoundsPrinted"; + Containers::String doMeshAttributeName(Trade::MeshAttribute name) override { + if(name == Trade::meshAttributeCustom(25)) + return "NormalButCustomSoNoBoundsPrinted"; return ""; } diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index b4c76a1b3..8c6f8f48e 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -775,7 +775,7 @@ well, the IDs reference attributes of the first mesh.)") if(!isMeshAttributeCustom(attributeName)) continue; /* Appending even empty ones so we don't have to special-case "not found" in doMeshAttributeName() */ - arrayAppend(attributeNames, InPlaceInit, meshAttributeCustom(attributeName), original.meshAttributeName(attributeName)); + arrayAppend(attributeNames, InPlaceInit, attributeName, original.meshAttributeName(attributeName)); } } @@ -787,8 +787,8 @@ well, the IDs reference attributes of the first mesh.)") Containers::String doMeshName(UnsignedInt) override { return name; } - Containers::String doMeshAttributeName(UnsignedShort name) override { - for(const Containers::Pair& i: attributeNames) + Containers::String doMeshAttributeName(Trade::MeshAttribute name) override { + for(const Containers::Pair& i: attributeNames) if(i.first() == name) return i.second(); /* All custom attributes, including the unnamed, are in the attributeNames array and both our attribute name propagation @@ -803,7 +803,7 @@ well, the IDs reference attributes of the first mesh.)") Trade::MeshData mesh; Containers::String name; - Containers::Array> attributeNames; + Containers::Array> attributeNames; }; /* Save the previous importer so we can pass it to the constructor in diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index f19ef7ffe..4ea07aa52 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -385,13 +385,13 @@ SceneField AbstractImporter::doSceneFieldForName(Containers::StringView) { Containers::String AbstractImporter::sceneFieldName(const SceneField name) { CORRADE_ASSERT(isSceneFieldCustom(name), "Trade::AbstractImporter::sceneFieldName():" << name << "is not custom", {}); - Containers::String out = doSceneFieldName(sceneFieldCustom(name)); + Containers::String out = doSceneFieldName(name); CORRADE_ASSERT(out.isSmall() || !out.deleter(), "Trade::AbstractImporter::sceneFieldName(): implementation is not allowed to use a custom String deleter", {}); return out; } -Containers::String AbstractImporter::doSceneFieldName(UnsignedInt) { return {}; } +Containers::String AbstractImporter::doSceneFieldName(SceneField) { return {}; } UnsignedInt AbstractImporter::animationCount() const { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::animationCount(): no file opened", {}); @@ -462,13 +462,13 @@ AnimationTrackTarget AbstractImporter::doAnimationTrackTargetForName(Containers: Containers::String AbstractImporter::animationTrackTargetName(const AnimationTrackTarget name) { CORRADE_ASSERT(isAnimationTrackTargetCustom(name), "Trade::AbstractImporter::animationTrackTargetName():" << name << "is not custom", {}); - Containers::String out = doAnimationTrackTargetName(animationTrackTargetCustom(name)); + Containers::String out = doAnimationTrackTargetName(name); CORRADE_ASSERT(out.isSmall() || !out.deleter(), "Trade::AbstractImporter::animationTrackTargetName(): implementation is not allowed to use a custom String deleter", {}); return out; } -Containers::String AbstractImporter::doAnimationTrackTargetName(UnsignedShort) { return {}; } +Containers::String AbstractImporter::doAnimationTrackTargetName(AnimationTrackTarget) { return {}; } UnsignedInt AbstractImporter::lightCount() const { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::lightCount(): no file opened", {}); @@ -1175,13 +1175,13 @@ MeshAttribute AbstractImporter::doMeshAttributeForName(Containers::StringView) { Containers::String AbstractImporter::meshAttributeName(const MeshAttribute name) { CORRADE_ASSERT(isMeshAttributeCustom(name), "Trade::AbstractImporter::meshAttributeName():" << name << "is not custom", {}); - Containers::String out = doMeshAttributeName(meshAttributeCustom(name)); + Containers::String out = doMeshAttributeName(name); CORRADE_ASSERT(out.isSmall() || !out.deleter(), "Trade::AbstractImporter::meshAttributeName(): implementation is not allowed to use a custom String deleter", {}); return out; } -Containers::String AbstractImporter::doMeshAttributeName(UnsignedShort) { return {}; } +Containers::String AbstractImporter::doMeshAttributeName(MeshAttribute) { return {}; } #ifdef MAGNUM_BUILD_DEPRECATED UnsignedInt AbstractImporter::mesh2DCount() const { diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 7d597b303..c7567b17c 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -1964,10 +1964,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * @brief Implementation for @ref sceneFieldName() * @m_since_latest * - * Receives the custom ID extracted via @ref sceneFieldCustom(SceneField). - * Default implementation returns an empty string. + * The @p name is always custom. Default implementation returns an + * empty string. */ - virtual Containers::String doSceneFieldName(UnsignedInt name); + virtual Containers::String doSceneFieldName(SceneField name); /** * @brief Implementation for @ref animationCount() @@ -2008,11 +2008,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * @brief Implementation for @ref animationTrackTargetName() * @m_since_latest * - * Receives the custom ID extracted via - * @ref animationTrackTargetCustom(AnimationTrackTarget). Default - * implementation returns an empty string. + * The @p name is always custom. Default implementation returns an + * empty string. */ - virtual Containers::String doAnimationTrackTargetName(UnsignedShort name); + virtual Containers::String doAnimationTrackTargetName(AnimationTrackTarget name); /** * @brief Implementation for @ref lightCount() @@ -2309,10 +2308,10 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * @brief Implementation for @ref meshAttributeName() * @m_since{2020,06} * - * Receives the custom ID extracted via @ref meshAttributeCustom(MeshAttribute). - * Default implementation returns an empty string. + * The @p name is always custom. Default implementation returns an + * empty string. */ - virtual Containers::String doMeshAttributeName(UnsignedShort name); + virtual Containers::String doMeshAttributeName(MeshAttribute name); #ifdef MAGNUM_BUILD_DEPRECATED /** @@ -2637,7 +2636,7 @@ updated interface string. */ /* Silly indentation to make the string appear in pluginInterface() docs */ #define MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \ -"cz.mosra.magnum.Trade.AbstractImporter/0.5.1" +"cz.mosra.magnum.Trade.AbstractImporter/0.5.2" /* [interface] */ #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/Magnum/Trade/AbstractSceneConverter.cpp b/src/Magnum/Trade/AbstractSceneConverter.cpp index 493297aa2..e2e89d793 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.cpp +++ b/src/Magnum/Trade/AbstractSceneConverter.cpp @@ -622,10 +622,10 @@ void AbstractSceneConverter::setSceneFieldName(const SceneField field, const Con CORRADE_ASSERT(isSceneFieldCustom(field), "Trade::AbstractSceneConverter::setSceneFieldName():" << field << "is not custom", ); - doSetSceneFieldName(sceneFieldCustom(field), name); + doSetSceneFieldName(field, name); } -void AbstractSceneConverter::doSetSceneFieldName(UnsignedInt, Containers::StringView) {} +void AbstractSceneConverter::doSetSceneFieldName(SceneField, Containers::StringView) {} void AbstractSceneConverter::setObjectName(const UnsignedLong object, const Containers::StringView name) { CORRADE_ASSERT(features() & SceneConverterFeature::AddScenes, @@ -849,10 +849,10 @@ void AbstractSceneConverter::setMeshAttributeName(const MeshAttribute attribute, CORRADE_ASSERT(isMeshAttributeCustom(attribute), "Trade::AbstractSceneConverter::setMeshAttributeName():" << attribute << "is not custom", ); - doSetMeshAttributeName(meshAttributeCustom(attribute), name); + doSetMeshAttributeName(attribute, name); } -void AbstractSceneConverter::doSetMeshAttributeName(UnsignedShort, Containers::StringView) {} +void AbstractSceneConverter::doSetMeshAttributeName(MeshAttribute, Containers::StringView) {} UnsignedInt AbstractSceneConverter::materialCount() const { CORRADE_ASSERT(_state, "Trade::AbstractSceneConverter::materialCount(): no conversion in progress", {}); diff --git a/src/Magnum/Trade/AbstractSceneConverter.h b/src/Magnum/Trade/AbstractSceneConverter.h index 19f403d5e..103faa6c7 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.h +++ b/src/Magnum/Trade/AbstractSceneConverter.h @@ -2197,11 +2197,9 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract * @brief Implementation for @ref setSceneFieldName() * @m_since_latest * - * Receives the custom ID extracted via - * @ref sceneFieldCustom(SceneField). Default implementation does - * nothing. + * The @p field is always custom. Default implementation does nothing. */ - virtual void doSetSceneFieldName(UnsignedInt field, Containers::StringView name); + virtual void doSetSceneFieldName(SceneField field, Containers::StringView name); /** * @brief Implementation for @ref setObjectName() @@ -2308,11 +2306,10 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract * @brief Implementation for @ref setMeshAttributeName() * @m_since_latest * - * Receives the custom ID extracted via - * @ref meshAttributeCustom(MeshAttribute). Default implementation does + * The @p attribute is always custom. Default implementation does * nothing. */ - virtual void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name); + virtual void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name); /** * @brief Implementation for @ref add(const MaterialData&, Containers::StringView) @@ -2441,7 +2438,7 @@ updated interface string. */ /* Silly indentation to make the string appear in pluginInterface() docs */ #define MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE /* [interface] */ \ -"cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.1" +"cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.2" /* [interface] */ }} diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index ba28793c8..26cad1420 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -3771,8 +3771,8 @@ void AbstractImporterTest::sceneFieldName() { return SceneField{}; } - Containers::String doSceneFieldName(UnsignedInt id) override { - if(id == 100037) return "OctreeCell"; + Containers::String doSceneFieldName(SceneField id) override { + if(id == sceneFieldCustom(100037)) return "OctreeCell"; return ""; } } importer; @@ -3822,7 +3822,7 @@ void AbstractImporterTest::sceneFieldNameCustomDeleter() { bool doIsOpened() const override { return true; } void doClose() override {} - Containers::String doSceneFieldName(UnsignedInt) override { + Containers::String doSceneFieldName(SceneField) override { return Containers::String{"a", 1, [](char*, std::size_t) {}}; } } importer; @@ -4098,8 +4098,8 @@ void AbstractImporterTest::animationTrackTargetName() { return AnimationTrackTarget{}; } - Containers::String doAnimationTrackTargetName(UnsignedShort id) override { - if(id == 37) return "visibility"; + Containers::String doAnimationTrackTargetName(AnimationTrackTarget id) override { + if(id == animationTrackTargetCustom(37)) return "visibility"; return ""; } } importer; @@ -4149,7 +4149,7 @@ void AbstractImporterTest::animationTrackTargetNameCustomDeleter() { bool doIsOpened() const override { return true; } void doClose() override {} - Containers::String doAnimationTrackTargetName(UnsignedShort) override { + Containers::String doAnimationTrackTargetName(AnimationTrackTarget) override { return Containers::String{"a", 1, [](char*, std::size_t) {}}; } } importer; @@ -5911,8 +5911,8 @@ void AbstractImporterTest::meshAttributeName() { return MeshAttribute{}; } - Containers::String doMeshAttributeName(UnsignedShort id) override { - if(id == 37) return "SMOOTH_GROUP_ID"; + Containers::String doMeshAttributeName(MeshAttribute id) override { + if(id == meshAttributeCustom(37)) return "SMOOTH_GROUP_ID"; return ""; } } importer; @@ -5962,7 +5962,7 @@ void AbstractImporterTest::meshAttributeNameCustomDeleter() { bool doIsOpened() const override { return true; } void doClose() override {} - Containers::String doMeshAttributeName(UnsignedShort) override { + Containers::String doMeshAttributeName(MeshAttribute) override { return Containers::String{"a", 1, [](char*, std::size_t) {}}; } } importer; diff --git a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp index fce7af7d8..50b531003 100644 --- a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp @@ -2823,8 +2823,8 @@ void AbstractSceneConverterTest::setSceneFieldName() { bool doBegin() override { return true; } - void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override { - CORRADE_COMPARE(field, 1337); + void doSetSceneFieldName(SceneField field, Containers::StringView name) override { + CORRADE_COMPARE(field, sceneFieldCustom(1337)); CORRADE_COMPARE(name, "hello!"); setSceneFieldNameCalled = true; } @@ -4122,8 +4122,8 @@ void AbstractSceneConverterTest::setMeshAttributeName() { bool doBegin() override { return true; } - void doSetMeshAttributeName(UnsignedShort field, Containers::StringView name) override { - CORRADE_COMPARE(field, 1337); + void doSetMeshAttributeName(MeshAttribute field, Containers::StringView name) override { + CORRADE_COMPARE(field, meshAttributeCustom(1337)); CORRADE_COMPARE(name, "hello!"); setMeshAttributeNameCalled = true; } @@ -6215,9 +6215,9 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() { }}; return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}}; } - Containers::String doSceneFieldName(UnsignedInt name) override { - if(name == 34977) return "OffsetSmall"; - if(name == 5266) return "ValueData"; + Containers::String doSceneFieldName(SceneField name) override { + if(name == sceneFieldCustom(34977)) return "OffsetSmall"; + if(name == sceneFieldCustom(5266)) return "ValueData"; CORRADE_FAIL("This should not be reached"); CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -6236,8 +6236,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() { Debug{} << "Adding scene"; return true; } - void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override { - Debug{} << "Setting field" << field << "name to" << name; + void doSetSceneFieldName(SceneField field, Containers::StringView name) override { + Debug{} << "Setting field" << sceneFieldCustom(field) << "name to" << name; } } converter; @@ -6280,9 +6280,9 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() { }}; return MeshData{MeshPrimitive::Points, 0}; } - Containers::String doMeshAttributeName(UnsignedShort name) override { - if(name == 31977) return "OffsetSmall"; - if(name == 5266) return "ValueData"; + Containers::String doMeshAttributeName(MeshAttribute name) override { + if(name == meshAttributeCustom(31977)) return "OffsetSmall"; + if(name == meshAttributeCustom(5266)) return "ValueData"; CORRADE_FAIL("This should not be reached"); CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -6302,8 +6302,8 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() { Debug{} << "Adding mesh levels"; return true; } - void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name) override { - Debug{} << "Setting attribute" << attribute << "name to" << name; + void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name) override { + Debug{} << "Setting attribute" << meshAttributeCustom(attribute) << "name to" << name; } } converter; diff --git a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp index 6d27d1120..dfa7161fe 100644 --- a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp +++ b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp @@ -191,8 +191,8 @@ bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const SceneDa return !!_converter->add(scene, name); } -void AnySceneConverter::doSetSceneFieldName(const UnsignedInt field, const Containers::StringView name) { - return _converter->setSceneFieldName(sceneFieldCustom(field), name); +void AnySceneConverter::doSetSceneFieldName(const SceneField field, const Containers::StringView name) { + return _converter->setSceneFieldName(field, name); } void AnySceneConverter::doSetObjectName(const UnsignedLong object, const Containers::StringView name) { @@ -238,8 +238,8 @@ bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const Contain return !!_converter->add(meshLevels, name); } -void AnySceneConverter::doSetMeshAttributeName(const UnsignedShort attribute, const Containers::StringView name) { - return _converter->setMeshAttributeName(meshAttributeCustom(attribute), name); +void AnySceneConverter::doSetMeshAttributeName(const MeshAttribute attribute, const Containers::StringView name) { + return _converter->setMeshAttributeName(attribute, name); } bool AnySceneConverter::doAdd(CORRADE_UNUSED const UnsignedInt id, const MaterialData& material, const Containers::StringView name) { diff --git a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h index 66194a5c4..47b43f8a7 100644 --- a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h +++ b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.h @@ -146,7 +146,7 @@ class MAGNUM_ANYSCENECONVERTER_EXPORT AnySceneConverter: public AbstractSceneCon bool doEndFile(Containers::StringView filename) override; bool doAdd(UnsignedInt id, const SceneData& scene, Containers::StringView name) override; - void doSetSceneFieldName(UnsignedInt field, Containers::StringView name) override; + void doSetSceneFieldName(SceneField field, Containers::StringView name) override; void doSetObjectName(UnsignedLong object, Containers::StringView name) override; void doSetDefaultScene(UnsignedInt id) override; @@ -158,7 +158,7 @@ class MAGNUM_ANYSCENECONVERTER_EXPORT AnySceneConverter: public AbstractSceneCon bool doAdd(UnsignedInt id, const MeshData& mesh, Containers::StringView name) override; bool doAdd(UnsignedInt id, const Containers::Iterable& meshLevels, Containers::StringView name) override; - void doSetMeshAttributeName(UnsignedShort attribute, Containers::StringView name) override; + void doSetMeshAttributeName(MeshAttribute attribute, Containers::StringView name) override; bool doAdd(UnsignedInt id, const MaterialData& material, Containers::StringView name) override; bool doAdd(UnsignedInt id, const TextureData& texture, Containers::StringView name) override; diff --git a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp index 3e565b4c5..f75c682a2 100644 --- a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp +++ b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp @@ -200,10 +200,10 @@ SceneField AnySceneImporter::doSceneFieldForName(const Containers::StringView na an invalid ID */ return _in ? _in->sceneFieldForName(name) : SceneField{}; } -Containers::String AnySceneImporter::doSceneFieldName(const UnsignedInt name) { +Containers::String AnySceneImporter::doSceneFieldName(const SceneField name) { /* This API can be called even if no file is opened, in that case return an invalid ID */ - return _in ? _in->sceneFieldName(sceneFieldCustom(name)) : Containers::String{}; + return _in ? _in->sceneFieldName(name) : Containers::String{}; } UnsignedInt AnySceneImporter::doLightCount() const { return _in->lightCount(); } @@ -250,10 +250,10 @@ MeshAttribute AnySceneImporter::doMeshAttributeForName(const Containers::StringV an invalid ID */ return _in ? _in->meshAttributeForName(name) : MeshAttribute{}; } -Containers::String AnySceneImporter::doMeshAttributeName(const UnsignedShort id) { +Containers::String AnySceneImporter::doMeshAttributeName(const MeshAttribute id) { /* This API can be called even if no file is opened, in that case return an invalid ID */ - return _in ? _in->meshAttributeName(meshAttributeCustom(id)) : Containers::String{}; + return _in ? _in->meshAttributeName(id) : Containers::String{}; } #ifdef MAGNUM_BUILD_DEPRECATED diff --git a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h index 27e97521a..ef81c14e6 100644 --- a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h +++ b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h @@ -194,7 +194,7 @@ class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter { MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doObjectName(UnsignedLong id) override; MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional doScene(UnsignedInt id) override; MAGNUM_ANYSCENEIMPORTER_LOCAL SceneField doSceneFieldForName(Containers::StringView name) override; - MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doSceneFieldName(Magnum::UnsignedInt name) override; + MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doSceneFieldName(SceneField name) override; MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doLightCount() const override; MAGNUM_ANYSCENEIMPORTER_LOCAL Int doLightForName(Containers::StringView name) override; @@ -238,7 +238,7 @@ class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter { MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional doMesh(UnsignedInt id, UnsignedInt level) override; MAGNUM_ANYSCENEIMPORTER_LOCAL MeshAttribute doMeshAttributeForName(Containers::StringView name) override; - MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doMeshAttributeName(UnsignedShort id) override; + MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::String doMeshAttributeName(MeshAttribute id) override; #ifdef MAGNUM_BUILD_DEPRECATED MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMesh2DCount() const override;