src/ldrawalgorithm.h

Wed, 25 May 2022 18:29:49 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 18:29:49 +0300
changeset 197
0e729e681a2c
parent 196
6bcb284679d4
child 200
ca23936b455b
permissions
-rw-r--r--

move drawState to Document

154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include "modeleditor.h"
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 namespace ldraw
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 {
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 /// Determines how quadrilaterals are split into triangles
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 enum class Diagonal
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 {
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 Diagonal_13,
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 Diagonal_24
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 };
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 // Splits the specified quadrilateral into triangles.
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 // If it is not a quadrilateral then no action is performed
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 auto splitQuadrilateral(ModelEditor& editor,
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 quadrilateralid_t quadrilateral_id,
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 Diagonal splitType = Diagonal::Diagonal_13
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 ) -> std::optional<std::pair<triangleid_t, triangleid_t>>;
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19
183
97b591813c8b - Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents: 154
diff changeset
20 void invert(ModelEditor& editor, ldraw::id_t id, GetPolygonsContext *context);
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 void makeUnofficial(ModelEditor &editor);
186
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
22
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
23 template<typename Fn>
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
24 void circle(int segments, int divisions, Fn&& fn)
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
25 {
196
6bcb284679d4 delete unneeded things
Teemu Piippo <teemu@hecknology.net>
parents: 186
diff changeset
26 float factor = 2.0f * pi<> / divisions;
186
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
27 for (int i = 0; i < segments; i += 1)
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
28 {
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
29 fn(
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
30 glm::vec2{std::sin((i - 1) * factor), std::cos((i - 1) * factor)},
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
31 glm::vec2{std::sin(i * factor), std::cos(i * factor)},
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
32 glm::vec2{std::sin((i + 1) * factor), std::cos((i - 1) * factor)}
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
33 );
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
34 }
922662adb72a work on circle tool
Teemu Piippo <teemu@hecknology.net>
parents: 183
diff changeset
35 }
154
47cb50cfa9ad add missing files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 }

mercurial