17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 17:26:22 +01:00

feat(editor): an end of a track dragged, and an end of a straight dragged by its handle, goes onto the ground at the height of the ballast, as a point laid; with Shift held it keeps its height

Selftest trackends: the ends of a track against the ground under them.
This commit is contained in:
maj00r
2026-10-24 18:45:47 +02:00
parent 9625b4b3d9
commit 11d1342181
7 changed files with 42 additions and 6 deletions

View File

@@ -93,6 +93,26 @@ editor_mode::selftest_result editor_mode::selftest_scene(std::string const &comm
WriteLog(format("SELFTEST selectat %.1f %.1f: %s", point.x, point.z, m_node != nullptr ? m_node->name().c_str() : "nothing"));
return selftest_result::handled;
}
if (command == "trackends")
{
// the ends of the first path of the track, against the ground under them
std::string name;
words >> name;
auto const *track{simulation::Paths.find(name)};
if (track == nullptr || track->m_paths.empty())
{
WriteLog("SELFTEST trackends " + name + ": no such track");
return selftest_result::handled;
}
for (auto const end : {segment_data::point::start, segment_data::point::end})
{
auto const &point{track->m_paths.front().points[end]};
std::vector<char> found;
auto const ground{ground_heights({glm::dvec3{point.x, point.y + 50.0, point.z}}, true, &found).front()};
WriteLog(format("SELFTEST trackends %s %s: %.2f %.3f %.2f, ground %.3f (found %d)", name.c_str(), end == segment_data::point::start ? "start" : "end", point.x, point.y, point.z, ground, found[0]));
}
return selftest_result::handled;
}
if (command == "kbreak")
{
// K on the track nearest the point: split there, the point between at the height of the ground and the ballast