Skip to content

Commit

Permalink
run clang-format on new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Pain committed Jan 18, 2024
1 parent 80a4740 commit bc16cca
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/galaxy/SystemBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,22 @@ bool SystemBody::IsScoopable() const
// all input units are in km
double SystemBody::ComputeDensity(const double radius, const double atmosphereHeight, const double h, const double baricStep) const
{
int numSamples = 16;
double totalHeight = radius + atmosphereHeight;
double minHeight = radius + h;
double tmax = sqrt(totalHeight*totalHeight - minHeight*minHeight); // maximum t
double tmin = -tmax;
double length = tmax - tmin;
double step = length / numSamples;

double density = 0.0;
for (int i = 0; i < numSamples; ++i) {
double t = tmin + step * (i + 0.5);
double h = sqrt(minHeight*minHeight + t*t) - radius;
density += step * exp(-h / baricStep);
}

return density;
int numSamples = 16;
double totalHeight = radius + atmosphereHeight;
double minHeight = radius + h;
double tmax = sqrt(totalHeight * totalHeight - minHeight * minHeight); // maximum t
double tmin = -tmax;
double length = tmax - tmin;
double step = length / numSamples;

double density = 0.0;
for (int i = 0; i < numSamples; ++i) {
double t = tmin + step * (i + 0.5);
double h = sqrt(minHeight * minHeight + t * t) - radius;
density += step * exp(-h / baricStep);
}

return density;
}

// these coefficients are to be passed into shaders, meant to accelerate scattering computation per-pixel
Expand All @@ -302,7 +302,7 @@ vector3f SystemBody::GetCoefficients(const double radius, const double atmHeight

// compute c - erf coefficient, which adjusts slope of erf near t=0 to match actual in-scattering
float erf1_minus_erf0 = 0.421463;
float sHeight = sqrt(radius*radius + 1.f) - radius;
float sHeight = sqrt(radius * radius + 1.f) - radius;
float c1 = exp(-sHeight / baricStep);
float c2 = k * erf1_minus_erf0;
c = c1 / c2;
Expand Down Expand Up @@ -370,8 +370,8 @@ AtmosphereParameters SystemBody::CalcAtmosphereParams() const
const float radiusPlanet_in_km = radiusPlanet_in_m / 1000;
const float atmosHeight_in_km = radiusPlanet_in_km * (params.atmosRadius - 1);
params.rayleighCoefficients = GetCoefficients(radiusPlanet_in_km, atmosHeight_in_km, atmosScaleHeight);
params.mieCoefficients = GetCoefficients(radiusPlanet_in_km, atmosHeight_in_km, atmosScaleHeight / 6.66); // 7994 / 1200 = 6.61
params.baricStep = vector2f(atmosScaleHeight, atmosScaleHeight / 6.66);
params.mieCoefficients = GetCoefficients(radiusPlanet_in_km, atmosHeight_in_km, atmosScaleHeight / 6.66); // 7994 / 1200 = 6.61
params.baricStep = vector2f(atmosScaleHeight, atmosScaleHeight / 6.66);

return params;
}
Expand Down

0 comments on commit bc16cca

Please sign in to comment.