src/vertexmap.h

Mon, 20 Jun 2022 22:41:34 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Mon, 20 Jun 2022 22:41:34 +0300
changeset 244
065db0753f05
parent 206
654661eab7f3
child 259
c27612f0eac0
permissions
-rw-r--r--

a bit of refactor in mapbox::util::nth

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

#endif // VERTEXMAP_H

mercurial