From 44c4b61e466382fea84a46e50c488ff2bcabf582 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Sat, 11 Nov 2023 03:53:35 +0100 Subject: [PATCH 1/3] Allow line loops on Cylindrical projection. Thanks to @10110111 for a bugfix --- src/core/StelVertexArray.cpp | 23 +++++++++++++++++++---- src/core/modules/GridLinesMgr.cpp | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/core/StelVertexArray.cpp b/src/core/StelVertexArray.cpp index a194505633356..29b465729d956 100644 --- a/src/core/StelVertexArray.cpp +++ b/src/core/StelVertexArray.cpp @@ -23,6 +23,7 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjector* prj) const { StelVertexArray ret = *this; + ret.primitiveType = Triangles; if (isIndexed()) { @@ -55,14 +56,13 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjecto else { ret.indices.clear(); - unsigned short int limit; + const unsigned short int limit=static_cast(vertex.size()); // Create a 'Triangles' vertex array from this array. // We have different algorithms for different original mode switch (primitiveType) { case TriangleStrip: ret.indices.reserve(vertex.size() * 3); - limit = static_cast(vertex.size()); for (unsigned short int i = 2; i < limit; ++i) { if (prj->intersectViewportDiscontinuity(vertex[i], vertex[i-1]) || @@ -83,7 +83,6 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjecto case Triangles: ret.indices.reserve(vertex.size()); - limit = static_cast(vertex.size()); for (unsigned short int i = 0; i < limit; i += 3) { if (prj->intersectViewportDiscontinuity(vertex.at(i), vertex.at(i+1)) || @@ -99,6 +98,23 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjecto } break; + case LineLoop: + case LineStrip: + // convert to an indexed set of GL_LINEs, leaving those away which intersect + ret.primitiveType=Lines; + ret.indices.reserve(2*vertex.size()); + for (unsigned short int i = 0; i < limit-1; i++) + { + if (!prj->intersectViewportDiscontinuity(vertex.at(i), vertex.at(i+1)) ) + ret.indices << i << i+1; + } + if (primitiveType==LineLoop) + { + if (!prj->intersectViewportDiscontinuity(vertex.at(limit-1), vertex.at(0)) ) + ret.indices << limit-1 << 0; + } + break; + default: Q_ASSERT(false); } @@ -108,7 +124,6 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjecto // FIXME: we should use an attribute for indexed array. if (ret.indices.isEmpty()) ret.vertex.clear(); - ret.primitiveType = Triangles; return ret; } diff --git a/src/core/modules/GridLinesMgr.cpp b/src/core/modules/GridLinesMgr.cpp index b5ac80b0bd5cd..b6d3b14d7cdff 100644 --- a/src/core/modules/GridLinesMgr.cpp +++ b/src/core/modules/GridLinesMgr.cpp @@ -931,7 +931,7 @@ void SkyLine::draw(StelCore *core) const rot.transfo(point); // rotate towards earth position circle.vertex.append(pos+point); // attach to earth centre } - sPainter.drawStelVertexArray(circle, false); // setting true does not paint for cylindrical&friends :-( + sPainter.drawStelVertexArray(circle, true); // Special case for Umbra and Penumbra labels Vec3d point(dist, 0.0, 0.0); From 1592160cc10729b06a66f642af4a7fb17ce1d86c Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Sat, 11 Nov 2023 11:48:38 +0100 Subject: [PATCH 2/3] Cosmetics --- src/core/StelVertexArray.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/StelVertexArray.cpp b/src/core/StelVertexArray.cpp index 29b465729d956..b4a483fb4b5ad 100644 --- a/src/core/StelVertexArray.cpp +++ b/src/core/StelVertexArray.cpp @@ -23,7 +23,6 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjector* prj) const { StelVertexArray ret = *this; - ret.primitiveType = Triangles; if (isIndexed()) { @@ -56,12 +55,14 @@ StelVertexArray StelVertexArray::removeDiscontinuousTriangles(const StelProjecto else { ret.indices.clear(); - const unsigned short int limit=static_cast(vertex.size()); + Q_ASSERT(vertex.size() <= std::numeric_limits::max()); + const unsigned short limit=vertex.size(); // Create a 'Triangles' vertex array from this array. // We have different algorithms for different original mode switch (primitiveType) { case TriangleStrip: + ret.primitiveType = Triangles; ret.indices.reserve(vertex.size() * 3); for (unsigned short int i = 2; i < limit; ++i) { From 63b41d29cecc15fac3ca193b9333c37011586876 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Sat, 11 Nov 2023 12:20:45 +0100 Subject: [PATCH 3/3] Apply same fix for earth shadow in Satellites plugin --- plugins/Satellites/src/Satellites.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Satellites/src/Satellites.cpp b/plugins/Satellites/src/Satellites.cpp index 1a559a8a83e30..941193cc1839b 100644 --- a/plugins/Satellites/src/Satellites.cpp +++ b/plugins/Satellites/src/Satellites.cpp @@ -2903,7 +2903,7 @@ void Satellites::drawCircles(StelCore* core, StelPainter &painter) umbra.vertex.append(pos+point); } painter.setColor(getUmbraColor(), 1.f); - painter.drawStelVertexArray(umbra, false); + painter.drawStelVertexArray(umbra, true); // plot a center cross mark texCross->bind(); @@ -2926,7 +2926,7 @@ void Satellites::drawCircles(StelCore* core, StelPainter &painter) } painter.setColor(getPenumbraColor(), 1.f); - painter.drawStelVertexArray(penumbra, false); + painter.drawStelVertexArray(penumbra, true); } painter.setProjector(saveProj); }