diff -r 2bdc3ac5e77c -r 55a55a9ec2c2 src/basics.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/basics.h Sun Sep 22 11:51:41 2019 +0300
@@ -0,0 +1,88 @@
+/*
+ * LDForge: LDraw parts authoring CAD
+ * Copyright (C) 2019 Teemu Piippo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using GLRotationMatrix = QMatrix4x4;
+
+enum Axis
+{
+ X,
+ Y,
+ Z
+};
+
+enum Winding
+{
+ NoWinding,
+ CounterClockwise,
+ Clockwise,
+};
+
+/*
+ * 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)
+{
+ if (one == NoWinding or other == NoWinding)
+ return NoWinding;
+ else
+ return static_cast(static_cast(one) ^ static_cast(other));
+}
+
+inline Winding& operator^=(Winding& one, Winding other)
+{
+ one = one ^ other;
+ return one;
+}
+
+template
+constexpr std::size_t countof(T(&)[N])
+{
+ return N;
+}
+
+static constexpr long double pi = M_PIl;
+
+// http://stackoverflow.com/a/18204188/3629665
+template
+inline auto rotl10(T x)
+ -> std::enable_if_t, T>
+{
+ return (x << 10) | ((x >> 22) & 0x000000ff);
+}
+
+template
+inline auto rotl20(T x)
+ -> std::enable_if_t, T>
+{
+ return (x << 20) | ((x >> 12) & 0x000000ff);
+}