src/vertexmap.h

Wed, 22 Sep 2021 00:25:13 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 22 Sep 2021 00:25:13 +0300
changeset 134
f77d2230e87c
parent 120
8c9fff699241
child 200
ca23936b455b
permissions
-rw-r--r--

Add remaining serialize methods

117
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #ifndef VERTEXMAP_H
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #define VERTEXMAP_H
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 #include <set>
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 #include "main.h"
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 #include "model.h"
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
7 /**
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
8 * @brief Collects a map of all vertices in a model to all objects that use the specified vertex.
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
9 */
117
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 class VertexMap : public QObject
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 {
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 Q_OBJECT
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
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
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 VertexMap(const Model *model);
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 Q_SLOT void build();
118
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
24 void apply(ApplyFunction fn) const;
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
25 Q_SIGNALS:
8e1c9f18ae15 Add vertex rendering
Teemu Piippo <teemu@hecknology.net>
parents: 117
diff changeset
26 Q_SIGNAL void verticesChanged();
117
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 private:
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 const Model* const model;
119
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
29 QSet<unsigned int> vertexHashes;
Teemu Piippo <teemu@hecknology.net>
parents: 118
diff changeset
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
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 };
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33
121a40d5e34c Add vertex map
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 #endif // VERTEXMAP_H

mercurial