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