mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
engine revolutions change rate tweak for diesel-electric vehicles, support for combined engine revving sound, alerter ui indicator
This commit is contained in:
18
DynObj.cpp
18
DynObj.cpp
@@ -4596,6 +4596,12 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
m_powertrainsounds.engine.m_amplitudefactor /= amplitudedivisor;
|
||||
}
|
||||
|
||||
else if( token == "dieselinc:" ) {
|
||||
// dzwiek przy wlazeniu na obroty woodwarda
|
||||
m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
m_powertrainsounds.engine_revving.owner( this );
|
||||
}
|
||||
|
||||
else if( ( token == "tractionmotor:" )
|
||||
&& ( MoverParameters->Power > 0 ) ) {
|
||||
// plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest.
|
||||
@@ -4659,12 +4665,6 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
rsDerailment.owner( this );
|
||||
}
|
||||
|
||||
else if( token == "dieselinc:" ) {
|
||||
// dzwiek przy wlazeniu na obroty woodwarda
|
||||
m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
m_powertrainsounds.engine_revving.owner( this );
|
||||
}
|
||||
|
||||
else if( token == "curve:" ) {
|
||||
rscurve.deserialize( parser, sound_type::single, sound_parameters::range );
|
||||
rscurve.owner( this );
|
||||
@@ -5595,8 +5595,14 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
||||
}
|
||||
engine_revs_last = Vehicle.enrot * 60;
|
||||
|
||||
if( false == engine_revving.is_combined() ) {
|
||||
// if the sound comes with multiple samples we reuse rpm-based calculation from the engine
|
||||
frequency = engine_revving.m_frequencyoffset + engine_revving.m_frequencyfactor * 1.0;
|
||||
}
|
||||
|
||||
if( enginerevvolume > 0.02 ) {
|
||||
engine_revving
|
||||
.pitch( frequency )
|
||||
.gain( enginerevvolume )
|
||||
.play( sound_flags::exclusive | sound_flags::looping );
|
||||
}
|
||||
|
||||
@@ -4191,43 +4191,59 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt)
|
||||
// *************************************************************************************************
|
||||
double TMoverParameters::TractionForce(double dt)
|
||||
{
|
||||
double PosRatio, dmoment, dtrans, tmp;// , tmpV;
|
||||
int i;
|
||||
double PosRatio, dmoment, dtrans, tmp;
|
||||
|
||||
Ft = 0;
|
||||
dtrans = 0;
|
||||
dmoment = 0;
|
||||
// tmpV =Abs(nrot * WheelDiameter / 2);
|
||||
// youBy
|
||||
if (EngineType == DieselElectric)
|
||||
{
|
||||
tmp = DElist[MainCtrlPos].RPM / 60.0;
|
||||
if ((Heating) && (HeatingPower > 0) && (MainCtrlPosNo > MainCtrlPos))
|
||||
{
|
||||
i = MainCtrlPosNo;
|
||||
while (DElist[i - 2].RPM / 60.0 > tmp)
|
||||
i--;
|
||||
tmp = DElist[i].RPM / 60.0;
|
||||
}
|
||||
switch( EngineType ) {
|
||||
case DieselElectric: {
|
||||
if( true == ConverterFlag ) {
|
||||
// NOTE: converter is currently a stand-in for a fuel pump
|
||||
tmp = DElist[ MainCtrlPos ].RPM / 60.0;
|
||||
|
||||
if (enrot != tmp * int(ConverterFlag))
|
||||
if (abs(tmp * int(ConverterFlag) - enrot) < 0.001)
|
||||
enrot = tmp * int(ConverterFlag);
|
||||
else if ((enrot < DElist[0].RPM * 0.01) && (ConverterFlag))
|
||||
enrot += (tmp * int(ConverterFlag) - enrot) * dt / 5.0;
|
||||
if( ( true == Heating )
|
||||
&& ( HeatingPower > 0 )
|
||||
&& ( MainCtrlPosNo > MainCtrlPos ) ) {
|
||||
|
||||
int i = MainCtrlPosNo;
|
||||
while( DElist[ i - 2 ].RPM / 60.0 > tmp ) {
|
||||
--i;
|
||||
}
|
||||
tmp = DElist[ i ].RPM / 60.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tmp = 0.0;
|
||||
}
|
||||
|
||||
if( enrot != tmp ) {
|
||||
enrot = clamp(
|
||||
enrot + ( dt / 1.25 ) * ( // TODO: equivalent of dizel_aim instead of fixed inertia
|
||||
enrot < tmp ?
|
||||
1.0 :
|
||||
-2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not
|
||||
0.0, std::max( tmp, enrot ) );
|
||||
if( std::abs( tmp - enrot ) < 0.001 ) {
|
||||
enrot = tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DieselEngine: {
|
||||
if( ShuntMode ) // dodatkowa przekładnia np. dla 2Ls150
|
||||
dtrans = AnPos * Transmision.Ratio * MotorParam[ ScndCtrlActualPos ].mIsat;
|
||||
else
|
||||
enrot += (tmp * int(ConverterFlag) - enrot) * 1.5 * dt;
|
||||
}
|
||||
else if (EngineType != DieselEngine)
|
||||
enrot = Transmision.Ratio * nrot;
|
||||
else // dla DieselEngine
|
||||
{
|
||||
if (ShuntMode) // dodatkowa przekładnia np. dla 2Ls150
|
||||
dtrans = AnPos * Transmision.Ratio * MotorParam[ScndCtrlActualPos].mIsat;
|
||||
else
|
||||
dtrans = Transmision.Ratio * MotorParam[ScndCtrlActualPos].mIsat;
|
||||
dmoment = dizel_Momentum(dizel_fill, dtrans * nrot * ActiveDir, dt); // oblicza tez
|
||||
// enrot
|
||||
dtrans = Transmision.Ratio * MotorParam[ ScndCtrlActualPos ].mIsat;
|
||||
|
||||
dmoment = dizel_Momentum( dizel_fill, dtrans * nrot * ActiveDir, dt ); // oblicza tez enrot
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
enrot = Transmision.Ratio * nrot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eAngle += enrot * dt;
|
||||
@@ -4252,7 +4268,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
&& ( ( std::abs( eimv[ eimv_If ] ) > 1.0 )
|
||||
|| ( tmpV > 0.1 ) ) ) {
|
||||
|
||||
i = 0;
|
||||
int i = 0;
|
||||
while( ( i < RlistSize - 1 )
|
||||
&& ( DElist[ i + 1 ].RPM < tmpV ) ) {
|
||||
++i;
|
||||
@@ -4891,7 +4907,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
dizel_fill = 0;
|
||||
EnginePower = 0;
|
||||
{
|
||||
for (i = 0; i < 21; i++)
|
||||
for (int i = 0; i < 21; ++i)
|
||||
eimv[i] = 0;
|
||||
}
|
||||
Hamulec->SetED(0);
|
||||
@@ -5647,7 +5663,7 @@ bool TMoverParameters::dizel_Update(double dt)
|
||||
|
||||
enrot = std::max(
|
||||
enrot,
|
||||
0.1 * ( // TODO: dac zaleznie od temperatury i baterii
|
||||
0.35 * ( // TODO: dac zaleznie od temperatury i baterii
|
||||
EngineType == DieselEngine ?
|
||||
dizel_nmin :
|
||||
DElist[ 0 ].RPM / 60.0 ) );
|
||||
|
||||
@@ -5306,8 +5306,8 @@ TTrain::update_sounds( double const Deltatime ) {
|
||||
&& ( false == Global::CabWindowOpen )
|
||||
&& ( DynamicObject->GetVelocity() > 0.5 ) ) {
|
||||
|
||||
volume = rsRunningNoise.m_amplitudefactor * mvOccupied->Vel + rsRunningNoise.m_amplitudeoffset;
|
||||
auto frequency { rsRunningNoise.m_frequencyfactor * mvOccupied->Vel + rsRunningNoise.m_frequencyoffset };
|
||||
volume = rsRunningNoise.m_amplitudeoffset + rsRunningNoise.m_amplitudefactor * mvOccupied->Vel;
|
||||
auto frequency { rsRunningNoise.m_frequencyoffset + rsRunningNoise.m_frequencyfactor * mvOccupied->Vel };
|
||||
|
||||
if( std::abs( mvOccupied->nrot ) > 0.01 ) {
|
||||
// hamulce wzmagaja halas
|
||||
|
||||
59
World.cpp
59
World.cpp
@@ -688,32 +688,32 @@ void TWorld::OnKeyDown(int cKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cKey == Global::Keys[k_EndSign])
|
||||
{ // Ra 2014-07: zabrane z kabiny
|
||||
else if (cKey == Global::Keys[k_EndSign]) {
|
||||
// Ra 2014-07: zabrane z kabiny
|
||||
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Global::pCameraPosition, 10, false, true ) ) };
|
||||
if (vehicle)
|
||||
|
||||
if( vehicle == nullptr ) { return; }
|
||||
|
||||
int const CouplNr {
|
||||
clamp(
|
||||
vehicle->DirectionGet()
|
||||
* ( LengthSquared3( vehicle->HeadPosition() - Camera.Pos ) > LengthSquared3( vehicle->RearPosition() - Camera.Pos ) ?
|
||||
1 :
|
||||
-1 ),
|
||||
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
||||
int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jakąś idiotyczną zmianę tapety pulpitu :/
|
||||
if (Global::shiftState) // z [Shift] zapalanie
|
||||
set = mask = light::rearendsignals; // bez [Ctrl] założyć tabliczki
|
||||
else if (Global::ctrlState)
|
||||
set = mask = ( light::redmarker_left | light::redmarker_right ); // z [Ctrl] zapalić światła czerwone
|
||||
else
|
||||
mask = ( light::rearendsignals | light::redmarker_left | light::redmarker_right ); // wyłączanie ściąga wszystko
|
||||
if (((vehicle->iLights[CouplNr]) & mask) != set)
|
||||
{
|
||||
int CouplNr = (LengthSquared3(vehicle->HeadPosition() - Camera.Pos) >
|
||||
LengthSquared3(vehicle->RearPosition() - Camera.Pos) ?
|
||||
1 :
|
||||
-1) *
|
||||
vehicle->DirectionGet();
|
||||
if (CouplNr < 0)
|
||||
CouplNr = 0; // z [-1,1] zrobić [0,1]
|
||||
int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jakąś idiotyczną zmianę tapety pulpitu :/
|
||||
if (Global::shiftState) // z [Shift] zapalanie
|
||||
set = mask = light::rearendsignals; // bez [Ctrl] założyć tabliczki
|
||||
else if (Global::ctrlState)
|
||||
set = mask = ( light::redmarker_left | light::redmarker_right ); // z [Ctrl] zapalić światła czerwone
|
||||
else
|
||||
mask = 2 + 32 + 64; // wyłączanie ściąga wszystko
|
||||
if (((vehicle->iLights[CouplNr]) & mask) != set)
|
||||
{
|
||||
vehicle->iLights[CouplNr] = (vehicle->iLights[CouplNr] & ~mask) | set;
|
||||
if (Train)
|
||||
{ // Ra: ten dźwięk z kabiny to przegięcie, ale na razie zostawiam
|
||||
Train->dsbSwitch.play();
|
||||
}
|
||||
vehicle->iLights[CouplNr] = (vehicle->iLights[CouplNr] & ~mask) | set;
|
||||
if (Train)
|
||||
{ // Ra: ten dźwięk z kabiny to przegięcie, ale na razie zostawiam
|
||||
Train->dsbSwitch.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1252,6 +1252,15 @@ TWorld::Update_UI() {
|
||||
|
||||
uitextline3 = "Brakes:" + to_string( mover->fBrakeCtrlPos, 1, 5 ) + "+" + std::to_string( mover->LocalBrakePos ) + ( mover->SlippingWheels ? " !" : " " );
|
||||
|
||||
uitextline4 = (
|
||||
true == TestFlag( mover->SecuritySystem.Status, s_aware ) ?
|
||||
"!ALERTER! " :
|
||||
" " );
|
||||
uitextline4 += (
|
||||
true == TestFlag( mover->SecuritySystem.Status, s_active ) ?
|
||||
"!SHP! " :
|
||||
" " );
|
||||
|
||||
if( Global::iScreenMode[ Global::iTextMode - GLFW_KEY_F1 ] == 1 ) {
|
||||
// detail mode on second key press
|
||||
uitextline2 +=
|
||||
@@ -1265,7 +1274,7 @@ TWorld::Update_UI() {
|
||||
|
||||
auto const trackblockdistance{ std::abs( Controlled->Mechanik->TrackBlock() ) };
|
||||
if( trackblockdistance <= 75.0 ) {
|
||||
uitextline4 = " Another vehicle ahead (distance: " + to_string( trackblockdistance, 1 ) + " m)";
|
||||
uitextline4 += " Another vehicle ahead (distance: " + to_string( trackblockdistance, 1 ) + " m)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user