16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 06:29:18 +02:00

build 170913. improved AI driving on slopes, consist collision distance in whois event, cab render fix

This commit is contained in:
tmj-fstate
2017-09-14 00:29:55 +02:00
parent d75c9ff14d
commit f6fa8ee09b
7 changed files with 83 additions and 68 deletions

View File

@@ -1355,7 +1355,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// modifies brake distance for low target speeds, to ease braking rate in such situations
float
TController::braking_distance_multiplier( float const Targetvelocity ) {
TController::braking_distance_multiplier( float const Targetvelocity ) const {
if( Targetvelocity > 65.f ) { return 1.f; }
if( Targetvelocity < 5.f ) { return 1.f; }
@@ -3989,6 +3989,11 @@ TController::UpdateSituation(double dt) {
// bottom margin raised to 2 km/h to give the AI more leeway at low speed limits
fVelPlus = clamp( std::ceil( 0.05 * VelDesired ), 2.0, 5.0 );
}
if( mvOccupied->BrakeDelayFlag == bdelay_G ) {
// increase distances for cargo trains to take into account slower reaction to brakes
fMinProximityDist += 10.0;
fMaxProximityDist += 10.0;
}
}
else {
// samochod (sokista też)
@@ -4299,6 +4304,12 @@ TController::UpdateSituation(double dt) {
if( vehicle->fTrackBlock <= fMinProximityDist ) {
VelDesired = 0.0;
}
if( ( mvOccupied->CategoryFlag & 1 )
&& ( OrderCurrentGet() & Obey_train ) ) {
// trains which move normally should try to stop at safe margin
ActualProximityDist -= fDriverDist;
}
}
}
else {
@@ -4449,8 +4460,8 @@ TController::UpdateSituation(double dt) {
// przeciwnie do zadanego kierunku jazdy
//(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS)
if( ( VelNext >= 0.0 )
&& ( ActualProximityDist <= routescanrange )
&& ( vel >= VelNext ) ) {
&& ( ActualProximityDist <= routescanrange )
&& ( vel >= VelNext ) ) {
// gdy zbliża się i jest za szybki do nowej prędkości, albo stoi na zatrzymaniu
if (vel > 0.0) {
// jeśli jedzie
@@ -4561,13 +4572,14 @@ TController::UpdateSituation(double dt) {
// jesli jedzie za szybko do AKTUALNEGO
if( VelDesired == 0.0 ) {
// jesli stoj, to hamuj, ale i tak juz za pozno :)
AccDesired = std::min( AccDesired, -0.9 ); // hamuj solidnie
AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie
}
else {
// slow down, not full stop
if( vel > ( VelDesired + fVelPlus ) ) {
// try to estimate increase of current velocity before engaged brakes start working
// if it looks like we'll exceed maximum allowed speed start thinking about slight slowing down
if( ( vel + vel * ( 1.0 - fBrake_a0[ 0 ] ) * AbsAccS ) > ( VelDesired + fVelPlus ) ) {
// hamuj tak średnio
AccDesired = std::min( AccDesired, -fBrake_a0[ 0 ] * 0.5 );
AccDesired = std::min( AccDesired, -0.25 );
}
else {
// o 5 km/h to olej (zacznij luzować)
@@ -4581,6 +4593,8 @@ TController::UpdateSituation(double dt) {
// last step sanity check, until the whole calculation is straightened out
AccDesired = std::min( AccDesired, AccPreferred );
// also take into account impact of gravity
AccDesired = clamp( AccDesired - fAccGravity, -0.9, 0.9 );
@@ -4637,15 +4651,20 @@ TController::UpdateSituation(double dt) {
}
// NOTE: as a stop-gap measure the routine is limited to trains only while car calculations seem off
if( mvControlling->CategoryFlag == 1 ) {
if( -AccDesired * BrakeAccFactor() < (
( ( fReady > 0.4 ) || ( VelNext > vel - 40.0 ) ) ?
fBrake_a0[ 0 ] * 0.8 :
-fAccThreshold )
/ braking_distance_multiplier( VelNext ) ) {
AccDesired = std::max( -0.06, AccDesired );
if( vel < VelDesired ) {
// don't adjust acceleration when going above current goal speed
if( -AccDesired * BrakeAccFactor() < (
( ( fReady > 0.4 )
|| ( VelNext > vel - 40.0 ) ) ?
fBrake_a0[ 0 ] * 0.8 :
-fAccThreshold )
/ braking_distance_multiplier( VelNext ) ) {
AccDesired = std::max( -0.06, AccDesired );
}
}
else {
ReactionTime = 0.25; // i orientuj się szybciej, jeśli hamujesz
// i orientuj się szybciej, jeśli hamujesz
ReactionTime = 0.25;
}
}
if (mvOccupied->BrakeSystem == Pneumatic) // napełnianie uderzeniowe
@@ -5510,6 +5529,13 @@ bool TController::IsStop()
return TrainParams->IsStop();
};
// returns most recently calculated distance to potential obstacle ahead
double
TController::TrackBlock() const {
return pVehicles[ TMoverParameters::side::front ]->fTrackBlock;
}
void TController::MoveTo(TDynamicObject *to)
{ // przesunięcie AI do innego pojazdu (przy zmianie kabiny)
// mvOccupied->CabDeactivisation(); //wyłączenie kabiny w opuszczanym