src/vertexmap.h

Wed, 28 Jul 2021 08:23:09 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 28 Jul 2021 08:23:09 +0300
changeset 119
24275a4064f4
parent 118
8e1c9f18ae15
child 120
8c9fff699241
permissions
-rw-r--r--

update

#ifndef VERTEXMAP_H
#define VERTEXMAP_H
#include <set>
#include "main.h"
#include "model.h"

/**
 * @brief Collects a map of all vertices in a model to all objects that use the specified vertex.
 */
class VertexMap : public QObject
{
	Q_OBJECT
public:
	using ApplyFunction = std::function<void(const glm::vec3&, const std::set<ldraw::id_t>&)>;
	VertexMap(const Model *model);
	Q_SLOT void build();
	void apply(ApplyFunction fn) const;
Q_SIGNALS:
	Q_SIGNAL void verticesChanged();
private:
	const Model* const model;
	QSet<unsigned int> vertexHashes;
	std::vector<glm::vec3> vertices;
	std::map<unsigned int, std::set<ldraw::id_t>> map;
};

#endif // VERTEXMAP_H

mercurial