replace thick lines with quads
Summary by Sourcery
Replace line-based rendering of thick connection, infomark, and character path graphics with quad-based rendering for more consistent appearance and control over thickness.
Enhancements:
- Render connections, infomarks, and character paths using colored quads instead of OpenGL line primitives, adjusting line widths to match the new approach.
- Improve handling of degenerate and long segments for connections and infomark arrows to maintain visual continuity and fading behavior.
- Slightly adjust one-way connection endpoint geometry for better visual alignment.
Reviewer's Guide
Replaces OpenGL line-based rendering of 3D map connections, infomark arrows, and character paths with quad-based geometry built via a new shared LineRendering utility, while adjusting visual constants and projection tolerances for more robust, consistent appearance.
Sequence diagram for quad-based connection line rendering
sequenceDiagram
participant MapCanvas
participant ConnectionDrawer
participant ConnectionFakeGL
participant OpenGL
participant mmgl_LineRendering
MapCanvas->>ConnectionDrawer: buildConnectionGeometry()
ConnectionDrawer->>ConnectionFakeGL: drawLineStrip(points)
loop over segments
ConnectionFakeGL->>ConnectionFakeGL: transform points
ConnectionFakeGL->>mmgl_LineRendering: isNearZero(segment)
alt zero-length segment
mmgl_LineRendering-->>ConnectionFakeGL: true
ConnectionFakeGL->>mmgl_LineRendering: drawZeroLengthSquare(quadVerts, center, width, color)
else non-zero segment
mmgl_LineRendering-->>ConnectionFakeGL: false
ConnectionFakeGL->>mmgl_LineRendering: getPerpendicularNormal(direction)
alt segment crosses Z layers
ConnectionFakeGL->>mmgl_LineRendering: getOrthogonalNormal(direction, perp_normal_1)
ConnectionFakeGL->>mmgl_LineRendering: generateLineQuad(quadVerts, p1, p2, width, color, perp_normal_1)
ConnectionFakeGL->>mmgl_LineRendering: generateLineQuad(quadVerts, p1, p2, width, color, perp_normal_2)
else same Z layer
ConnectionFakeGL->>mmgl_LineRendering: generateLineQuad(quadVerts, p1, p2, width, color, perp_normal_1)
end
end
end
ConnectionDrawer->>OpenGL: ConnectionDrawerBuffers.getMeshes()
OpenGL-->>ConnectionDrawer: ConnectionMeshes(normalQuads, redQuads, tris)
MapCanvas->>ConnectionMeshes: render(thisLayer, focusedLayer)
ConnectionMeshes->>OpenGL: normalQuads.render(state)
ConnectionMeshes->>OpenGL: redQuads.render(state)
ConnectionMeshes->>OpenGL: normalTris.render(state)
ConnectionMeshes->>OpenGL: redTris.render(state)
Sequence diagram for quad-based infomark arrow rendering
sequenceDiagram
participant MapCanvas
participant InfomarksBatch
participant OpenGL
participant mmgl_LineRendering
MapCanvas->>InfomarksBatch: drawInfomark(batch, ARROW, ...)
MapCanvas->>InfomarksBatch: drawLine(shaftStart, shaftEnd)
InfomarksBatch->>mmgl_LineRendering: generateLineQuadsSafe(m_quads, start_v, end_v, width, color)
mmgl_LineRendering-->>InfomarksBatch: quad vertices appended
MapCanvas->>InfomarksBatch: drawTriangle(arrowhead vertices)
MapCanvas->>InfomarksBatch: renderImmediate(state)
InfomarksBatch->>OpenGL: renderColoredTris(m_tris, state)
InfomarksBatch->>OpenGL: renderColoredQuads(m_quads, state)
InfomarksBatch->>OpenGL: renderPoints(m_points, state.withPointSize())
InfomarksBatch->>OpenGL: font.render3dTextImmediate(text)
Class diagram for quad-based line rendering utilities and consumers
classDiagram
class mmgl_LineRendering {
+float W_PROJECTION_EPSILON
+float GEOMETRIC_EPSILON
+float PROJECTION_EPSILON
+float ZERO_LENGTH_THRESHOLD_SQ
+generateLineQuad(verts, p1, p2, width, color, perpendicular_normal)
+drawZeroLengthSquare(verts, center, width, color)
+getPerpendicularNormal(direction) glm::vec3
+getOrthogonalNormal(direction, perp_normal_1) glm::vec3
+generateLineQuadsSafe(verts, p1, p2, width, color)
+isDegenerate(vec) bool
+isNearZero(segment) bool
}
class ConnectionDrawerColorBuffer {
+std_vector_ColorVert triVerts
+std_vector_ColorVert quadVerts
+clear()
+empty() bool
}
class ConnectionMeshes {
+UniqueMesh normalTris
+UniqueMesh redTris
+UniqueMesh normalQuads
+UniqueMesh redQuads
+render(thisLayer, focusedLayer)
}
class InfomarksBatch {
-OpenGL m_realGL
-Font3d m_font
-Color m_color
-std_vector_ColorVert m_points
-std_vector_ColorVert m_tris
-std_vector_ColorVert m_quads
+drawPoint(a)
+drawLine(a, b)
+drawTriangle(a, b, c)
+renderImmediate(state)
+getMeshes() InfomarksMeshes
}
class InfomarksMeshes {
+UniqueMesh points
+UniqueMesh tris
+UniqueMesh quads
+UniqueMesh textMesh
+bool isValid
+render()
}
class CharacterBatch_CharFakeGL {
-std_vector_ColorVert m_charTris
-std_vector_ColorVert m_charBeaconQuads
-std_vector_ColorVert m_charLines
-std_vector_ColoredTexVert m_charRoomQuads
-std_vector_ColorVert m_pathPoints
-std_vector_ColorVert m_pathLineQuads
-std_vector_FontVert3d m_screenSpaceArrows
+drawPathSegment(p1, p2, color)
+drawPathPoint(color, pos)
+reallyDrawPaths(gl)
}
mmgl_LineRendering <.. ConnectionDrawerColorBuffer : uses
mmgl_LineRendering <.. ConnectionMeshes : uses
mmgl_LineRendering <.. InfomarksBatch : uses
mmgl_LineRendering <.. CharacterBatch_CharFakeGL : uses
ConnectionDrawerColorBuffer --> ConnectionMeshes : provides data
InfomarksBatch --> InfomarksMeshes : builds
CharacterBatch_CharFakeGL --> OpenGL : reallyDrawPaths
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Introduce shared quad-based line rendering helpers and tolerance constants in a new LineRendering module and wire it into build. |
|
src/opengl/LineRendering.cppsrc/opengl/LineRendering.hsrc/CMakeLists.txt |
| Convert connection rendering from line primitives to quad geometry with updated fading, Z-layer handling, and endpoint tweaks. |
|
src/display/Connections.cppsrc/display/Connections.hsrc/display/ConnectionLineBuilder.cpp |
| Convert infomark arrows from line primitives to quads and adjust arrow drawing to separate shaft and head. |
|
src/display/Infomarks.cppsrc/display/Infomarks.h |
| Render character path lines as quad geometry instead of GL lines, and adjust path width. |
|
src/display/Characters.cppsrc/display/Characters.h |
| Use shared projection tolerances from LineRendering when projecting/unprojecting map coordinates. |
|
src/display/MapCanvasData.cpp |
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
-
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. -
Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 66.37%. Comparing base (26d1a9d) to head (b233e82).
:warning: Report is 125 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #412 +/- ##
==========================================
- Coverage 66.48% 66.37% -0.12%
==========================================
Files 85 86 +1
Lines 4186 3937 -249
Branches 255 257 +2
==========================================
- Hits 2783 2613 -170
+ Misses 1403 1324 -79
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@sourcery-ai review
https://github.com/sourcery-ai review
@sourcery-ai review
@sourcery-ai review
https://github.com/sourcery-ai review
@sourcery-ai review
@sourcery-ai review
@sourcery-ai review