diff -r 36ea1a8aee33 -r 8305e2f968fb src/ui/canvas.cpp --- a/src/ui/canvas.cpp Sat Mar 05 13:32:58 2022 +0200 +++ b/src/ui/canvas.cpp Sat Mar 05 13:38:22 2022 +0200 @@ -228,19 +228,23 @@ } /** + * @brief Draws a polyline to where the specified vector of 3D points would appear on the screen. + * @param painter Painter to use to draw with + * @param points 3D points to render + */ +void Canvas::drawWorldPolyline(QPainter *painter, const std::vector &points) +{ + painter->drawPolyline(QPolygonF{this->convertWorldPointsToScreenPoints(points)}); +} + +/** * @brief Draws a polygon to where the specified vector of 3D points would appear on the screen. * @param painter Painter to use to draw with * @param points 3D points to render */ void Canvas::drawWorldPolygon(QPainter* painter, const std::vector &points) { - QVector points2d; - points2d.reserve(points.size()); - for (const glm::vec3& point : points) - { - points2d.push_back(this->modelToScreenCoordinates(point)); - } - painter->drawPolygon(QPolygonF{points2d}); + painter->drawPolygon(QPolygonF{this->convertWorldPointsToScreenPoints(points)}); } /** @@ -329,6 +333,17 @@ return std::abs(dot) < threshold; } +QVector Canvas::convertWorldPointsToScreenPoints(const std::vector &worldPoints) +{ + QVector points2d; + points2d.reserve(worldPoints.size()); + for (const glm::vec3& point : worldPoints) + { + points2d.push_back(this->modelToScreenCoordinates(point)); + } + return points2d; +} + /** * @brief Clears the selection. */