Render line segments during draw mode nicer

Wed, 15 Jun 2022 12:41:57 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 15 Jun 2022 12:41:57 +0300
changeset 227
011600b3cf73
parent 226
60d6b797a12e
child 228
948867719906

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);

mercurial