src/basics.h

changeset 1430
6ce6d3da584f
parent 1428
ece049033adc
child 1431
2e0e2c696605
equal deleted inserted replaced
1429:80e8aaabeeed 1430:6ce6d3da584f
72 72
73 /* 73 /*
74 * Special operator definition that implements the XOR operator for windings. 74 * Special operator definition that implements the XOR operator for windings.
75 * However, if either winding is NoWinding, then this function returns NoWinding. 75 * However, if either winding is NoWinding, then this function returns NoWinding.
76 */ 76 */
77 inline Winding operator^(Winding one, Winding other) 77 Winding constexpr operator^(Winding one, Winding other)
78 { 78 {
79 if (one == NoWinding or other == NoWinding) 79 if (one == NoWinding or other == NoWinding)
80 return NoWinding; 80 return NoWinding;
81 else 81 else
82 return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other)); 82 return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other));
86 { 86 {
87 one = one ^ other; 87 one = one ^ other;
88 return one; 88 return one;
89 } 89 }
90 90
91 static const double pi = 3.14159265358979323846; 91 constexpr double pi = 3.14159265358979323846;
92 static const double inf = std::numeric_limits<double>::infinity(); 92 constexpr double inf = std::numeric_limits<double>::infinity();
93 93
94 /* 94 /*
95 * Returns the norm of a vector. 95 * Returns the norm of a vector.
96 */ 96 */
97 static inline qreal abs(const QVector3D &vector) 97 inline qreal abs(const QVector3D &vector)
98 { 98 {
99 return vector.length(); 99 return vector.length();
100 } 100 }
101 101
102 template<typename T> 102 template<typename T>
103 unsigned int qHash(const std::unique_ptr<T>& pointer) 103 unsigned int qHash(const std::unique_ptr<T>& pointer)
104 { 104 {
105 return qHash(pointer.get()); 105 return qHash(pointer.get());
106 }
107
108 inline void offset(QMatrix4x4& matrix, const QVector3D& vector)
109 {
110 matrix(0, 3) += vector.x();
111 matrix(1, 3) += vector.y();
112 matrix(2, 3) += vector.z();
106 } 113 }
107 114
108 qreal determinant(qreal a, qreal b, qreal c, qreal d); 115 qreal determinant(qreal a, qreal b, qreal c, qreal d);
109 qreal determinant(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f, qreal g, qreal h, qreal i); 116 qreal determinant(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f, qreal g, qreal h, qreal i);
110 qreal determinant(const QMatrix2x2& matrix); 117 qreal determinant(const QMatrix2x2& matrix);

mercurial