mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
reformat: remove redundant parentheses
This commit is contained in:
@@ -68,14 +68,14 @@ float cMoon::getIntensity() {
|
||||
// which roughly matches how much sunlight is reflected by the moon
|
||||
// We alter the intensity further based on current phase of the moon
|
||||
auto const phasefactor = 1.0f - std::abs( m_phase - 29.53f * 0.5f ) / ( 29.53f * 0.5f );
|
||||
return static_cast<float>( ( m_body.etr/ 1399.0 ) * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value
|
||||
return static_cast<float>( m_body.etr / 1399.0 * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value
|
||||
}
|
||||
|
||||
void cMoon::setLocation( float const Longitude, float const Latitude ) {
|
||||
|
||||
// convert fraction from geographical base of 6o minutes
|
||||
m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0;
|
||||
m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ;
|
||||
m_observer.longitude = (int)Longitude + (Longitude - (int)Longitude) * 100.0 / 60.0;
|
||||
m_observer.latitude = (int)Latitude + (Latitude - (int)Latitude) * 100.0 / 60.0 ;
|
||||
}
|
||||
|
||||
// sets current time, overriding one acquired from the system clock
|
||||
@@ -120,7 +120,7 @@ void cMoon::move() {
|
||||
+ 275 * localtime.wMonth / 9
|
||||
+ localtime.wDay
|
||||
- 730530
|
||||
+ ( localut / 24.0 );
|
||||
+ localut / 24.0;
|
||||
|
||||
// Universal Coordinated (Greenwich standard) time
|
||||
m_observer.utime = localut - m_observer.timezone;
|
||||
@@ -254,7 +254,7 @@ void cMoon::refract() {
|
||||
else
|
||||
refcor = -20.774 / tanelev;
|
||||
|
||||
prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) );
|
||||
prestemp = m_observer.press * 283.0 / ( 1013.0 * ( 273.0 + m_observer.temp ) );
|
||||
refcor *= prestemp / 3600.0;
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ void cMoon::irradiance() {
|
||||
void
|
||||
cMoon::phase() {
|
||||
SYSTEMTIME lt = simulation::Time.data();
|
||||
if ((lt.wMonth==5)&&(lt.wDay==4)) //May the forth be with you!
|
||||
if (lt.wMonth == 5 && lt.wDay == 4) //May the forth be with you!
|
||||
m_phase = 50;
|
||||
else {
|
||||
// calculate moon's age in days from new moon
|
||||
|
||||
@@ -17,8 +17,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
void TSky::Init() {
|
||||
|
||||
if( ( Global.asSky != "1" )
|
||||
&& ( Global.asSky != "0" ) ) {
|
||||
if (Global.asSky != "1"
|
||||
&& Global.asSky != "0" ) {
|
||||
|
||||
mdCloud = TModelsManager::GetModel( Global.asSky );
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ void CSkyDome::Generate() {
|
||||
|
||||
for( int i = 0; i <= latitudes; ++i ) {
|
||||
|
||||
float const latitude = M_PI * ( -0.5f + (float)( i ) / latitudes / 2 ); // half-sphere only
|
||||
float const latitude = M_PI * ( -0.5f + (float)i / 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 = 2.0 * M_PI * (float)( j ) / longitudes;
|
||||
float const longitude = 2.0 * M_PI * (float)j / longitudes;
|
||||
float const x = std::cos( longitude );
|
||||
float const y = std::sin( longitude );
|
||||
/*
|
||||
@@ -89,7 +89,7 @@ void CSkyDome::Generate() {
|
||||
m_vertices.emplace_back( glm::vec3( -x * zr, -z - offset, -y * zr ) * radius );
|
||||
m_colours.emplace_back( glm::vec3( 0.75f, 0.75f, 0.75f ) ); // placeholder
|
||||
|
||||
if( (i == 0) || (j == 0) ) {
|
||||
if( i == 0 || j == 0 ) {
|
||||
// initial edge of the dome, don't start indices yet
|
||||
++index;
|
||||
}
|
||||
@@ -188,8 +188,8 @@ void CSkyDome::RebuildColors() {
|
||||
auto gammacorrection = glm::mix( glm::vec3( 1.0f ), glm::vec3( 0.45f ), twilightfactor );
|
||||
|
||||
// get zenith luminance
|
||||
float const chi = ( (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;
|
||||
float const chi = ( 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
|
||||
float zenithx = GetZenith( m_zenithxmatrix, m_thetasun, m_turbidity );
|
||||
@@ -243,8 +243,8 @@ void CSkyDome::RebuildColors() {
|
||||
float const yover = std::max( 0.01f, zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f );
|
||||
|
||||
float const Y = std::lerp( yclear, yover, m_overcast );
|
||||
float const X = (x / y) * Y;
|
||||
float const Z = ((1.0f - x - y) / y) * Y;
|
||||
float const X = x / y * Y;
|
||||
float const Z = (1.0f - x - y) / y * Y;
|
||||
|
||||
colorconverter = glm::vec3( X, Y, Z );
|
||||
color = colors::XYZtoRGB( colorconverter );
|
||||
@@ -263,13 +263,13 @@ void CSkyDome::RebuildColors() {
|
||||
colorconverter.y = std::clamp( colorconverter.y * Global.m_skysaturationcorrection, 0.0f, 1.0f );
|
||||
// desaturate sky colour, based on overcast level
|
||||
if( colorconverter.y > 0.0f ) {
|
||||
colorconverter.y *= ( 1.0f - 0.5f * m_overcast );
|
||||
colorconverter.y *= 1.0f - 0.5f * m_overcast;
|
||||
}
|
||||
|
||||
// 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 = 90.0f - m_thetasun * ( 180.0f / M_PI );
|
||||
auto const sunbasedphase = std::clamp( (1.0f / 15.0f) * ( degreesabovehorizon - 10.0f ), 0.0f, 1.0f );
|
||||
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 );
|
||||
// this height-based factor is reduced the farther the sun is up in the sky
|
||||
@@ -282,8 +282,8 @@ void CSkyDome::RebuildColors() {
|
||||
|
||||
// crude correction for the times where the model breaks (late night)
|
||||
// TODO: use proper night sky calculation for these times instead
|
||||
if( ( color.x <= 0.05f )
|
||||
&& ( color.y <= 0.05f ) ) {
|
||||
if( color.x <= 0.05f
|
||||
&& color.y <= 0.05f ) {
|
||||
// darken the sky as the sun goes deeper below the horizon
|
||||
// 15:50:75 is picture-based night sky colour. it may not be accurate but looks 'right enough'
|
||||
color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f );
|
||||
@@ -291,7 +291,7 @@ void CSkyDome::RebuildColors() {
|
||||
color.y = 0.65f * color.z;
|
||||
}
|
||||
// simple gradient, darkening towards the top
|
||||
color *= std::clamp( ( 1.0f - vertex.y * 0.75f ), 0.0f, 1.f );
|
||||
color *= std::clamp( 1.0f - vertex.y * 0.75f, 0.0f, 1.f );
|
||||
|
||||
float const horizonboost = 1.5f + m_overcast;
|
||||
float const horizonbandwidth = 0.2f; // boost tapers to 0 by ~11.5 degrees elevation
|
||||
@@ -302,7 +302,7 @@ void CSkyDome::RebuildColors() {
|
||||
//color *= ( 0.25f - vertex.y );
|
||||
m_colours[ i ] = color;
|
||||
averagecolor += color;
|
||||
if( ( m_vertices.size() - i ) <= ( m_tesselation * 10 + 10 ) ) {
|
||||
if( m_vertices.size() - i <= m_tesselation * 10 + 10 ) {
|
||||
// calculate horizon colour from the bottom band of tris
|
||||
averagehorizoncolor += color;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ float cSun::getIntensity() {
|
||||
void cSun::setLocation( float const Longitude, float const Latitude ) {
|
||||
|
||||
// convert fraction from geographical base of 6o minutes
|
||||
m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0;
|
||||
m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ;
|
||||
m_observer.longitude = (int)Longitude + (Longitude - (int)Longitude) * 100.0 / 60.0;
|
||||
m_observer.latitude = (int)Latitude + (Latitude - (int)Latitude) * 100.0 / 60.0 ;
|
||||
}
|
||||
|
||||
// sets current time, overriding one acquired from the system clock
|
||||
@@ -125,7 +125,7 @@ void cSun::move() {
|
||||
+ 275 * localtime.wMonth / 9
|
||||
+ localtime.wDay
|
||||
- 730530
|
||||
+ ( localut / 24.0 );
|
||||
+ localut / 24.0;
|
||||
|
||||
// Universal Coordinated (Greenwich standard) time
|
||||
m_observer.utime = localut - m_observer.timezone;
|
||||
@@ -228,7 +228,7 @@ void cSun::refract() {
|
||||
else
|
||||
refcor = -20.774 / tanelev;
|
||||
|
||||
prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) );
|
||||
prestemp = m_observer.press * 283.0 / ( 1013.0 * ( 273.0 + m_observer.temp ) );
|
||||
refcor *= prestemp / 3600.0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user