summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qvector3d.h
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-04-07 06:16:22 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-04-08 00:19:12 (GMT)
commita83faaf1bedfd321c4fc759156369d2f86fbbbed (patch)
tree9fefa2840ae8a784fcd323551de6a74835e5b267 /src/gui/math3d/qvector3d.h
parent939623b2bc8e441618ee1a1886cc656880bee62b (diff)
downloadQt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.zip
Qt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.tar.gz
Qt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.tar.bz2
Remove fixed-point support from math3d
The main use case for fixed-point support is to build large arrays of vertices. This can be handled using qvertextype or something similar at higher levels. So it isn't worth risking numerical instability in the core classes. Reviewed-by: trustme
Diffstat (limited to 'src/gui/math3d/qvector3d.h')
-rw-r--r--src/gui/math3d/qvector3d.h41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 8f8f3b4..4771d5a 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -130,16 +129,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp;
+ float xp, yp, zp;
- QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QVector3D(float xpos, float ypos, float zpos, int dummy);
friend class QVector2D;
friend class QVector4D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
- friend class QGLPainter;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
@@ -150,7 +147,7 @@ inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QVector3D::QVector3D(qreal xpos, qreal ypos, qreal zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QVector3D::QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
+inline QVector3D::QVector3D(float xpos, float ypos, float zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
inline QVector3D::QVector3D(int xpos, int ypos, int zpos) : xp(xpos), yp(ypos), zp(zpos) {}
@@ -163,9 +160,9 @@ inline bool QVector3D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline qreal QVector3D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector3D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector3D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
+inline qreal QVector3D::x() const { return qreal(xp); }
+inline qreal QVector3D::y() const { return qreal(yp); }
+inline qreal QVector3D::z() const { return qreal(zp); }
inline void QVector3D::setX(qreal x) { xp = x; }
inline void QVector3D::setY(qreal y) { yp = y; }
@@ -189,10 +186,9 @@ inline QVector3D &QVector3D::operator-=(const QVector3D &vector)
inline QVector3D &QVector3D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
return *this;
}
@@ -206,10 +202,9 @@ inline QVector3D &QVector3D::operator*=(const QVector3D& vector)
inline QVector3D &QVector3D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
return *this;
}
@@ -235,14 +230,12 @@ inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
inline const QVector3D operator*(qreal factor, const QVector3D &vector)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
@@ -257,8 +250,7 @@ inline const QVector3D operator-(const QVector3D &vector)
inline const QVector3D operator/(const QVector3D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector3D(vector.xp / d, vector.yp / d, vector.zp / d, 1);
+ return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
@@ -275,8 +267,7 @@ inline QPoint QVector3D::toPoint() const
inline QPointF QVector3D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM