Changeset 232


Ignore:
Timestamp:
Jan 19, 2011, 1:34:12 PM (10 years ago)
Author:
sam
Message:

Float2 and Float3 are now templates, thus creating Int2 and Int3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/matrix.h

    r221 r232  
    1717#define __DH_MATRIX_H__
    1818
    19 struct Float2
     19template <typename T> struct Vector2
    2020{
    21     Float2() { x = y = 0.0f; }
    22     Float2(float _x, float _y) { x = _x; y = _y; }
     21    Vector2() { x = y = 0; }
     22    Vector2(T _x, T _y) { x = _x; y = _y; }
    2323
    24     float x, y;
     24    union { T x; T a; T i; };
     25    union { T y; T b; T j; };
    2526};
    2627
    27 struct Float3
     28typedef Vector2<float> Float2;
     29typedef Vector2<int> Int2;
     30
     31template <typename T> struct Vector3
    2832{
    29     Float3() { x = y = z = 0.0f; }
    30     Float3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }
     33    Vector3() { x = y = z = 0; }
     34    Vector3(T _x, T _y, T _z) { x = _x; y = _y; z = _z; }
    3135
    32     float x, y, z;
     36    union { T x; T a; T i; };
     37    union { T y; T b; T j; };
     38    union { T z; T c; T k; };
    3339};
     40
     41typedef Vector3<float> Float3;
     42typedef Vector3<int> Int3;
    3443
    3544#endif // __DH_MATRIX_H__
Note: See TracChangeset for help on using the changeset viewer.