diff options
Diffstat (limited to 'src/math.hpp')
-rw-r--r-- | src/math.hpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/math.hpp b/src/math.hpp index dc077e1..9b909cf 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -269,6 +269,13 @@ public: } template <typename U> + operator sf::Vector3<U>() const + { + static_assert(N == 3, "conversion of vec_t with N != 3 to sf::Vector3"); + return sf::Vector3<U>((U)v[0], (U)v[1], (U)v[2]); + } + + template <typename U> vec_t(sf::Vector2<U> b) { static_assert(N == 2, "conversion of sf::Vector2 to vec_t with N != 2"); @@ -276,6 +283,15 @@ public: v[1] = b.y; } + template <typename U> + vec_t(sf::Vector3<U> b) + { + static_assert(N == 3, "conversion of sf::Vector2 to vec_t with N != 3"); + v[0] = b.x; + v[1] = b.y; + v[2] = b.z; + } + // Compatibility with iostream friend std::ostream& operator<<(std::ostream& stream, vec_t<T, N> v) @@ -405,7 +421,5 @@ public: // Shorthands typedef vec_t<float, 2> v2f_t; -typedef vec_t<double, 2> v2d_t; +typedef vec_t<float, 3> v3f_t; typedef rect_t<float, 2> rectf_t; -typedef rect_t<double, 2> rectd_t; - |