diff --git a/application/editormode.cpp b/application/editormode.cpp index 019b0809..061f2fb1 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -560,18 +560,12 @@ editor_mode::editor_mode() { m_orthophoto.height_source([](double const X, double const Z, double &Height) { return EditorTerrain.height_at(X, Z, Height); }); // the imagery often comes before the terrain made from the model: it lies where the terrain will be m_orthophoto.guess_source([this](double const X, double const Z, double &Height) { - if (nmt_ahead(X, Z, Height)) + if (nmt_ground(X, Z, Height)) return true; - if (false == m_nmt.placed()) - return false; - if (false == m_nmt.height(X, Z, Height)) - { - // asked for, the tile goes onto it once it comes + // asked for, the tile goes onto it once it comes + if (m_nmt.placed()) m_nmt.request({X - 1.0, Z - 1.0}, {X + 1.0, Z + 1.0}); - return false; - } - Height += nmt_offset_at(X, Z); - return true; + return false; }); editor_track::observe(this); } diff --git a/application/editormode.h b/application/editormode.h index 6f90aacf..3afb6341 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -439,6 +439,9 @@ class editor_mode : public application_mode, private editor_track::observer, pri void nmt_follow_tracks(); // the height the ground will have where the terrain is made ahead of the track laid and isn't there yet bool nmt_ahead(double const X, double const Z, double &Height) const; + // the same, else the height of the model with the offset of the scenery where its square is in: the ground where there's no + // terrain made yet, as under the base map of the top view + bool nmt_ground(double const X, double const Z, double &Height) const; // the squares of the model under the rectangle are in, none of them waiting to be asked for again bool nmt_ready(glm::dvec2 const &Min, glm::dvec2 const &Max); // Only: the paths of these tracks are shaped anew, the modifiers of those removed taken away; null: all of them. the number diff --git a/application/editormodenmt.cpp b/application/editormodenmt.cpp index 782bc703..52355678 100644 --- a/application/editormodenmt.cpp +++ b/application/editormodenmt.cpp @@ -748,6 +748,16 @@ bool editor_mode::nmt_ahead(double const X, double const Z, double &Height) cons return true; } +bool editor_mode::nmt_ground(double const X, double const Z, double &Height) const +{ + if (nmt_ahead(X, Z, Height)) + return true; + if (false == m_nmt.placed() || false == m_nmt.height(X, Z, Height)) + return false; + Height += nmt_offset_at(X, Z); + return true; +} + editor_mode::nmt_chunk editor_mode::add_chunk_from_nmt(heightmap::chunk_key const &Key, std::optional const Offset) { auto const low{heightmap::chunk_corner(Key)}; @@ -1040,9 +1050,16 @@ void editor_mode::nmt_grow() { auto &state{m_nmt_state}; auto const now{ImGui::GetTime()}; - if (false == state.grow || now - state.grow_time < 0.5 || (false == m_lay.active && false == m_extend.active) || m_streamer.resident() == 0 || false == m_nmt.placed()) + if (false == state.grow || now - state.grow_time < 0.5 || (false == m_lay.active && false == m_extend.active) || false == m_nmt.placed()) return; state.grow_time = now; + // the model under the cursor, for the heights of the points laid where there's no terrain yet, as over the base map + { + auto const at{m_extend.active ? m_extend.mouse : m_lay.mouse}; + m_nmt.request({at.x - 100.0, at.z - 100.0}, {at.x + 100.0, at.z + 100.0}); + } + if (m_streamer.resident() == 0) + return; auto const at{m_extend.active ? m_extend.mouse : m_lay.mouse}; glm::dvec2 const cursor{at.x, at.z}; double constexpr grow_reach{400.0}; // m around the cursor @@ -1173,13 +1190,8 @@ void editor_mode::draw_nmt_pending() const } } auto const height = [&](double const X, double const Z, double &Height) { - if (m_streamer.height_at(X, Z, Height) || nmt_ahead(X, Z, Height)) + if (m_streamer.height_at(X, Z, Height) || nmt_ground(X, Z, Height)) return true; - if (m_nmt.placed() && m_nmt.height(X, Z, Height)) - { - Height += nmt_offset_at(X, Z); - return true; - } Height = fallback; return true; }; diff --git a/application/editormodetrackbed.cpp b/application/editormodetrackbed.cpp index cae113d4..374d118c 100644 --- a/application/editormodetrackbed.cpp +++ b/application/editormodetrackbed.cpp @@ -38,7 +38,7 @@ glm::dvec3 editor_mode::cursor_terrain(double const Height) { std::vector found; auto ground{ground_heights({glm::dvec3{point.x, std::max(point.y, static_cast(Global.pCamera.Pos.y)), point.z}}, true, &found).front()}; - if (found[0] == 0 && false == nmt_ahead(point.x, point.z, ground)) + if (found[0] == 0 && false == nmt_ground(point.x, point.z, ground)) ground = nearby_ground(point); if (std::isnan(ground)) return point; @@ -99,7 +99,7 @@ std::vector editor_mode::bed_heights(std::vector const &Poin std::vector found; auto heights{ground_heights(probes, true, &found)}; for (std::size_t i = 0; i < probes.size(); ++i) - if (found[i] == 0 && nmt_ahead(probes[i].x, probes[i].z, heights[i])) + if (found[i] == 0 && nmt_ground(probes[i].x, probes[i].z, heights[i])) found[i] = 1; std::vector result(Points.size(), std::numeric_limits::quiet_NaN()); for (std::size_t i = 0; i < Points.size(); ++i) diff --git a/lang/editor_pl.po b/lang/editor_pl.po index d6a3a7b6..aeaf3758 100644 --- a/lang/editor_pl.po +++ b/lang/editor_pl.po @@ -11522,7 +11522,7 @@ msgid "Height of the track on the ground" msgstr "Wysokość toru na terenie" msgid "Fitted" -msgstr "Dopasowana" +msgstr "Wygładzona niweleta" msgid "Point to point" msgstr "Punkt–punkt"