mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-04 23:45:17 +01:00
Merge remote-tracking branch 'origin/feat/editor-track-domain' into feat/editor-level-crossing-surface
# Conflicts: # application/editormode.cpp # application/editormode.h # lang/editor_pl.po # tests/editor/README.md
This commit is contained in:
+54
-10
@@ -68,6 +68,7 @@ extern char **environ;
|
||||
#include "utilities/Logs.h"
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
@@ -3039,13 +3040,60 @@ void editor_mode::area_grow()
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// the failed tiles drawn, the first of them; those after aren't outlined
|
||||
std::size_t constexpr orthophoto_failures_drawn = 400;
|
||||
} // namespace
|
||||
|
||||
void editor_mode::ground_orthophoto_failures(std::vector<std::pair<glm::dvec2, glm::dvec2>> const &Failed) const
|
||||
{
|
||||
// the tiles no longer failing forgotten
|
||||
std::set<std::pair<double, double>> failing;
|
||||
for (auto const &tile : Failed)
|
||||
failing.emplace(tile.first.x, tile.first.y);
|
||||
std::erase_if(m_orthophoto_failure_ground, [&failing](auto const &Entry) { return false == failing.contains(Entry.first); });
|
||||
|
||||
// two tiles asked for a frame: those with a corner not found yet each second, those found all round each 30 s, as the ground
|
||||
// under them may have come or changed since
|
||||
double const now{ImGui::GetTime()};
|
||||
int asked{0};
|
||||
auto const count{std::min(Failed.size(), orthophoto_failures_drawn)};
|
||||
for (std::size_t index = 0; index < count && asked < 2; ++index)
|
||||
{
|
||||
auto const &[low, high]{Failed[index]};
|
||||
auto &entry{m_orthophoto_failure_ground[{low.x, low.y}]};
|
||||
auto const complete{std::ranges::all_of(entry.found, [](bool const Found) { return Found; })};
|
||||
if (now - entry.asked < (complete ? 30.0 : 1.0))
|
||||
continue;
|
||||
entry.asked = now;
|
||||
++asked;
|
||||
std::vector<glm::dvec3> const above{{low.x, 10000.0, low.y}, {high.x, 10000.0, low.y}, {high.x, 10000.0, high.y}, {low.x, 10000.0, high.y}};
|
||||
std::vector<char> found;
|
||||
auto const ground{ground_heights(above, false, &found)};
|
||||
for (std::size_t corner = 0; corner < entry.heights.size(); ++corner)
|
||||
{
|
||||
if (found[corner] == 0)
|
||||
continue;
|
||||
entry.heights[corner] = ground[corner];
|
||||
entry.found[corner] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void editor_mode::draw_orthophoto_failures() const
|
||||
{
|
||||
if (false == m_orthophoto.enabled())
|
||||
{
|
||||
m_orthophoto_failure_ground.clear();
|
||||
return;
|
||||
}
|
||||
auto const failed{m_orthophoto.failed()};
|
||||
if (failed.empty())
|
||||
{
|
||||
m_orthophoto_failure_ground.clear();
|
||||
return;
|
||||
}
|
||||
// the tiles which failed outlined in red, with a cross over them: there's no photo there yet, it's tried again by itself
|
||||
screen_projection const projection;
|
||||
auto *drawlist{ImGui::GetBackgroundDrawList(ImGui::GetMainViewport())};
|
||||
@@ -3054,22 +3102,18 @@ void editor_mode::draw_orthophoto_failures() const
|
||||
// where the terrain lies well above or below it. Seen from above the height doesn't matter
|
||||
auto const grounded{m_orthophoto.settings().drape && false == Global.EditorOrtho};
|
||||
auto const colour{IM_COL32(240, 70, 60, 210)};
|
||||
if (grounded)
|
||||
ground_orthophoto_failures(failed);
|
||||
std::size_t drawn{0};
|
||||
for (auto const &[low, high] : failed)
|
||||
{
|
||||
if (++drawn > 400)
|
||||
if (++drawn > orthophoto_failures_drawn)
|
||||
break;
|
||||
std::vector<glm::dvec3> corners{{low.x, height, low.y}, {high.x, height, low.y}, {high.x, height, high.y}, {low.x, height, high.y}};
|
||||
if (grounded)
|
||||
std::array<glm::dvec3, 4> corners{{{low.x, height, low.y}, {high.x, height, low.y}, {high.x, height, high.y}, {low.x, height, high.y}}};
|
||||
if (auto const entry{grounded ? m_orthophoto_failure_ground.find({low.x, low.y}) : m_orthophoto_failure_ground.end()}; entry != m_orthophoto_failure_ground.end())
|
||||
{
|
||||
std::vector<glm::dvec3> above{corners};
|
||||
for (auto &corner : above)
|
||||
corner.y = 10000.0;
|
||||
std::vector<char> found;
|
||||
auto const ground{ground_heights(above, false, &found)};
|
||||
for (std::size_t i = 0; i < corners.size(); ++i)
|
||||
if (found[i] != 0)
|
||||
corners[i].y = ground[i];
|
||||
corners[i].y = entry->second.found[i] ? entry->second.heights[i] : corners[i].y;
|
||||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
projection.line(drawlist, corners[i], corners[(i + 1) % 4], colour, 2.0f);
|
||||
|
||||
Reference in New Issue
Block a user