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>
bb10
Konstantin Ritt 2015-02-19 13:34:33 +04:00
parent ad2d4e8386
commit d07166af64
1 changed files with 5 additions and 1 deletions

View File

@ -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);