diff -r aad3e897bc32 -r 121a40d5e34c src/vertexmap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/vertexmap.cpp Tue Jul 27 13:23:34 2021 +0300 @@ -0,0 +1,39 @@ +#include "vertexmap.h" +#include "linetypes/polygonobject.h" + +VertexMap::VertexMap(const Model *model) : + model{model} +{ + connect( + model, + &Model::dataChanged, + this, + &VertexMap::build + ); + connect( + model, + &Model::rowsInserted, + this, + &VertexMap::build + ); + connect( + model, + &Model::rowsRemoved, + this, + &VertexMap::build + ); + this->build(); +} + +void VertexMap::build() +{ + this->map.clear(); + this->model->apply([&](const ldraw::Object* object) + { + for (int i = 0; i < object->numPoints(); i += 1) + { + const glm::vec3& point = object->getPoint(i); + this->map[qHash(point)].insert(object->id); + } + }); +}