matrix: fix transposed matrix in look_at

This commit is contained in:
Danny Robson 2016-09-15 21:33:03 +10:00
parent e2b4e48315
commit 6054fd59a2

View File

@ -280,16 +280,18 @@ matrix<S,T>::look_at (util::point<3,T> eye,
util::point<3,T> target, util::point<3,T> target,
util::vector<3,T> up) util::vector<3,T> up)
{ {
const auto f = normalised (target - eye); auto forward = normalised (eye.to (target));
const auto s = normalised (cross (f, up)); auto side = normalised (cross (forward, up));
const auto u = cross (s, f); up = cross (side, forward);
return { { auto rot = util::matrix4<T> {{
{ s.x, s.y, s.z, -dot (s, eye) }, { side[0], up[0], -forward[0], 0 },
{ u.x, u.y, u.z, -dot (u, eye) }, { side[1], up[1], -forward[1], 0 },
{ -f.x, -f.y, -f.z, dot (f, eye) }, { side[2], up[2], -forward[2], 0 },
{ 0, 0, 0, 1 }, { 0, 0, 0, 1 }
} }; }};
return util::matrix4<T>::translation (-eye.template as<vector> ()) * rot;
} }