Wed, 22 Sep 2021 13:28:53 +0300
Document model.h
117 | 1 | #ifndef VERTEXMAP_H |
2 | #define VERTEXMAP_H | |
3 | #include <set> | |
4 | #include "main.h" | |
5 | #include "model.h" | |
6 | ||
118 | 7 | /** |
8 | * @brief Collects a map of all vertices in a model to all objects that use the specified vertex. | |
9 | */ | |
117 | 10 | class VertexMap : public QObject |
11 | { | |
12 | Q_OBJECT | |
13 | public: | |
120
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
14 | struct VertexInfo |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
15 | { |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
16 | glm::vec3 point; |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
17 | std::set<ldraw::id_t> objects; |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
18 | bool transformSet = false; |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
19 | glm::mat4 transform; |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
20 | }; |
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
21 | using ApplyFunction = std::function<void(const glm::vec3&, const VertexInfo&)>; |
117 | 22 | VertexMap(const Model *model); |
23 | Q_SLOT void build(); | |
118 | 24 | void apply(ApplyFunction fn) const; |
25 | Q_SIGNALS: | |
26 | Q_SIGNAL void verticesChanged(); | |
117 | 27 | private: |
28 | const Model* const model; | |
119 | 29 | QSet<unsigned int> vertexHashes; |
30 | std::vector<glm::vec3> vertices; | |
120
8c9fff699241
rework rendering of vertices
Teemu Piippo <teemu@hecknology.net>
parents:
119
diff
changeset
|
31 | std::map<unsigned int, VertexInfo> map; |
117 | 32 | }; |
33 | ||
34 | #endif // VERTEXMAP_H |