From d2b1d51ecbd5e76c7bd6e9a9db358fe122ad696e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Oct 2018 00:07:50 +0200 Subject: [PATCH] Math/Angle: Replace conversion constructors by conversion operators --- include/Nazara/Math/Angle.hpp | 7 +++-- include/Nazara/Math/Angle.inl | 48 ++++++++++++++++------------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/include/Nazara/Math/Angle.hpp b/include/Nazara/Math/Angle.hpp index fe559e958..d65dc7c4f 100644 --- a/include/Nazara/Math/Angle.hpp +++ b/include/Nazara/Math/Angle.hpp @@ -27,8 +27,6 @@ namespace Nz public: Angle() = default; Angle(T value); - template> explicit Angle(const Angle& value) { Set(value); } - template> explicit Angle(const Angle& value) { Set(value); } template explicit Angle(const Angle& Angle); Angle(const Angle&) = default; ~Angle() = default; @@ -42,8 +40,6 @@ namespace Nz void Normalize(); - template> Angle& Set(const Angle& ang); - template> Angle& Set(const Angle& ang); Angle& Set(const Angle& ang); template Angle& Set(const Angle& ang); @@ -55,6 +51,9 @@ namespace Nz Angle ToRadianAngle() const; String ToString() const; + template> operator Angle(); + template> operator Angle(); + Angle& operator=(const Angle&) = default; Angle operator+(const Angle& other) const; diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index 855987a4a..d50bcb6d1 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -236,32 +236,6 @@ namespace Nz value += twoLimit; } - /*! - * \brief Changes the angle value by converting a radian angle - * - * \param Angle Radian angle which will be converted - */ - template - template - Angle& Angle::Set(const Angle& ang) - { - value = RadianToDegree(ang.value); - return *this; - } - - /*! - * \brief Changes the angle value by converting a degree angle - * - * \param Angle Degree angle which will be converted - */ - template - template - Angle& Angle::Set(const Angle& ang) - { - value = DegreeToRadian(ang.value); - return *this; - } - /*! * \brief Copies the angle value of an angle * @@ -367,6 +341,28 @@ namespace Nz return Detail::AngleUtils::ToString(value); } + /*! + * \brief Returns the degree angle that is equivalent to this one + * \return Equivalent degree angle + */ + template + template + Angle::operator Angle() + { + return ToDegreeAngle(); + } + + /*! + * \brief Converts the angle to a string representation + * \return String representation of the angle + */ + template + template + Angle::operator Angle() + { + return ToRadianAngle(); + } + /*! * \brief Addition operator * \return Adds two angles together