From 9fa90997acbf3a2b2b31ed71b6dae014d6ebe7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 22 Oct 2020 12:52:32 +0200 Subject: [PATCH] Trade: fix cone angle defaults in LightData. Those were initially implemented and documented when I thought glTF uses a full cone angle, and I forgot to update them once I discovered glTF has a half-angle. This is thus now consistent with glTF defaults again. --- src/Magnum/Trade/LightData.cpp | 2 +- src/Magnum/Trade/LightData.h | 14 +++++++------- src/Magnum/Trade/Test/LightDataTest.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Trade/LightData.cpp b/src/Magnum/Trade/LightData.cpp index 36fb5aca7..f506b8b19 100644 --- a/src/Magnum/Trade/LightData.cpp +++ b/src/Magnum/Trade/LightData.cpp @@ -42,7 +42,7 @@ LightData::LightData(const Type type, const Color3& color, const Float intensity 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 ? 45.0_degf : 360.0_degf, + type == Type::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} {} diff --git a/src/Magnum/Trade/LightData.h b/src/Magnum/Trade/LightData.h index b4bef1fd3..b63c2f167 100644 --- a/src/Magnum/Trade/LightData.h +++ b/src/Magnum/Trade/LightData.h @@ -185,7 +185,7 @@ class MAGNUM_TRADE_EXPORT LightData { * than or equal to @cpp 0.0_degf @ce and less than or equal to * @p outerConeAngle for a @ref Type::Spot light, * @cpp 360.0_degf @ce otherwise. - * @param outerConeAngle Inner cone angle. Expected to be greater + * @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 otherwise. @@ -231,7 +231,7 @@ class MAGNUM_TRADE_EXPORT LightData { * @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 45.0_degf @ce, + * 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*) * in order to specify cone angles as well. @@ -281,7 +281,7 @@ class MAGNUM_TRADE_EXPORT LightData { * @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 45.0_degf @ce, + * 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*) * in order to specify cone angles as well. @@ -300,7 +300,7 @@ class MAGNUM_TRADE_EXPORT LightData { * than or equal to @cpp 0.0_degf @ce and less than or equal to * @p outerConeAngle for a @ref Type::Spot light, * @cpp 360.0_degf @ce otherwise. - * @param outerConeAngle Inner cone angle. Expected to be greater + * @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 otherwise. @@ -337,7 +337,7 @@ class MAGNUM_TRADE_EXPORT LightData { * 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 45.0_degf @ce, + * 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*) * in order to specify cone angles as well. @@ -353,7 +353,7 @@ class MAGNUM_TRADE_EXPORT LightData { * than or equal to @cpp 0.0_degf @ce and less than or equal to * @p outerConeAngle for a @ref Type::Spot light, * @cpp 360.0_degf @ce otherwise. - * @param outerConeAngle Inner cone angle. Expected to be greater + * @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 otherwise. @@ -387,7 +387,7 @@ class MAGNUM_TRADE_EXPORT LightData { * information. * * For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set - * to @cpp 0.0_degf @ce and @ref outerConeAngle() to @cpp 45.0_degf @ce, + * 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. diff --git a/src/Magnum/Trade/Test/LightDataTest.cpp b/src/Magnum/Trade/Test/LightDataTest.cpp index 69d56b4a4..b339f9662 100644 --- a/src/Magnum/Trade/Test/LightDataTest.cpp +++ b/src/Magnum/Trade/Test/LightDataTest.cpp @@ -132,7 +132,7 @@ void LightDataTest::construct() { CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); CORRADE_COMPARE(data.range(), 15.0f); CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); - CORRADE_COMPARE(data.outerConeAngle(), 45.0_degf); + CORRADE_COMPARE(data.outerConeAngle(), 90.0_degf); CORRADE_COMPARE(data.importerState(), &a); /* Implicit non-spot angles */ @@ -187,7 +187,7 @@ void LightDataTest::constructAttenuation() { CORRADE_COMPARE(data.attenuation(), (Vector3{0.1f, 0.5f, 0.7f})); CORRADE_COMPARE(data.range(), Constants::inf()); CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); - CORRADE_COMPARE(data.outerConeAngle(), 45.0_degf); + CORRADE_COMPARE(data.outerConeAngle(), 90.0_degf); CORRADE_COMPARE(data.importerState(), &a); /* Implicit range + non-spot angles */ @@ -242,7 +242,7 @@ void LightDataTest::constructRange() { CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); CORRADE_COMPARE(data.range(), 15.0f); CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); - CORRADE_COMPARE(data.outerConeAngle(), 45.0_degf); + CORRADE_COMPARE(data.outerConeAngle(), 90.0_degf); CORRADE_COMPARE(data.importerState(), &a); /* Implicit attenuation for a point + non-spot angles */ @@ -329,7 +329,7 @@ void LightDataTest::constructNone() { CORRADE_COMPARE(data.attenuation(), (Vector3{1.0f, 0.0f, 1.0f})); CORRADE_COMPARE(data.range(), Constants::inf()); CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); - CORRADE_COMPARE(data.outerConeAngle(), 45.0_degf); + CORRADE_COMPARE(data.outerConeAngle(), 90.0_degf); CORRADE_COMPARE(data.importerState(), &a); /* Implicit attenuation + range for a point + non-spot angles */