Tue, 28 Jun 2022 11:51:17 +0300
- Add CMake build type to about page and window title
- Use locale-dependant short date format in window title and long format in about page
- Move version definition into project() call
- Renamed the c++ macros to match CMake variable names
154 | 1 | #pragma once |
264
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
262
diff
changeset
|
2 | #include "src/basics.h" |
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
262
diff
changeset
|
3 | #include "src/model.h" |
154 | 4 | |
5 | namespace ldraw | |
6 | { | |
7 | /// Determines how quadrilaterals are split into triangles | |
8 | enum class Diagonal | |
9 | { | |
10 | Diagonal_13, | |
11 | Diagonal_24 | |
12 | }; | |
13 | ||
200 | 14 | std::pair<Triangle, Triangle> splitTriangles( |
15 | const Quadrilateral& q, | |
16 | ldraw::Diagonal diagonal); | |
154 | 17 | |
262
dc33f8a707c4
Add action to make a model unofficial (modifies the !LDRAW_ORG line)
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
261
diff
changeset
|
18 | std::vector<ModelAction> makeUnofficial(const Model *model); |
186 | 19 | |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
20 | constexpr float circleAngle(unsigned int divisions, unsigned int i) |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
21 | { |
261
6a875faebde2
pi is no longer a template
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
250
diff
changeset
|
22 | constexpr float ofs = 0.5 * pi; |
6a875faebde2
pi is no longer a template
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
250
diff
changeset
|
23 | float factor = -2.0f * pi / static_cast<float>(divisions); |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
24 | return static_cast<float>(i) * factor + ofs; |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
25 | } |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
26 | |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
27 | constexpr glm::vec2 rimpoint(unsigned int divisions, unsigned int i) |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
28 | { |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
29 | const float angle = circleAngle(divisions, i); |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
30 | return glm::vec2{std::sin(angle), std::cos(angle)}; |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
31 | } |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
32 | |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
33 | template<typename Fn> |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
34 | void circleAngles(unsigned int segments, unsigned int divisions, Fn&& fn) |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
35 | { |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
36 | for (unsigned int i = 0; i < segments; i += 1) |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
37 | { |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
38 | const float a1 = circleAngle(divisions, i - 1); |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
39 | const float a2 = circleAngle(divisions, i); |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
40 | const float a3 = circleAngle(divisions, i + 1); |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
41 | fn(a1, a2, a3); |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
42 | } |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
43 | } |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
44 | |
186 | 45 | template<typename Fn> |
250
2837b549e616
I felt that the compiler was too kind to me, so I enabled a big pile of warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
232
diff
changeset
|
46 | void circle(unsigned int segments, unsigned int divisions, Fn&& fn) |
186 | 47 | { |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
48 | circleAngles(segments, divisions, [&fn]( |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
49 | const float a1, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
50 | const float a2, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
51 | const float a3 |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
52 | ){ |
186 | 53 | fn( |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
54 | glm::vec2{std::sin(a1), std::cos(a1)}, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
55 | glm::vec2{std::sin(a2), std::cos(a2)}, |
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
56 | glm::vec2{std::sin(a3), std::cos(a3)} |
186 | 57 | ); |
232
8efa3a33172e
Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
206
diff
changeset
|
58 | }); |
186 | 59 | } |
154 | 60 | } |
200 | 61 | |
62 | ModelElement inverted(const ModelElement &element); |