Browse Source

Fix a few warnings here and there, and try to use the vector classes.

legacy
Sam Hocevar sam 14 years ago
parent
commit
502deb7597
2 changed files with 18 additions and 4 deletions
  1. +1
    -4
      src/input.cpp
  2. +17
    -0
      src/matrix.h

+ 1
- 4
src/input.cpp View File

@@ -57,10 +57,7 @@ float2 Input::GetAxis(int axis)
f.x += left;
f.y += up;
if (left && up)
{
f.x *= invsqrt2;
f.y *= invsqrt2;
}
f = f * invsqrt2;

return f;
}


+ 17
- 0
src/matrix.h View File

@@ -46,6 +46,15 @@
return ret; \
}

#define CAST_OP(elems, dest) \
inline operator Vec##dest<T>() const \
{ \
Vec##dest<T> ret; \
for (int n = 0; n < elems && n < dest; n++) \
ret[n] = (*this)[n]; \
return ret; \
}

#define OPERATORS(elems) \
inline T& operator[](int n) { return *(&x + n); } \
inline T const& operator[](int n) const { return *(&x + n); } \
@@ -63,6 +72,10 @@
SCALAR_OP(elems, *) \
SCALAR_OP(elems, /) \
\
CAST_OP(elems, 2) \
CAST_OP(elems, 3) \
CAST_OP(elems, 4) \
\
template<typename U> \
inline operator Vec##elems<U>() const \
{ \
@@ -85,6 +98,10 @@
return sqrtf((float)sqlen()); \
}

template <typename T> struct Vec2;
template <typename T> struct Vec3;
template <typename T> struct Vec4;

template <typename T> struct Vec2
{
inline Vec2() { x = y = 0; }


Loading…
Cancel
Save