Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
dcbe7d8
Vectorlayer
LucasDworschak Nov 22, 2024
6723eaf
Vector Layer - Rasterizer
LucasDworschak Nov 25, 2024
1c990ad
Vector layer - Rasterizer:
LucasDworschak Nov 26, 2024
23920c9
Vector Layer - Rasterizer
LucasDworschak Nov 27, 2024
6b28b89
Vector layer - rasterizer
LucasDworschak Nov 27, 2024
bfc15e6
Vector layer - rasterizer
LucasDworschak Nov 27, 2024
928975d
Vector layer - rasterizer:
LucasDworschak Nov 28, 2024
48b4f39
Vector layer - Rasterizer
LucasDworschak Dec 2, 2024
ae62485
Vector layer - rasterizer
LucasDworschak Dec 2, 2024
74b151c
Vector layer - rasterizer
LucasDworschak Dec 2, 2024
6088e1d
Vector layer - rasterizer
LucasDworschak Dec 2, 2024
752095d
Vector layer - rasterizer
LucasDworschak Dec 3, 2024
b0d70d3
Revert "Vector layer - rasterizer"
LucasDworschak Dec 3, 2024
76881fd
reenabled ordering test in rasterizer.cpp
LucasDworschak Dec 3, 2024
1d9ff4c
added specific versions to deploy.yml to try and fix android builds
LucasDworschak Dec 3, 2024
9571a23
Revert "added specific versions to deploy.yml to try and fix android …
LucasDworschak Dec 3, 2024
46ee282
git deploy without android
LucasDworschak Dec 3, 2024
99d2db2
second attempt to exclude android builds
LucasDworschak Dec 3, 2024
bb7eece
Revert "second attempt to exclude android builds"
LucasDworschak Dec 4, 2024
b5e6cc7
Revert "git deploy without android"
LucasDworschak Dec 4, 2024
8f0df0a
Merge branch 'main' into rasterizer
LucasDworschak Dec 5, 2024
de38952
improved rasterizer
LucasDworschak Dec 5, 2024
320188a
added rasterizer benchmarks
LucasDworschak Dec 5, 2024
3cacfce
Merge branch 'rasterizer'
LucasDworschak Dec 5, 2024
e2ac775
added rasterizer benchmarks with increased distance
LucasDworschak Dec 5, 2024
0509330
Merge branch 'main' into rasterizer
LucasDworschak Dec 5, 2024
a0580ba
Merge pull request #141 from LucasDworschak/main
adam-ce Dec 5, 2024
1081cb4
rasterizer - added possibility to remove duplicate vertices
LucasDworschak Dec 13, 2024
c34e73c
Merge remote-tracking branch 'upstream/next'
LucasDworschak Dec 13, 2024
9a98dbe
Merge branch 'rasterizer'
LucasDworschak Dec 13, 2024
95371b1
Merge pull request #142 from LucasDworschak/main
adam-ce Dec 13, 2024
8f88387
Rasterizer - extracted edge generation to separate function
LucasDworschak Dec 19, 2024
a650f29
Rasterizer - Bugfix for specific triangles + small fixes
LucasDworschak Dec 22, 2024
34b0da6
Merge remote-tracking branch 'upstream/main' into rasterizer
LucasDworschak Dec 22, 2024
5c6841a
Merge branch 'rasterizer'
LucasDworschak Dec 22, 2024
c1c9d15
Rasterizer - renamed rasterizer debug image macro and commented it out
LucasDworschak Dec 22, 2024
b94c273
Merge branch 'rasterizer'
LucasDworschak Dec 22, 2024
e7982c5
Rasterizer - removed macros as they likely cause github tests to fail
LucasDworschak Dec 22, 2024
8283211
Merge remote-tracking branch 'upstream/main'
LucasDworschak Dec 22, 2024
c6d52cf
Rasterizer Bugfix - wrong fill_direction due to int rounding
LucasDworschak Dec 23, 2024
c3bb761
Merge remote-tracking branch 'upstream/main'
LucasDworschak Dec 23, 2024
27ee99e
Revert "Rasterizer - removed macros as they likely cause github tests…
LucasDworschak Dec 23, 2024
4d5a2cd
Merge branch 'main' into rasterizer
LucasDworschak Dec 23, 2024
5c545d0
Merge branch 'rasterizer'
LucasDworschak Dec 23, 2024
e861f11
Merge pull request #143 from AlpineMapsOrg/main
adam-ce Dec 26, 2024
3e42145
Merge branch 'main' into next
adam-ce Dec 26, 2024
ea6e418
Merge remote-tracking branch 'upstream/main'
LucasDworschak Dec 27, 2024
a7b8967
Merge branch 'upstream_main' into new_next
adam-ce Jan 5, 2025
ff847a3
Rasterizer - removed randomness from test to be the same on all compi…
LucasDworschak Jan 14, 2025
918b173
Merge remote-tracking branch 'upstream/main'
LucasDworschak Jan 14, 2025
4a4f8e5
Added support for RGB32UI textures + RG32UI and RGB32UI array textures
LucasDworschak Jan 14, 2025
6b47ca4
added R32UI array test and texture upload; changed clang format Alway…
LucasDworschak Jan 14, 2025
e26430d
Merge pull request #149 from AlpineMapsOrg/main
adam-ce Jan 15, 2025
531f818
Merge branch 'next' into main
LucasDworschak Jan 15, 2025
f4b505b
Merge pull request #150 from LucasDworschak/main
adam-ce Jan 15, 2025
2701d45
Merge pull request #164 from AlpineMapsOrg/main
adam-ce Feb 8, 2025
0dcdfe7
Merge pull request #172 from AlpineMapsOrg/main
adam-ce Feb 15, 2025
da3f7b6
Merge branch 'upstream_main' into next
adam-ce Mar 30, 2025
3f06310
Merge pull request #213 from AlpineMapsOrg/main
adam-ce Jul 1, 2025
03d4a7f
Merge pull request #216 from AlpineMapsOrg/main
adam-ce Jul 3, 2025
4988604
Merge pull request #229 from AlpineMapsOrg/main
adam-ce Nov 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
fetch-depth: 0
fetch-tags: true

