src/vertexmap.h

Sat, 05 Mar 2022 00:51:23 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 05 Mar 2022 00:51:23 +0200
changeset 157
869fe95c4e5e
parent 120
8c9fff699241
child 200
ca23936b455b
permissions
-rw-r--r--

improve grid rendering

#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:
	struct VertexInfo
	{
		glm::vec3 point;
		std::set<ldraw::id_t> objects;
		bool transformSet = false;
		glm::mat4 transform;
	};
	using ApplyFunction = std::function<void(const glm::vec3&, const VertexInfo&)>;
	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, VertexInfo> map;
};

#endif // VERTEXMAP_H

mercurial