From 120286a9309d63971314332a4881569d5248781c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 30 Jun 2021 12:30:56 +0200 Subject: [PATCH] Add Degh, Radh and Range*Dh typedefs. We have half-float vectors and matrices, so why not these as well. Not sure for what all is the angle precision usable, but at the very least it could be useful for compact meshlet occlusion cone / AABB representation or rough animations. --- doc/changelog.dox | 2 ++ src/Magnum/Magnum.h | 30 ++++++++++++++++++++++++++++++ src/Magnum/Math/Angle.h | 4 ++-- src/Magnum/Math/Range.h | 12 ++++++------ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 55a855c53..ac6332885 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -51,6 +51,8 @@ See also: including mapping to @ref GL::PixelFormat / @ref GL::PixelType, @ref GL::TextureFormat and @ref Vk::PixelFormat and (partial) support in @ref DebugTools::CompareImage +- New @ref Degh, @ref Radh, @ref Range1Dh, @ref Range2Dh and @ref Range3Dh + typedefs for half-float angles and ranges @subsubsection changelog-latest-new-debugtools DebugTools library diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 82fc79e15..12d7688cc 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -967,6 +967,36 @@ typedef Math::Matrix4x3 Matrix4x3h; */ typedef Math::Matrix4x4 Matrix4x4h; +/** +@brief Angle in half-float degrees +@m_since_latest +*/ +typedef Math::Deg Degh; + +/** +@brief Angle in half-float radians +@m_since_latest +*/ +typedef Math::Rad Radh; + +/** +@brief One-dimensional half-float range +@m_since_latest +*/ +typedef Math::Range1D Range1Dh; + +/** +@brief Two-dimensional half-float range +@m_since_latest +*/ +typedef Math::Range2D Range2Dh; + +/** +@brief Three-dimensional half-float range +@m_since_latest +*/ +typedef Math::Range3D Range3Dh; + /* Since 1.8.17, the original short-hand group closing doesn't work anymore. FFS. */ /** diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index 9edb499c7..13f4e70d8 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -94,7 +94,7 @@ These silent errors are easily avoided by requiring explicit conversions: @snippet MagnumMath.cpp Deg-usage-explicit-conversion -@see @ref Magnum::Deg, @ref Magnum::Degd +@see @ref Magnum::Deg, @ref Magnum::Degh, @ref Magnum::Degd */ template class Deg: public Unit { public: @@ -166,7 +166,7 @@ constexpr Deg operator "" _degf(long double value) { return Deg(Fl @brief Angle in radians See @ref Deg for more information. -@see @ref Magnum::Rad, @ref Magnum::Radd +@see @ref Magnum::Rad, @ref Magnum::Radh, @ref Magnum::Radd */ template class Rad: public Unit { public: diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index 10e2333e6..91c7d21b9 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -348,8 +348,8 @@ template class Range { Convenience alternative to @cpp Range<1, T> @ce. See @ref Range for more information. -@see @ref Range2D, @ref Range3D, @ref Magnum::Range1D, @ref Magnum::Range1Di, - @ref Magnum::Range1Dd +@see @ref Range2D, @ref Range3D, @ref Magnum::Range1D, @ref Magnum::Range1Dh, + @ref Magnum::Range1Dd, @ref Magnum::Range1Di */ #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */ template using Range1D = Range<1, T>; @@ -359,8 +359,8 @@ template using Range1D = Range<1, T>; @brief Two-dimensional range See @ref Range for more information. -@see @ref Range1D, @ref Range3D, @ref Magnum::Range2D, @ref Magnum::Range2Di, - @ref Magnum::Range2Dd +@see @ref Range1D, @ref Range3D, @ref Magnum::Range2D, @ref Magnum::Range2Dh, + @ref Magnum::Range2Dd, @ref Magnum::Range2Di */ template class Range2D: public Range<2, T> { public: @@ -513,8 +513,8 @@ template class Range2D: public Range<2, T> { @brief Three-dimensional range See @ref Range for more information. -@see @ref Range1D, @ref Range2D, @ref Magnum::Range3D, @ref Magnum::Range3Di, - @ref Magnum::Range3Dd +@see @ref Range1D, @ref Range2D, @ref Magnum::Range3D, @ref Magnum::Range3Dh, + @ref Magnum::Range3Dd, @ref Magnum::Range3Di */ template class Range3D: public Range<3, T> { public: