From 7547458efc4e324a609c9beccb4f4dbd42adec38 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 19 Jan 2011 12:34:12 +0000 Subject: [PATCH] Float2 and Float3 are now templates, thus creating Int2 and Int3. --- src/matrix.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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__