mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-29 16:02:13 +01:00
Merge remote-tracking branch 'origin/feat/derailment-overspeed-criteria' into feat/track-buckling
# Conflicts: # McZapkie/Mover.cpp
This commit is contained in:
@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "world/Track.h"
|
||||
#include "world/TrackRails.h"
|
||||
#include "world/TrackCheck.h"
|
||||
#include "simulation/simulation.h"
|
||||
#include "scene/scene.h"
|
||||
#include "utilities/Globals.h"
|
||||
@@ -4197,6 +4198,68 @@ path_table::InitTracks() {
|
||||
TTrack::fetch_default_profiles();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// the tightest radius of the curve of a path in the plan [m], from the circles through its design points about 5 m apart
|
||||
// (without the unevenness, whose short waves would bend it): the curve the axles of a vehicle follow, whether the track
|
||||
// gives the radius or only its control points. 0 for a straight one; a radius over 15 km is taken for one, as
|
||||
// TDynamicObject::Update() takes it
|
||||
double tightest_radius(TSegment const &Segment) {
|
||||
|
||||
auto const length { Segment.GetLength() };
|
||||
if( length < 0.5 ) {
|
||||
return 0.0;
|
||||
}
|
||||
auto const intervals { std::max( 2, static_cast<int>( std::ceil( length / 5.0 ) ) ) };
|
||||
auto const flat = [&]( int const Index ) {
|
||||
auto const point { Segment.FastGetPoint( static_cast<double>( Index ) / intervals ) };
|
||||
return glm::dvec2 { point.x, point.z }; };
|
||||
auto tightest { 0.0 };
|
||||
for( int index = 1; index < intervals; ++index ) {
|
||||
auto const a { flat( index - 1 ) };
|
||||
auto const b { flat( index ) };
|
||||
auto const c { flat( index + 1 ) };
|
||||
auto const ab { b - a };
|
||||
auto const ac { c - a };
|
||||
auto const area2 { std::abs( ab.x * ac.y - ab.y * ac.x ) };
|
||||
if( area2 < 1e-9 ) {
|
||||
continue;
|
||||
}
|
||||
auto const radius { glm::length( ab ) * glm::length( c - b ) * glm::length( ac ) / ( 2.0 * area2 ) };
|
||||
if( radius < 15000.0 && ( tightest == 0.0 || radius < tightest ) ) {
|
||||
tightest = radius;
|
||||
}
|
||||
}
|
||||
return tightest;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
path_table::CheckTracks() const {
|
||||
|
||||
std::vector<track_check::track> tracks;
|
||||
for( auto *path : sequence() ) {
|
||||
if( path == nullptr || ( path->iCategoryFlag & 1 ) == 0 || path->Segment == nullptr ) {
|
||||
continue;
|
||||
}
|
||||
track_check::track track;
|
||||
track.name = path->name();
|
||||
track.velocity = path->VelocityGet();
|
||||
track.plain = ( path->eType == tt_Normal );
|
||||
track.radius = track.plain ? tightest_radius( *path->Segment ) : 0.0;
|
||||
float roll1 { 0.f }, roll2 { 0.f };
|
||||
path->Segment->GetRolls( roll1, roll2 );
|
||||
track.gauge = path->fTrackWidth;
|
||||
auto const spacing { 1000.0 * derailment::contact_spacing( track.gauge ) };
|
||||
track.cant = { spacing * std::sin( roll1 ), spacing * std::sin( roll2 ) };
|
||||
track.damage = path->iDamageFlag;
|
||||
track.uneven = path->m_uneven;
|
||||
tracks.emplace_back( std::move( track ) );
|
||||
}
|
||||
track_check::scan( tracks, []( std::string const &Line ) { WriteLog( Line ); } );
|
||||
}
|
||||
|
||||
// legacy method, sends list of occupied paths over network
|
||||
void
|
||||
path_table::TrackBusyList() const {
|
||||
|
||||
Reference in New Issue
Block a user