17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-05 14:24:51 +01:00

fix(track): what the review of unevenness found in the engine

- A path of no length gave a joint with a vector across of NaN to the path
  joined to it, on any scenery, with unevenness or not. It now has no
  vector across, and so makes no joint.
- Axles no longer stray along the track. It moved vehicles against each
  other, changing the distance their couplers go by.
- The bend under an axle goes straight on past the ends of a path: the
  polynomial ran off on a short curved one, with a kick in the cab shake.
- A track left out of its rail run, where tracks are joined one way only,
  no longer walks the whole run again on every call.
- The clatter of an axle goes by the outer axle on its side of the vehicle,
  and not always by the same one, as the two can be on different tracks.
- A vertex works out the amounts once, and the foot of the ballast not at all.
This commit is contained in:
maj00r
2026-10-31 19:02:55 +01:00
parent ec2d226688
commit 371de52342
6 changed files with 105 additions and 25 deletions

View File

@@ -224,6 +224,31 @@ inline double bed_share( double const Depth, double const Rail, double const Hei
return Height > 0.0 ? std::clamp( 1.0 - ( Depth - Rail ) / Height, 0.0, 1.0 ) : 1.0;
}
// a displacement with the part along the track taken out, Across being a unit vector in the plan. Along the track
// it would only change the distance between coupled vehicles, and with it the forces between them
inline glm::dvec3 across_only( glm::dvec3 const &Offset, glm::dvec3 const &Across ) {
return Across * glm::dot( Offset, Across ) + glm::dvec3 { 0.0, Offset.y, 0.0 };
}
// the unit vector across a direction in the plan, or across the chord if it has none; zero for a path of no length, which has neither
inline glm::dvec3 across_of( glm::dvec3 const &Direction, glm::dvec3 const &Chord ) {
for( auto const &along : { Direction, Chord } ) {
glm::dvec3 const across { -along.z, 0.0, along.x };
if( glm::dot( across, across ) > 0.0 ) {
return glm::normalize( across );
}
}
return glm::dvec3 { 0.0 };
}
// the cant where two paths meet, theirs turned to the way of this one: a switch takes that of a plain track, alike ones meet halfway
inline float joint_roll( float const Own, float const Their, bool const Switch, bool const Theirswitch ) {
return Switch == Theirswitch ? 0.5f * ( Own + Their ) : Switch ? Their : Own;
}
// distance from the joint behind the point
inline double rail_phase( double const Along, double const Rail ) {