Browse Source

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.
pull/481/head
Vladimír Vondruš 6 years ago
parent
commit
9fa90997ac
  1. 2
      src/Magnum/Trade/LightData.cpp
  2. 14
      src/Magnum/Trade/LightData.h
  3. 8
      src/Magnum/Trade/Test/LightDataTest.cpp

2
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, 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 ? 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} {} 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 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} {}

14
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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @cpp 360.0_degf @ce otherwise.
@ -231,7 +231,7 @@ class MAGNUM_TRADE_EXPORT LightData {
* @ref Trade-LightData-attenuation for more information. * @ref Trade-LightData-attenuation for more information.
* *
* For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set * 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 * and both are @cpp 360.0_degf @ce otherwise. Use
* @ref LightData(Type, const Color3&, Float, const Vector3&, Float, Rad, Rad, const void*) * @ref LightData(Type, const Color3&, Float, const Vector3&, Float, Rad, Rad, const void*)
* in order to specify cone angles as well. * in order to specify cone angles as well.
@ -281,7 +281,7 @@ class MAGNUM_TRADE_EXPORT LightData {
* @ref Trade-LightData-attenuation for more information. * @ref Trade-LightData-attenuation for more information.
* *
* For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set * 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 * and both are @cpp 360.0_degf @ce otherwise. Use
* @ref LightData(Type, const Color3&, Float, const Vector3&, Rad, Rad, const void*) * @ref LightData(Type, const Color3&, Float, const Vector3&, Rad, Rad, const void*)
* in order to specify cone angles as well. * 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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @cpp 360.0_degf @ce otherwise.
@ -337,7 +337,7 @@ class MAGNUM_TRADE_EXPORT LightData {
* for more information. * for more information.
* *
* For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set * 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 * and both are @cpp 360.0_degf @ce otherwise. Use
* @ref LightData(Type, const Color3&, Float, Float, Rad, Rad, const void*) * @ref LightData(Type, const Color3&, Float, Float, Rad, Rad, const void*)
* in order to specify cone angles as well. * 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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @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 * 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 Type::Spot light,
* @cpp 360.0_degf @ce otherwise. * @cpp 360.0_degf @ce otherwise.
@ -387,7 +387,7 @@ class MAGNUM_TRADE_EXPORT LightData {
* information. * information.
* *
* For a @ref Type::Spot light, @ref innerConeAngle() is implicitly set * 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 * and both are @cpp 360.0_degf @ce otherwise. Use
* @ref LightData(Type, const Color3&, Float, Rad, Rad, const void*) in * @ref LightData(Type, const Color3&, Float, Rad, Rad, const void*) in
* order to specify cone angles as well. * order to specify cone angles as well.

8
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.attenuation(), (Vector3{0.1f, 0.5f, 0.7f}));
CORRADE_COMPARE(data.range(), 15.0f); CORRADE_COMPARE(data.range(), 15.0f);
CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); 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); CORRADE_COMPARE(data.importerState(), &a);
/* Implicit non-spot angles */ /* 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.attenuation(), (Vector3{0.1f, 0.5f, 0.7f}));
CORRADE_COMPARE(data.range(), Constants::inf()); CORRADE_COMPARE(data.range(), Constants::inf());
CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); 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); CORRADE_COMPARE(data.importerState(), &a);
/* Implicit range + non-spot angles */ /* 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.attenuation(), (Vector3{1.0f, 0.0f, 1.0f}));
CORRADE_COMPARE(data.range(), 15.0f); CORRADE_COMPARE(data.range(), 15.0f);
CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); 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); CORRADE_COMPARE(data.importerState(), &a);
/* Implicit attenuation for a point + non-spot angles */ /* 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.attenuation(), (Vector3{1.0f, 0.0f, 1.0f}));
CORRADE_COMPARE(data.range(), Constants::inf()); CORRADE_COMPARE(data.range(), Constants::inf());
CORRADE_COMPARE(data.innerConeAngle(), 0.0_degf); 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); CORRADE_COMPARE(data.importerState(), &a);
/* Implicit attenuation + range for a point + non-spot angles */ /* Implicit attenuation + range for a point + non-spot angles */

Loading…
Cancel
Save