diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-19 13:34:33 +0400 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-26 20:15:00 +0000 |
commit | d07166af645fa65cb7e9f571dbc34eb946463627 (patch) | |
tree | bc228ee707fdc9212681b06bab59e9fe1270435e /src/gui/math3d | |
parent | ad2d4e8386742df9985ca918b6fea6c7603e70bf (diff) |
Fix QMatrix4x4::lookAt() in case of null direction
If direction is null, any valid orientation fits, so that the resulting
matrix must be valid.
Change-Id: Ie8060f44801822ee337b25f75fb275bd02223fe8
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/math3d')
-rw-r--r-- | src/gui/math3d/qmatrix4x4.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index a54ca451d4..19d1fe6a8c 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1530,7 +1530,11 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP */ void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up) { - QVector3D forward = (center - eye).normalized(); + QVector3D forward = center - eye; + if (qFuzzyIsNull(forward.x()) && qFuzzyIsNull(forward.y()) && qFuzzyIsNull(forward.z())) + return; + + forward.normalize(); QVector3D side = QVector3D::crossProduct(forward, up).normalized(); QVector3D upVector = QVector3D::crossProduct(side, forward); |