Skip to content

Commit

Permalink
moved m_waves_height in more proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
tritonas00 committed Jun 21, 2021
1 parent c899aac commit 948207c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/main/gfx/Water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ float Water::CalcWavesHeight(Vector3 pos)
{
// calculate the amplitude that this wave will have. wavetrains[i].amplitude is read from the config
// upper limit: prevent too big waves by setting an upper limit
float amp = std::min(m_wavetrain_defs[i].amplitude * (waveheight + m_waves_height), m_wavetrain_defs[i].maxheight);
float amp = std::min(m_wavetrain_defs[i].amplitude * waveheight, m_wavetrain_defs[i].maxheight);
// now the main thing:
// calculate the sinus with the values of the config file and add it to the result
result += amp * sin(Math::TWO_PI * ((time_sec * m_wavetrain_defs[i].wavespeed + m_wavetrain_defs[i].dir_sin * pos.x + m_wavetrain_defs[i].dir_cos * pos.z) / m_wavetrain_defs[i].wavelength));
Expand Down Expand Up @@ -652,6 +652,7 @@ float Water::GetWaveHeight(Vector3 pos)
// (mapsize.z * m_waterplane_mesh_scale) / 2 = terrain height / 2
// calculate distance to the center of the terrain and divide by 3.000.000
float waveheight = (pos - Vector3((m_map_size.x * m_waterplane_mesh_scale) * 0.5, m_water_height, (m_map_size.z * m_waterplane_mesh_scale) * 0.5)).squaredLength() / 3000000.0;
waveheight += m_waves_height;

return waveheight;
}
Expand Down

0 comments on commit 948207c

Please # to comment.