diff --git a/pyproject.toml b/pyproject.toml index c536a30..8cd962e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "slamd" -version = "3.0.0" +version = "3.0.1" description = "A 3D visualiztion library" authors = [{ name = "Robert Leo", email = "robert.leo.jonsson@gmail.com" }] readme = "README.md" diff --git a/slamd/src/window/run_window.cpp b/slamd/src/window/run_window.cpp index 062b558..49332ef 100644 --- a/slamd/src/window/run_window.cpp +++ b/slamd/src/window/run_window.cpp @@ -110,7 +110,20 @@ void run_window( ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); - glfwWaitEventsTimeout(0.1); + + bool any_dirty = false; + for (auto& [name, view] : state_manager.views) { + if (view->_dirty) { + any_dirty = true; + break; + } + } + + if (any_dirty) { + glfwPollEvents(); + } else { + glfwWaitEventsTimeout(0.1); + } } SPDLOG_INFO("Window closed!"); diff --git a/slamd/src/window/view/scene_view.cpp b/slamd/src/window/view/scene_view.cpp index 98fa436..9f47ce7 100644 --- a/slamd/src/window/view/scene_view.cpp +++ b/slamd/src/window/view/scene_view.cpp @@ -135,6 +135,26 @@ void SceneView::handle_mouse_input() { this->mark_dirty(); } + if (ImGui::IsMouseDragging(ImGuiMouseButton_Right)) { + auto delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right); + ImGui::ResetMouseDragDelta(ImGuiMouseButton_Right); + + float scale = 1.0f / static_cast(std::min( + this->frame_buffer.width(), + this->frame_buffer.height() + )); + + glm::vec3 translation( + -delta.x * scale, + delta.y * scale, + 0.0f + ); + + this->arcball.translate_relative(translation); + this->arcball_indicator.interact(); + this->mark_dirty(); + } + if (io.MouseWheel != 0.0f) { auto scroll_input = static_cast(io.MouseWheel); diff --git a/uv.lock b/uv.lock index 7d4218c..1f54b7d 100644 --- a/uv.lock +++ b/uv.lock @@ -401,7 +401,7 @@ wheels = [ [[package]] name = "slamd" -version = "2.2.0" +version = "3.0.1" source = { editable = "." } dependencies = [ { name = "numpy" },