Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize map contour lines and fix long line bug #5852

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

faern
Copy link
Member

@faern faern commented Feb 23, 2024

This PR implements the changes needed to match with mullvad/globe-mesh-builder#1. The description for this change is basically the same, so I'll copy it over:

This PR does three things to the contour lines between geographical entities:

  • Subdivide long contour edges just like we do with triangles. Makes long lines not take a shortcut through earth and end up not visible
  • Removed duplicate contour line segments. Keep a HashSet with seen edges and skip already drawn edges
  • Order the contour line index buffer so it can be drawn as a single continuous line with GL_LINE_STRIP instead of the current GL_LINES. This reduces the size of the land_contour_indices.bin file from 873 kb bytes to 392 kb.

If we had access to OpenGL 3.1 we could draw the line strips much nicer with a single draw call thanks to glPrimitiveRestartIndex. But sadly this is not available to us. Instead this uses a hack where we continue the continuous line by drawing underneath the earths crust to the new position and pop back up there.


This change is Reviewable

@faern faern requested review from Rawa and raksooo February 23, 2024 14:45
Copy link
Member Author

@faern faern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion


android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/shapes/Globe.kt line 156 at r1 (raw file):

    companion object {
        private const val LAND_OCEAN_SCALE_FACTOR = 0.99999f

We can draw the land triangles closer to the contour lines now. This is because the contour lines are subdivided into shorter segments, staying closer to the sphere radius of 1.0. As such they don't go through the crust as easily and the crust can move closer!

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! :lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion

Copy link
Member

@raksooo raksooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion

@faern faern force-pushed the optimize-map-contour-lines branch from b67c62d to 941666b Compare February 27, 2024 08:40
@faern faern force-pushed the optimize-map-contour-lines branch from 941666b to 2f82e10 Compare February 27, 2024 09:45
@faern faern merged commit 2ca2186 into main Feb 27, 2024
18 checks passed
@faern faern deleted the optimize-map-contour-lines branch February 27, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants