diff --git a/doc/changelog.dox b/doc/changelog.dox index 9652223f8..bf3582592 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1112,9 +1112,11 @@ See also: possible cases. The variant taking an @ref Animation::TrackView is kept however as it may be convenient when exporting already-populated animation instances. -- @cpp Trade::LightData::Type::Infinite @ce, originally adapted from the +- @cpp Trade::LightData::Type @ce is deprecated in favor of + @ref Trade::LightType that is shorter to type and can be forward-declared +- @cpp Trade::LightType::Infinite @ce, originally adapted from the OpenGEX specification, is deprecated in favor of - @ref Trade::LightData::Type::Directional as that's the more commonly used + @ref Trade::LightType::Directional as that's the more commonly used term - @cpp Trade::PhongMaterialData::ambientCoordinateSet() @ce, @cpp diffuseCoordinateSet() @ce, @cpp specularCoordinateSet() @ce and diff --git a/doc/snippets/MagnumTrade.cpp b/doc/snippets/MagnumTrade.cpp index b39fafa89..f89332cce 100644 --- a/doc/snippets/MagnumTrade.cpp +++ b/doc/snippets/MagnumTrade.cpp @@ -496,7 +496,7 @@ for(auto&& row: data.mutablePixels()) { /* [LightData-populating-range] */ -Trade::LightData data{Trade::LightData::Type::Point, +Trade::LightData data{Trade::LightType::Point, 0xfff3d6_srgbf, 1.0f, 15.0f}; /* [LightData-populating-range] */ @@ -504,7 +504,7 @@ Trade::LightData data{Trade::LightData::Type::Point, { /* [LightData-populating-attenuation] */ -Trade::LightData data{Trade::LightData::Type::Spot, +Trade::LightData data{Trade::LightType::Spot, 0xf3d6ff_srgbf, 10.0f, {0.01f, 0.5f, 2.0f}, 25.0_degf, 55.0_degf}; @@ -513,7 +513,7 @@ Trade::LightData data{Trade::LightData::Type::Spot, { /* [LightData-populating-none] */ -Trade::LightData data{Trade::LightData::Type::Directional, +Trade::LightData data{Trade::LightType::Directional, 0xd6fff3_srgbf, 0.25f}; /* [LightData-populating-none] */ } diff --git a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h index d5a87a8e6..23303a465 100644 --- a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h +++ b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h @@ -796,7 +796,7 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility d << Debug::newline << " Type:" << Debug::packed << Debug::color(Debug::Color::Cyan) << info.data.type() << Debug::resetColor; - if(info.data.type() == Trade::LightData::Type::Spot) + if(info.data.type() == Trade::LightType::Spot) d << Debug::nospace << "," << Debug::packed << Deg(info.data.innerConeAngle()) << Debug::nospace << "° -" << Debug::packed << Deg(info.data.outerConeAngle()) @@ -807,8 +807,8 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility d << Debug::packed << info.data.color(); if(!Math::equal(info.data.intensity(), 1.0f)) d << "*" << info.data.intensity(); - if(info.data.type() != Trade::LightData::Type::Ambient && - info.data.type() != Trade::LightData::Type::Directional) + if(info.data.type() != Trade::LightType::Ambient && + info.data.type() != Trade::LightType::Directional) d << Debug::newline << " Attenuation:" << Debug::packed << info.data.attenuation(); if(info.data.range() != Constants::inf()) diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index fde3eef7e..52fc0c48a 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -464,7 +464,7 @@ void SceneConverterImplementationTest::infoLights() { Containers::Optional doLight(UnsignedInt id) override { /* First a blue spot light */ if(id == 0) return Trade::LightData{ - Trade::LightData::Type::Spot, + Trade::LightType::Spot, 0x3457ff_rgbf, 15.0f, {1.2f, 0.3f, 0.04f}, @@ -475,7 +475,7 @@ void SceneConverterImplementationTest::infoLights() { /* Second a yellow directional light with infinite range */ if(id == 1) return Trade::LightData{ - Trade::LightData::Type::Directional, + Trade::LightType::Directional, 0xff5734_rgbf, 5.0f }; @@ -998,17 +998,17 @@ void SceneConverterImplementationTest::infoReferenceCount() { } Containers::Optional doLight(UnsignedInt id) override { if(id == 0) return Trade::LightData{ - Trade::LightData::Type::Directional, + Trade::LightType::Directional, 0x57ff34_rgbf, 5.0f }; if(id == 1) return Trade::LightData{ - Trade::LightData::Type::Ambient, + Trade::LightType::Ambient, 0xff5734_rgbf, 0.1f }; if(id == 2) return Trade::LightData{ - Trade::LightData::Type::Directional, + Trade::LightType::Directional, 0x3457ff_rgbf, 1.0f }; diff --git a/src/Magnum/Trade/LightData.cpp b/src/Magnum/Trade/LightData.cpp index bb7e1de3f..27c0f7140 100644 --- a/src/Magnum/Trade/LightData.cpp +++ b/src/Magnum/Trade/LightData.cpp @@ -31,50 +31,50 @@ namespace Magnum { namespace Trade { using namespace Math::Literals; -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Vector3& attenuation, const Float range, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: _type{type}, _color{color}, _intensity{intensity}, _attenuation{attenuation}, _range{range}, _innerConeAngle{innerConeAngle}, _outerConeAngle{outerConeAngle}, _importerState{importerState} { - CORRADE_ASSERT(_type != Type::Spot || (Deg(_innerConeAngle) >= 0.0_degf && _innerConeAngle <= _outerConeAngle && Deg(_outerConeAngle) <= 360.0_degf), +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Vector3& attenuation, const Float range, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: _type{type}, _color{color}, _intensity{intensity}, _attenuation{attenuation}, _range{range}, _innerConeAngle{innerConeAngle}, _outerConeAngle{outerConeAngle}, _importerState{importerState} { + CORRADE_ASSERT(_type != LightType::Spot || (Deg(_innerConeAngle) >= 0.0_degf && _innerConeAngle <= _outerConeAngle && Deg(_outerConeAngle) <= 360.0_degf), "Trade::LightData: spot light inner and outer cone angles have to be in range [0°, 360°] and inner not larger than outer but got" << Deg(_innerConeAngle) << "and" << Deg(_outerConeAngle), ); - CORRADE_ASSERT(_type == Type::Spot || (Math::equal(Deg(_innerConeAngle),360.0_degf) && Math::equal(Deg(_outerConeAngle), 360.0_degf)), + CORRADE_ASSERT(_type == LightType::Spot || (Math::equal(Deg(_innerConeAngle),360.0_degf) && Math::equal(Deg(_outerConeAngle), 360.0_degf)), "Trade::LightData: cone angles have to be 360° for lights that aren't spot but got" << Deg(_innerConeAngle) << "and" << Deg(_outerConeAngle), ); - CORRADE_ASSERT((_type != Type::Ambient && _type != Type::Directional) || (_attenuation == Vector3{1.0f, 0.0f, 0.0f}), + CORRADE_ASSERT((_type != LightType::Ambient && _type != LightType::Directional) || (_attenuation == Vector3{1.0f, 0.0f, 0.0f}), "Trade::LightData: attenuation has to be (1, 0, 0) for an ambient or directional light but got" << _attenuation, ); - CORRADE_ASSERT((_type != Type::Ambient && _type != Type::Directional) || _range == Constants::inf(), + CORRADE_ASSERT((_type != LightType::Ambient && _type != LightType::Directional) || _range == Constants::inf(), "Trade::LightData: range has to be infinity for an ambient or directional light but got" << _range, ); } -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Vector3& attenuation, const Float range, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, range, - type == Type::Spot ? 0.0_degf : 360.0_degf, - type == Type::Spot ? 90.0_degf : 360.0_degf, +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Vector3& attenuation, const Float range, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, range, + type == LightType::Spot ? 0.0_degf : 360.0_degf, + type == LightType::Spot ? 90.0_degf : 360.0_degf, importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Vector3& attenuation, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, Constants::inf(), innerConeAngle, outerConeAngle, importerState} {} +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Vector3& attenuation, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, Constants::inf(), innerConeAngle, outerConeAngle, importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Vector3& attenuation, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, Constants::inf(), importerState} {} +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Vector3& attenuation, const void* const importerState) noexcept: LightData{type, color, intensity, attenuation, Constants::inf(), importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Float range, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, - type == Type::Ambient || type == Type::Directional ? +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Float range, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, + type == LightType::Ambient || type == LightType::Directional ? Vector3{1.0f, 0.0f, 0.0f} : Vector3{1.0f, 0.0f, 1.0f}, range, innerConeAngle, outerConeAngle, importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Float range, const void* const importerState) noexcept: LightData{type, color, intensity, - type == Type::Ambient || type == Type::Directional ? +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Float range, const void* const importerState) noexcept: LightData{type, color, intensity, + type == LightType::Ambient || type == LightType::Directional ? Vector3{1.0f, 0.0f, 0.0f} : Vector3{1.0f, 0.0f, 1.0f}, range, importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, Constants::inf(), innerConeAngle, outerConeAngle, importerState} {} +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const Rad innerConeAngle, const Rad outerConeAngle, const void* const importerState) noexcept: LightData{type, color, intensity, Constants::inf(), innerConeAngle, outerConeAngle, importerState} {} -LightData::LightData(const Type type, const Color3& color, const Float intensity, const void* const importerState) noexcept: LightData{type, color, intensity, Constants::inf(), importerState} {} +LightData::LightData(const LightType type, const Color3& color, const Float intensity, const void* const importerState) noexcept: LightData{type, color, intensity, Constants::inf(), importerState} {} #ifndef DOXYGEN_GENERATING_OUTPUT -Debug& operator<<(Debug& debug, const LightData::Type value) { +Debug& operator<<(Debug& debug, const LightType value) { const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; if(!packed) - debug << "Trade::LightData::Type" << Debug::nospace; + debug << "Trade::LightType" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(value) case LightData::Type::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; + #define _c(value) case LightType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; _c(Ambient) _c(Directional) _c(Point) diff --git a/src/Magnum/Trade/LightData.h b/src/Magnum/Trade/LightData.h index 902f2ef39..da7ac3437 100644 --- a/src/Magnum/Trade/LightData.h +++ b/src/Magnum/Trade/LightData.h @@ -35,6 +35,63 @@ namespace Magnum { namespace Trade { +/** +@brief Light type +@m_since_latest + +@see @ref LightData::type() +*/ +enum class LightType: UnsignedByte { + /* Zero reserved for an invalid value */ + + /** + * Ambient light, without any position, direction or attenuation. Meant to + * be added to ambient color in Phong workflows, has no use in physically + * based workflows. + * @m_since_latest + */ + Ambient = 1, + + /** + * Light at a position that is infinitely far away, emitted in a direction + * of negative Z axis. The rotation is inherited from absolute object + * transformation; scale and position don't affect the light in any way. + * Because the light is at infinite distance, it's not attenuated in any + * way. + * @m_since_latest + */ + Directional, + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * Directional light. + * @m_deprecated_since_latest Use @ref LightType::Directional instead. + */ + Infinite CORRADE_DEPRECATED_ENUM("use LightType::Directional instead") = Directional, + #endif + + /** + * Point light, emitting light in all directions. The position is inherited + * from absolute object transformation; scale and rotation don't affect the + * light in any way. Brightness attenuates depending on the + * @ref LightData::range() value. + */ + Point, + + /** + * Spot light, emitting light in a cone in direction of local negative Z + * axis. The position and rotation is inherited from absolute object + * transformation; scale doesn't affect the light in any way. The angle and + * falloff of the cone is defined using @ref LightData::innerConeAngle() + * and @ref LightData::outerConeAngle() and brightness attenuates depending + * on the @ref LightData::range() value. + */ + Spot +}; + +/** @debugoperatorenum{LightType} */ +MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, LightType value); + /** @brief Light data @@ -50,20 +107,22 @@ everything except spotlights. You can choose a constructor overload that matches the subset of input parameters and let the class set the rest implicitly. For example, a -@ref Type::Point light constructed using a range will have @ref attenuation() -implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce and cone angles to -@cpp 360.0_degf @ce: +@ref LightType::Point light constructed using a range will have +@ref attenuation() implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce and cone +angles to @cpp 360.0_degf @ce: @snippet MagnumTrade.cpp LightData-populating-range -Or, a @ref Type::Spot light constructed from a constant / linear / quadratic -attenuation will have @ref range() implicitly set to @ref Constants::inf(): +Or, a @ref LightType::Spot light constructed from a constant / linear / +quadratic attenuation will have @ref range() implicitly set to +@ref Constants::inf(): @snippet MagnumTrade.cpp LightData-populating-attenuation -And a @ref Type::Directional light that doesn't attenuate can be constructed -without either, causing @ref attenuation() to be @cpp {1.0f, 0.0f, 0.0f} @ce -and @ref range() @ref Constants::inf(), cancelling out the attenuation equation: +And a @ref LightType::Directional light that doesn't attenuate can be +constructed without either, causing @ref attenuation() to be +@cpp {1.0f, 0.0f, 0.0f} @ce and @ref range() @ref Constants::inf(), cancelling +out the attenuation equation: @snippet MagnumTrade.cpp LightData-populating-none @@ -100,7 +159,7 @@ a simple inverse square: @f[ F_{att} = \lim_{{\color{m-info} R} \to \infty} \frac{{\color{m-dim} \operatorname{clamp}(} 1 \mathbin{\color{m-dim} -} {\color{m-dim} (\frac{d}{R})^4, 0, 1)^2}}{{\color{m-success} K_c} + {\color{m-dim} K_l d} \mathbin{\color{m-dim} +} {\color{m-success} K_q} d^2} = \frac{1}{1 + d^2} @f] -As a special case, a @ref Type::Directional light is defined by +As a special case, a @ref LightType::Directional light is defined by @ref attenuation() set to @cpp {1.0f, 0.0f, 0.0f} @ce and @ref range() to @ref Constants::inf() --- thus without any attenuation: @f[ F_{att} = \lim_{{\color{m-info} R} \to \infty} \frac{{\color{m-dim} \operatorname{clamp}(} 1 \mathbin{\color{m-dim} -} {\color{m-dim} (\frac{d}{R})^4, 0, 1)^2}}{{\color{m-success} K_c} \mathbin{\color{m-dim} +} {\color{m-dim} K_l d + K_q d^2}} = 1 @@ -109,67 +168,20 @@ As a special case, a @ref Type::Directional light is defined by @section Trade-LightData-units Units To follow physically-based principles in lighting calculation, intensity is -assumed to be in in *candela* (lm/sr) for @ref Type::Point and @ref Type::Spot, -and in *lux* (lm/m2) for @ref Type::Directional. Distance @f$ d @f$ -is in meters. +assumed to be in in *candela* (lm/sr) for @ref LightType::Point and +@ref LightType::Spot, and in *lux* (lm/m2) for +@ref LightType::Directional. Distance @f$ d @f$ is in meters. @see @ref AbstractImporter::light() */ class MAGNUM_TRADE_EXPORT LightData { public: - /** - * @brief Light type - * - * @see @ref type() - * @todo move this to LightType outside of the class for consistency + #ifdef MAGNUM_BUILD_DEPRECATED + /** @brief @copybrief LightType + * @m_deprecated_since_latest Use @ref LightType instead. */ - enum class Type: UnsignedByte { - /* Zero reserved for an invalid value */ - - /** - * Ambient light, without any position, direction or attenuation. - * Meant to be added to ambient color in Phong workflows, has no - * use in physically based workflows. - * @m_since_latest - */ - Ambient = 1, - - /** - * Light at a position that is infinitely far away, emitted in a - * direction of negative Z axis. The rotation is inherited from - * absolute object transformation; scale and position don't affect - * the light in any way. Because the light is at infinite distance, - * it's not attenuated in any way. - * @m_since_latest - */ - Directional, - - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * Directional light. - * @m_deprecated_since_latest Use @ref Type::Directional instead. - */ - Infinite CORRADE_DEPRECATED_ENUM("use Type::Directional instead") = Directional, - #endif - - /** - * Point light, emitting light in all directions. The position is - * inherited from absolute object transformation; scale and - * rotation don't affect the light in any way. Brightness - * attenuates depending on the @ref range() value. - */ - Point, - - /** - * Spot light, emitting light in a cone in direction of local - * negative Z axis. The position and rotation is inherited from - * absolute object transformation; scale doesn't affect the light - * in any way. The angle and falloff of the cone is defined using - * @ref innerConeAngle() and @ref outerConeAngle() and brightness - * attenuates depending on the @ref range() value. - */ - Spot - }; + typedef CORRADE_DEPRECATED("use LightType instead") LightType Type; + #endif /** * @brief Constructor @@ -178,35 +190,37 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param attenuation Constant, linear and quadratic light * attenuation factor. Expected to be @cpp {1.0f, 0.0f, 0.0f} @ce - * for an @ref Type::Ambient and @ref Type::Directional light. + * for an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param range Light range, after which the intensity is * considered to be zero. Expected to be @ref Constants::inf() for - * an @ref Type::Ambient and @ref Type::Directional light. + * an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param innerConeAngle Inner cone angle. Expected to be greater * than or equal to @cpp 0.0_degf @ce and less than or equal to - * @p outerConeAngle for a @ref Type::Spot light, + * @p outerConeAngle for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param outerConeAngle Outer cone angle. Expected to be greater * than or equal to @p innerConeAngle and less than or equal to - * @cpp 360.0_degf @ce for a @ref Type::Spot light, + * @cpp 360.0_degf @ce for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param importerState Importer-specific state * @m_since_latest * * This is a combined constructor including both attenuation and range - * parameters. Use @ref LightData(Type, const Color3&, Float, const Vector3&, Rad, Rad, const void*) + * parameters. Use @ref LightData(LightType, const Color3&, Float, const Vector3&, Rad, Rad, const void*) * for light data defined by just attenuation parameters and - * @ref LightData(Type, const Color3&, Float, Float, Rad, Rad, const void*) + * @ref LightData(LightType, const Color3&, Float, Float, Rad, Rad, const void*) * for light data defined by a range alone, and - * @ref LightData(Type, const Color3&, Float, Rad, Rad, const void*) + * @ref LightData(LightType, const Color3&, Float, Rad, Rad, const void*) * for an implicit inverse square attenuation. See * @ref Trade-LightData-attenuation for more information. * * For lights other than spot it may be more convenient to use - * @ref LightData(Type, const Color3&, Float, const Vector3&, Float, const void*) + * @ref LightData(LightType, const Color3&, Float, const Vector3&, Float, const void*) * and friends instead. */ - explicit LightData(Type type, const Color3& color, Float intensity, const Vector3& attenuation, Float range, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, const Vector3& attenuation, Float range, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; /** * @brief Construct with implicit cone angles @@ -215,29 +229,31 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param attenuation Constant, linear and quadratic light * attenuation factor. Expected to be @cpp {1.0f, 0.0f, 0.0f} @ce - * for an @ref Type::Ambient and @ref Type::Directional light. + * for an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param range Light range, after which the intensity is * considered to be zero. Expected to be @ref Constants::inf() for - * an @ref Type::Ambient and @ref Type::Directional light. + * an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param importerState Importer-specific state * @m_since_latest * * This is a combined constructor including both attenuation and range - * parameters. Use @ref LightData(Type, const Color3&, Float, const Vector3&, const void*) + * parameters. Use @ref LightData(LightType, const Color3&, Float, const Vector3&, const void*) * for light data defined by just attenuation parameters and - * @ref LightData(Type, const Color3&, Float, Float, const void*) for - * light data defined by a range alone, and - * @ref LightData(Type, const Color3&, Float, const void*) for an + * @ref LightData(LightType, const Color3&, Float, Float, const void*) + * for light data defined by a range alone, and + * @ref LightData(LightType, const Color3&, Float, const void*) for an * implicit inverse square attenuation. See * @ref Trade-LightData-attenuation for more information. * - * For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set - * to @cpp 0.0_degf @ce and @ref outerConeAngle() to @cpp 90.0_degf @ce, - * and both are @cpp 360.0_degf @ce otherwise. Use - * @ref LightData(Type, const Color3&, Float, const Vector3&, Float, Rad, Rad, const void*) + * For a @ref LightType::Spot light, @ref innerConeAngle() is + * implicitly set to @cpp 0.0_degf @ce and @ref outerConeAngle() to + * @cpp 90.0_degf @ce, and both are @cpp 360.0_degf @ce otherwise. Use + * @ref LightData(LightType, const Color3&, Float, const Vector3&, Float, Rad, Rad, const void*) * in order to specify cone angles as well. */ - explicit LightData(Type type, const Color3& color, Float intensity, const Vector3& attenuation, Float range, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, const Vector3& attenuation, Float range, const void* importerState = nullptr) noexcept; /** * @brief Construct attenuation-based light data @@ -246,14 +262,15 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param attenuation Constant, linear and quadratic light * attenuation factor. Expected to be @cpp {1.0f, 0.0f, 0.0f} @ce - * for an @ref Type::Ambient and @ref Type::Directional light. + * for an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param innerConeAngle Inner cone angle. Expected to be greater * than or equal to @cpp 0.0_degf @ce and less than or equal to - * @p outerConeAngle for a @ref Type::Spot light, + * @p outerConeAngle for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param outerConeAngle Inner cone angle. Expected to be greater * than or equal to @p innerConeAngle and less than or equal to - * @cpp 360.0_degf @ce for a @ref Type::Spot light, + * @cpp 360.0_degf @ce for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param importerState Importer-specific state * @m_since_latest @@ -262,10 +279,10 @@ class MAGNUM_TRADE_EXPORT LightData { * @ref Trade-LightData-attenuation for more information. * * For lights other than spot it may be more convenient to use - * @ref LightData(Type, const Color3&, Float, const Vector3&, const void*) + * @ref LightData(LightType, const Color3&, Float, const Vector3&, const void*) * instead. */ - explicit LightData(Type type, const Color3& color, Float intensity, const Vector3& attenuation, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, const Vector3& attenuation, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; /** * @brief Construct attenuation-based light data with implicit cone angles @@ -274,20 +291,21 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param attenuation Constant, linear and quadratic light * attenuation factor. Expected to be @cpp {1.0f, 0.0f, 0.0f} @ce - * for an @ref Type::Ambient and @ref Type::Directional light. + * for an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param importerState Importer-specific state * @m_since_latest * * The @ref range() is implicitly set to @ref Constants::inf(). See * @ref Trade-LightData-attenuation for more information. * - * For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set - * to @cpp 0.0_degf @ce and @ref outerConeAngle() to @cpp 90.0_degf @ce, - * and both are @cpp 360.0_degf @ce otherwise. Use - * @ref LightData(Type, const Color3&, Float, const Vector3&, Rad, Rad, const void*) + * For a @ref LightType::Spot light, @ref innerConeAngle() is + * implicitly set to @cpp 0.0_degf @ce and @ref outerConeAngle() to + * @cpp 90.0_degf @ce, and both are @cpp 360.0_degf @ce otherwise. Use + * @ref LightData(LightType, const Color3&, Float, const Vector3&, Rad, Rad, const void*) * in order to specify cone angles as well. */ - explicit LightData(Type type, const Color3& color, Float intensity, const Vector3& attenuation, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, const Vector3& attenuation, const void* importerState = nullptr) noexcept; /** * @brief Construct range-based light data @@ -296,29 +314,30 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param range Light range, after which the intensity is * considered to be zero. Expected to be @ref Constants::inf() for - * an @ref Type::Ambient and @ref Type::Directional light. + * an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param innerConeAngle Inner cone angle. Expected to be greater * than or equal to @cpp 0.0_degf @ce and less than or equal to - * @p outerConeAngle for a @ref Type::Spot light, + * @p outerConeAngle for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param outerConeAngle Outer cone angle. Expected to be greater * than or equal to @p innerConeAngle and less than or equal to - * @cpp 360.0_degf @ce for a @ref Type::Spot light, + * @cpp 360.0_degf @ce for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param importerState Importer-specific state * @m_since_latest * * The @ref attenuation() is implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce - * for a @ref Type::Point and @ref Type::Spot light and to - * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref Type::Ambient and - * @ref Type::Directional light. See @ref Trade-LightData-attenuation - * for more information. + * for a @ref LightType::Point and @ref LightType::Spot light and to + * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref LightType::Ambient and + * @ref LightType::Directional light. See + * @ref Trade-LightData-attenuation for more information. * * For lights other than spot it may be more convenient to use - * @ref LightData(Type, const Color3&, Float, Float, const void*) + * @ref LightData(LightType, const Color3&, Float, Float, const void*) * instead. */ - explicit LightData(Type type, const Color3& color, Float intensity, Float range, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, Float range, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; /** * @brief Construct range-based light data with implicit cone angles @@ -327,23 +346,24 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param range Light range, after which the intensity is * considered to be zero. Expected to be @ref Constants::inf() for - * an @ref Type::Ambient and @ref Type::Directional light. + * an @ref LightType::Ambient and @ref LightType::Directional + * light. * @param importerState Importer-specific state * @m_since_latest * * The @ref attenuation() is implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce - * for a @ref Type::Point and @ref Type::Spot light and to - * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref Type::Ambient and - * @ref Type::Directional light. See @ref Trade-LightData-attenuation - * for more information. + * for a @ref LightType::Point and @ref LightType::Spot light and to + * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref LightType::Ambient and + * @ref LightType::Directional light. See + * @ref Trade-LightData-attenuation for more information. * - * For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set - * to @cpp 0.0_degf @ce and @ref outerConeAngle() to @cpp 90.0_degf @ce, - * and both are @cpp 360.0_degf @ce otherwise. Use - * @ref LightData(Type, const Color3&, Float, Float, Rad, Rad, const void*) + * For a @ref LightType::Spot light, @ref innerConeAngle() is + * implicitly set to @cpp 0.0_degf @ce and @ref outerConeAngle() to + * @cpp 90.0_degf @ce, and both are @cpp 360.0_degf @ce otherwise. Use + * @ref LightData(LightType, const Color3&, Float, Float, Rad, Rad, const void*) * in order to specify cone angles as well. */ - explicit LightData(Type type, const Color3& color, Float intensity, Float range, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, Float range, const void* importerState = nullptr) noexcept; /** * @brief Construct light data with implicit attenuation @@ -352,26 +372,27 @@ class MAGNUM_TRADE_EXPORT LightData { * @param intensity Light intensity * @param innerConeAngle Inner cone angle. Expected to be greater * than or equal to @cpp 0.0_degf @ce and less than or equal to - * @p outerConeAngle for a @ref Type::Spot light, + * @p outerConeAngle for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param outerConeAngle Outer cone angle. Expected to be greater * than or equal to @p innerConeAngle and less than or equal to - * @cpp 360.0_degf @ce for a @ref Type::Spot light, + * @cpp 360.0_degf @ce for a @ref LightType::Spot light, * @cpp 360.0_degf @ce otherwise. * @param importerState Importer-specific state * @m_since_latest * * The @ref attenuation() is implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce - * for a @ref Type::Point and @ref Type::Spot light and to - * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref Type::Ambient and - * @ref Type::Directional light; @ref range() is always + * for a @ref LightType::Point and @ref LightType::Spot light and to + * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref LightType::Ambient and + * @ref LightType::Directional light; @ref range() is always * @ref Constants::inf(). See @ref Trade-LightData-attenuation for more * information. * * For lights other than spot it may be more convenient to use - * @ref LightData(Type, const Color3&, Float, const void*) instead. + * @ref LightData(LightType, const Color3&, Float, const void*) + * instead. */ - explicit LightData(Type type, const Color3& color, Float intensity, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, Rad innerConeAngle, Rad outerConeAngle, const void* importerState = nullptr) noexcept; /** * @brief Construct light data with implicit attenuation and cone angles @@ -381,19 +402,19 @@ class MAGNUM_TRADE_EXPORT LightData { * @param importerState Importer-specific state * * The @ref attenuation() is implicitly set to @cpp {1.0f, 0.0f, 1.0f} @ce - * for a @ref Type::Point and @ref Type::Spot light and to - * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref Type::Ambient and - * @ref Type::Directional light; @ref range() is always + * for a @ref LightType::Point and @ref LightType::Spot light and to + * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref LightType::Ambient and + * @ref LightType::Directional light; @ref range() is always * @ref Constants::inf(). See @ref Trade-LightData-attenuation for more * information. * - * For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set - * to @cpp 0.0_degf @ce and @ref outerConeAngle() to @cpp 90.0_degf @ce, - * and both are @cpp 360.0_degf @ce otherwise. Use - * @ref LightData(Type, const Color3&, Float, Rad, Rad, const void*) in - * order to specify cone angles as well. + * For a @ref LightType::Spot light, @ref innerConeAngle() is + * implicitly set to @cpp 0.0_degf @ce and @ref outerConeAngle() to + * @cpp 90.0_degf @ce, and both are @cpp 360.0_degf @ce otherwise. Use + * @ref LightData(LightType, const Color3&, Float, Rad, Rad, const void*) + * in order to specify cone angles as well. */ - explicit LightData(Type type, const Color3& color, Float intensity, const void* importerState = nullptr) noexcept; + explicit LightData(LightType type, const Color3& color, Float intensity, const void* importerState = nullptr) noexcept; /** @brief Copying is not allowed */ LightData(const LightData&) = delete; @@ -408,7 +429,7 @@ class MAGNUM_TRADE_EXPORT LightData { LightData& operator=(LightData&&) noexcept = default; /** @brief Light type */ - Type type() const { return _type; } + LightType type() const { return _type; } /** @brief Light color */ Color3 color() const { return _color; } @@ -416,9 +437,9 @@ class MAGNUM_TRADE_EXPORT LightData { /** * @brief Light intensity * - * Defined in *candela* (lm/sr) for @ref Type::Point and - * @ref Type::Spot, and in *lux* (lm/m2) for - * @ref Type::Directional. + * Defined in *candela* (lm/sr) for @ref LightType::Point and + * @ref LightType::Spot, and in *lux* (lm/m2) for + * @ref LightType::Directional. */ Float intensity() const { return _intensity; } @@ -429,11 +450,11 @@ class MAGNUM_TRADE_EXPORT LightData { * Values of @f$ \color{m-success} K_c @f$, * @f$ \color{m-success} K_l @f$ and @f$ \color{m-success} K_q @f$ in * the @ref Trade-LightData-attenuation "attenuation equation". Always - * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref Type::Ambient and - * @ref Type::Directional light, set to @cpp {1.0f, 0.0f, 1.0f} @ce for - * range-based attenuation --- and if @ref range() is - * @ref Constants::inf() as well, the attenuation equation is simply - * @f$ F_{att} = \frac{1}{1 + d^2} @f$. + * @cpp {1.0f, 0.0f, 0.0f} @ce for an @ref LightType::Ambient and + * @ref LightType::Directional light, set to + * @cpp {1.0f, 0.0f, 1.0f} @ce for range-based attenuation --- and if + * @ref range() is @ref Constants::inf() as well, the attenuation + * equation is simply @f$ F_{att} = \frac{1}{1 + d^2} @f$. */ Vector3 attenuation() const { return _attenuation; } @@ -450,7 +471,8 @@ class MAGNUM_TRADE_EXPORT LightData { * - if @ref attenuation() is @cpp {1.0f, 0.0f, 0.0f} @ce, the * attenuation equation is @f$ F_{att} = 1 @f$. * - * The latter is always the case for a @ref Type::Directional light. + * The latter is always the case for a @ref LightType::Directional + * light. */ Float range() const { return _range; } @@ -458,9 +480,9 @@ class MAGNUM_TRADE_EXPORT LightData { * @brief Inner cone angle * @m_since_latest * - * For a @ref Type::Spot light, it's always less than - * @ref outerConeAngle(). For a @ref Type::Directional or - * @ref Type::Point light it's always @cpp 360.0_degf @ce. + * For a @ref LightType::Spot light, it's always less than + * @ref outerConeAngle(). For a @ref LightType::Directional or + * @ref LightType::Point light it's always @cpp 360.0_degf @ce. */ Rad innerConeAngle() const { return _innerConeAngle; } @@ -468,10 +490,10 @@ class MAGNUM_TRADE_EXPORT LightData { * @brief Outer cone angle * @m_since_latest * - * For a @ref Type::Spot light, it's always greater than + * For a @ref LightType::Spot light, it's always greater than * @ref outerConeAngle() and less than or equal to @cpp 90.0_degf @ce. - * For a @ref Type::Directional or @ref Type::Point light it's always - * @cpp 360.0_degf @ce. + * For a @ref LightType::Directional or @ref LightType::Point light + * it's always @cpp 360.0_degf @ce. */ Rad outerConeAngle() const { return _outerConeAngle; } @@ -483,7 +505,7 @@ class MAGNUM_TRADE_EXPORT LightData { const void* importerState() const { return _importerState; } private: - Type _type; + LightType _type; Vector3 _color; Float _intensity; Vector3 _attenuation; @@ -492,9 +514,6 @@ class MAGNUM_TRADE_EXPORT LightData { const void* _importerState; }; -/** @debugoperatorclassenum{LightData,LightData::Type} */ -MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, LightData::Type value); - }} #endif diff --git a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp index 4533ef836..fce7af7d8 100644 --- a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp @@ -1080,7 +1080,7 @@ void AbstractSceneConverterTest::thingNotSupported() { converter.setDefaultScene(0); converter.add(AnimationData{nullptr, nullptr}); - converter.add(LightData{LightData::Type::Point, {}, 0.0f}); + converter.add(LightData{LightType::Point, {}, 0.0f}); converter.add(CameraData{CameraType::Orthographic3D, {}, 0.0f, 1.0f}); converter.add(SkinData2D{nullptr, nullptr}); converter.add(SkinData3D{nullptr, nullptr}); @@ -2584,7 +2584,7 @@ void AbstractSceneConverterTest::thingNoBegin() { converter.add(AnimationData{nullptr, nullptr}); converter.lightCount(); - converter.add(LightData{LightData::Type::Point, {}, 0.0f}); + converter.add(LightData{LightType::Point, {}, 0.0f}); converter.cameraCount(); converter.add(CameraData{CameraType::Orthographic3D, {}, 0.0f, 1.0f}); @@ -3106,10 +3106,10 @@ void AbstractSceneConverterTest::addLight() { CORRADE_VERIFY(converter.begin()); CORRADE_COMPARE(converter.lightCount(), 0); - CORRADE_COMPARE(converter.add(LightData{LightData::Type::Point, {}, 0.0f, reinterpret_cast(0xdeadbeef)}, "hello"), 0); + CORRADE_COMPARE(converter.add(LightData{LightType::Point, {}, 0.0f, reinterpret_cast(0xdeadbeef)}, "hello"), 0); CORRADE_VERIFY(converter.addCalled); CORRADE_COMPARE(converter.lightCount(), 1); - CORRADE_COMPARE(converter.add(LightData{LightData::Type::Point, {}, 0.0f, reinterpret_cast(0xdeadbeef)}, "hello"), 1); + CORRADE_COMPARE(converter.add(LightData{LightType::Point, {}, 0.0f, reinterpret_cast(0xdeadbeef)}, "hello"), 1); CORRADE_COMPARE(converter.lightCount(), 2); } @@ -3134,7 +3134,7 @@ void AbstractSceneConverterTest::addLightFailed() { { std::ostringstream out; Error redirectError{&out}; - CORRADE_VERIFY(!converter.add(LightData{LightData::Type::Point, {}, 0.0f})); + CORRADE_VERIFY(!converter.add(LightData{LightType::Point, {}, 0.0f})); CORRADE_COMPARE(out.str(), ""); } @@ -3159,7 +3159,7 @@ void AbstractSceneConverterTest::addLightNotImplemented() { std::ostringstream out; Error redirectError{&out}; - converter.add(LightData{LightData::Type::Point, {}, 0.0f}); + converter.add(LightData{LightType::Point, {}, 0.0f}); CORRADE_COMPARE(out.str(), "Trade::AbstractSceneConverter::add(): light conversion advertised but not implemented\n"); } @@ -5926,7 +5926,7 @@ void AbstractSceneConverterTest::addImporterContents() { return Utility::format("Light {}", id); } Containers::Optional doLight(UnsignedInt id) override { - return LightData{LightData::Type::Point, {}, {}, reinterpret_cast(0x11600000 + id)}; + return LightData{LightType::Point, {}, {}, reinterpret_cast(0x11600000 + id)}; } UnsignedInt doCameraCount() const override { @@ -6355,7 +6355,7 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { } Containers::Optional doLight(UnsignedInt id) override { if(id == 2) return {}; - return LightData{LightData::Type::Point, {}, {}}; + return LightData{LightType::Point, {}, {}}; } UnsignedInt doCameraCount() const override { @@ -6597,7 +6597,7 @@ void AbstractSceneConverterTest::addImporterContentsConversionFail() { return 4; } Containers::Optional doLight(UnsignedInt) override { - return LightData{LightData::Type::Point, {}, {}}; + return LightData{LightType::Point, {}, {}}; } UnsignedInt doCameraCount() const override { @@ -7160,7 +7160,7 @@ void AbstractSceneConverterTest::addSupportedImporterContents() { UnsignedInt doLightCount() const override { return 4; } Containers::Optional doLight(UnsignedInt) override { - return LightData{LightData::Type::Point, {}, {}}; + return LightData{LightType::Point, {}, {}}; } UnsignedInt doCameraCount() const override { return 5; } diff --git a/src/Magnum/Trade/Test/LightDataTest.cpp b/src/Magnum/Trade/Test/LightDataTest.cpp index c285c59d6..b9a6c5df4 100644 --- a/src/Magnum/Trade/Test/LightDataTest.cpp +++ b/src/Magnum/Trade/Test/LightDataTest.cpp @@ -53,35 +53,35 @@ using namespace Math::Literals; const struct { const char* name; - LightData::Type type; + LightType type; Vector3 attenuation; Float range; Rad innerConeAngle; Rad outerConeAngle; const char* message; } ConstructInvalidData[] { - {"invalid ambient attenuation", LightData::Type::Ambient, + {"invalid ambient attenuation", LightType::Ambient, {1.0f, 0.0f, 1.0f}, Constants::inf(), 360.0_degf, 360.0_degf, "attenuation has to be (1, 0, 0) for an ambient or directional light but got Vector(1, 0, 1)"}, - {"invalid directional attenuation", LightData::Type::Directional, + {"invalid directional attenuation", LightType::Directional, {1.0f, 0.0f, 1.0f}, Constants::inf(), 360.0_degf, 360.0_degf, "attenuation has to be (1, 0, 0) for an ambient or directional light but got Vector(1, 0, 1)"}, - {"invalid ambient range", LightData::Type::Ambient, + {"invalid ambient range", LightType::Ambient, {1.0f, 0.0f, 0.0f}, 2.0f, 360.0_degf, 360.0_degf, "range has to be infinity for an ambient or directional light but got 2"}, - {"invalid directional range", LightData::Type::Directional, + {"invalid directional range", LightType::Directional, {1.0f, 0.0f, 0.0f}, 2.0f, 360.0_degf, 360.0_degf, "range has to be infinity for an ambient or directional light but got 2"}, - {"invalid point angles", LightData::Type::Point, + {"invalid point angles", LightType::Point, {1.0f, 0.0f, 1.0f}, Constants::inf(), 15.0_degf, 90.0_degf, "cone angles have to be 360° for lights that aren't spot but got Deg(15) and Deg(90)"}, - {"negative inner spot angle", LightData::Type::Spot, + {"negative inner spot angle", LightType::Spot, {1.0f, 0.0f, 1.0f}, Constants::inf(), -1.0_degf, 90.0_degf, "spot light inner and outer cone angles have to be in range [0°, 360°] and inner not larger than outer but got Deg(-1) and Deg(90)"}, - {"too big outer spot angle", LightData::Type::Spot, + {"too big outer spot angle", LightType::Spot, {1.0f, 0.0f, 1.0f}, Constants::inf(), 0.0_degf, 361.0_degf, "spot light inner and outer cone angles have to be in range [0°, 360°] and inner not larger than outer but got Deg(0) and Deg(361)"}, - {"inner spot angle larger than outer", LightData::Type::Spot, + {"inner spot angle larger than outer", LightType::Spot, {1.0f, 0.0f, 1.0f}, Constants::inf(), 35.0_degf, 30.0_degf, "spot light inner and outer cone angles have to be in range [0°, 360°] and inner not larger than outer but got Deg(35) and Deg(30)"} }; @@ -105,13 +105,13 @@ LightDataTest::LightDataTest() { void LightDataTest::construct() { { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, 15.0f, 15.0_degf, 35.0_degf, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -123,12 +123,12 @@ void LightDataTest::construct() { /* Implicit spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, 15.0f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -140,12 +140,12 @@ void LightDataTest::construct() { /* Implicit non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Point, + LightData data{LightType::Point, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, 15.0f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Point); + CORRADE_COMPARE(data.type(), LightType::Point); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -160,13 +160,13 @@ void LightDataTest::constructAttenuation() { /* Implicit range */ { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, 15.0_degf, 35.0_degf, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -178,12 +178,12 @@ void LightDataTest::constructAttenuation() { /* Implicit range + spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -195,12 +195,12 @@ void LightDataTest::constructAttenuation() { /* Implicit range + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Point, + LightData data{LightType::Point, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Point); + CORRADE_COMPARE(data.type(), LightType::Point); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -215,13 +215,13 @@ void LightDataTest::constructRange() { /* Implicit attenuation for a spot */ { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, 15.0f, 15.0_degf, 35.0_degf, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -233,12 +233,12 @@ void LightDataTest::constructRange() { /* Implicit attenuation for a spot + spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, 15.0f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -250,12 +250,12 @@ void LightDataTest::constructRange() { /* Implicit attenuation for a point + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Point, + LightData data{LightType::Point, 0xccff33_rgbf, 0.8f, 15.0f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Point); + CORRADE_COMPARE(data.type(), LightType::Point); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -267,12 +267,12 @@ void LightDataTest::constructRange() { /* Implicit attenuation for an ambient + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Ambient, + LightData data{LightType::Ambient, 0xccff33_rgbf, 0.8f, Constants::inf(), &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Ambient); + CORRADE_COMPARE(data.type(), LightType::Ambient); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 0.0f})); @@ -284,12 +284,12 @@ void LightDataTest::constructRange() { /* Implicit attenuation for a directional + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Directional, + LightData data{LightType::Directional, 0xccff33_rgbf, 0.8f, Constants::inf(), &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Directional); + CORRADE_COMPARE(data.type(), LightType::Directional); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 0.0f})); @@ -304,12 +304,12 @@ void LightDataTest::constructNone() { /* Implicit attenuation + range for a spot */ { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, 15.0_degf, 35.0_degf, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -321,11 +321,11 @@ void LightDataTest::constructNone() { /* Implicit attenuation + range for a spot + spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Spot, + LightData data{LightType::Spot, 0xccff33_rgbf, 0.8f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Spot); + CORRADE_COMPARE(data.type(), LightType::Spot); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -337,11 +337,11 @@ void LightDataTest::constructNone() { /* Implicit attenuation + range for a point + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Point, + LightData data{LightType::Point, 0xccff33_rgbf, 0.8f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Point); + CORRADE_COMPARE(data.type(), LightType::Point); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); @@ -353,11 +353,11 @@ void LightDataTest::constructNone() { /* Implicit attenuation for an ambient + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Ambient, + LightData data{LightType::Ambient, 0xccff33_rgbf, 0.8f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Ambient); + CORRADE_COMPARE(data.type(), LightType::Ambient); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 0.0f})); @@ -369,11 +369,11 @@ void LightDataTest::constructNone() { /* Implicit attenuation for a directional + non-spot angles */ } { int a{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData data{LightData::Type::Directional, + LightData data{LightType::Directional, 0xccff33_rgbf, 0.8f, &a}; - CORRADE_COMPARE(data.type(), LightData::Type::Directional); + CORRADE_COMPARE(data.type(), LightType::Directional); CORRADE_COMPARE(data.color(), 0xccff33_rgbf); CORRADE_COMPARE(data.intensity(), 0.8f); CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 0.0f})); @@ -403,14 +403,14 @@ void LightDataTest::constructCopy() { void LightDataTest::constructMove() { int state{}; /* GCC 11 complains that "maybe uninitialized" w/o the {} */ - LightData a{LightData::Type::Spot, + LightData a{LightType::Spot, 0xccff33_rgbf, 0.8f, {0.1f, 0.5f, 0.7f}, 15.0f, 15.0_degf, 35.0_degf, &state}; LightData b{std::move(a)}; - CORRADE_COMPARE(b.type(), LightData::Type::Spot); + CORRADE_COMPARE(b.type(), LightType::Spot); CORRADE_COMPARE(b.color(), 0xccff33_rgbf); CORRADE_COMPARE(b.intensity(), 0.8f); CORRADE_COMPARE(b.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -421,7 +421,7 @@ void LightDataTest::constructMove() { LightData c{{}, {}, {}}; c = std::move(a); - CORRADE_COMPARE(c.type(), LightData::Type::Spot); + CORRADE_COMPARE(c.type(), LightType::Spot); CORRADE_COMPARE(c.color(), 0xccff33_rgbf); CORRADE_COMPARE(c.intensity(), 0.8f); CORRADE_COMPARE(c.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); @@ -437,15 +437,15 @@ void LightDataTest::constructMove() { void LightDataTest::debugType() { std::ostringstream out; - Debug(&out) << LightData::Type::Spot << LightData::Type(0xbe); - CORRADE_COMPARE(out.str(), "Trade::LightData::Type::Spot Trade::LightData::Type(0xbe)\n"); + Debug(&out) << LightType::Spot << LightType(0xbe); + CORRADE_COMPARE(out.str(), "Trade::LightType::Spot Trade::LightType(0xbe)\n"); } void LightDataTest::debugTypePacked() { std::ostringstream out; /* Last is not packed, ones before should not make any flags persistent */ - Debug(&out) << Debug::packed << LightData::Type::Spot << Debug::packed << LightData::Type(0xbe) << LightData::Type::Ambient; - CORRADE_COMPARE(out.str(), "Spot 0xbe Trade::LightData::Type::Ambient\n"); + Debug(&out) << Debug::packed << LightType::Spot << Debug::packed << LightType(0xbe) << LightType::Ambient; + CORRADE_COMPARE(out.str(), "Spot 0xbe Trade::LightType::Ambient\n"); } }}}} diff --git a/src/Magnum/Trade/Trade.h b/src/Magnum/Trade/Trade.h index 9dc14db6c..6512e2a2b 100644 --- a/src/Magnum/Trade/Trade.h +++ b/src/Magnum/Trade/Trade.h @@ -82,6 +82,7 @@ typedef ImageData<1> ImageData1D; typedef ImageData<2> ImageData2D; typedef ImageData<3> ImageData3D; +enum class LightType: UnsignedByte; class LightData; enum class MeshAttribute: UnsignedShort;