17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 11:32:11 +01:00

refactor(sonar): clean up issues reported on PR 209

- remove locals left unused after the dead-store cleanup (cpp:S1481, cpp:S1854)
- unnamed unused parameter (cpp:S1172)
- single-use declarations moved into if init-statements (cpp:S6004)
- auto for casted initialisers (cpp:S5827)
- const references and pointers where nothing is modified (cpp:S5350)
- rename structured bindings shadowed by inner declarations (cpp:S1117)
This commit is contained in:
jerrrrycho
2026-10-11 01:41:01 +02:00
parent 555e5f0aab
commit 2b74c6dba7
17 changed files with 37 additions and 50 deletions

View File

@@ -156,7 +156,6 @@ void cMoon::move() {
double const yeclip = m_body.distance * ( std::sin( degtorad * longascnode ) * std::cos( vpluswinrad ) + std::cos( degtorad * longascnode ) * std::sin( vpluswinrad ) * std::cos( degtorad * inclination ) );
double const zeclip = m_body.distance * std::sin( vpluswinrad ) * std::sin( degtorad * inclination );
// ecliptic coordinates
double ecliplat = radtodeg * std::atan2( zeclip, std::sqrt( xeclip*xeclip + yeclip*yeclip ) );
m_body.eclong = clamp_circular( radtodeg * std::atan2( yeclip, xeclip ) );
// distance
m_body.distance = std::sqrt( xeclip*xeclip + yeclip*yeclip + zeclip*zeclip );
@@ -172,8 +171,6 @@ void cMoon::move() {
m_body.mnlong = clamp_circular( longascnode + perigeearg + m_body.mnanom );
// Moon's mean elongation: D = Lm - Ls
double const mnelong = clamp_circular( m_body.mnlong - sunmnlong );
// Moon's argument of latitude: F = Lm - N
double const arglat = clamp_circular( m_body.mnlong - longascnode );
// longitude perturbations
double const pertevection = -1.274 * std::sin( degtorad * ( m_body.mnanom - 2.0 * mnelong ) ); // Evection
double const pertvariation = +0.658 * std::sin( degtorad * ( 2.0 * mnelong ) ); // Variation
@@ -303,7 +300,7 @@ cMoon::phase() {
float
cMoon::normalize( const float Value ) const {
float value = static_cast<float>(Value - floor( Value ));
auto value = static_cast<float>(Value - floor( Value ));
if( value < 0.f ) { ++value; }
return value;

View File

@@ -70,13 +70,13 @@ void CSkyDome::Generate() {
for( int i = 0; i <= latitudes; ++i ) {
float const latitude = static_cast<float>(M_PI * ( -0.5f + (float)i / static_cast<float>(latitudes) / 2 )); // half-sphere only
auto const latitude = static_cast<float>(M_PI * ( -0.5f + (float)i / static_cast<float>(latitudes) / 2 )); // half-sphere only
float const z = std::sin( latitude );
float const zr = std::cos( latitude );
for( int j = 0; j <= longitudes; ++j ) {
float const longitude = static_cast<float>(2.0 * M_PI * (float)j / longitudes);
auto const longitude = static_cast<float>(2.0 * M_PI * (float)j / longitudes);
float const x = std::cos( longitude );
float const y = std::sin( longitude );
/*
@@ -168,7 +168,7 @@ float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, cons
float CSkyDome::PerezFunctionO1( float const Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) const {
const float val = static_cast<float>(( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) *
const auto val = static_cast<float>(( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) *
( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Thetasun ) + Perezcoeffs[ 4 ] * std::pow( std::cos( Thetasun ), 2 ) ));
return Zenithval / val;
@@ -187,7 +187,7 @@ void CSkyDome::RebuildColors() {
auto gammacorrection = glm::mix( glm::vec3( 1.0f ), glm::vec3( 0.45f ), twilightfactor );
// get zenith luminance
float const chi = static_cast<float>(( 4.0f / 9.0f - m_turbidity / 120.0f ) * ( M_PI - 2.0f * m_thetasun ));
auto const chi = static_cast<float>(( 4.0f / 9.0f - m_turbidity / 120.0f ) * ( M_PI - 2.0f * m_thetasun ));
float zenithluminance = ( 4.0453f * m_turbidity - 4.9710f ) * std::tan( chi ) - 0.2155f * m_turbidity + 2.4192f;
// get x / y zenith
@@ -238,7 +238,7 @@ void CSkyDome::RebuildColors() {
// = 1.0f / cosf( arccos( vertex.y ) );
// = 1.0f / vertex.y;
float const icostheta = 1.0f / vertex.y;
float const cosgamma2 = static_cast<float>(std::pow( std::cos( gamma ), 2 ));
auto const cosgamma2 = static_cast<float>(std::pow( std::cos( gamma ), 2 ));
// Compute x,y values
float const x = PerezFunctionO2( perezx.data(), icostheta, gamma, cosgamma2, zenithx );
@@ -274,7 +274,7 @@ void CSkyDome::RebuildColors() {
// override the hue, based on sun height above the horizon. crude way to deal with model shortcomings
// correction begins when the sun is higher than 10 degrees above the horizon, and fully in effect at 10+15 degrees
float const degreesabovehorizon = static_cast<float>(90.0f - m_thetasun * ( 180.0f / M_PI ));
auto const degreesabovehorizon = static_cast<float>(90.0f - m_thetasun * ( 180.0f / M_PI ));
auto const sunbasedphase = std::clamp( 1.0f / 15.0f * ( degreesabovehorizon - 10.0f ), 0.0f, 1.0f );
// correction is applied in linear manner from the bottom, becomes fully in effect for vertices with y = 0.50
auto const heightbasedphase = std::clamp( vertex.y * 2.0f, 0.0f, 1.0f );