Add C++11 constexpr to 3D vector classes
This turns QVector2D(1,1) into compile-time expressions when using a C++11 compiler. Change-Id: Ifea2d1cdfd5481300f9a5a0c7bbe8bfe9115c636 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
3d2691ae77
commit
ae4e905993
@ -57,10 +57,10 @@ class QVariant;
|
|||||||
class Q_GUI_EXPORT QVector2D
|
class Q_GUI_EXPORT QVector2D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVector2D();
|
Q_DECL_CONSTEXPR QVector2D();
|
||||||
QVector2D(float xpos, float ypos);
|
Q_DECL_CONSTEXPR QVector2D(float xpos, float ypos);
|
||||||
explicit QVector2D(const QPoint& point);
|
Q_DECL_CONSTEXPR explicit QVector2D(const QPoint& point);
|
||||||
explicit QVector2D(const QPointF& point);
|
Q_DECL_CONSTEXPR explicit QVector2D(const QPointF& point);
|
||||||
#ifndef QT_NO_VECTOR3D
|
#ifndef QT_NO_VECTOR3D
|
||||||
explicit QVector2D(const QVector3D& vector);
|
explicit QVector2D(const QVector3D& vector);
|
||||||
#endif
|
#endif
|
||||||
@ -70,8 +70,8 @@ public:
|
|||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
float x() const;
|
Q_DECL_CONSTEXPR float x() const;
|
||||||
float y() const;
|
Q_DECL_CONSTEXPR float y() const;
|
||||||
|
|
||||||
void setX(float x);
|
void setX(float x);
|
||||||
void setY(float y);
|
void setY(float y);
|
||||||
@ -96,17 +96,17 @@ public:
|
|||||||
|
|
||||||
static float dotProduct(const QVector2D& v1, const QVector2D& v2);
|
static float dotProduct(const QVector2D& v1, const QVector2D& v2);
|
||||||
|
|
||||||
friend inline bool operator==(const QVector2D &v1, const QVector2D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator==(const QVector2D &v1, const QVector2D &v2);
|
||||||
friend inline bool operator!=(const QVector2D &v1, const QVector2D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector2D &v1, const QVector2D &v2);
|
||||||
friend inline const QVector2D operator+(const QVector2D &v1, const QVector2D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator+(const QVector2D &v1, const QVector2D &v2);
|
||||||
friend inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2);
|
||||||
friend inline const QVector2D operator*(float factor, const QVector2D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator*(float factor, const QVector2D &vector);
|
||||||
friend inline const QVector2D operator*(const QVector2D &vector, float factor);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator*(const QVector2D &vector, float factor);
|
||||||
friend inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2);
|
||||||
friend inline const QVector2D operator-(const QVector2D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator-(const QVector2D &vector);
|
||||||
friend inline const QVector2D operator/(const QVector2D &vector, float divisor);
|
Q_DECL_CONSTEXPR friend inline const QVector2D operator/(const QVector2D &vector, float divisor);
|
||||||
|
|
||||||
friend inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2);
|
Q_DECL_CONSTEXPR friend inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2);
|
||||||
|
|
||||||
#ifndef QT_NO_VECTOR3D
|
#ifndef QT_NO_VECTOR3D
|
||||||
QVector3D toVector3D() const;
|
QVector3D toVector3D() const;
|
||||||
@ -115,8 +115,8 @@ public:
|
|||||||
QVector4D toVector4D() const;
|
QVector4D toVector4D() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPoint toPoint() const;
|
Q_DECL_CONSTEXPR QPoint toPoint() const;
|
||||||
QPointF toPointF() const;
|
Q_DECL_CONSTEXPR QPointF toPointF() const;
|
||||||
|
|
||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
|
|
||||||
@ -129,21 +129,21 @@ private:
|
|||||||
|
|
||||||
Q_DECLARE_TYPEINFO(QVector2D, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QVector2D, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
|
||||||
|
|
||||||
inline QVector2D::QVector2D(float xpos, float ypos) : xp(xpos), yp(ypos) {}
|
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(float xpos, float ypos) : xp(xpos), yp(ypos) {}
|
||||||
|
|
||||||
inline QVector2D::QVector2D(const QPoint& point) : xp(point.x()), yp(point.y()) {}
|
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(const QPoint& point) : xp(point.x()), yp(point.y()) {}
|
||||||
|
|
||||||
inline QVector2D::QVector2D(const QPointF& point) : xp(point.x()), yp(point.y()) {}
|
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(const QPointF& point) : xp(point.x()), yp(point.y()) {}
|
||||||
|
|
||||||
inline bool QVector2D::isNull() const
|
inline bool QVector2D::isNull() const
|
||||||
{
|
{
|
||||||
return qIsNull(xp) && qIsNull(yp);
|
return qIsNull(xp) && qIsNull(yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float QVector2D::x() const { return xp; }
|
Q_DECL_CONSTEXPR inline float QVector2D::x() const { return xp; }
|
||||||
inline float QVector2D::y() const { return yp; }
|
Q_DECL_CONSTEXPR inline float QVector2D::y() const { return yp; }
|
||||||
|
|
||||||
inline void QVector2D::setX(float aX) { xp = aX; }
|
inline void QVector2D::setX(float aX) { xp = aX; }
|
||||||
inline void QVector2D::setY(float aY) { yp = aY; }
|
inline void QVector2D::setY(float aY) { yp = aY; }
|
||||||
@ -195,62 +195,62 @@ inline QVector2D &QVector2D::operator/=(float divisor)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const QVector2D &v1, const QVector2D &v2)
|
Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp == v2.xp && v1.yp == v2.yp;
|
return v1.xp == v2.xp && v1.yp == v2.yp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const QVector2D &v1, const QVector2D &v2)
|
Q_DECL_CONSTEXPR inline bool operator!=(const QVector2D &v1, const QVector2D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp != v2.xp || v1.yp != v2.yp;
|
return v1.xp != v2.xp || v1.yp != v2.yp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator+(const QVector2D &v1, const QVector2D &v2)
|
Q_DECL_CONSTEXPR inline const QVector2D operator+(const QVector2D &v1, const QVector2D &v2)
|
||||||
{
|
{
|
||||||
return QVector2D(v1.xp + v2.xp, v1.yp + v2.yp);
|
return QVector2D(v1.xp + v2.xp, v1.yp + v2.yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
|
Q_DECL_CONSTEXPR inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
|
||||||
{
|
{
|
||||||
return QVector2D(v1.xp - v2.xp, v1.yp - v2.yp);
|
return QVector2D(v1.xp - v2.xp, v1.yp - v2.yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator*(float factor, const QVector2D &vector)
|
Q_DECL_CONSTEXPR inline const QVector2D operator*(float factor, const QVector2D &vector)
|
||||||
{
|
{
|
||||||
return QVector2D(vector.xp * factor, vector.yp * factor);
|
return QVector2D(vector.xp * factor, vector.yp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator*(const QVector2D &vector, float factor)
|
Q_DECL_CONSTEXPR inline const QVector2D operator*(const QVector2D &vector, float factor)
|
||||||
{
|
{
|
||||||
return QVector2D(vector.xp * factor, vector.yp * factor);
|
return QVector2D(vector.xp * factor, vector.yp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
|
Q_DECL_CONSTEXPR inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
|
||||||
{
|
{
|
||||||
return QVector2D(v1.xp * v2.xp, v1.yp * v2.yp);
|
return QVector2D(v1.xp * v2.xp, v1.yp * v2.yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator-(const QVector2D &vector)
|
Q_DECL_CONSTEXPR inline const QVector2D operator-(const QVector2D &vector)
|
||||||
{
|
{
|
||||||
return QVector2D(-vector.xp, -vector.yp);
|
return QVector2D(-vector.xp, -vector.yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector2D operator/(const QVector2D &vector, float divisor)
|
Q_DECL_CONSTEXPR inline const QVector2D operator/(const QVector2D &vector, float divisor)
|
||||||
{
|
{
|
||||||
return QVector2D(vector.xp / divisor, vector.yp / divisor);
|
return QVector2D(vector.xp / divisor, vector.yp / divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
|
Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
|
||||||
{
|
{
|
||||||
return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
|
return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPoint QVector2D::toPoint() const
|
Q_DECL_CONSTEXPR inline QPoint QVector2D::toPoint() const
|
||||||
{
|
{
|
||||||
return QPoint(qRound(xp), qRound(yp));
|
return QPoint(qRound(xp), qRound(yp));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPointF QVector2D::toPointF() const
|
Q_DECL_CONSTEXPR inline QPointF QVector2D::toPointF() const
|
||||||
{
|
{
|
||||||
return QPointF(qreal(xp), qreal(yp));
|
return QPointF(qreal(xp), qreal(yp));
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,10 @@ class QVector4D;
|
|||||||
class Q_GUI_EXPORT QVector3D
|
class Q_GUI_EXPORT QVector3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVector3D();
|
Q_DECL_CONSTEXPR QVector3D();
|
||||||
QVector3D(float xpos, float ypos, float zpos);
|
Q_DECL_CONSTEXPR QVector3D(float xpos, float ypos, float zpos);
|
||||||
explicit QVector3D(const QPoint& point);
|
Q_DECL_CONSTEXPR explicit QVector3D(const QPoint& point);
|
||||||
explicit QVector3D(const QPointF& point);
|
Q_DECL_CONSTEXPR explicit QVector3D(const QPointF& point);
|
||||||
#ifndef QT_NO_VECTOR2D
|
#ifndef QT_NO_VECTOR2D
|
||||||
QVector3D(const QVector2D& vector);
|
QVector3D(const QVector2D& vector);
|
||||||
QVector3D(const QVector2D& vector, float zpos);
|
QVector3D(const QVector2D& vector, float zpos);
|
||||||
@ -71,9 +71,9 @@ public:
|
|||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
float x() const;
|
Q_DECL_CONSTEXPR float x() const;
|
||||||
float y() const;
|
Q_DECL_CONSTEXPR float y() const;
|
||||||
float z() const;
|
Q_DECL_CONSTEXPR float z() const;
|
||||||
|
|
||||||
void setX(float x);
|
void setX(float x);
|
||||||
void setY(float y);
|
void setY(float y);
|
||||||
@ -105,17 +105,17 @@ public:
|
|||||||
float distanceToPlane(const QVector3D& plane1, const QVector3D& plane2, const QVector3D& plane3) const;
|
float distanceToPlane(const QVector3D& plane1, const QVector3D& plane2, const QVector3D& plane3) const;
|
||||||
float distanceToLine(const QVector3D& point, const QVector3D& direction) const;
|
float distanceToLine(const QVector3D& point, const QVector3D& direction) const;
|
||||||
|
|
||||||
friend inline bool operator==(const QVector3D &v1, const QVector3D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator==(const QVector3D &v1, const QVector3D &v2);
|
||||||
friend inline bool operator!=(const QVector3D &v1, const QVector3D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector3D &v1, const QVector3D &v2);
|
||||||
friend inline const QVector3D operator+(const QVector3D &v1, const QVector3D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator+(const QVector3D &v1, const QVector3D &v2);
|
||||||
friend inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2);
|
||||||
friend inline const QVector3D operator*(float factor, const QVector3D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator*(float factor, const QVector3D &vector);
|
||||||
friend inline const QVector3D operator*(const QVector3D &vector, float factor);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator*(const QVector3D &vector, float factor);
|
||||||
friend const QVector3D operator*(const QVector3D &v1, const QVector3D& v2);
|
Q_DECL_CONSTEXPR friend const QVector3D operator*(const QVector3D &v1, const QVector3D& v2);
|
||||||
friend inline const QVector3D operator-(const QVector3D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator-(const QVector3D &vector);
|
||||||
friend inline const QVector3D operator/(const QVector3D &vector, float divisor);
|
Q_DECL_CONSTEXPR friend inline const QVector3D operator/(const QVector3D &vector, float divisor);
|
||||||
|
|
||||||
friend inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2);
|
Q_DECL_CONSTEXPR friend inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2);
|
||||||
|
|
||||||
#ifndef QT_NO_VECTOR2D
|
#ifndef QT_NO_VECTOR2D
|
||||||
QVector2D toVector2D() const;
|
QVector2D toVector2D() const;
|
||||||
@ -124,8 +124,8 @@ public:
|
|||||||
QVector4D toVector4D() const;
|
QVector4D toVector4D() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPoint toPoint() const;
|
Q_DECL_CONSTEXPR QPoint toPoint() const;
|
||||||
QPointF toPointF() const;
|
Q_DECL_CONSTEXPR QPointF toPointF() const;
|
||||||
|
|
||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
|
|
||||||
@ -142,22 +142,22 @@ private:
|
|||||||
|
|
||||||
Q_DECLARE_TYPEINFO(QVector3D, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QVector3D, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
|
||||||
|
|
||||||
inline QVector3D::QVector3D(float xpos, float ypos, float zpos) : xp(xpos), yp(ypos), zp(zpos) {}
|
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(float xpos, float ypos, float zpos) : xp(xpos), yp(ypos), zp(zpos) {}
|
||||||
|
|
||||||
inline QVector3D::QVector3D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
||||||
|
|
||||||
inline QVector3D::QVector3D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
||||||
|
|
||||||
inline bool QVector3D::isNull() const
|
inline bool QVector3D::isNull() const
|
||||||
{
|
{
|
||||||
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
|
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float QVector3D::x() const { return xp; }
|
Q_DECL_CONSTEXPR inline float QVector3D::x() const { return xp; }
|
||||||
inline float QVector3D::y() const { return yp; }
|
Q_DECL_CONSTEXPR inline float QVector3D::y() const { return yp; }
|
||||||
inline float QVector3D::z() const { return zp; }
|
Q_DECL_CONSTEXPR inline float QVector3D::z() const { return zp; }
|
||||||
|
|
||||||
inline void QVector3D::setX(float aX) { xp = aX; }
|
inline void QVector3D::setX(float aX) { xp = aX; }
|
||||||
inline void QVector3D::setY(float aY) { yp = aY; }
|
inline void QVector3D::setY(float aY) { yp = aY; }
|
||||||
@ -215,64 +215,64 @@ inline QVector3D &QVector3D::operator/=(float divisor)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const QVector3D &v1, const QVector3D &v2)
|
Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp;
|
return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const QVector3D &v1, const QVector3D &v2)
|
Q_DECL_CONSTEXPR inline bool operator!=(const QVector3D &v1, const QVector3D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp;
|
return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator+(const QVector3D &v1, const QVector3D &v2)
|
Q_DECL_CONSTEXPR inline const QVector3D operator+(const QVector3D &v1, const QVector3D &v2)
|
||||||
{
|
{
|
||||||
return QVector3D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp);
|
return QVector3D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
|
Q_DECL_CONSTEXPR inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
|
||||||
{
|
{
|
||||||
return QVector3D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp);
|
return QVector3D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator*(float factor, const QVector3D &vector)
|
Q_DECL_CONSTEXPR inline const QVector3D operator*(float factor, const QVector3D &vector)
|
||||||
{
|
{
|
||||||
return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
|
return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator*(const QVector3D &vector, float factor)
|
Q_DECL_CONSTEXPR inline const QVector3D operator*(const QVector3D &vector, float factor)
|
||||||
{
|
{
|
||||||
return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
|
return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
|
Q_DECL_CONSTEXPR inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
|
||||||
{
|
{
|
||||||
return QVector3D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp);
|
return QVector3D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator-(const QVector3D &vector)
|
Q_DECL_CONSTEXPR inline const QVector3D operator-(const QVector3D &vector)
|
||||||
{
|
{
|
||||||
return QVector3D(-vector.xp, -vector.yp, -vector.zp);
|
return QVector3D(-vector.xp, -vector.yp, -vector.zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector3D operator/(const QVector3D &vector, float divisor)
|
Q_DECL_CONSTEXPR inline const QVector3D operator/(const QVector3D &vector, float divisor)
|
||||||
{
|
{
|
||||||
return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor);
|
return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
|
Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
|
||||||
{
|
{
|
||||||
return qFuzzyCompare(v1.xp, v2.xp) &&
|
return qFuzzyCompare(v1.xp, v2.xp) &&
|
||||||
qFuzzyCompare(v1.yp, v2.yp) &&
|
qFuzzyCompare(v1.yp, v2.yp) &&
|
||||||
qFuzzyCompare(v1.zp, v2.zp);
|
qFuzzyCompare(v1.zp, v2.zp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPoint QVector3D::toPoint() const
|
Q_DECL_CONSTEXPR inline QPoint QVector3D::toPoint() const
|
||||||
{
|
{
|
||||||
return QPoint(qRound(xp), qRound(yp));
|
return QPoint(qRound(xp), qRound(yp));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPointF QVector3D::toPointF() const
|
Q_DECL_CONSTEXPR inline QPointF QVector3D::toPointF() const
|
||||||
{
|
{
|
||||||
return QPointF(qreal(xp), qreal(yp));
|
return QPointF(qreal(xp), qreal(yp));
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,10 @@ class QVector3D;
|
|||||||
class Q_GUI_EXPORT QVector4D
|
class Q_GUI_EXPORT QVector4D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QVector4D();
|
Q_DECL_CONSTEXPR QVector4D();
|
||||||
QVector4D(float xpos, float ypos, float zpos, float wpos);
|
Q_DECL_CONSTEXPR QVector4D(float xpos, float ypos, float zpos, float wpos);
|
||||||
explicit QVector4D(const QPoint& point);
|
Q_DECL_CONSTEXPR explicit QVector4D(const QPoint& point);
|
||||||
explicit QVector4D(const QPointF& point);
|
Q_DECL_CONSTEXPR explicit QVector4D(const QPointF& point);
|
||||||
#ifndef QT_NO_VECTOR2D
|
#ifndef QT_NO_VECTOR2D
|
||||||
QVector4D(const QVector2D& vector);
|
QVector4D(const QVector2D& vector);
|
||||||
QVector4D(const QVector2D& vector, float zpos, float wpos);
|
QVector4D(const QVector2D& vector, float zpos, float wpos);
|
||||||
@ -72,10 +72,10 @@ public:
|
|||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
float x() const;
|
Q_DECL_CONSTEXPR float x() const;
|
||||||
float y() const;
|
Q_DECL_CONSTEXPR float y() const;
|
||||||
float z() const;
|
Q_DECL_CONSTEXPR float z() const;
|
||||||
float w() const;
|
Q_DECL_CONSTEXPR float w() const;
|
||||||
|
|
||||||
void setX(float x);
|
void setX(float x);
|
||||||
void setY(float y);
|
void setY(float y);
|
||||||
@ -99,17 +99,17 @@ public:
|
|||||||
|
|
||||||
static float dotProduct(const QVector4D& v1, const QVector4D& v2);
|
static float dotProduct(const QVector4D& v1, const QVector4D& v2);
|
||||||
|
|
||||||
friend inline bool operator==(const QVector4D &v1, const QVector4D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator==(const QVector4D &v1, const QVector4D &v2);
|
||||||
friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2);
|
Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2);
|
||||||
friend inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2);
|
||||||
friend inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2);
|
||||||
friend inline const QVector4D operator*(float factor, const QVector4D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator*(float factor, const QVector4D &vector);
|
||||||
friend inline const QVector4D operator*(const QVector4D &vector, float factor);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator*(const QVector4D &vector, float factor);
|
||||||
friend inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2);
|
||||||
friend inline const QVector4D operator-(const QVector4D &vector);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator-(const QVector4D &vector);
|
||||||
friend inline const QVector4D operator/(const QVector4D &vector, float divisor);
|
Q_DECL_CONSTEXPR friend inline const QVector4D operator/(const QVector4D &vector, float divisor);
|
||||||
|
|
||||||
friend inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2);
|
Q_DECL_CONSTEXPR friend inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2);
|
||||||
|
|
||||||
#ifndef QT_NO_VECTOR2D
|
#ifndef QT_NO_VECTOR2D
|
||||||
QVector2D toVector2D() const;
|
QVector2D toVector2D() const;
|
||||||
@ -120,8 +120,8 @@ public:
|
|||||||
QVector3D toVector3DAffine() const;
|
QVector3D toVector3DAffine() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPoint toPoint() const;
|
Q_DECL_CONSTEXPR QPoint toPoint() const;
|
||||||
QPointF toPointF() const;
|
Q_DECL_CONSTEXPR QPointF toPointF() const;
|
||||||
|
|
||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
|
|
||||||
@ -138,23 +138,23 @@ private:
|
|||||||
|
|
||||||
Q_DECLARE_TYPEINFO(QVector4D, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QVector4D, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
|
||||||
|
|
||||||
inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
|
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
|
||||||
|
|
||||||
inline QVector4D::QVector4D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
||||||
|
|
||||||
inline QVector4D::QVector4D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
||||||
|
|
||||||
inline bool QVector4D::isNull() const
|
inline bool QVector4D::isNull() const
|
||||||
{
|
{
|
||||||
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
|
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float QVector4D::x() const { return xp; }
|
Q_DECL_CONSTEXPR inline float QVector4D::x() const { return xp; }
|
||||||
inline float QVector4D::y() const { return yp; }
|
Q_DECL_CONSTEXPR inline float QVector4D::y() const { return yp; }
|
||||||
inline float QVector4D::z() const { return zp; }
|
Q_DECL_CONSTEXPR inline float QVector4D::z() const { return zp; }
|
||||||
inline float QVector4D::w() const { return wp; }
|
Q_DECL_CONSTEXPR inline float QVector4D::w() const { return wp; }
|
||||||
|
|
||||||
inline void QVector4D::setX(float aX) { xp = aX; }
|
inline void QVector4D::setX(float aX) { xp = aX; }
|
||||||
inline void QVector4D::setY(float aY) { yp = aY; }
|
inline void QVector4D::setY(float aY) { yp = aY; }
|
||||||
@ -218,52 +218,52 @@ inline QVector4D &QVector4D::operator/=(float divisor)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const QVector4D &v1, const QVector4D &v2)
|
Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp && v1.wp == v2.wp;
|
return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp && v1.wp == v2.wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const QVector4D &v1, const QVector4D &v2)
|
Q_DECL_CONSTEXPR inline bool operator!=(const QVector4D &v1, const QVector4D &v2)
|
||||||
{
|
{
|
||||||
return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp || v1.wp != v2.wp;
|
return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp || v1.wp != v2.wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2)
|
Q_DECL_CONSTEXPR inline const QVector4D operator+(const QVector4D &v1, const QVector4D &v2)
|
||||||
{
|
{
|
||||||
return QVector4D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp, v1.wp + v2.wp);
|
return QVector4D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp, v1.wp + v2.wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
|
Q_DECL_CONSTEXPR inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
|
||||||
{
|
{
|
||||||
return QVector4D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp, v1.wp - v2.wp);
|
return QVector4D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp, v1.wp - v2.wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator*(float factor, const QVector4D &vector)
|
Q_DECL_CONSTEXPR inline const QVector4D operator*(float factor, const QVector4D &vector)
|
||||||
{
|
{
|
||||||
return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor);
|
return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator*(const QVector4D &vector, float factor)
|
Q_DECL_CONSTEXPR inline const QVector4D operator*(const QVector4D &vector, float factor)
|
||||||
{
|
{
|
||||||
return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor);
|
return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
|
Q_DECL_CONSTEXPR inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
|
||||||
{
|
{
|
||||||
return QVector4D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp, v1.wp * v2.wp);
|
return QVector4D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp, v1.wp * v2.wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator-(const QVector4D &vector)
|
Q_DECL_CONSTEXPR inline const QVector4D operator-(const QVector4D &vector)
|
||||||
{
|
{
|
||||||
return QVector4D(-vector.xp, -vector.yp, -vector.zp, -vector.wp);
|
return QVector4D(-vector.xp, -vector.yp, -vector.zp, -vector.wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QVector4D operator/(const QVector4D &vector, float divisor)
|
Q_DECL_CONSTEXPR inline const QVector4D operator/(const QVector4D &vector, float divisor)
|
||||||
{
|
{
|
||||||
return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor);
|
return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
|
Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
|
||||||
{
|
{
|
||||||
return qFuzzyCompare(v1.xp, v2.xp) &&
|
return qFuzzyCompare(v1.xp, v2.xp) &&
|
||||||
qFuzzyCompare(v1.yp, v2.yp) &&
|
qFuzzyCompare(v1.yp, v2.yp) &&
|
||||||
@ -271,12 +271,12 @@ inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
|
|||||||
qFuzzyCompare(v1.wp, v2.wp);
|
qFuzzyCompare(v1.wp, v2.wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPoint QVector4D::toPoint() const
|
Q_DECL_CONSTEXPR inline QPoint QVector4D::toPoint() const
|
||||||
{
|
{
|
||||||
return QPoint(qRound(xp), qRound(yp));
|
return QPoint(qRound(xp), qRound(yp));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QPointF QVector4D::toPointF() const
|
Q_DECL_CONSTEXPR inline QPointF QVector4D::toPointF() const
|
||||||
{
|
{
|
||||||
return QPointF(qreal(xp), qreal(yp));
|
return QPointF(qreal(xp), qreal(yp));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user