From 866f626668cf8d02f3f364992416b6051acad9e5 Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 12 Oct 2026 00:44:54 +0200 Subject: [PATCH] fix(editor): K splits the selected track where the cursor points on screen (as the hover highlight finds it), not at the delayed depth pick which hit the ground beside the rail --- application/editormode.cpp | 6 +++++- application/editormode.h | 2 +- application/editormodetrackux.cpp | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/application/editormode.cpp b/application/editormode.cpp index de7cf339..2096bb72 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -5477,7 +5477,11 @@ void editor_mode::on_key(int const Key, int const Scancode, int const Action, in break; } if (is_press(Action) && ui()->mode() == nodebank_panel::TRACK && selected_track() != nullptr) - split_track_at(*selected_track(), Global.pCamera.Pos + GfxRenderer->Mouse_Position()); + { + auto const under{track_under_cursor(selected_track())}; + if (under.track != nullptr) + split_track_at(*under.track, under.point); + } break; case GLFW_KEY_F: diff --git a/application/editormode.h b/application/editormode.h index 32c59c6b..c5676b4c 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1236,7 +1236,7 @@ class editor_mode : public application_mode, private editor_track::observer double since{0.0}; }; track_hover m_hover; - track_hover track_under_cursor() const; + track_hover track_under_cursor(TTrack const *Only = nullptr) const; void update_track_hover(); void draw_track_hover() const; struct track_intent diff --git a/application/editormodetrackux.cpp b/application/editormodetrackux.cpp index 26b3442c..ecde52e7 100644 --- a/application/editormodetrackux.cpp +++ b/application/editormodetrackux.cpp @@ -92,16 +92,16 @@ double segment_distance2(glm::vec2 const &Point, glm::vec2 const &A, glm::vec2 c } // namespace -editor_mode::track_hover editor_mode::track_under_cursor() const +editor_mode::track_hover editor_mode::track_under_cursor(TTrack const *Only) const { track_hover result; auto const &io{ImGui::GetIO()}; screen_projection const projection; glm::vec2 const mouse{io.MousePos.x, io.MousePos.y}; - double best{kHoverPixels * kHoverPixels}; + double best{Only != nullptr ? std::numeric_limits::max() : kHoverPixels * kHoverPixels}; for (auto *track : simulation::Paths.sequence()) { - if (track == nullptr || false == rail(*track) || track->m_editorremoved) + if (track == nullptr || false == rail(*track) || track->m_editorremoved || (Only != nullptr && track != Only)) continue; for (int i = 0; i < static_cast(track->m_paths.size()); ++i) {