From c08ff181c309ce50e1dd41cb400d4434303174b9 Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sun, 1 Mar 2026 15:21:09 +0100 Subject: [PATCH 1/3] optimimze wheel size --- .github/workflows/pip_publish.yml | 6 +----- python_bindings/CMakeLists.txt | 31 ++++++++++++++++++++++++++----- python_bindings/pyproject.toml | 1 + 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pip_publish.yml b/.github/workflows/pip_publish.yml index 72e55de..3b7eb67 100644 --- a/.github/workflows/pip_publish.yml +++ b/.github/workflows/pip_publish.yml @@ -40,7 +40,6 @@ jobs: CIBW_BEFORE_ALL_LINUX: | yum install -y epel-release && \ yum install -y \ - glfw-devel \ libX11-devel \ libXcursor-devel \ libXrandr-devel \ @@ -48,10 +47,7 @@ jobs: libXi-devel \ wayland-devel \ mesa-libEGL-devel \ - mesa-libGLES-devel \ - SDL2-devel \ - qt5-qtbase-devel \ - gtk3-devel + mesa-libGLES-devel run: | cd python_bindings cibuildwheel --output-dir dist diff --git a/python_bindings/CMakeLists.txt b/python_bindings/CMakeLists.txt index e586ca7..361b924 100644 --- a/python_bindings/CMakeLists.txt +++ b/python_bindings/CMakeLists.txt @@ -8,6 +8,18 @@ set(LIB_DIR vendored_deps) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(BUILD_SHARED_LIBS OFF) +# Disable unnecessary sub-targets from vendored deps +set(OPTION_BUILD_TOOLS OFF CACHE BOOL "" FORCE) +set(OPTION_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +set(OPTION_BUILD_DOCS OFF CACHE BOOL "" FORCE) +set(OPTION_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) +set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE) +set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE) +set(SPDLOG_BUILD_BENCH OFF CACHE BOOL "" FORCE) + find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) @@ -24,30 +36,32 @@ endif() add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_OFF) +# EXCLUDE_FROM_ALL prevents vendored deps from installing their own +# files (static archives, examples, tools) into the wheel. if(NOT TARGET spdlog::spdlog) message(STATUS "Adding spdlog...") - add_subdirectory(${LIB_DIR}/spdlog) + add_subdirectory(${LIB_DIR}/spdlog EXCLUDE_FROM_ALL) endif() if(NOT TARGET glbinding::glbinding-aux) message(STATUS "Adding glbinding...") - add_subdirectory(${LIB_DIR}/glbinding) + add_subdirectory(${LIB_DIR}/glbinding EXCLUDE_FROM_ALL) endif() if(NOT TARGET glfw) message(STATUS "Adding glfw...") - add_subdirectory(${LIB_DIR}/glfw) + add_subdirectory(${LIB_DIR}/glfw EXCLUDE_FROM_ALL) endif() if(NOT TARGET imgui::imgui) message(STATUS "Adding imgui...") - add_subdirectory(${LIB_DIR}/imgui_wrapper) + add_subdirectory(${LIB_DIR}/imgui_wrapper EXCLUDE_FROM_ALL) endif() if(NOT TARGET slamd) message(STATUS "Adding slamd...") - add_subdirectory(slamd_src) + add_subdirectory(slamd_src EXCLUDE_FROM_ALL) endif() @@ -96,5 +110,12 @@ target_link_libraries(bindings fmt::fmt ) +# slamd_window is excluded from ALL due to EXCLUDE_FROM_ALL on slamd_src, +# so we need to make bindings depend on it to ensure it gets built. +add_dependencies(bindings slamd_window) + install(TARGETS slamd_window DESTINATION slamd) install(TARGETS bindings DESTINATION slamd) + +# Strip installed binaries to reduce wheel size +set(CMAKE_INSTALL_DO_STRIP ON) diff --git a/python_bindings/pyproject.toml b/python_bindings/pyproject.toml index 7431d3f..9db5a88 100644 --- a/python_bindings/pyproject.toml +++ b/python_bindings/pyproject.toml @@ -16,6 +16,7 @@ slamd-window = "slamd:_window_cli" [tool.scikit-build] minimum-version = "build-system.requires" +cmake.build-type = "MinSizeRel" [tool.cibuildwheel] skip = ["*musllinux*", "*win*", "pp*"] From 0b25aba3b8ec7cae09a57a71c5d619ca2a3d9394 Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sun, 1 Mar 2026 15:30:20 +0100 Subject: [PATCH 2/3] clean up build system for only python --- examples/CMakeLists.txt | 62 -------- examples/arrows/CMakeLists.txt | 12 -- examples/arrows/main.cpp | 68 --------- examples/camera_frustum/CMakeLists.txt | 7 - examples/camera_frustum/main.cpp | 88 ----------- examples/circles/CMakeLists.txt | 7 - examples/circles/main.cpp | 22 --- examples/hello_canvas/CMakeLists.txt | 15 -- examples/hello_canvas/main.cpp | 97 ------------- examples/hello_visualizer/CMakeLists.txt | 9 -- examples/hello_visualizer/main.cpp | 34 ----- examples/hello_world/CMakeLists.txt | 7 - examples/hello_world/main.cpp | 11 -- examples/mesh/CMakeLists.txt | 7 - examples/mesh/main.cpp | 100 ------------- examples/moving_box/CMakeLists.txt | 14 -- examples/moving_box/main.cpp | 31 ---- examples/one_scene_two_views/CMakeLists.txt | 12 -- examples/one_scene_two_views/main.cpp | 17 --- examples/point_cloud/CMakeLists.txt | 7 - examples/point_cloud/main.cpp | 73 ---------- examples/poly_line/CMakeLists.txt | 7 - examples/poly_line/main.cpp | 73 ---------- examples/poly_line_2d/CMakeLists.txt | 7 - examples/poly_line_2d/main.cpp | 67 --------- examples/slamd | 1 - examples/three_d_spiral/CMakeLists.txt | 8 - examples/three_d_spiral/main.cpp | 52 ------- examples/two_scenes/CMakeLists.txt | 8 - examples/two_scenes/main.cpp | 22 --- examples/vcpkg.json | 14 -- python_bindings/CMakeLists.txt | 34 +---- slamd/CMakeLists.txt | 153 +++----------------- slamd/cmake/slamdConfig.cmake.in | 3 - slamd/flatb/CMakeLists.txt | 16 +- 35 files changed, 25 insertions(+), 1140 deletions(-) delete mode 100644 examples/CMakeLists.txt delete mode 100644 examples/arrows/CMakeLists.txt delete mode 100644 examples/arrows/main.cpp delete mode 100644 examples/camera_frustum/CMakeLists.txt delete mode 100644 examples/camera_frustum/main.cpp delete mode 100644 examples/circles/CMakeLists.txt delete mode 100644 examples/circles/main.cpp delete mode 100644 examples/hello_canvas/CMakeLists.txt delete mode 100644 examples/hello_canvas/main.cpp delete mode 100644 examples/hello_visualizer/CMakeLists.txt delete mode 100644 examples/hello_visualizer/main.cpp delete mode 100644 examples/hello_world/CMakeLists.txt delete mode 100644 examples/hello_world/main.cpp delete mode 100644 examples/mesh/CMakeLists.txt delete mode 100644 examples/mesh/main.cpp delete mode 100644 examples/moving_box/CMakeLists.txt delete mode 100644 examples/moving_box/main.cpp delete mode 100644 examples/one_scene_two_views/CMakeLists.txt delete mode 100644 examples/one_scene_two_views/main.cpp delete mode 100644 examples/point_cloud/CMakeLists.txt delete mode 100644 examples/point_cloud/main.cpp delete mode 100644 examples/poly_line/CMakeLists.txt delete mode 100644 examples/poly_line/main.cpp delete mode 100644 examples/poly_line_2d/CMakeLists.txt delete mode 100644 examples/poly_line_2d/main.cpp delete mode 120000 examples/slamd delete mode 100644 examples/three_d_spiral/CMakeLists.txt delete mode 100644 examples/three_d_spiral/main.cpp delete mode 100644 examples/two_scenes/CMakeLists.txt delete mode 100644 examples/two_scenes/main.cpp delete mode 100644 examples/vcpkg.json delete mode 100644 slamd/cmake/slamdConfig.cmake.in diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index 368820b..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -project(slam_dunk_examples) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -# Check if our lord and savious ccache exists -# We use ccache to massively speed up recompile times -find_program(CCACHE_FOUND ccache) -if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) -endif(CCACHE_FOUND) - - -if(APPLE) - message(STATUS "APPLE") - set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg_installed/arm64-osx") -elseif(UNIX) - message(STATUS "UNIX") - set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg_installed/x64-linux") -endif() - -set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") - -find_path(Stb_INCLUDE_DIR "stb_image.h") - -# find_package(spdlog CONFIG REQUIRED) - -# to use as submodule -add_subdirectory(slamd) - -# to use with fetchcontent -# include(FetchContent) - -# FetchContent_Declare( -# slamd -# GIT_REPOSITORY https://github.com/Robertleoj/slam_dunk.git -# GIT_TAG main -# SOURCE_SUBDIR slamd -# ) - -# FetchContent_MakeAvailable(slamd) - -add_subdirectory(hello_world) -add_subdirectory(two_scenes) -add_subdirectory(one_scene_two_views) -add_subdirectory(arrows) -add_subdirectory(poly_line) -add_subdirectory(poly_line_2d) -add_subdirectory(mesh) -add_subdirectory(moving_box) -add_subdirectory(hello_canvas) -add_subdirectory(point_cloud) -add_subdirectory(camera_frustum) -add_subdirectory(circles) -add_subdirectory(hello_visualizer) -add_subdirectory(three_d_spiral) \ No newline at end of file diff --git a/examples/arrows/CMakeLists.txt b/examples/arrows/CMakeLists.txt deleted file mode 100644 index 043d371..0000000 --- a/examples/arrows/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_executable(arrows main.cpp) -target_link_libraries( - arrows - PRIVATE - - slamd::slamd - spdlog::spdlog -) - -target_include_directories( - arrows PRIVATE -) \ No newline at end of file diff --git a/examples/arrows/main.cpp b/examples/arrows/main.cpp deleted file mode 100644 index 86efe73..0000000 --- a/examples/arrows/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -slamd::geom::ArrowsPtr cool_arrows() { - std::vector starts; - std::vector ends; - std::vector colors; - - int num_arrows = 500; - - for (int i = 0; i < num_arrows; ++i) { - glm::vec3 start( - random_float(-10.f, 10.f), - random_float(-10.f, 10.f), - random_float(-10.f, 10.f) - ); - - glm::vec3 direction( - random_float(-1.f, 1.f), - random_float(-1.f, 1.f), - random_float(-1.f, 1.f) - ); - - glm::vec3 end = - start + glm::normalize(direction) * random_float(0.5f, 2.0f); - - starts.push_back(start); - ends.push_back(end); - - colors.emplace_back( - random_float(0.f, 1.f), - random_float(0.f, 1.f), - random_float(0.f, 1.f) - ); - } - - float thickness = 0.05f; - return slamd::geom::arrows(starts, ends, colors, thickness); -} - -int main() { - auto vis = slamd::visualizer("arrows"); - - auto scene = slamd::scene(); - - vis->add_scene("scene", scene); - - auto arrows = cool_arrows(); - - scene->set_object("/arrows", arrows); - - vis->hang_forever(); -} diff --git a/examples/camera_frustum/CMakeLists.txt b/examples/camera_frustum/CMakeLists.txt deleted file mode 100644 index 363c085..0000000 --- a/examples/camera_frustum/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(camera_frustum main.cpp) - -target_link_libraries( - camera_frustum PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/camera_frustum/main.cpp b/examples/camera_frustum/main.cpp deleted file mode 100644 index df23210..0000000 --- a/examples/camera_frustum/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float rand_float( - float min, - float max -) { - std::uniform_real_distribution dist(min, max); - return dist(gen); -} - -glm::vec3 random_vector( - float min, - float max -) { - return glm::vec3( - rand_float(min, max), - rand_float(min, max), - rand_float(min, max) - ); -} - -glm::mat4 random_transform( - bool scale = false -) { - glm::vec3 position = random_vector(-10.0, 10.0); - - float angle = rand_float(0.0f, 359.0f); - - glm::vec3 axis = random_vector(0.0, 10.0); - - axis = glm::normalize(axis); // make sure it's a unit vector - - glm::mat4 transform = - glm::translate(glm::mat4(1.0f), position) * - glm::rotate(glm::mat4(1.0f), glm::radians(angle), axis); - - if (scale) { - glm::vec3 random_scale = random_vector(0.1f, 2.0f); - - transform = transform * glm::scale(glm::mat4(1.0f), random_scale); - } - - return transform; -} - -slamd::geom::CameraFrustumPtr get_frustum() { - float fx = 525.0f; - float fy = 525.0f; - float cx = 320.0f; - float cy = 240.0f; - - glm::mat3 K( - glm::vec3(fx, 0.0f, 0.0f), - glm::vec3(0.0f, fy, 0.0f), - glm::vec3(cx, cy, 1.0f) - ); - - size_t width = 640; - size_t height = 480; - - return slamd::geom::camera_frustum(K, width, height, 1.0); -} - -int main() { - auto vis = slamd::visualizer("camera_frustum"); - - auto scene = slamd::scene(); - - auto frustum = get_frustum(); - - for (size_t i = 0; i < 100; i++) { - std::string key = std::format("/{}/frustum", i); - - scene->set_object(key, frustum); - - scene->set_transform(key, random_transform()); - } - - vis->add_scene("scene", scene); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/circles/CMakeLists.txt b/examples/circles/CMakeLists.txt deleted file mode 100644 index b61e6ad..0000000 --- a/examples/circles/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(circles main.cpp) - -target_link_libraries( - circles PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/circles/main.cpp b/examples/circles/main.cpp deleted file mode 100644 index 60915c6..0000000 --- a/examples/circles/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -int main() { - auto vis = slamd::visualizer("circles"); - - auto circles = slamd::geom2d::circles( - {glm::vec2(0.0f, 0.0f)}, - {glm::vec3(1.0f, 0.0f, 0.0f)}, - {1.0f}, - 0.1f - ); - - auto canvas = slamd::canvas(); - canvas->set_object("/circles", circles); - - vis->add_canvas("canvas", canvas); - - while (true) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - } -} \ No newline at end of file diff --git a/examples/hello_canvas/CMakeLists.txt b/examples/hello_canvas/CMakeLists.txt deleted file mode 100644 index d9294f8..0000000 --- a/examples/hello_canvas/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_executable(hello_canvas main.cpp) - -target_link_libraries( - hello_canvas PRIVATE - - slamd::slamd - spdlog::spdlog -) - -target_include_directories( - hello_canvas - - PRIVATE - ${Stb_INCLUDE_DIR} -) \ No newline at end of file diff --git a/examples/hello_canvas/main.cpp b/examples/hello_canvas/main.cpp deleted file mode 100644 index c44e5d3..0000000 --- a/examples/hello_canvas/main.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#define STB_IMAGE_IMPLEMENTATION -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fs = std::filesystem; - -std::random_device rd; -std::mt19937 gen(rd()); - -const fs::path image_path = fs::path(__FILE__) - .parent_path() // hello canvas - .parent_path() // examples - .parent_path() // repo root - / "images" / "logo.png"; - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -slamd::data::Image read_image() { - int width, height, channels; - unsigned char* data_ptr = - stbi_load(image_path.string().c_str(), &width, &height, &channels, 0); - - if (data_ptr == nullptr) { - throw std::runtime_error( - std::format("Failed to load image at", image_path.string()) - ); - } - - size_t num_bytes = sizeof(uint8_t) * height * width * channels; - - // clang-format off - std::cout - << "Loaded image:\n" - << "\twidth: " << width << "\n" - << "\theight: " << height << "\n" - << "\tchannels: " << channels << "\n" - << "\ttotal bytes: " << num_bytes - << std::endl; - // clang-format on - - std::vector data(data_ptr, data_ptr + num_bytes); - - stbi_image_free(data_ptr); - - return slamd::data::Image(std::move(data), width, height, channels); -} - -auto random_points() { - std::vector pos; - std::vector rad; - std::vector col; - - for (size_t i = 0; i < 500; i++) { - pos.emplace_back( - random_float(0.0f, 1024.0f), - random_float(0.0f, 630.0f) - ); - - rad.push_back(random_float(5.0f, 10.0f)); - - col.emplace_back( - random_float(0.0f, 1.0f), - random_float(0.0f, 1.0f), - random_float(0.0f, 1.0f) - ); - } - - return slamd::geom2d::points(pos, col, rad); -} - -int main() { - auto vis = slamd::visualizer("hello_canvas"); - - auto canvas = slamd::canvas(); - - vis->add_canvas("canvas", canvas); - - slamd::data::Image image = read_image(); - - canvas->set_object("/image", slamd::geom2d::image(std::move(image))); - - canvas->set_object("/points", random_points()); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/hello_visualizer/CMakeLists.txt b/examples/hello_visualizer/CMakeLists.txt deleted file mode 100644 index 6ffc519..0000000 --- a/examples/hello_visualizer/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_executable(hello_visualizer main.cpp) - -target_link_libraries( - hello_visualizer - PRIVATE - - slamd::slamd - spdlog::spdlog -) \ No newline at end of file diff --git a/examples/hello_visualizer/main.cpp b/examples/hello_visualizer/main.cpp deleted file mode 100644 index fa63698..0000000 --- a/examples/hello_visualizer/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include - -int main() { - spdlog::set_level(spdlog::level::debug); - - auto vis = slamd::visualizer("hello viz"); - - auto scene = slamd::scene(); - - vis->add_scene("scene1", scene); - - auto scene2 = slamd::scene(); - - scene2->set_object("/origin/triad", slamd::geom::triad()); - - glm::mat4 transform(1.0); - transform[3][0] = 10.0f; - - scene2->set_transform("/origin", transform); - - vis->add_scene("scene2", scene2); - - auto canvas = slamd::canvas(); - - vis->add_canvas("canvas", canvas); - - while (true) { - std::this_thread::sleep_for(std::chrono::seconds(1)); - } -} \ No newline at end of file diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt deleted file mode 100644 index df57a83..0000000 --- a/examples/hello_world/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(hello_world main.cpp) - -target_link_libraries( - hello_world PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/hello_world/main.cpp b/examples/hello_world/main.cpp deleted file mode 100644 index 766f0a3..0000000 --- a/examples/hello_world/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int main() { - auto vis = slamd::visualizer("hello_world"); - - auto scene = vis->scene("scene"); - - scene->set_object("/origin", slamd::geom::triad()); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/mesh/CMakeLists.txt b/examples/mesh/CMakeLists.txt deleted file mode 100644 index f8f520b..0000000 --- a/examples/mesh/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(mesh main.cpp) - -target_link_libraries( - mesh PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/mesh/main.cpp b/examples/mesh/main.cpp deleted file mode 100644 index 299a066..0000000 --- a/examples/mesh/main.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -slamd::data::MeshData generate_trippy_ribbon_mesh() { - std::vector positions; - std::vector colors; - std::vector indices; - std::vector normals; - - int segments = 200; - float width = 1.0f; - float radius = 5.0f; - float twist = 5.0f; // number of twists - - for (int i = 0; i <= segments; ++i) { - float t = (float)i / (float)segments; - float angle = glm::two_pi() * t * twist; - - glm::vec3 center = glm::vec3( - radius * glm::cos(glm::two_pi() * t), - radius * glm::sin(glm::two_pi() * t), - 5.0f * glm::sin(2.0f * glm::two_pi() * t) - ); - - glm::vec3 tangent = glm::normalize(glm::vec3( - -radius * glm::sin(glm::two_pi() * t), - radius * glm::cos(glm::two_pi() * t), - 10.0f * glm::cos(2.0f * glm::two_pi() * t) - )); - - glm::vec3 normal = - glm::normalize(glm::cross(tangent, glm::vec3(0, 0, 1))); - glm::vec3 binormal = glm::normalize(glm::cross(tangent, normal)); - - glm::vec3 offset1 = center + width * glm::cos(angle) * normal + - width * glm::sin(angle) * binormal; - glm::vec3 offset2 = center - width * glm::cos(angle) * normal - - width * glm::sin(angle) * binormal; - - positions.push_back(offset1); - positions.push_back(offset2); - - colors.emplace_back( - random_float(0.4f, 1.0f), - random_float(0.4f, 1.0f), - random_float(0.4f, 1.0f) - ); - colors.emplace_back( - random_float(0.4f, 1.0f), - random_float(0.4f, 1.0f), - random_float(0.4f, 1.0f) - ); - - normals.push_back(glm::normalize(offset1 - center)); - normals.push_back(glm::normalize(offset2 - center)); - } - - for (int i = 0; i < segments; ++i) { - int idx = i * 2; - indices.push_back(idx); - indices.push_back(idx + 1); - indices.push_back(idx + 2); - - indices.push_back(idx + 1); - indices.push_back(idx + 3); - indices.push_back(idx + 2); - } - - return slamd::data::MeshData(positions, colors, indices, normals); -} - -int main() { - auto vis = slamd::visualizer("trippy_ribbon"); - - auto scene = slamd::scene(); - vis->add_scene("scene", scene); - - auto mesh_data = generate_trippy_ribbon_mesh(); - auto mesh = slamd::geom::mesh(mesh_data); - - scene->set_object("/trippy_ribbon", mesh); - - vis->hang_forever(); -} diff --git a/examples/moving_box/CMakeLists.txt b/examples/moving_box/CMakeLists.txt deleted file mode 100644 index 29950e3..0000000 --- a/examples/moving_box/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_executable( - moving_box - - main.cpp -) - -target_link_libraries( - moving_box - - PRIVATE - - slamd::slamd - spdlog::spdlog -) diff --git a/examples/moving_box/main.cpp b/examples/moving_box/main.cpp deleted file mode 100644 index acf9de8..0000000 --- a/examples/moving_box/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int main() { - auto vis = slamd::visualizer("moving_box"); - - auto scene = slamd::scene(); - - scene->set_object("/rot/trans/box", slamd::geom::box()); - - scene->set_transform("/rot/trans", slamd::gmath::tx3D(10.0f)); - - glm::mat4 current_rot = glm::mat4(1.0); - - vis->add_scene("scene", scene); - - while (true) { - // rotate by 1 degree every 10ms - current_rot = - slamd::gmath::rz3D(slamd::gmath::Angle::deg(1.0)) * current_rot; - - scene->set_transform("/rot", current_rot); - - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } -} \ No newline at end of file diff --git a/examples/one_scene_two_views/CMakeLists.txt b/examples/one_scene_two_views/CMakeLists.txt deleted file mode 100644 index 209fcb3..0000000 --- a/examples/one_scene_two_views/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_executable( - one_scene_two_views - main.cpp -) - -target_link_libraries( - one_scene_two_views - - PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/one_scene_two_views/main.cpp b/examples/one_scene_two_views/main.cpp deleted file mode 100644 index 14eec84..0000000 --- a/examples/one_scene_two_views/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() { - auto vis = slamd::visualizer("one_scene_two_views"); - - auto scene = slamd::scene(); - - // add the scene twice - this will give - // two views of the same scene - vis->add_scene("scene view 1", scene); - vis->add_scene("scene view 2", scene); - - // example object - triad at origin - scene->set_object("/origin", slamd::geom::triad()); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/point_cloud/CMakeLists.txt b/examples/point_cloud/CMakeLists.txt deleted file mode 100644 index cae9a41..0000000 --- a/examples/point_cloud/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(point_cloud main.cpp) - -target_link_libraries( - point_cloud PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/point_cloud/main.cpp b/examples/point_cloud/main.cpp deleted file mode 100644 index ac74f45..0000000 --- a/examples/point_cloud/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -float surface( - float x, - float y -) { - return 3.0f * glm::cos(x) * glm::sin(y) + 0.1f * x * y + 0.2f * y; -} - -slamd::geom::PointCloudPtr cool_point_cloud() { - std::vector positions; - std::vector colors; - std::vector radii; - - float min = -10.0f; - float max = 10.0f; - - float density = 200.0f; - float step = (max - min) / density; - - for (float i = min; i < max; i += step) { - for (float j = min; j < max; j += step) { - positions.emplace_back(i, j, surface(i, j)); - } - } - - size_t count = positions.size(); - - colors.reserve(count); - radii.reserve(count); - - for (int i = 0; i < count; ++i) { - colors.emplace_back( - random_float(0.f, 1.f), - random_float(0.f, 1.f), - random_float(0.f, 1.f) - ); - - radii.push_back(random_float(0.01f, 0.1f)); // min 0.1, max 0.6 - } - - return slamd::geom::point_cloud(positions, colors, radii); -} - -int main() { - auto vis = slamd::visualizer("point_cloud"); - - auto scene = slamd::scene(); - - vis->add_scene("scene", scene); - - auto point_cloud = cool_point_cloud(); - - scene->set_object("/point_cloud", point_cloud); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/poly_line/CMakeLists.txt b/examples/poly_line/CMakeLists.txt deleted file mode 100644 index d7806b4..0000000 --- a/examples/poly_line/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(poly_line main.cpp) - -target_link_libraries( - poly_line PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/poly_line/main.cpp b/examples/poly_line/main.cpp deleted file mode 100644 index 9303add..0000000 --- a/examples/poly_line/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -slamd::geom::PolyLinePtr trippy_poly_line() { - std::vector points; - - int num_points = static_cast(random_float(50, 300)); - float freq_x = random_float(0.5f, 3.0f); - float freq_y = random_float(0.5f, 3.0f); - float freq_z = random_float(0.5f, 3.0f); - - float amp_x = random_float(2.0f, 8.0f); - float amp_y = random_float(2.0f, 8.0f); - float amp_z = random_float(2.0f, 8.0f); - - float phase_x = random_float(0.f, glm::pi()); - float phase_y = random_float(0.f, glm::pi()); - float phase_z = random_float(0.f, glm::pi()); - - for (int i = 0; i < num_points; ++i) { - float t = i * 0.1f; - - float x = amp_x * glm::sin(freq_x * t + phase_x); - float y = amp_y * glm::cos(freq_y * t + phase_y); - float z = amp_z * glm::sin(freq_z * t + phase_z); - - points.emplace_back(x, y, z); - } - - float thickness = random_float(0.02f, 0.15f); - glm::vec3 color( - random_float(0.2f, 1.f), - random_float(0.2f, 1.f), - random_float(0.2f, 1.f) - ); - - return slamd::geom::poly_line(points, thickness, color); -} - -int main() { - auto vis = slamd::visualizer("trippy_poly_lines"); - - auto scene = slamd::scene(); - - vis->add_scene("scene", scene); - - // Spawn a whole nebula of trippy lines - int num_lines = 5; - - for (int i = 0; i < num_lines; ++i) { - auto poly_line = trippy_poly_line(); - - std::string name = "/poly_line_" + std::to_string(i); - scene->set_object(name, poly_line); - } - - vis->hang_forever(); -} diff --git a/examples/poly_line_2d/CMakeLists.txt b/examples/poly_line_2d/CMakeLists.txt deleted file mode 100644 index 60c75c6..0000000 --- a/examples/poly_line_2d/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(poly_line_2d main.cpp) - -target_link_libraries( - poly_line_2d PRIVATE - - slamd::slamd -) \ No newline at end of file diff --git a/examples/poly_line_2d/main.cpp b/examples/poly_line_2d/main.cpp deleted file mode 100644 index 5ee3300..0000000 --- a/examples/poly_line_2d/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include - -std::random_device rd; -std::mt19937 gen(rd()); - -float random_float( - float start, - float end -) { - std::uniform_real_distribution dist(start, end); - return dist(gen); -} - -std::vector crazy_polyline_shape( - float offset_x, - float offset_y -) { - std::vector points; - - int num_points = static_cast(random_float(20, 80)); - float radius = random_float(100.f, 300.f); - - for (int i = 0; i < num_points; ++i) { - float angle = i * (2.0f * glm::pi() / num_points); - float wiggle = random_float(0.8f, 1.2f); - - float x = offset_x + radius * wiggle * glm::cos(angle); - float y = offset_y + radius * wiggle * glm::sin(angle); - - points.emplace_back(x, y); - } - - return points; -} - -slamd::geom2d::PolyLinePtr make_trippy_polyline() { - float offset_x = random_float(200.f, 800.f); - float offset_y = random_float(150.f, 500.f); - - auto points = crazy_polyline_shape(offset_x, offset_y); - - glm::vec3 color( - random_float(0.3f, 1.f), - random_float(0.3f, 1.f), - random_float(0.3f, 1.f) - ); - - float thickness = random_float(2.f, 8.f); - - return slamd::geom2d::poly_line(points, color, thickness); -} - -int main() { - auto vis = slamd::visualizer("trippy_2d_polyline"); - - auto canvas = slamd::canvas(); - vis->add_canvas("canvas", canvas); - - // Drop a whole bundle of random 2D poly lines - for (int i = 0; i < 10; ++i) { - auto polyline = make_trippy_polyline(); - canvas->set_object("/polyline_" + std::to_string(i), polyline); - } - - vis->hang_forever(); -} diff --git a/examples/slamd b/examples/slamd deleted file mode 120000 index 605e769..0000000 --- a/examples/slamd +++ /dev/null @@ -1 +0,0 @@ -../slamd \ No newline at end of file diff --git a/examples/three_d_spiral/CMakeLists.txt b/examples/three_d_spiral/CMakeLists.txt deleted file mode 100644 index 494f99f..0000000 --- a/examples/three_d_spiral/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ - -add_executable(three_d_spiral main.cpp) -target_link_libraries( - three_d_spiral PRIVATE - - slamd::slamd -) - diff --git a/examples/three_d_spiral/main.cpp b/examples/three_d_spiral/main.cpp deleted file mode 100644 index 92458bc..0000000 --- a/examples/three_d_spiral/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include -#include -#include - -std::vector cool_spiral( - int n, - float t -) { - std::vector points; - float max_r = 10.0f; - float t_start = t; - float t_end = t + 20.0f * glm::pi(); - - for (int i = 0; i < n; ++i) { - float alpha = static_cast(i) / static_cast(n - 1); - float r = alpha * max_r; - float angle = t_start + alpha * (t_end - t_start); - - float x = r * std::cos(angle); - float y = r * std::sin(angle); - float z = std::cos(x) * std::sin(y) + r; - - points.emplace_back(x, y, z); - } - - return points; -} - -int main() { - auto vis = slamd::visualizer("3d_spiral"); - - auto scene = slamd::scene(); - vis->add_scene("scene", scene); - - glm::vec3 pink(212.0f / 255.0f, 13.0f / 255.0f, 125.0f / 255.0f); - - float t = 0.0f; - - while (true) { - auto coords = cool_spiral(1000, t); - - auto poly_line = slamd::geom::poly_line(coords, 0.7f, pink); - - scene->set_object("/poly_line", poly_line); - - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - t += 0.05f; - } -} diff --git a/examples/two_scenes/CMakeLists.txt b/examples/two_scenes/CMakeLists.txt deleted file mode 100644 index 77ba5ff..0000000 --- a/examples/two_scenes/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ - -add_executable(two_scenes main.cpp) -target_link_libraries( - two_scenes PRIVATE - - slamd::slamd -) - diff --git a/examples/two_scenes/main.cpp b/examples/two_scenes/main.cpp deleted file mode 100644 index fa28a32..0000000 --- a/examples/two_scenes/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -int main() { - auto vis = slamd::visualizer("two_scenes"); - - auto scene1 = slamd::scene(); - auto scene2 = slamd::scene(); - - vis->add_scene("scene 1", scene1); - scene1->set_object("/box", slamd::geom::box()); - - vis->add_scene("scene 2", scene2); - scene2->set_object("/origin", slamd::geom::triad()); - scene2->set_object("/ball", slamd::geom::sphere(2.0f)); - - glm::mat4 sphere_transform(1.0); - sphere_transform[3] += glm::vec4(5.0, 1.0, 2.0, 1.0); - scene2->set_transform("/ball", sphere_transform); - - vis->hang_forever(); -} \ No newline at end of file diff --git a/examples/vcpkg.json b/examples/vcpkg.json deleted file mode 100644 index ef6cb94..0000000 --- a/examples/vcpkg.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "dependencies": [ - "stb", - "glbinding", - { - "name": "imgui", - "features": [ - "docking-experimental", - "glfw-binding", - "opengl3-binding" - ] - } - ] -} \ No newline at end of file diff --git a/python_bindings/CMakeLists.txt b/python_bindings/CMakeLists.txt index 361b924..d0cd603 100644 --- a/python_bindings/CMakeLists.txt +++ b/python_bindings/CMakeLists.txt @@ -32,39 +32,11 @@ else() set(INSTALL_PATH "$ORIGIN") endif() - add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_OFF) - # EXCLUDE_FROM_ALL prevents vendored deps from installing their own # files (static archives, examples, tools) into the wheel. -if(NOT TARGET spdlog::spdlog) - message(STATUS "Adding spdlog...") - add_subdirectory(${LIB_DIR}/spdlog EXCLUDE_FROM_ALL) -endif() - -if(NOT TARGET glbinding::glbinding-aux) - message(STATUS "Adding glbinding...") - add_subdirectory(${LIB_DIR}/glbinding EXCLUDE_FROM_ALL) -endif() - -if(NOT TARGET glfw) - message(STATUS "Adding glfw...") - add_subdirectory(${LIB_DIR}/glfw EXCLUDE_FROM_ALL) -endif() - -if(NOT TARGET imgui::imgui) - message(STATUS "Adding imgui...") - add_subdirectory(${LIB_DIR}/imgui_wrapper EXCLUDE_FROM_ALL) -endif() - - -if(NOT TARGET slamd) - message(STATUS "Adding slamd...") - add_subdirectory(slamd_src EXCLUDE_FROM_ALL) -endif() - - +add_subdirectory(slamd_src EXCLUDE_FROM_ALL) find_package(Python REQUIRED COMPONENTS Interpreter Development.Module REQUIRED) @@ -96,13 +68,13 @@ target_include_directories( ${LIB_DIR}/glfw/include ) -target_link_libraries(bindings +target_link_libraries(bindings PUBLIC slamd::slamd slamd_common slamd_flatbuff - PRIVATE + PRIVATE imgui::imgui glfw glbinding::glbinding diff --git a/slamd/CMakeLists.txt b/slamd/CMakeLists.txt index 96225ae..6f32bad 100644 --- a/slamd/CMakeLists.txt +++ b/slamd/CMakeLists.txt @@ -4,9 +4,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -option(SLAMD_ENABLE_INSTALL "Enable install targets" OFF) -option(SLAMD_VENDOR_DEPS "Use vendored dependencies" ON) - project(slam_dunk VERSION 0.1.0) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -14,66 +11,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(LIB_DIR vendored_deps) -function(find_required_package - pkg_name - target_name - found_var - subdir -) - if (NOT TARGET ${target_name}) - if (SLAMD_VENDOR_DEPS) - message(STATUS "Vendoring is ON, skipping find_package for ${pkg_name}") - if (NOT TARGET ${target_name}) - message(STATUS "${pkg_name} target not found, trying add_subdirectory") - add_subdirectory(${subdir}) - endif() - else() - message(STATUS "Finding ${pkg_name}") - find_package(${pkg_name} CONFIG QUIET) - endif() - - if (NOT TARGET ${target_name}) - message(FATAL_ERROR "${pkg_name} still not found. No target, no backup — we're hosed.") - endif() - endif() -endfunction() - -# sometimes glbinding-aux does not come with -# glbinding, so we need to check for that target -find_required_package( - glbinding - glbinding::glbinding-aux - glbinding_FOUND - ${LIB_DIR}/glbinding -) +if(NOT TARGET glbinding::glbinding-aux) + add_subdirectory(${LIB_DIR}/glbinding) +endif() -find_required_package( - glfw - glfw - glfw_FOUND - ${LIB_DIR}/glfw -) - -find_required_package( - spdlog - spdlog::spdlog - spdlog_FOUND - ${LIB_DIR}/spdlog -) +if(NOT TARGET glfw) + add_subdirectory(${LIB_DIR}/glfw) +endif() -find_required_package( - imgui - imgui::imgui - imgui_FOUND - ${LIB_DIR}/imgui_wrapper -) +if(NOT TARGET spdlog::spdlog) + add_subdirectory(${LIB_DIR}/spdlog) +endif() -find_required_package( - fmt - fmt::fmt - fmt_FOUND - ${LIB_DIR}/fmt -) +if(NOT TARGET imgui::imgui) + add_subdirectory(${LIB_DIR}/imgui_wrapper) +endif() + +if(NOT TARGET fmt::fmt) + add_subdirectory(${LIB_DIR}/fmt) +endif() add_subdirectory(${LIB_DIR}/glm) add_subdirectory(${LIB_DIR}/cxxopts) @@ -108,7 +64,6 @@ target_include_directories( PUBLIC ${LIB_DIR}/glm $ - $ ) target_compile_options(slamd_common PRIVATE -Wall -Wextra) @@ -185,12 +140,11 @@ target_include_directories( $ $ $ - $ ) target_link_libraries( slamd_window - + PRIVATE glfw spdlog::spdlog @@ -248,16 +202,6 @@ target_sources( src/slamd/geom/circles_2d.cpp ) -# target_include_directories( -# slamd - -# PUBLIC -# $ -# $ -# ${LIB_DIR}/glm -# ${LIB_DIR}/asio/asio/include -# ) - target_include_directories( slamd @@ -265,12 +209,11 @@ target_include_directories( $ $ $ - $ ) target_link_libraries( - slamd - + slamd + PRIVATE spdlog::spdlog @@ -279,61 +222,3 @@ target_link_libraries( slamd_common ) target_compile_options(slamd PRIVATE -Wall -Wextra) - - - - -# only install if this is the top-level dir -if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - install(TARGETS slamd - EXPORT slamdTargets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include - ) - - install(DIRECTORY include/ DESTINATION include) - - include(CMakePackageConfigHelpers) - - configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/slamdConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/slamdConfig.cmake" - INSTALL_DESTINATION share/slamd - ) - - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/slamdConfigVersion.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion - ) - - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/slamdConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/slamdConfigVersion.cmake" - DESTINATION share/slamd - ) - - install(EXPORT slamdTargets - FILE slamdTargets.cmake - NAMESPACE slamd:: - DESTINATION share/slamd - ) - - install(TARGETS slamd_common - - EXPORT slamdTargets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - INCLUDES DESTINATION include - ) - - install(TARGETS slamd_flatbuff - - EXPORT slamdTargets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - INCLUDES DESTINATION include - ) -endif() diff --git a/slamd/cmake/slamdConfig.cmake.in b/slamd/cmake/slamdConfig.cmake.in deleted file mode 100644 index 89db7ab..0000000 --- a/slamd/cmake/slamdConfig.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/slamdTargets.cmake") \ No newline at end of file diff --git a/slamd/flatb/CMakeLists.txt b/slamd/flatb/CMakeLists.txt index 4cf68d0..0c1f713 100644 --- a/slamd/flatb/CMakeLists.txt +++ b/slamd/flatb/CMakeLists.txt @@ -1,19 +1,9 @@ add_compile_options(-Wno-stringop-overflow) if (NOT TARGET flatbuffers) - if (SLAMD_VENDOR_DEPS) - message(STATUS "flatbuffers target not found, trying add_subdirectory") - set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" FORCE) - set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" FORCE) - add_subdirectory(../vendored_deps/flatbuffers ${CMAKE_CURRENT_BINARY_DIR}/_deps/flatbuffers) - else() - message(STATUS "Finding flatbuffers") - find_package(flatbuffers CONFIG QUIET) - endif() - - if (NOT TARGET flatbuffers) - message(FATAL_ERROR "flatbuffers still not found. No target, no backup — we're hosed.") - endif() + set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" FORCE) + add_subdirectory(../vendored_deps/flatbuffers ${CMAKE_CURRENT_BINARY_DIR}/_deps/flatbuffers) endif() # Grab all .cpp and .h/.hpp files in current dir From f1df9cb7eaac25eb8d82c176d0492ccbba73804c Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sun, 1 Mar 2026 15:47:16 +0100 Subject: [PATCH 3/3] update version --- python_bindings/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_bindings/pyproject.toml b/python_bindings/pyproject.toml index 9db5a88..f02323c 100644 --- a/python_bindings/pyproject.toml +++ b/python_bindings/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "slamd" -version = "2.1.13" +version = "2.2.0" description = "Python bindings for SlamDunk" authors = [{ name = "Robert Leo", email = "robert.leo.jonsson@gmail.com" }] readme = "README.md"