summaryrefslogtreecommitdiff
path: root/src/math.hpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-03-31 16:04:04 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-03-31 16:04:04 +0200
commitd72e8d61de2f7efba3685dda2dc52b31f64f8a6e (patch)
tree2cda01dcc5b0e17fcf109469ac99296c2212346b /src/math.hpp
parentd87217dffc1582b8dbed10da62b3b4d3f7b511de (diff)
3D audio.
Diffstat (limited to 'src/math.hpp')
-rw-r--r--src/math.hpp20
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;
-