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

feat(editor): the point of a track laid where there's no terrain yet, as over the base map of the top view, takes the height of the terrain model with the offset of the scenery and the ballast, the model under the cursor asked for while laying; the fitted heights of the laying called a smoothed grade line in Polish

This commit is contained in:
maj00r
2026-10-24 18:37:44 +02:00
parent 2ae10f5901
commit 641619e13f
5 changed files with 29 additions and 20 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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<double> 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;
};

View File

@@ -38,7 +38,7 @@ glm::dvec3 editor_mode::cursor_terrain(double const Height)
{
std::vector<char> found;
auto ground{ground_heights({glm::dvec3{point.x, std::max(point.y, static_cast<double>(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<double> editor_mode::bed_heights(std::vector<glm::dvec3> const &Poin
std::vector<char> 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<double> result(Points.size(), std::numeric_limits<double>::quiet_NaN());
for (std::size_t i = 0; i < Points.size(); ++i)

View File

@@ -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"