浏览代码

math: add mat2::identity, etc. as global constants.

undefined
Sam Hocevar 11 年前
父节点
当前提交
2291ce5d1e
共有 2 个文件被更改,包括 33 次插入15 次删除
  1. +6
    -0
      src/lol/math/vector.h
  2. +27
    -15
      src/math/constants.cpp

+ 6
- 0
src/lol/math/vector.h 查看文件

@@ -1632,6 +1632,8 @@ template <typename T> struct Mat2
}

Vec2<T> v0, v1;

static const Mat2<T> identity;
};

/*
@@ -1756,6 +1758,8 @@ template <typename T> struct Mat3
}

Vec3<T> v0, v1, v2;

static const Mat3<T> identity;
};

/*
@@ -1927,6 +1931,8 @@ template <typename T> struct Mat4
}

Vec4<T> v0, v1, v2, v3;

static const Mat4<T> identity;
};

template<typename T> T determinant(Mat2<T> const &);


+ 27
- 15
src/math/constants.cpp 查看文件

@@ -28,7 +28,17 @@ namespace lol {
template<> \
Vec4<type> const Vec4<type>::name = Vec4<type>((type)a, (type)b, (type)c, (type)d);

#define LOL_ALL_VECTOR_CONST_INNER(type) \
#define LOL_MAT_CONST(type, name, a) \
template<> \
Mat2<type> const Mat2<type>::name = Mat2<type>((type)a); \
\
template<> \
Mat3<type> const Mat3<type>::name = Mat3<type>((type)a); \
\
template<> \
Mat4<type> const Mat4<type>::name = Mat4<type>((type)a);

#define LOL_ALL_CONST_INNER(type) \
LOL_VEC_2_CONST(type, one, 1, 1) \
LOL_VEC_2_CONST(type, mone,-1,-1) \
LOL_VEC_2_CONST(type, zero, 0, 0) \
@@ -48,22 +58,24 @@ namespace lol {
LOL_VEC_4_CONST(type, axis_x, 1, 0, 0, 0) \
LOL_VEC_4_CONST(type, axis_y, 0, 1, 0, 0) \
LOL_VEC_4_CONST(type, axis_z, 0, 0, 1, 0) \
LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1)
LOL_VEC_4_CONST(type, axis_w, 0, 0, 0, 1) \
\
LOL_MAT_CONST(type, identity, 1)

LOL_ALL_VECTOR_CONST_INNER(half)
LOL_ALL_VECTOR_CONST_INNER(float)
LOL_ALL_VECTOR_CONST_INNER(double)
LOL_ALL_VECTOR_CONST_INNER(ldouble)
LOL_ALL_VECTOR_CONST_INNER(real)
LOL_ALL_CONST_INNER(half)
LOL_ALL_CONST_INNER(float)
LOL_ALL_CONST_INNER(double)
LOL_ALL_CONST_INNER(ldouble)
LOL_ALL_CONST_INNER(real)

LOL_ALL_VECTOR_CONST_INNER(int8_t)
LOL_ALL_VECTOR_CONST_INNER(uint8_t)
LOL_ALL_VECTOR_CONST_INNER(int16_t)
LOL_ALL_VECTOR_CONST_INNER(uint16_t)
LOL_ALL_VECTOR_CONST_INNER(int32_t)
LOL_ALL_VECTOR_CONST_INNER(uint32_t)
LOL_ALL_VECTOR_CONST_INNER(int64_t)
LOL_ALL_VECTOR_CONST_INNER(uint64_t)
LOL_ALL_CONST_INNER(int8_t)
LOL_ALL_CONST_INNER(uint8_t)
LOL_ALL_CONST_INNER(int16_t)
LOL_ALL_CONST_INNER(uint16_t)
LOL_ALL_CONST_INNER(int32_t)
LOL_ALL_CONST_INNER(uint32_t)
LOL_ALL_CONST_INNER(int64_t)
LOL_ALL_CONST_INNER(uint64_t)

}; /* namespace lol */


正在加载...
取消
保存