18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 08:35:01 +01:00

feat(editor): ~ shows or hides the orthophoto, Ctrl+~ downloads what the camera sees first; the speed of the camera in the View menu (#312)

* feat(editor): ~ shows or hides the orthophoto, Ctrl+~ downloads what the camera sees first; the speed of the camera in the View menu

~ (the key left of 1) turns the orthophoto on and off. Ctrl+~ finds what of the ground the camera sees (rays through a grid
over the screen down to the level of the ground under the camera, or as far as 2.5 km where they don't come down to it) and
puts those tiles at the front of the queue of the downloads, the ones which failed tried again at once; the status line
tells how many. Tab is not used, the laying and the switches have it.

View > Camera speed: the speed of the free camera of the editor (x0.05 to x10, 1 as it was), how many times faster Ctrl makes
it (1 to 30, 30 as it was), and in the top view as fast as the view is zoomed, so the map crosses the screen at the same pace
zoomed in or out. Kept in the settings of the editor; the camera of the cab and of the free fly outside the editor unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): Ctrl+~ in the top view, over a scenery with no terrain under the camera and with the orthophoto off; "As it was" without the speed going with the zoom

In the top view the box is the view itself, its corners on the ground. The ground under the camera is the terrain, else the
scenery, else the rays go as far as the reach. The tile of the camera is taken anew by hurry(), it isn't followed while the
layer is off. The top view is as fast zoomed in as out by default, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): the corners of the top view on the ground put where the camera is (the view matrix is camera-relative)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* i18n(editor): Polish for the orthophoto keys and the camera speed, on top of the master's own translations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): Ctrl+~ asks only for the tiles update() would ask for; the tooltip of "Track colours" back in its place

After the reviews of #312:
- hurry() skips the tiles outside the download area set and marks the ones outside the area the service covers
  as empty, as update() does, so Ctrl+~ no longer queues downloads update() drops at once (and the workers took
  anyway, into the disk cache, against the area set), nor requests the service can't answer.
- A blank tile hurried takes the standard image first, as in update(); first_level() and outside_area() are
  shared by both loops, and the body of the loop of hurry() is hurry_tile().
- orthophoto_hurry() takes the level of the terrain only when it's below the camera, as the branch of the
  scenery already did: a camera under the terrain (a tunnel, under the heightmap) no longer flips the box of
  the view behind it.
- The "Camera speed" menu goes after the tooltip of "Track colours", which it had taken.
- #include <set> once in editorOrthophoto.hpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1K1Qu7TCsa74zsNURd

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
pol102
2026-11-20 03:55:34 +01:00
committed by GitHub
parent 7524cfbcc2
commit 6c94f9743b
9 changed files with 317 additions and 9 deletions

View File

