src/vertexmap.h

Wed, 29 Jun 2022 16:21:44 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 29 Jun 2022 16:21:44 +0300
changeset 308
daa8770b9d26
parent 264
76a025db4948
child 309
d862721d19a3
permissions
-rw-r--r--

add comments in colors.h

#ifndef VERTEXMAP_H
#define VERTEXMAP_H
#include <set>
#include "src/basics.h"
#include "src/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<ModelId> 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<hash_t> vertexHashes;
	std::vector<glm::vec3> vertices;
	std::map<hash_t, VertexInfo> map;
};

#endif // VERTEXMAP_H

mercurial