diff --git a/doc/changelog.dox b/doc/changelog.dox index 3705cb822..f8d91247c 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -162,6 +162,11 @@ See also: afterwards. This can cause compilation breakages in case the type constructor has the parent parameter non-optional, pass the parent explicitly in that case. +- Mutable access to @ref Trade::PhongMaterialData color and texture + information, deprecated in 2020.06, is now removed, as it's impossible to + implement through the redesigned @ref Trade::MaterialData APIs. However + these APIs were mainly used to populate the contents in asset importers, so + this shouldn't cause any breakages in user code. @section changelog-2020-06 2020.06 @@ -821,6 +826,10 @@ Released 2020-06-27, tagged as deprecated on the 3D variant, use separate @ref Shaders::MeshVisualizer3D::setTransformationMatrix() and @ref Shaders::MeshVisualizer3D::setProjectionMatrix() instead +- Mutable access to @ref Trade::PhongMaterialData color and texture + information is deprecated. This was mainly used to populate the contents + in asset importers, but the class was redesigned and this is no longer + needed. - The unprefixed and alien-looking @cpp FLOAT_EQUALITY_PRECISION @ce, @cpp DOUBLE_EQUALITY_PRECISION @ce and @cpp LONG_DOUBLE_EQUALITY_PRECISION @ce macros are no longer used by any code and thus deprecated in favor of using diff --git a/src/Magnum/Trade/PhongMaterialData.cpp b/src/Magnum/Trade/PhongMaterialData.cpp index c0e667dea..85435a2d5 100644 --- a/src/Magnum/Trade/PhongMaterialData.cpp +++ b/src/Magnum/Trade/PhongMaterialData.cpp @@ -75,12 +75,6 @@ UnsignedInt PhongMaterialData::ambientTexture() const { return _ambientTexture; } -#ifdef MAGNUM_BUILD_DEPRECATED -UnsignedInt& PhongMaterialData::ambientTexture() { - CORRADE_ASSERT(flags() & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientTexture(): the material doesn't have an ambient texture", _ambientTexture); - return _ambientTexture; -} -#endif UnsignedInt PhongMaterialData::ambientCoordinateSet() const { CORRADE_ASSERT(flags() & Flag::AmbientTexture, "Trade::PhongMaterialData::ambientCoordinateSet(): the material doesn't have an ambient texture", {}); @@ -92,12 +86,6 @@ UnsignedInt PhongMaterialData::diffuseTexture() const { return _diffuseTexture; } -#ifdef MAGNUM_BUILD_DEPRECATED -UnsignedInt& PhongMaterialData::diffuseTexture() { - CORRADE_ASSERT(flags() & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseTexture(): the material doesn't have a diffuse texture", _diffuseTexture); - return _diffuseTexture; -} -#endif UnsignedInt PhongMaterialData::diffuseCoordinateSet() const { CORRADE_ASSERT(flags() & Flag::DiffuseTexture, "Trade::PhongMaterialData::diffuseCoordinateSet(): the material doesn't have a diffuse texture", {}); @@ -109,12 +97,6 @@ UnsignedInt PhongMaterialData::specularTexture() const { return _specularTexture; } -#ifdef MAGNUM_BUILD_DEPRECATED -UnsignedInt& PhongMaterialData::specularTexture() { - CORRADE_ASSERT(flags() & Flag::SpecularTexture, "Trade::PhongMaterialData::specularTexture(): the material doesn't have a specular texture", _specularTexture); - return _specularTexture; -} -#endif UnsignedInt PhongMaterialData::specularCoordinateSet() const { CORRADE_ASSERT(flags() & Flag::SpecularTexture, "Trade::PhongMaterialData::specularCoordinateSet(): the material doesn't have a specular texture", {}); diff --git a/src/Magnum/Trade/PhongMaterialData.h b/src/Magnum/Trade/PhongMaterialData.h index 3565b8892..835522cc3 100644 --- a/src/Magnum/Trade/PhongMaterialData.h +++ b/src/Magnum/Trade/PhongMaterialData.h @@ -212,18 +212,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ Color4 ambientColor() const { return _ambientColor; } - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead. - */ - /* Not marked with CORRADE_DEPRECATED() because the compiler picks this - overload over the const one for a non-const instance and there's no - way to selectively enable deprecation warnings only if the code - attempts to modify the value. */ - Color4& ambientColor() { return _ambientColor; } - #endif - /** * @brief Ambient texture ID * @@ -233,15 +221,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ UnsignedInt ambientTexture() const; - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead of modifying the instance afterwards. - */ - /* Not using CORRADE_DEPRECATED(), see why above */ - UnsignedInt& ambientTexture(); - #endif - /** * @brief Ambient texture coordinate set * @m_since{2020,06} @@ -260,15 +239,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ Color4 diffuseColor() const { return _diffuseColor; } - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead of modifying the instance afterwards. - */ - /* Not using CORRADE_DEPRECATED(), see why above */ - Color4& diffuseColor() { return _diffuseColor; } - #endif - /** * @brief Diffuse texture ID * @@ -278,15 +248,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ UnsignedInt diffuseTexture() const; - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead of modifying the instance afterwards. - */ - /* Not using CORRADE_DEPRECATED(), see why above */ - UnsignedInt& diffuseTexture(); - #endif - /** * @brief Diffuse texture coordinate set * @m_since{2020,06} @@ -305,15 +266,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ Color4 specularColor() const { return _specularColor; } - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead of modifying the instance afterwards. - */ - /* Not using CORRADE_DEPRECATED(), see why above */ - Color4& specularColor() { return _specularColor; } - #endif - /** * @brief Specular texture ID * @@ -323,15 +275,6 @@ class MAGNUM_TRADE_EXPORT PhongMaterialData: public AbstractMaterialData { */ UnsignedInt specularTexture() const; - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @m_deprecated_since{2020,06} Use the constructor to populate all - * values instead of modifying the instance afterwards. - */ - /* Not using CORRADE_DEPRECATED(), see why above */ - UnsignedInt& specularTexture(); - #endif - /** * @brief Specular texture coordinate set * @m_since{2020,06} diff --git a/src/Magnum/Trade/Test/MaterialDataTest.cpp b/src/Magnum/Trade/Test/MaterialDataTest.cpp index 26ecfd31c..d683b24e3 100644 --- a/src/Magnum/Trade/Test/MaterialDataTest.cpp +++ b/src/Magnum/Trade/Test/MaterialDataTest.cpp @@ -88,18 +88,16 @@ void MaterialDataTest::constructPhong() { 0xacabad_rgbf, {}, {}, {}, MaterialAlphaMode::Mask, 0.3f, 80.0f, &a}; - /** @todo use data directly once deprecated mutable access is gone */ - const PhongMaterialData& cdata = data; - CORRADE_COMPARE(cdata.type(), MaterialType::Phong); - CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flags{}); - CORRADE_COMPARE(cdata.ambientColor(), 0xccffbb_rgbf); - CORRADE_COMPARE(cdata.diffuseColor(), 0xebefbf_rgbf); - CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); - CORRADE_COMPARE(cdata.textureMatrix(), Matrix3{}); - CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Mask); - CORRADE_COMPARE(cdata.alphaMask(), 0.3f); - CORRADE_COMPARE(cdata.shininess(), 80.0f); - CORRADE_COMPARE(cdata.importerState(), &a); + CORRADE_COMPARE(data.type(), MaterialType::Phong); + CORRADE_COMPARE(data.flags(), PhongMaterialData::Flags{}); + CORRADE_COMPARE(data.ambientColor(), 0xccffbb_rgbf); + CORRADE_COMPARE(data.diffuseColor(), 0xebefbf_rgbf); + CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); + CORRADE_COMPARE(data.textureMatrix(), Matrix3{}); + CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Mask); + CORRADE_COMPARE(data.alphaMask(), 0.3f); + CORRADE_COMPARE(data.shininess(), 80.0f); + CORRADE_COMPARE(data.importerState(), &a); } void MaterialDataTest::constructPhongTextured() { @@ -113,22 +111,20 @@ void MaterialDataTest::constructPhongTextured() { 0xacabad_rgbf, 17, {}, {}, MaterialAlphaMode::Blend, 0.37f, 96.0f, &a}; - /** @todo use data directly once deprecated mutable access is gone */ - const PhongMaterialData& cdata = data; - CORRADE_COMPARE(cdata.type(), MaterialType::Phong); - CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture); - CORRADE_COMPARE(cdata.ambientColor(), 0x111111_rgbf); - CORRADE_COMPARE(cdata.ambientTexture(), 42); - CORRADE_COMPARE(cdata.ambientCoordinateSet(), 0); - CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); - CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); - CORRADE_COMPARE(cdata.specularTexture(), 17); - CORRADE_COMPARE(cdata.specularCoordinateSet(), 0); - CORRADE_COMPARE(cdata.textureMatrix(), Matrix3{}); - CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Blend); - CORRADE_COMPARE(cdata.alphaMask(), 0.37f); - CORRADE_COMPARE(cdata.shininess(), 96.0f); - CORRADE_COMPARE(cdata.importerState(), &a); + CORRADE_COMPARE(data.type(), MaterialType::Phong); + CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture); + CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf); + CORRADE_COMPARE(data.ambientTexture(), 42); + CORRADE_COMPARE(data.ambientCoordinateSet(), 0); + CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf); + CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); + CORRADE_COMPARE(data.specularTexture(), 17); + CORRADE_COMPARE(data.specularCoordinateSet(), 0); + CORRADE_COMPARE(data.textureMatrix(), Matrix3{}); + CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend); + CORRADE_COMPARE(data.alphaMask(), 0.37f); + CORRADE_COMPARE(data.shininess(), 96.0f); + CORRADE_COMPARE(data.importerState(), &a); } void MaterialDataTest::constructPhongTexturedTextureTransform() { @@ -143,20 +139,18 @@ void MaterialDataTest::constructPhongTexturedTextureTransform() { Matrix3::rotation(90.0_degf), MaterialAlphaMode::Opaque, 0.5f, 96.0f, &a}; - /** @todo use data directly once deprecated mutable access is gone */ - const PhongMaterialData& cdata = data; - CORRADE_COMPARE(cdata.type(), MaterialType::Phong); - CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation); - CORRADE_COMPARE(cdata.ambientColor(), 0x111111_rgbf); - CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); - CORRADE_COMPARE(cdata.diffuseTexture(), 42); - CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); - CORRADE_COMPARE(cdata.normalTexture(), 17); - CORRADE_COMPARE(cdata.textureMatrix(), Matrix3::rotation(90.0_degf)); - CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Opaque); - CORRADE_COMPARE(cdata.alphaMask(), 0.5f); - CORRADE_COMPARE(cdata.shininess(), 96.0f); - CORRADE_COMPARE(cdata.importerState(), &a); + CORRADE_COMPARE(data.type(), MaterialType::Phong); + CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::DiffuseTexture|PhongMaterialData::Flag::NormalTexture|PhongMaterialData::Flag::TextureTransformation); + CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf); + CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf); + CORRADE_COMPARE(data.diffuseTexture(), 42); + CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); + CORRADE_COMPARE(data.normalTexture(), 17); + CORRADE_COMPARE(data.textureMatrix(), Matrix3::rotation(90.0_degf)); + CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Opaque); + CORRADE_COMPARE(data.alphaMask(), 0.5f); + CORRADE_COMPARE(data.shininess(), 96.0f); + CORRADE_COMPARE(data.importerState(), &a); } void MaterialDataTest::constructPhongTexturedCoordinateSets() { @@ -171,22 +165,20 @@ void MaterialDataTest::constructPhongTexturedCoordinateSets() { {}, 0, {}, MaterialAlphaMode::Blend, 0.37f, 96.0f, &a}; - /** @todo use data directly once deprecated mutable access is gone */ - const PhongMaterialData& cdata = data; - CORRADE_COMPARE(cdata.type(), MaterialType::Phong); - CORRADE_COMPARE(cdata.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinateSets); - CORRADE_COMPARE(cdata.ambientColor(), 0x111111_rgbf); - CORRADE_COMPARE(cdata.ambientTexture(), 42); - CORRADE_COMPARE(cdata.ambientCoordinateSet(), 3); - CORRADE_COMPARE(cdata.diffuseColor(), 0xeebbff_rgbf); - CORRADE_COMPARE(cdata.specularColor(), 0xacabad_rgbf); - CORRADE_COMPARE(cdata.specularTexture(), 17); - CORRADE_COMPARE(cdata.specularCoordinateSet(), 1); - CORRADE_COMPARE(cdata.textureMatrix(), Matrix3{}); - CORRADE_COMPARE(cdata.alphaMode(), MaterialAlphaMode::Blend); - CORRADE_COMPARE(cdata.alphaMask(), 0.37f); - CORRADE_COMPARE(cdata.shininess(), 96.0f); - CORRADE_COMPARE(cdata.importerState(), &a); + CORRADE_COMPARE(data.type(), MaterialType::Phong); + CORRADE_COMPARE(data.flags(), PhongMaterialData::Flag::AmbientTexture|PhongMaterialData::Flag::SpecularTexture|PhongMaterialData::Flag::TextureCoordinateSets); + CORRADE_COMPARE(data.ambientColor(), 0x111111_rgbf); + CORRADE_COMPARE(data.ambientTexture(), 42); + CORRADE_COMPARE(data.ambientCoordinateSet(), 3); + CORRADE_COMPARE(data.diffuseColor(), 0xeebbff_rgbf); + CORRADE_COMPARE(data.specularColor(), 0xacabad_rgbf); + CORRADE_COMPARE(data.specularTexture(), 17); + CORRADE_COMPARE(data.specularCoordinateSet(), 1); + CORRADE_COMPARE(data.textureMatrix(), Matrix3{}); + CORRADE_COMPARE(data.alphaMode(), MaterialAlphaMode::Blend); + CORRADE_COMPARE(data.alphaMask(), 0.37f); + CORRADE_COMPARE(data.shininess(), 96.0f); + CORRADE_COMPARE(data.importerState(), &a); } void MaterialDataTest::constructPhongTextureTransformNoTextures() {