mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 17:26:22 +01:00
fix(track): what Sonar reports on the unevenness
The blockers are in the EP brake of a vehicle, older than this work: its arrays made with new[] are vectors now, which also removes the deletes. - The caches of the unevenness of a track are no longer mutable: what fills them isn't const any more. - TSegment gets back to RaPositionGet in one piece, with what the path has to do with the others in one struct. - Less nesting in the group of switches and in the fields of the editor, nested conditionals written out, and the attribute is read from a string_view. A test no longer counts in floating point. No change in behaviour.
This commit is contained in:
@@ -3382,14 +3382,12 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
FzadED = 0; //pętla bezpieczeństwa - bez ED
|
||||
auto const FzadPN = Fzad - FrED * MoverParameters->MED_FrED_factor;
|
||||
//np = 0;
|
||||
// BUG: likely memory leak, allocation per inner loop, deleted only once outside
|
||||
// TODO: sort this shit out
|
||||
bool* PrzekrF = new bool[np];
|
||||
std::vector<bool> PrzekrF( np );
|
||||
float nPrzekrF = 0;
|
||||
bool test = true;
|
||||
float* FzED = new float[np];
|
||||
float* FzEP = new float[np];
|
||||
float* FmaxEP = new float[np];
|
||||
std::vector<float> FzED( np );
|
||||
std::vector<float> FzEP( np );
|
||||
std::vector<float> FmaxEP( np );
|
||||
// 3. ustaw pojazdom sile hamowania ED
|
||||
// - proporcjonalnie do mozliwosci
|
||||
|
||||
@@ -3548,11 +3546,6 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
|
||||
}
|
||||
|
||||
delete[] PrzekrF;
|
||||
delete[] FzED;
|
||||
delete[] FzEP;
|
||||
delete[] FmaxEP;
|
||||
|
||||
MED_oldFED = FzadED;
|
||||
}
|
||||
|
||||
@@ -3661,33 +3654,32 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
1 :
|
||||
ctOwner->Vehicle()->DirectionGet() == DirectionGet() ? 1 : -1 ) };
|
||||
for( auto &axle : m_axlesounds ) {
|
||||
if( axle_passed_joint( axle, dDOMoveLen, directioninconsist ) ) {
|
||||
if( MoverParameters->Vel > 0.1 ) {
|
||||
// NOTE: for combined clatter sound we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range
|
||||
auto const frequency = true == axle.clatter.is_combined() ? MoverParameters->Vel * 0.01 : 1.0;
|
||||
axle.clatter
|
||||
.pitch( frequency )
|
||||
.gain( volume )
|
||||
.play();
|
||||
// crude bump simulation, drop down on even axles, move back up on
|
||||
// the odd ones
|
||||
// MoverParameters->AccVert += (MoverParameters->Vel*0.1f) *
|
||||
double const headroom = std::clamp(
|
||||
MoverParameters->Vmax - ( MoverParameters->Vel + MoverParameters->Vmax * 0.32f ),
|
||||
0.0, MoverParameters->Vmax );
|
||||
double const jolt = headroom * .05f * ( MyTrack->iDamageFlag * 0.25f );
|
||||
if (MyTrack->eType == tt_Normal)
|
||||
{
|
||||
MoverParameters->AccVert += std::clamp( jolt, 0.0, 4.0 );
|
||||
}
|
||||
else if (MyTrack->eType == tt_Switch)
|
||||
{
|
||||
double const accHorizontal = std::clamp( jolt, 0.0, 1.0 ) * ((axleindex % 2) != 0 ? 1 : -1);
|
||||
MoverParameters->AccS += accHorizontal;
|
||||
MoverParameters->AccN += accHorizontal;
|
||||
MoverParameters->AccVert += std::clamp( jolt, 0.0, 2.0 );
|
||||
}
|
||||
}
|
||||
if( axle_passed_joint( axle, dDOMoveLen, directioninconsist )
|
||||
&& MoverParameters->Vel > 0.1 ) {
|
||||
// NOTE: for combined clatter sound we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range
|
||||
auto const frequency = true == axle.clatter.is_combined() ? MoverParameters->Vel * 0.01 : 1.0;
|
||||
axle.clatter
|
||||
.pitch( frequency )
|
||||
.gain( volume )
|
||||
.play();
|
||||
// crude bump simulation, drop down on even axles, move back up on
|
||||
// the odd ones
|
||||
// MoverParameters->AccVert += (MoverParameters->Vel*0.1f) *
|
||||
double const headroom = std::clamp(
|
||||
MoverParameters->Vmax - ( MoverParameters->Vel + MoverParameters->Vmax * 0.32f ),
|
||||
0.0, MoverParameters->Vmax );
|
||||
double const jolt = headroom * .05f * ( MyTrack->iDamageFlag * 0.25f );
|
||||
if (MyTrack->eType == tt_Normal)
|
||||
{
|
||||
MoverParameters->AccVert += std::clamp( jolt, 0.0, 4.0 );
|
||||
}
|
||||
else if (MyTrack->eType == tt_Switch)
|
||||
{
|
||||
double const accHorizontal = std::clamp( jolt, 0.0, 1.0 ) * ((axleindex % 2) != 0 ? 1 : -1);
|
||||
MoverParameters->AccS += accHorizontal;
|
||||
MoverParameters->AccN += accHorizontal;
|
||||
MoverParameters->AccVert += std::clamp( jolt, 0.0, 2.0 );
|
||||
}
|
||||
}
|
||||
++axleindex;
|
||||
}
|
||||
@@ -8072,12 +8064,11 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
||||
}
|
||||
|
||||
bool
|
||||
TDynamicObject::axle_passed_joint( axle_sounds &Axle, double const Move, int const Direction ) {
|
||||
TDynamicObject::axle_passed_joint( axle_sounds &Axle, double const Move, int const Direction ) const {
|
||||
|
||||
// by the outer axle on its side of the vehicle: the two can be on different tracks
|
||||
auto const &outer { Axle.offset >= 0.0 ? Axle0 : Axle1 };
|
||||
auto const railphase { outer.RailPhase( Axle.offset - std::copysign( 0.5 * fAxleDist, Axle.offset ) ) };
|
||||
if( railphase >= 0.0 ) {
|
||||
if( auto const railphase { outer.RailPhase( Axle.offset - std::copysign( 0.5 * fAxleDist, Axle.offset ) ) }; railphase >= 0.0 ) {
|
||||
// the rails under the axle, which aren't always those under the track the vehicle is on
|
||||
auto const passed { Axle.atjoints && std::abs( railphase - Axle.distance ) > 0.5 * outer.GetTrack()->fSoundDistance };
|
||||
Axle.distance = railphase;
|
||||
|
||||
Reference in New Issue
Block a user