diff -r 121a40d5e34c -r 8e1c9f18ae15 src/vertexmap.cpp --- a/src/vertexmap.cpp Tue Jul 27 13:23:34 2021 +0300 +++ b/src/vertexmap.cpp Tue Jul 27 16:29:00 2021 +0300 @@ -28,12 +28,29 @@ void VertexMap::build() { this->map.clear(); + this->vertices.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); + const unsigned int hash = qHash(point); + this->map[hash].insert(object->id); + this->vertices[hash] = point; } }); + Q_EMIT this->verticesChanged(); } + +/** + * @brief Apply \c fn for all vertices in the map. + * @param fn + */ +void VertexMap::apply(ApplyFunction fn) const +{ + for (auto it = this->map.cbegin(); it != this->map.cend(); ++it) + { + const glm::vec3& point = this->vertices.at(it->first); + fn(point, it->second); + } +}