mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Fixed mtxLookAt when eye looks straight up or down.
This commit is contained in:
17
src/math.cpp
17
src/math.cpp
@@ -248,9 +248,20 @@ namespace bx
|
||||
? sub(_eye, _at)
|
||||
: sub(_at, _eye)
|
||||
);
|
||||
const Vec3 uxv = cross(_up, view);
|
||||
const Vec3 right = normalize(uxv);
|
||||
const Vec3 up = cross(view, right);
|
||||
|
||||
const Vec3 uxv = cross(_up, view);
|
||||
Vec3 right = bx::InitNone;
|
||||
|
||||
if (0.0f == dot(uxv, uxv) )
|
||||
{
|
||||
right = { -1.0f, 0.0f, 0.0f };
|
||||
}
|
||||
else
|
||||
{
|
||||
right = normalize(uxv);
|
||||
}
|
||||
|
||||
const Vec3 up = cross(view, right);
|
||||
|
||||
memSet(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = right.x;
|
||||
|
||||
Reference in New Issue
Block a user