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

fix(track): a path with its radius given is a curve however gently it bends, it isn't straightened as it's loaded: a path whose control vectors lay within 2 cm of where a straight has them was laid as a straight, a short one bent with a gentle curve too, as the 9.44 m of the main track of a switch of a slip bent into a curve of R 800 m, whose diverging track kept its curve: the two tracks of the switch 14 mm apart where they're one, the blades of a side of the slip shaped from 0.354 m, of the other side not at all. Plain tracks, switches and the pieces of their paths alike; one with no radius, as a straight given its control vectors along it, is straightened as before. Selftest bladetips: a Rkpd 49E1-190-1:9 bent into R 800 m and R 4000 m with the blades of all four switches from 1.248 m, as on straights

This commit is contained in:
maj00r
2026-10-27 19:21:50 +01:00
parent 6533914024
commit c353435cc1

View File

@@ -60,8 +60,10 @@ void init_switch_piece( TSegment &Segment, segment_data const &Piece, bool const
p1.y += 0.18;
p2.y += 0.18;
}
if( glm::length2( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ) < sq( 0.02 )
|| glm::length2( ( p1 + p2 + p2 ) / 3.0 - p2 - cp2 ) < sq( 0.02 ) ) {
// one with its radius given is a curve however gently it bends, as a short path bent with the curve it's laid into
if( Piece.radius == 0.f
&& ( glm::length2( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ) < sq( 0.02 )
|| glm::length2( ( p1 + p2 + p2 ) / 3.0 - p2 - cp2 ) < sq( 0.02 ) ) ) {
cp1 = cp2 = glm::dvec3( 0, 0, 0 );
}
auto const straight { cp1 == glm::dvec3() && cp2 == glm::dvec3() };
@@ -837,10 +839,11 @@ void TTrack::init_segments( bool const Initial ) {
// length2 is better than length for comparing because it does not require sqrt function
// "prostowanie" prostych z kontrolnymi, dokładność 2cm: a straight only where both control vectors lie along it, or aren't
// given; one of them moved off it, the other one left where a straight has it, makes a curve
// given; one of them moved off it, the other one left where a straight has it, makes a curve. One with its radius given is a
// curve however gently it bends, as a short path bent with the curve it's laid into
auto const startalong { cp1 == glm::dvec3() || glm::length2( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ) < sq( 0.02 ) };
auto const endalong { cp2 == glm::dvec3() || glm::length2( ( p1 + p2 + p2 ) / 3.0 - p2 - cp2 ) < sq( 0.02 ) };
if( startalong && endalong ) {
if( startalong && endalong && fRadius == 0 ) {
cp1 = cp2 = glm::dvec3(0, 0, 0);
}
@@ -932,8 +935,8 @@ void TTrack::init_segments( bool const Initial ) {
// na przechyłce doliczyć jeszcze pół przechyłki?
}
if( eType != tt_Cross ) {
// dla skrzyżowań muszą być podane kontrolne
if( eType != tt_Cross && fRadiusTable[ 0 ] == 0 ) {
// dla skrzyżowań muszą być podane kontrolne; a path with its radius given is a curve however gently it bends
// length2 is better than length for comparing because it does not require sqrt function
if( glm::length2(( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ) < sq(0.02)
|| glm::length2(( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ) < sq(0.02) ) {
@@ -997,8 +1000,8 @@ void TTrack::init_segments( bool const Initial ) {
// na przechyłce doliczyć jeszcze pół przechyłki?
}
if( eType != tt_Cross ) {
// dla skrzyżowań muszą być podane kontrolne
if( eType != tt_Cross && fRadiusTable[ 1 ] == 0 ) {
// dla skrzyżowań muszą być podane kontrolne; a path with its radius given is a curve however gently it bends
// length2 is better than length for comparing because it does not require sqrt function
if( glm::length2((p3 + p3 + p4) / 3.0 - p3 - cp3) < sq(0.02)
|| glm::length2((p3 + p4 + p4) / 3.0 - p4 + cp3) < sq(0.02) ) {