src/basics.h

changeset 1430
6ce6d3da584f
parent 1428
ece049033adc
child 1431
2e0e2c696605
--- a/src/basics.h	Tue Aug 07 20:34:32 2018 +0300
+++ b/src/basics.h	Sat Sep 15 15:57:56 2018 +0300
@@ -74,7 +74,7 @@
  * Special operator definition that implements the XOR operator for windings.
  * However, if either winding is NoWinding, then this function returns NoWinding.
  */
-inline Winding operator^(Winding one, Winding other)
+Winding constexpr operator^(Winding one, Winding other)
 {
 	if (one == NoWinding or other == NoWinding)
 		return NoWinding;
@@ -88,13 +88,13 @@
 	return one;
 }
 
-static const double pi = 3.14159265358979323846;
-static const double inf = std::numeric_limits<double>::infinity();
+constexpr double pi = 3.14159265358979323846;
+constexpr double inf = std::numeric_limits<double>::infinity();
 
 /*
  * Returns the norm of a vector.
  */
-static inline qreal abs(const QVector3D &vector)
+inline qreal abs(const QVector3D &vector)
 {
 	return vector.length();
 }
@@ -105,6 +105,13 @@
 	return qHash(pointer.get());
 }
 
+inline void offset(QMatrix4x4& matrix, const QVector3D& vector)
+{
+	matrix(0, 3) += vector.x();
+	matrix(1, 3) += vector.y();
+	matrix(2, 3) += vector.z();
+}
+
 qreal determinant(qreal a, qreal b, qreal c, qreal d);
 qreal determinant(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f, qreal g, qreal h, qreal i);
 qreal determinant(const QMatrix2x2& matrix);

mercurial