From c353435cc1f4a57675ce1388c7224956d1909a80 Mon Sep 17 00:00:00 2001 From: maj00r Date: Tue, 27 Oct 2026 19:21:50 +0100 Subject: [PATCH] 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 --- world/Track.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/world/Track.cpp b/world/Track.cpp index a54dcd9f..384cb2a7 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -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) ) {