Wed, 15 Jun 2022 12:41:57 +0300
Render line segments during draw mode nicer
src/document.cpp | file | annotate | diff | comparison | revisions |
--- a/src/document.cpp Wed Jun 15 12:33:16 2022 +0300 +++ b/src/document.cpp Wed Jun 15 12:41:57 2022 +0300 @@ -188,15 +188,18 @@ case DrawMode: painter->setPen(pens.polygonPen); for (const ModelAction& action : this->actions()) { - const opt<std::vector<glm::vec3>> points = modelActionPoints(action); - if (points.has_value()) { - if (worldPolygonWinding(*points, this->renderer) == Winding::Clockwise) { + const std::vector<glm::vec3> points = modelActionPoints(action).value_or(std::vector<glm::vec3>{}); + if (points.size() == 2) { + drawWorldPolyline(painter, points, renderer); + } + else { + if (worldPolygonWinding(points, this->renderer) == Winding::Clockwise) { painter->setBrush(pens.greenPolygonBrush); } else { painter->setBrush(pens.redPolygonBrush); } - drawWorldPolygon(painter, *points, this->renderer); + drawWorldPolygon(painter, points, this->renderer); } } //drawWorldPolyline(painter, this->previewPolygon, this->renderer);