- name: Install Qt native version (the one provided by aqt doesn't seem to work)
- name: Install Qt native version (the one provided by aqt does not seem to work)
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ jobs:
modules: 'qtcharts qtpositioning'
cache: true

- name: Debug output
shell: bash
run: |
echo "${{github.workspace}}/qt/Qt/6.8.1":
ls ${{github.workspace}}/qt/Qt/6.8.1
echo "==="
echo "${QT_ROOT_DIR}/lib/cmake/Qt6Linguist:"
ls ${QT_ROOT_DIR}/lib/cmake/Qt6Linguist
echo "==="

- name: Configure
env:
CC: ${{ matrix.CC }}
Expand Down
6 changes: 5 additions & 1 deletion gl_engine/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ GlParams gl_tex_params(gl_engine::Texture::Format format)
return { GL_RG8, GL_RG, GL_UNSIGNED_BYTE, 2, 1, true };
case F::RG32UI:
return { GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, 2, 4 };
case F::RGB32UI:
return { GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT, 3, 4 };
case F::R8UI:
return { GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 1, 1 };
case F::R16UI:
Expand Down Expand Up @@ -230,8 +232,9 @@ template <typename T> void gl_engine::Texture::upload(const nucleus::Raster<T>&
template void gl_engine::Texture::upload<uint8_t>(const nucleus::Raster<uint8_t>&, unsigned);
template void gl_engine::Texture::upload<uint16_t>(const nucleus::Raster<uint16_t>&, unsigned);
template void gl_engine::Texture::upload<uint32_t>(const nucleus::Raster<uint32_t>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<2, uint32_t>>(const nucleus::Raster<glm::vec<2, uint32_t>>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<2, uint8_t>>(const nucleus::Raster<glm::vec<2, uint8_t>>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<2, uint32_t>>(const nucleus::Raster<glm::vec<2, uint32_t>>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<3, uint32_t>>(const nucleus::Raster<glm::vec<3, uint32_t>>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<4, uint8_t>>(const nucleus::Raster<glm::vec<4, uint8_t>>&, unsigned);
template void gl_engine::Texture::upload<glm::vec<4, float>>(const nucleus::Raster<glm::vec<4, float>>&, unsigned);

Expand Down Expand Up @@ -260,6 +263,7 @@ template void gl_engine::Texture::upload<uint8_t>(const nucleus::Raster<uint8_t>
template void gl_engine::Texture::upload<uint16_t>(const nucleus::Raster<uint16_t>&);
template void gl_engine::Texture::upload<uint32_t>(const nucleus::Raster<uint32_t>&);
template void gl_engine::Texture::upload<glm::vec<2, uint32_t>>(const nucleus::Raster<glm::vec<2, uint32_t>>&);
template void gl_engine::Texture::upload<glm::vec<3, uint32_t>>(const nucleus::Raster<glm::vec<3, uint32_t>>&);
template void gl_engine::Texture::upload<glm::vec<2, uint8_t>>(const nucleus::Raster<glm::vec<2, uint8_t>>&);
template void gl_engine::Texture::upload<glm::vec<4, uint8_t>>(const nucleus::Raster<glm::vec<4, uint8_t>>&);
template void gl_engine::Texture::upload<glm::vec<4, float>>(const nucleus::Raster<glm::vec<4, float>>&);
Expand Down
6 changes: 6 additions & 0 deletions gl_engine/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Texture {
RGBA32F,
RG8, // normalised on gpu
RG32UI,
RGB32UI,
R8UI,
R16UI,
R32UI,
Expand Down Expand Up @@ -84,7 +85,12 @@ class Texture {
extern template void gl_engine::Texture::upload<uint16_t>(const nucleus::Raster<uint16_t>&);
extern template void gl_engine::Texture::upload<uint32_t>(const nucleus::Raster<uint32_t>&);
extern template void gl_engine::Texture::upload<glm::vec<2, uint32_t>>(const nucleus::Raster<glm::vec<2, uint32_t>>&);
extern template void gl_engine::Texture::upload<glm::vec<3, uint32_t>>(const nucleus::Raster<glm::vec<3, uint32_t>>&);
extern template void gl_engine::Texture::upload<glm::vec<2, uint8_t>>(const nucleus::Raster<glm::vec<2, uint8_t>>&);
extern template void gl_engine::Texture::upload<glm::vec<4, uint8_t>>(const nucleus::Raster<glm::vec<4, uint8_t>>&);

extern template void gl_engine::Texture::upload<uint32_t>(const nucleus::Raster<uint32_t>&, unsigned int);
extern template void gl_engine::Texture::upload<glm::vec<2, uint32_t>>(const nucleus::Raster<glm::vec<2, uint32_t>>&, unsigned int);
extern template void gl_engine::Texture::upload<glm::vec<3, uint32_t>>(const nucleus::Raster<glm::vec<3, uint32_t>>&, unsigned int);

} // namespace gl_engine
7 changes: 6 additions & 1 deletion nucleus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(ALP_ENABLE_LABELS)
alp_add_git_repository(vector_tiles URL https://github.com/AlpineMapsOrg/vector-tile.git COMMITISH faba88257716c4bc01ebd44d8b8b98f711ecb78c)
endif()
alp_add_git_repository(goofy_tc URL https://github.com/AlpineMapsOrgDependencies/Goofy_slim.git COMMITISH 13b228784960a6227bb6ca704ff34161bbac1b91 DO_NOT_ADD_SUBPROJECT)
alp_add_git_repository(cdt URL https://github.com/artem-ogre/CDT.git COMMITISH 46f1ce1f495a97617d90e8c833d0d29406335fdf DO_NOT_ADD_SUBPROJECT)

add_library(zppbits INTERFACE)
target_include_directories(zppbits SYSTEM INTERFACE ${zppbits_SOURCE_DIR})
Expand All @@ -40,6 +41,9 @@ set_target_properties(goofy_tc PROPERTIES SYSTEM true)
add_library(tl_expected INTERFACE)
target_include_directories(tl_expected INTERFACE ${tl_expected_SOURCE_DIR}/include)

add_library(cdt INTERFACE)
target_include_directories(cdt INTERFACE ${cdt_SOURCE_DIR}/CDT/include)

set(alp_version_out ${CMAKE_BINARY_DIR}/alp_version/nucleus/version.cpp)

# cmake tests for existance of ${alp_version_out}.do_always_run. since it's always missing, cmake tries to generate it using this command.
Expand Down Expand Up @@ -113,6 +117,7 @@ qt_add_library(nucleus STATIC
tile/GeometryScheduler.h tile/GeometryScheduler.cpp
utils/error.h
utils/lang.h
utils/rasterizer.h utils/rasterizer.cpp
tile/SchedulerDirector.h tile/SchedulerDirector.cpp
tile/drawing.h tile/drawing.cpp
camera/gesture.h
Expand Down Expand Up @@ -147,7 +152,7 @@ endif()

target_include_directories(nucleus PUBLIC ${CMAKE_SOURCE_DIR})
# Please keep Qt::Gui outside the nucleus. If you need it optional via a cmake based switch
target_link_libraries(nucleus PUBLIC radix Qt::Core Qt::Network zppbits tl_expected nucleus_version stb_slim goofy_tc)
target_link_libraries(nucleus PUBLIC radix Qt::Core Qt::Network zppbits tl_expected nucleus_version stb_slim goofy_tc cdt)

qt_add_resources(nucleus "icons"
PREFIX "/map_icons"
Expand Down
34 changes: 34 additions & 0 deletions nucleus/tile/conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,38 @@ inline glm::u8vec4 uint162alpineRGBA(uint16_t v)
{
return { v >> 8, v & 255, 0, 255 };
}

inline QImage u8raster_to_qimage(const nucleus::Raster<uint8_t>& raster)
{
size_t width = raster.width();
size_t height = raster.height();

QImage image(width, height, QImage::Format_Grayscale8);

for (size_t y = 0; y < height; ++y) {
uchar* line = image.scanLine(y);
for (size_t x = 0; x < width; ++x) {
line[x] = raster.pixel({ x, y });
}
}

return image;
}

inline QImage u8raster_2_to_qimage(const nucleus::Raster<uint8_t>& raster1, const nucleus::Raster<uint8_t>& raster2)
{
size_t width = raster1.width();
size_t height = raster1.height();

QImage image(width, height, QImage::Format_RGB888);

for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width; ++x) {
image.setPixel(QPoint(x, y), (raster1.pixel({ x, y }) << 16) + (raster2.pixel({ x, y }) << 8));
}
}

return image;
}

} // namespace nucleus::tile::conversion
103 changes: 103 additions & 0 deletions nucleus/utils/rasterizer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*****************************************************************************
* AlpineMaps.org
* Copyright (C) 2024 Lucas Dworschak
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#include "rasterizer.h"

#include <CDT.h>

namespace nucleus::utils::rasterizer {

std::vector<glm::ivec2> generate_neighbour_edges(std::vector<glm::vec2> polygon_points, const size_t start_offset)
{
std::vector<glm::ivec2> edges;
{ // create the edges
edges.reserve(polygon_points.size());
for (size_t i = 0; i < polygon_points.size() - 1; i++) {
edges.push_back(glm::ivec2(start_offset + int(i), start_offset + int(i + 1)));
}

// last edge between start and end vertex
edges.push_back(glm::ivec2(start_offset + polygon_points.size() - 1, start_offset));
}

return edges;
}

std::vector<glm::vec2> triangulize(std::vector<glm::vec2> polygon_points, std::vector<glm::ivec2> edges, bool remove_duplicate_vertices)
{
std::vector<glm::vec2> processed_triangles;

// triangulation
CDT::Triangulation<double> cdt;

if (remove_duplicate_vertices) {
CDT::RemoveDuplicatesAndRemapEdges<double>(
polygon_points,
[](const glm::vec2& p) { return p.x; },
[](const glm::vec2& p) { return p.y; },
edges.begin(),
edges.end(),
[](const glm::ivec2& p) { return p.x; },
[](const glm::ivec2& p) { return p.y; },
[](CDT::VertInd start, CDT::VertInd end) { return glm::ivec2 { start, end }; });
}

cdt.insertVertices(polygon_points.begin(), polygon_points.end(), [](const glm::vec2& p) { return p.x; }, [](const glm::vec2& p) { return p.y; });
cdt.insertEdges(edges.begin(), edges.end(), [](const glm::ivec2& p) { return p.x; }, [](const glm::ivec2& p) { return p.y; });
cdt.eraseOuterTrianglesAndHoles();

// fill our own data structures
for (size_t i = 0; i < cdt.triangles.size(); ++i) {
auto tri = cdt.triangles[i];

std::vector<size_t> tri_indices = { tri.vertices[0], tri.vertices[1], tri.vertices[2] };

int top_index = (cdt.vertices[tri.vertices[0]].y < cdt.vertices[tri.vertices[1]].y) ? ((cdt.vertices[tri.vertices[0]].y < cdt.vertices[tri.vertices[2]].y) ? 0 : 2)
: ((cdt.vertices[tri.vertices[1]].y < cdt.vertices[tri.vertices[2]].y) ? 1 : 2);
// for middle and bottom index we first initialize them randomly with the values that still need to be tested
int middle_index;
int bottom_index;
if (top_index == 0) {
middle_index = 1;
bottom_index = 2;
} else if (top_index == 1) {
middle_index = 2;
bottom_index = 0;
} else {
middle_index = 0;
bottom_index = 1;
}

// and now we test if we assigned them correctly
if (cdt.vertices[tri.vertices[middle_index]].y > cdt.vertices[tri.vertices[bottom_index]].y) {
// if not we have to interchange them
int tmp = middle_index;
middle_index = bottom_index;
bottom_index = tmp;
}

// lastly add the vertices to the vector in the correct order
processed_triangles.push_back({ cdt.vertices[tri.vertices[top_index]].x, cdt.vertices[tri.vertices[top_index]].y });
processed_triangles.push_back({ cdt.vertices[tri.vertices[middle_index]].x, cdt.vertices[tri.vertices[middle_index]].y });
processed_triangles.push_back({ cdt.vertices[tri.vertices[bottom_index]].x, cdt.vertices[tri.vertices[bottom_index]].y });
}

return processed_triangles;
}

} // namespace nucleus::utils::rasterizer
Loading