17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-30 09:40:29 +01:00

feat(editor): far out the top view shows the base map of OpenStreetMap from geoportal.gov.pl in place of the imagery, tiles as large as the view needs, the ground not drawn under it nor streamed as far as the view; the tracks over it in the colour of the rails, blue by default, and the joints of the pieces left out far out

This commit is contained in:
maj00r
2026-10-23 13:35:07 +02:00
parent a892532fda
commit 5e846018b6
10 changed files with 229 additions and 22 deletions

View File

@@ -1470,6 +1470,14 @@ bool editor_mode::update()
draw_terrain_overlay();
// --- geoportal orthophoto: streamed around the camera, drawn beneath the other overlays ---
// far out the top view shows the base map in place of the imagery, and the ground isn't drawn under it
{
auto const &io{ImGui::GetIO()};
auto const metres{Global.EditorOrtho && io.DisplaySize.y > 0.0f ? 2.0 * static_cast<double>(Global.EditorOrthoExtent) / io.DisplaySize.y : 0.0};
auto const aspect{io.DisplaySize.y > 0.0f ? static_cast<double>(io.DisplaySize.x / io.DisplaySize.y) : 1.0};
Global.EditorOrthoMap = m_orthophoto.enabled() && metres >= (m_orthophoto.overview() ? 1.6 : 2.0);
m_orthophoto.overview(Global.EditorOrthoMap ? metres : 0.0, static_cast<double>(Global.EditorOrthoExtent) * std::sqrt(1.0 + aspect * aspect));
}
m_orthophoto.update(Camera.Pos);
nmt_update();
draw_orthophoto();
@@ -1486,7 +1494,7 @@ bool editor_mode::update()
draw_track_labels();
draw_track_legend();
}
else if (Global.EditorOrtho && Global.EditorOrthoTracks > 1)
else if (Global.EditorOrtho && (Global.EditorOrthoTracks > 1 || Global.EditorOrthoMap))
draw_track_lines();
if (selected_track())
draw_track_overlay();
@@ -2494,6 +2502,15 @@ void editor_mode::draw_orthophoto()
ImGuiIO const &io = ImGui::GetIO();
float const aspect = io.DisplaySize.y > 0.0f ? io.DisplaySize.x / io.DisplaySize.y : 1.0f;
m_orthophoto.draw(editor_mode::projection_matrix(aspect) * view, Camera.Pos, io.DisplaySize.x, io.DisplaySize.y);
if (false == m_orthophoto.overview())
return;
char const *credit{STR_C("(c) OpenStreetMap contributors, geoportal.gov.pl")};
auto const size{ImGui::CalcTextSize(credit)};
auto const corner{editor_ui::view_max()};
ImVec2 const from{corner.x - size.x - 12.0f, corner.y - size.y - 44.0f};
auto *drawlist{ImGui::GetBackgroundDrawList(ImGui::GetMainViewport())};
drawlist->AddRectFilled(ImVec2(from.x - 4.0f, from.y - 2.0f), ImVec2(from.x + size.x + 4.0f, from.y + size.y + 2.0f), IM_COL32(255, 255, 255, 190), 3.0f);
drawlist->AddText(from, IM_COL32(40, 40, 40, 255), credit);
}
void editor_mode::draw_ortho_compass() const

View File

@@ -2201,8 +2201,12 @@ void editor_mode::draw_build_overlay() const
// in the 3D view only near the camera, where they can be told apart; from above all of them
glm::dvec3 const eye{Global.pCamera.Pos};
auto const in_reach = [&](glm::dvec3 const &Point) { return Global.EditorOrtho || glm::distance(Point, eye) <= kDotsRange; };
// far out the joints of the pieces would cover the tracks, only the free ends are told
auto const joints{false == Global.EditorOrtho || display.y <= 0.0f || 2.0 * static_cast<double>(Global.EditorOrthoExtent) / display.y <= 1.0};
for (auto const *track : simulation::Paths.sequence())
{
if (false == joints)
break;
if (track == nullptr || track->m_editorremoved || track->m_paths.empty())
continue;
for (auto const &path : track->m_paths)

View File

@@ -204,7 +204,7 @@ void editor_mode::draw_track_lines() const
auto const metres{ortho_metres_per_pixel()};
auto const colouring{ui()->mode() == nodebank_panel::TRACK ? m_track_colouring : track_colouring::plain};
// the top view of the rails alone draws them in a colour of their own, as on a plan: both rails where they're apart on the screen
auto const rails{metres > 0.0 && Global.EditorOrthoTracks > 1 && colouring == track_colouring::plain};
auto const rails{metres > 0.0 && (Global.EditorOrthoTracks > 1 || Global.EditorOrthoMap) && colouring == track_colouring::plain};
if (metres < kLinesFrom && colouring == track_colouring::plain && false == rails)
return;
auto const &io{ImGui::GetIO()};