summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/BasicMath.hpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/Common/interface/BasicMath.hpp b/Common/interface/BasicMath.hpp
index afc48ceb..9f748c78 100644
--- a/Common/interface/BasicMath.hpp
+++ b/Common/interface/BasicMath.hpp
@@ -211,14 +211,18 @@ template <class T> struct Vector2
y >= right.y ? static_cast<T>(1) : static_cast<T>(0));
}
+ T* data() { return reinterpret_cast<T*>(this); }
+
+ const T* data() const { return reinterpret_cast<const T*>(this); }
+
T& operator[](size_t index)
{
- return reinterpret_cast<T*>(this)[index];
+ return data()[index];
}
const T& operator[](size_t index) const
{
- return reinterpret_cast<const T*>(this)[index];
+ return data()[index];
}
Vector2() :
@@ -409,14 +413,18 @@ template <class T> struct Vector3
z >= right.z ? static_cast<T>(1) : static_cast<T>(0));
}
+ T* data() { return reinterpret_cast<T*>(this); }
+
+ const T* data() const { return reinterpret_cast<const T*>(this); }
+
T& operator[](size_t index)
{
- return reinterpret_cast<T*>(this)[index];
+ return data()[index];
}
const T& operator[](size_t index) const
{
- return reinterpret_cast<const T*>(this)[index];
+ return data()[index];
}
Vector3() :
@@ -621,14 +629,18 @@ template <class T> struct Vector4
w >= right.w ? static_cast<T>(1) : static_cast<T>(0));
}
+ T* data() { return reinterpret_cast<T*>(this); }
+
+ const T* data() const { return reinterpret_cast<const T*>(this); }
+
T& operator[](size_t index)
{
- return reinterpret_cast<T*>(this)[index];
+ return data()[index];
}
const T& operator[](size_t index) const
{
- return reinterpret_cast<const T*>(this)[index];
+ return data()[index];
}
Vector4() :
@@ -744,6 +756,11 @@ template <class T> struct Matrix2x2
return m[row];
}
+ T* data() { return (*this)[0]; }
+
+ const T* data() const { return (*this)[0]; }
+
+
Matrix2x2& operator*=(T s)
{
for (int i = 0; i < 4; ++i)
@@ -906,6 +923,10 @@ template <class T> struct Matrix3x3
return m[row];
}
+ T* data() { return (*this)[0]; }
+
+ const T* data() const { return (*this)[0]; }
+
Matrix3x3& operator*=(T s)
{
for (int i = 0; i < 9; ++i)
@@ -1096,6 +1117,10 @@ template <class T> struct Matrix4x4
return m[row];
}
+ T* data() { return (*this)[0]; }
+
+ const T* data() const { return (*this)[0]; }
+
Matrix4x4& operator*=(T s)
{
for (int i = 0; i < 16; ++i)