mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-18 07:59:19 +02:00
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
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<double>::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<int>(track->m_paths.size()); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user