diff --git a/src/matrix.h b/src/matrix.h index d8d96508..ff4aa579 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -16,21 +16,30 @@ #if !defined __DH_MATRIX_H__ #define __DH_MATRIX_H__ -struct Float2 +template struct Vector2 { - Float2() { x = y = 0.0f; } - Float2(float _x, float _y) { x = _x; y = _y; } + Vector2() { x = y = 0; } + Vector2(T _x, T _y) { x = _x; y = _y; } - float x, y; + union { T x; T a; T i; }; + union { T y; T b; T j; }; }; -struct Float3 +typedef Vector2 Float2; +typedef Vector2 Int2; + +template struct Vector3 { - Float3() { x = y = z = 0.0f; } - Float3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; } + Vector3() { x = y = z = 0; } + Vector3(T _x, T _y, T _z) { x = _x; y = _y; z = _z; } - float x, y, z; + union { T x; T a; T i; }; + union { T y; T b; T j; }; + union { T z; T c; T k; }; }; +typedef Vector3 Float3; +typedef Vector3 Int3; + #endif // __DH_MATRIX_H__