Sat, 01 Feb 2020 15:33:57 +0200
wired renderstyle up
3 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
24 | 3 | * Copyright (C) 2013 - 2020 Teemu Piippo |
3 | 4 | * |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | #pragma once | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
20 | #include <algorithm> |
3 | 21 | #include <cstdio> |
22 | #include <cstdlib> | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
23 | #include <cstring> |
3 | 24 | #include <cmath> |
25 | #include <QMatrix4x4> | |
26 | #include <QObject> | |
27 | #include <QPointF> | |
28 | #include <QSet> | |
29 | #include <QString> | |
30 | #include <QStringList> | |
31 | #include <QVariant> | |
32 | #include <QVector> | |
33 | #include <QVector3D> | |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
34 | #include <glm/glm.hpp> |
3 | 35 | |
36 | using GLRotationMatrix = QMatrix4x4; | |
37 | ||
38 | enum Axis | |
39 | { | |
21 | 40 | X = 0, |
41 | Y = 1, | |
42 | Z = 2 | |
3 | 43 | }; |
44 | ||
26 | 45 | enum Result |
46 | { | |
47 | Success = 0, | |
48 | PartialSuccess, | |
49 | Failure | |
50 | }; | |
51 | ||
52 | constexpr bool failed(Result r) | |
53 | { | |
54 | return r == Failure; | |
55 | } | |
56 | ||
3 | 57 | enum Winding |
58 | { | |
59 | NoWinding, | |
8
44679e468ba9
major update with many things
Teemu Piippo <teemu@hecknology.net>
parents:
7
diff
changeset
|
60 | Anticlockwise, |
3 | 61 | Clockwise, |
62 | }; | |
63 | ||
64 | /* | |
65 | * Special operator definition that implements the XOR operator for windings. | |
66 | * However, if either winding is NoWinding, then this function returns NoWinding. | |
67 | */ | |
68 | inline Winding operator^(Winding one, Winding other) | |
69 | { | |
70 | if (one == NoWinding or other == NoWinding) | |
71 | return NoWinding; | |
72 | else | |
73 | return static_cast<Winding>(static_cast<int>(one) ^ static_cast<int>(other)); | |
74 | } | |
75 | ||
76 | inline Winding& operator^=(Winding& one, Winding other) | |
77 | { | |
78 | one = one ^ other; | |
79 | return one; | |
80 | } | |
21 | 81 | |
82 | template<typename T, int N> | |
83 | constexpr int countof(T(&)[N]) | |
84 | { | |
85 | return N; | |
86 | } | |
33
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
87 | |
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
88 | Q_DECLARE_METATYPE(glm::vec3) |
4c41bfe2ec6e
replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents:
26
diff
changeset
|
89 | Q_DECLARE_METATYPE(glm::mat4) |