mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 11:15:23 +01:00
fix(vehicle): articulated joints keep their length, hoses bend smoothly from their cocks, buffers take the deflection of their end
- A joint of two cars (a rooted bonebend whose head is held to the whole turn of the next car) keeps the pieces of its spine as long as made (bones::keep_lengths): the bellows and the roof cables turn with the cars, no longer stretched and pressed by the play of the articulated coupling as the train brakes and pulls. - The turn is spread evenly along a rooted bend only for such a joint; a hose hanging from its cock (rooted, its head held to a line) turns along its chain, and is halved into small triangles like any other hose. - Each buffer is pressed in by the deflection of its end as the coupling has it (half the distance of the couplers, or that of the end in the physical model of the coupling) and by half of what its head stands nearer to the one it meets than the axis does: on the straight as before, on a curve the inside more. Assets (SVN pctga, scratchpad tool weze.py, not committed there yet): the .mmd of 404 vehicles get hose chains (hz_*: from each cock of pneumatic<n>[r]_On and cpneumatic<n>[r]_On to the point the heads share with the next vehicle), and those with automatic couplers a bone turning coupler<n>/cctrl<n>_on towards the pivot of the next one; the EN57 through a new attachments_<stem>_w.inc. The whole control cables of ukrotnienie.py are rehung smoothly from socket to socket. Without them the vehicles are drawn as before.
This commit is contained in:
@@ -520,6 +520,24 @@ TEST_CASE("bones: a hose on a running vehicle is drawn with its ends, not left b
|
||||
CHECK(glm::distance(bones::drawn(state, 1), before + travelled) < 1.0e-9);
|
||||
}
|
||||
|
||||
TEST_CASE("bones: a joint keeps the lengths of its pieces as made, stretched or pressed by the play of the coupling") {
|
||||
std::vector<glm::dvec3> const rest{{0.0, 0.0, 2.0}, {0.0, 0.2, 2.0}, {0.0, 0.4, 2.0}};
|
||||
// the next car 3 cm farther, turned a little round a curve
|
||||
std::vector<glm::dvec3> now{{0.0, 0.0, 2.0}, {0.01, 0.215, 2.0}, {0.03, 0.43, 2.0}};
|
||||
auto const turned{glm::normalize(now[2] - now[1])};
|
||||
bones::keep_lengths(rest, now);
|
||||
CHECK(now[0] == glm::dvec3{0.0, 0.0, 2.0});
|
||||
CHECK(glm::distance(now[1], now[0]) == doctest::Approx(0.2));
|
||||
CHECK(glm::distance(now[2], now[1]) == doctest::Approx(0.2));
|
||||
// each piece still pointing where it pointed
|
||||
auto const kept{glm::normalize(now[2] - now[1])};
|
||||
CHECK(glm::dot(kept, turned) == doctest::Approx(1.0));
|
||||
// pressed together, the same
|
||||
std::vector<glm::dvec3> pressed{{0.0, 0.0, 2.0}, {0.0, 0.18, 2.0}, {0.0, 0.36, 2.0}};
|
||||
bones::keep_lengths(rest, pressed);
|
||||
CHECK(pressed[2].y == doctest::Approx(0.4));
|
||||
}
|
||||
|
||||
TEST_CASE("bones: a joint held to the whole turn of the next car, spread evenly along it from either side") {
|
||||
bones::rig rig;
|
||||
REQUIRE(bones::add_point(rig, {"root", "fixed", "0", "0", "2"}).empty());
|
||||
|
||||
Reference in New Issue
Block a user