mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 20:29:17 +02:00
Merge branch 'tmj-dev' into nogfx
This commit is contained in:
69
Driver.cpp
69
Driver.cpp
@@ -3586,36 +3586,46 @@ bool TController::UpdateSituation(double dt)
|
||||
pVehicles[ 0 ] == pVehicles[ 1 ] ?
|
||||
pVehicles[ 0 ] :
|
||||
pVehicles[ 1 ] );
|
||||
if( iDirection > 0 ) {
|
||||
if( mvOccupied->V >= 0.0 ) {
|
||||
// towards coupler 0
|
||||
if( ( rearvehicle->NextConnected != nullptr )
|
||||
&& ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 1 : 0 ) ].CouplingFlag == ctrain_virtual ) ) {
|
||||
// scan behind if we had something connected there and are moving away
|
||||
rearvehicle->ABuScanObjects( -1, fMaxProximityDist );
|
||||
if( ( mvOccupied->V * iDirection < 0.0 )
|
||||
|| ( ( rearvehicle->NextConnected != nullptr )
|
||||
&& ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 1 : 0 ) ].CouplingFlag == ctrain_virtual ) ) ) {
|
||||
// scan behind if we're moving backward, or if we had something connected there and are moving away
|
||||
rearvehicle->ABuScanObjects( (
|
||||
pVehicle->DirectionGet() == rearvehicle->DirectionGet() ?
|
||||
-1 :
|
||||
1 ),
|
||||
fMaxProximityDist );
|
||||
}
|
||||
pVehicles[ 0 ]->ABuScanObjects( 1, scandistance );
|
||||
pVehicles[ 0 ]->ABuScanObjects( (
|
||||
pVehicle->DirectionGet() == pVehicles[ 0 ]->DirectionGet() ?
|
||||
1 :
|
||||
-1 ),
|
||||
scandistance );
|
||||
}
|
||||
else {
|
||||
// towards coupler 1
|
||||
if( ( rearvehicle->PrevConnected != nullptr )
|
||||
&& ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 0 : 1 ) ].CouplingFlag == ctrain_virtual ) ) {
|
||||
// scan behind if we had something connected there and are moving away
|
||||
rearvehicle->ABuScanObjects( 1, fMaxProximityDist );
|
||||
if( ( mvOccupied->V * iDirection < 0.0 )
|
||||
|| ( ( rearvehicle->PrevConnected != nullptr )
|
||||
&& ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 0 : 1 ) ].CouplingFlag == ctrain_virtual ) ) ) {
|
||||
// scan behind if we're moving backward, or if we had something connected there and are moving away
|
||||
rearvehicle->ABuScanObjects( (
|
||||
pVehicle->DirectionGet() == rearvehicle->DirectionGet() ?
|
||||
1 :
|
||||
-1 ),
|
||||
fMaxProximityDist );
|
||||
}
|
||||
pVehicles[ 0 ]->ABuScanObjects( -1, scandistance );
|
||||
pVehicles[ 0 ]->ABuScanObjects( (
|
||||
pVehicle->DirectionGet() == pVehicles[ 0 ]->DirectionGet() ?
|
||||
-1 :
|
||||
1 ),
|
||||
scandistance );
|
||||
}
|
||||
}
|
||||
/*
|
||||
pVehicles[ 0 ]->fScanDist = (
|
||||
mvOccupied->Vel > 5.0 ?
|
||||
400 + fBrakeDist :
|
||||
300.0 );
|
||||
pVehicles[ 0 ]->Update_scan();
|
||||
if( pVehicles[ 1 ] != pVehicles[ 0 ] ) {
|
||||
pVehicles[ 1 ]->fScanDist = pVehicles[ 0 ]->fScanDist;
|
||||
pVehicles[ 1 ]->Update_scan();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (AIControllFlag)
|
||||
{ // tu bedzie logika sterowania
|
||||
if (mvOccupied->CommandIn.Command != "")
|
||||
@@ -4362,7 +4372,7 @@ bool TController::UpdateSituation(double dt)
|
||||
if (ActualProximityDist < fMaxProximityDist) {
|
||||
// jak minął już maksymalny dystans po prostu hamuj (niski stopień)
|
||||
// ma stanąć, a jest w drodze hamowania albo ma jechać
|
||||
VelDesired = VelNext;
|
||||
VelDesired = Global::Min0RSpeed( VelDesired, VelNext );
|
||||
if( VelDesired == 0.0 ) {
|
||||
// hamowanie tak, aby stanąć
|
||||
AccDesired = ( VelNext * VelNext - vel * vel ) / ( 25.92 * ( ActualProximityDist + 0.1 - 0.5*fMinProximityDist ) );
|
||||
@@ -4458,19 +4468,6 @@ bool TController::UpdateSituation(double dt)
|
||||
}
|
||||
// koniec predkosci aktualnej
|
||||
|
||||
#ifdef DEBUGFAC
|
||||
if (fAccThreshold > -0.3) // bez sensu, ale dla towarowych korzystnie
|
||||
{ // Ra 2014-03: to nie uwzględnia odległości i zaczyna hamować, jak tylko zobaczy
|
||||
// W4
|
||||
if ((AccDesired > 0.0) &&
|
||||
(VelNext >= 0.0)) // wybieg bądź lekkie hamowanie, warunki byly zamienione
|
||||
if (vel > VelNext + 100.0) // lepiej zaczac hamowac
|
||||
AccDesired = fAccThreshold;
|
||||
else if (vel > VelNext + 70.0)
|
||||
AccDesired = 0.0; // nie spiesz się, bo będzie hamowanie
|
||||
// koniec wybiegu i hamowania
|
||||
}
|
||||
#endif // DEBUGFAC
|
||||
// last step sanity check, until the whole calculation is straightened out
|
||||
AccDesired = std::min( AccDesired, AccPreferred );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user