浏览代码

math: fix grave dot product bug introduced in the quat/cmplx refactor.

undefined
Sam Hocevar 11 年前
父节点
当前提交
5b4a17de51
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. +8
    -8
      src/lol/math/vector.h

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

@@ -426,25 +426,25 @@ template <typename T> struct Cmplx
}; };


template<typename T> template<typename T>
static inline T dot(Cmplx<T> const &q1, Cmplx<T> const &q2)
static inline T dot(Cmplx<T> const &z1, Cmplx<T> const &z2)
{ {
T ret(0); T ret(0);
for (size_t i = 0; i < sizeof(ret) / sizeof(T); ++i)
ret += q1[i] * q2[i];
for (size_t i = 0; i < sizeof(Cmplx<T>) / sizeof(T); ++i)
ret += z1[i] * z2[i];
return ret; return ret;
} }


template<typename T> template<typename T>
static inline T sqlength(Cmplx<T> const &q)
static inline T sqlength(Cmplx<T> const &z)
{ {
return dot(q, q);
return dot(z, z);
} }


template<typename T> template<typename T>
static inline T length(Cmplx<T> const &q)
static inline T length(Cmplx<T> const &z)
{ {
/* FIXME: this is not very nice */ /* FIXME: this is not very nice */
return (T)sqrt((double)sqlength(q));
return (T)sqrt((double)sqlength(z));
} }


template<typename T> template<typename T>
@@ -1274,7 +1274,7 @@ template<typename T>
static inline T dot(Quat<T> const &q1, Quat<T> const &q2) static inline T dot(Quat<T> const &q1, Quat<T> const &q2)
{ {
T ret(0); T ret(0);
for (size_t i = 0; i < sizeof(ret) / sizeof(T); ++i)
for (size_t i = 0; i < sizeof(Quat<T>) / sizeof(T); ++i)
ret += q1[i] * q2[i]; ret += q1[i] * q2[i];
return ret; return ret;
} }


正在加载...
取消
保存