diff options
Diffstat (limited to 'src/gui/math3d/qvector3d.cpp')
-rw-r--r-- | src/gui/math3d/qvector3d.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index 7d4ddf7..9552e3a 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -205,7 +205,10 @@ QVector3D::QVector3D(const QVector4D& vector) */ QVector3D QVector3D::normalized() const { - qreal len = lengthSquared(); + // Need some extra precision if the length is very small. + double len = double(xp) * double(xp) + + double(yp) * double(yp) + + double(zp) * double(zp); if (qFuzzyIsNull(len - 1.0f)) return *this; else if (!qFuzzyIsNull(len)) @@ -222,7 +225,10 @@ QVector3D QVector3D::normalized() const */ void QVector3D::normalize() { - qreal len = lengthSquared(); + // Need some extra precision if the length is very small. + double len = double(xp) * double(xp) + + double(yp) * double(yp) + + double(zp) * double(zp); if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len)) return; |