17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 18:09:04 +01:00

feat(editor): the selftest fastentour, the camera over each cell of a grid with switches or crossings laying timbers in turn, for a fastencheck of the whole scenery after it

This commit is contained in:
maj00r
2026-10-24 02:19:06 +02:00
parent f36fa81fd1
commit 8375891c41
2 changed files with 27 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
// railtime lays out the rails of every track, as when its geometry is made, and logs how long it took
// throw <0|1> sets every switch to the path and moves its blades there at once
// crossings [name] logs where rails of tracks cross rails of other tracks and of what kind (acute, obtuse, middle acute or obtuse, wide), checks that each acute crossing has one partner and one nose
// fastentour [cell] [frames] the camera over each cell of the grid with switches laying timbers in turn, for a fastencheck after of the whole scenery
// switchtimbers <model|none> the model of the timbers set on all the switches and crossings, as the buttons of the switch tool do it
// frogkey name [on|off] sets or clears the frogs key of a switch (one undo step); logs the key, whether it is written, the frog and the crossings
// geomhash [name] logs the number of vertices and a hash of the drawn geometry of each rail track (rails, trackbed, cut faces), to compare builds; exact: the bits of every value, userdata and tread materials too

View File

@@ -198,6 +198,32 @@ editor_mode::selftest_result editor_mode::selftest_sleepers(std::string const &c
WriteLog(format("SELFTEST fastenings %s: %d plates, %d chairs, %d checks", track->name().c_str(), counts[track_sleepers::part_plate], counts[track_sleepers::part_chair], counts[track_sleepers::part_check]));
return selftest_result::handled;
}
if (command == "fastentour")
{
// the camera over each cell of the grid with switches or crossings laying timbers, in turn, as the tracks get their beams only
// near it: the steps of the tour go in after this one, a fastencheck after them takes the whole scenery
double cell{400.0};
int frames{40};
words >> cell >> frames;
std::map<std::pair<long, long>, glm::dvec3> stops;
for (auto *track : simulation::Paths.sequence())
{
if (track == nullptr || track->m_editorremoved || (track->eType != tt_Switch && track->m_crossings.empty()) || false == track_sleepers::lays(*track))
continue;
auto const at{track->location()};
stops.emplace(std::make_pair(std::lround(std::floor(at.x / cell)), std::lround(std::floor(at.z / cell))), at);
}
std::vector<std::string> steps;
for (auto const &stop : stops)
{
auto const &at{stop.second};
steps.push_back(format("camera %.2f %.2f %.2f %.2f %.2f %.2f", at.x, at.y + 60.0, at.z + 1.0, at.x, at.y, at.z));
steps.push_back("wait " + std::to_string(frames));
}
m_selftest.lines.insert(m_selftest.lines.begin() + static_cast<std::ptrdiff_t>(m_selftest.next), steps.begin(), steps.end());
WriteLog(format("SELFTEST fastentour: %zu stops of %.0f m", stops.size(), cell));
return selftest_result::handled;
}
if (command == "fastencheck")
{
// the fastenings of all the tracks laying timbers with them: of each kind, and those over one another on a timber