17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-20 23:23:30 +02:00

fix(editor): a touchpad swipe going on past the edge of the window no longer throws the camera away

With the cursor out of the window ImGui has no place for it, and the ray
under it came out as NaN: the zoom put the camera there for good and the
next look at the ground under the cursor aborted. The wheel is left
alone then, and the ground isn't asked for a point which isn't one. The
self-test gets leave, the cursor taken out of the window.
This commit is contained in:
maj00r
2026-10-19 20:02:03 +02:00
parent 90ce10960e
commit 33892c1936
2 changed files with 11 additions and 1 deletions

View File

@@ -3350,6 +3350,8 @@ glm::dvec3 editor_mode::placement_on_ground(glm::dvec3 Location)
double constexpr height_tolerance = 50.0; // with nothing there or lower, how far up the ground is looked for
float constexpr terrain_model_radius = 50.0f; // the same models count as ground as for the area fill and the orthophoto
if (false == std::isfinite(Location.x) || false == std::isfinite(Location.y) || false == std::isfinite(Location.z))
return Location;
glm::dvec2 const bmin{Location.x - reach, Location.z - reach};
glm::dvec2 const bmax{Location.x + reach, Location.z + reach};
std::vector<world_triangle> triangles;
@@ -5884,7 +5886,8 @@ void editor_mode::on_scroll(double const Xoffset, double const Yoffset)
{
if (false == ImGui::GetIO().WantCaptureMouse && track_wheel(Yoffset != 0.0 ? Yoffset : Xoffset))
return;
if (ImGui::GetIO().WantCaptureMouse || Yoffset == 0.0)
// a swipe on a touchpad goes on after the cursor left the window, with no place for the ray under it
if (ImGui::GetIO().WantCaptureMouse || Yoffset == 0.0 || false == ImGui::IsMousePosValid())
return;
// a fast swipe on a touchpad can come as one big step
auto const notches{std::clamp(Yoffset, -2.0, 2.0)};

View File

@@ -93,6 +93,13 @@ bool scripted_input::dispatch(std::string const &Command, std::istringstream &Wo
WriteLog(format("SELFTEST mouse %.0f %.0f", screen.x, screen.y));
return true;
}
if (Command == "leave")
{
m_mouse.reset();
queue([]() { ui_layer::cursor_enter_callback(0); });
WriteLog("SELFTEST leave");
return true;
}
if (Command == "button")
{
std::string which;