@@ -1032,6 +1032,20 @@ editor_orthophoto::statistics editor_orthophoto::stats() const
return out;
}
int editor_orthophoto::first_level(tile const &Tile, int const Level)
{
// a tile showing nothing yet takes the standard image first, from the disk cache at once mostly: the 4K one comes from a slow
// service a few at a time, the tiles around the camera stayed blank meanwhile though their standard images lay on the disk
if (Level > standard_pixels && Tile.level < standard_pixels)
return standard_pixels;
return Level;
}
bool editor_orthophoto::outside_area(tile_key const &Key) const
{
return false == m_area.empty() && 0 == m_area_tiles.count(Key);
}
int editor_orthophoto::level_for(int Distance, bool Hires)
{
// coarser imagery further away keeps the memory use of large radii in check
@@ -1630,7 +1644,7 @@ void editor_orthophoto::update(glm::dvec3 const &Camera)
{
tile_key const key{centre.first + dx, centre.second + dy};
// outside the download area: nothing asked for, nothing shown
if (false == m_area.empty() && 0 == m_area_tiles.count(key))
if (outside_area(key))
{
if (auto const found{m_tiles.find(key)}; found != m_tiles.end())
{
@@ -1642,11 +1656,7 @@ void editor_orthophoto::update(glm::dvec3 const &Camera)
tile &t = m_tiles[key];
if (!in_service_area(key.first, key.second))
t.empty = true;
int level = level_for(std::max(std::abs(dx), std::abs(dy)), m_config.hires);
// a tile showing nothing yet takes the standard image first, from the disk cache at once mostly: the 4K one comes from a slow
// service a few at a time, the tiles around the camera stayed blank meanwhile though their standard images lay on the disk
if (level > standard_pixels && t.level < standard_pixels)
level = standard_pixels;
int const level = first_level(t, level_for(std::max(std::abs(dx), std::abs(dy)), m_config.hires));
if (t.empty || (t.level == level && t.alpha == m_alpha) || (t.requested == level && t.requested_alpha == m_alpha) || now < t.retry_at)
continue;
schedule(key, t, level, m_alpha);
@@ -1713,7 +1723,8 @@ void editor_orthophoto::worker()
continue;
long long const dx = it->key.first - m_focus.first;
long long const dy = it->key.second - m_focus.second;
long long const d = dx * dx + dy * dy;
// the tiles hurried (Ctrl+~) before all the others, the nearest of them first
long long const d = dx * dx + dy * dy - (m_urgent.count(it->key) > 0 ? (1LL << 40) : 0LL);
if (d < bestdistance)
{
bestdistance = d;
@@ -1730,6 +1741,7 @@ void editor_orthophoto::worker()
{
current = *best;
m_queue.erase(best);
m_urgent.erase(current.key);
m_running.insert(current.key);
if (current.level >= hires_pixels)
++m_running_hires;
@@ -1957,3 +1969,58 @@ void editor_orthophoto::draw(glm::mat4 const &ViewProjection, glm::dvec3 const &
drawlist->PopTextureID();
}
}
bool editor_orthophoto::hurry_tile(tile_key const &Key, int const Distance)
{
// as update() does: nothing asked for outside the download area, nor outside the area the service covers, where the requests
// can't be answered
if (outside_area(Key))
return false;
auto &t{m_tiles[Key]};
if (false == in_service_area(Key.first, Key.second))
t.empty = true;
if (t.empty)
return false;
auto const level{first_level(t, level_for(Distance, m_config.hires))};
t.retry_at = 0.0;
if (t.level == level && t.alpha == m_alpha)
return false; // already shown as it should be
if (false == (t.requested == level && t.requested_alpha == m_alpha))
schedule(Key, t, level, m_alpha);
return true;
}
std::size_t editor_orthophoto::hurry(glm::dvec2 const &Min, glm::dvec2 const &Max, glm::dvec3 const &Camera)
{
if (false == m_enabled)
return 0;
// the tile of the camera as it is now: it isn't followed while the layer is off
m_camera_tile = camera_tile(Camera);
{
std::lock_guard<std::mutex> lock(m_mutex);
m_focus = m_camera_tile;
}
auto const a{camera_tile(glm::dvec3{Min.x, 0.0, Min.y})};
auto const b{camera_tile(glm::dvec3{Max.x, 0.0, Max.y})};
tile_key const first{std::min(a.first, b.first), std::min(a.second, b.second)};
tile_key const last{std::max(a.first, b.first), std::max(a.second, b.second)};
auto const centre{m_camera_tile};
int const radius = m_config.radius;
std::vector<tile_key> keys;
for (int y = first.second; y <= last.second; ++y)
for (int x = first.first; x <= last.first; ++x)
{
tile_key const key{x, y};
auto const distance{std::max(std::abs(x - centre.first), std::abs(y - centre.second))};
if (distance <= radius && hurry_tile(key, distance))
keys.push_back(key);
}
auto const count{keys.size()};
{
std::lock_guard<std::mutex> lock(m_mutex);
m_urgent.clear();
m_urgent.insert(keys.begin(), keys.end());
}
m_wakeup.notify_all();
return count;
}