Ticket #1743: WaterFix.patch

File WaterFix.patch, 24.7 KB (added by wraitii, 10 years ago)
  • binaries/data/mods/public/maps/random/rmgen/environment.js

     
    5656    WATER_LEVEL_CHANGED = true;
    5757}
    5858
    59 // Set water shininess
    60 function setWaterShininess(s)
    61 {
    62     g_Environment.Water.WaterBody.Shininess = s;
    63 }
    64 
    6559// Set water waviness
    6660function setWaterWaviness(w)
    6761{
  • binaries/data/mods/public/maps/random/rmgen/mapgen.js

     
    1515            Type: "default",
    1616            Colour: {r: 0.3, g: 0.35, b: 0.7, a: 0},
    1717            Height: 5,
    18             Shininess: 150,
    1918            Waviness: 8,
    2019            Murkiness: 0.45,
    2120            Tint: {r: 0.28, g: 0.3, b: 0.59, a: 0},
  • binaries/data/mods/public/shaders/glsl/model_water.fs

     
    3434uniform vec3 sunDir;
    3535uniform vec3 cameraPos;
    3636
    37 
    38 uniform float shininess;
    3937uniform float specularStrength;
    4038uniform float waviness;
    4139uniform vec3 waterTint;
     
    124122    refrColor = (0.5 + 0.5*ndotl) * mix(vec3(0.3), sunColor * waterTint,
    125123                    murkiness * clamp(waterDepth / fullDepth, 0.0, 1.0)); // Murkiness and tint at this pixel (tweaked based on lighting and depth)
    126124   
    127     specular = pow(max(0.0, ndoth), shininess) * sunColor * specularStrength;
     125    specular = pow(max(0.0, ndoth), 150.0f) * sunColor * specularStrength;
    128126
    129127    losMod = texture2D(losTex, v_los).a;
    130128
  • binaries/data/mods/public/shaders/glsl/water_high.fs

     
    55uniform vec3 sunColor;
    66uniform vec3 cameraPos;
    77uniform sampler2D losMap;
    8 uniform float shininess;        // Blinn-Phong specular strength
    98uniform float specularStrength; // Scaling for specular reflection (specular color is (this,this,this))
    109uniform float waviness;         // "Wildness" of the reflections and refractions; choose based on texture
    1110uniform vec3 tint;              // Tint for refraction (used to simulate particles in water)
     
    102101        vec2 beachOrientation = heightmapval.rg;
    103102        float distToShore = heightmapval.b;
    104103    #endif
    105    
    106    
     104       
    107105    vec3 n, l, h, v;        // Normal, light vector, half-vector and view vector (vector to eye)
    108106    float ndotl, ndoth, ndotv;
    109107    float fresnel;
     
    185183        // texture is not rotated, moves twice faster in the opposite direction, translated.
    186184        vec2 foam2RC = gl_TexCoord[0].st*1.8 + vec2(time*-0.019,time*-0.012) - 0.012*n.xz + vec2(0.4,0.2);
    187185       
    188         vec2 WaveRocking = cos(time*1.2566) * beachOrientation * clamp(1.0 - distToShore,0.1,1.0)/3.0;
     186        vec2 WaveRocking = cos(time*1.2566) * beachOrientation * clamp(1.0 - distToShore*0.8,0.1,1.0)/3.0;
    189187        vec4 foam1 = texture2D(Foam, foam1RC + vec2(-WaveRocking.t,WaveRocking.s));
    190188        vec4 foam2 = foam1.r*texture2D(Foam, foam2RC + WaveRocking);
    191189       
  • source/graphics/MapReader.cpp

     
    583583    EL(type);
    584584    EL(colour);
    585585    EL(height);
    586     EL(shininess);
     586    EL(shininess);  // for compatibility
    587587    EL(waviness);
    588588    EL(murkiness);
    589589    EL(tint);
     
    718718                    if (!m_MapReader.pWaterMan)
    719719                        continue;
    720720
     721                    float this_avoids_a_warning_about_unused_variables = 0;
     722                   
    721723                    if (element_name == el_type)
    722724                    {
    723725                        // TODO: implement this, when WaterManager supports it
     
    740742                    } \
    741743
    742744                    READ_COLOUR(el_colour, m_MapReader.pWaterMan->m_WaterColor)
    743                     READ_FLOAT(el_shininess, m_MapReader.pWaterMan->m_Shininess)
     745                    READ_FLOAT(el_shininess, this_avoids_a_warning_about_unused_variables)
    744746                    READ_FLOAT(el_waviness, m_MapReader.pWaterMan->m_Waviness)
    745747                    READ_FLOAT(el_murkiness, m_MapReader.pWaterMan->m_Murkiness)
    746748                    READ_COLOUR(el_tint, m_MapReader.pWaterMan->m_WaterTint)
     
    14611463        // TODO: Water type not implemented
    14621464
    14631465        GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Colour, pWaterMan->m_WaterColor)
    1464         GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Shininess, pWaterMan->m_Shininess)
    14651466        GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Waviness, pWaterMan->m_Waviness)
    14661467        GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Murkiness, pWaterMan->m_Murkiness)
    14671468        GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Tint, pWaterMan->m_WaterTint)
  • source/graphics/MapWriter.cpp

     
    256256                    CmpPtr<ICmpWaterManager> cmpWaterManager(*pSimulation2, SYSTEM_ENTITY);
    257257                    ENSURE(cmpWaterManager);
    258258                    XML_Setting("Height", cmpWaterManager->GetExactWaterLevel(0, 0));
    259                     XML_Setting("Shininess", pWaterMan->m_Shininess);
    260259                    XML_Setting("Waviness", pWaterMan->m_Waviness);
    261260                    XML_Setting("Murkiness", pWaterMan->m_Murkiness);
    262261                    {
  • source/ps/CStrInternStatic.h

     
    126126X(shadowScale)
    127127X(shadowTex)
    128128X(shadowTransform)
    129 X(shininess)
    130129X(skinBlendMatrices)
    131130X2(skinBlendMatrices_0, "skinBlendMatrices[0]")
    132131X(skyCube)
  • source/renderer/TerrainRenderer.cpp

     
    658658            defines.Add(str_USE_NORMALS, str_1);
    659659        if (WaterMgr->m_WaterRealDepth)
    660660            defines.Add(str_USE_REAL_DEPTH, str_1);
    661         if (WaterMgr->m_WaterFoam && !g_AtlasGameLoop->running)
     661        if (WaterMgr->m_WaterFoam)
    662662            defines.Add(str_USE_FOAM, str_1);
    663663        if (WaterMgr->m_WaterCoastalWaves && !g_AtlasGameLoop->running)
    664664            defines.Add(str_USE_WAVES, str_1);
     
    747747    GLuint FramebufferName = 0;
    748748
    749749    // rendering waves to a framebuffer
    750     if (WaterMgr->m_WaterCoastalWaves && WaterMgr->m_VBWaves && !g_AtlasGameLoop->running)
     750    // TODO: reactivate this with something that looks good.
     751    if (false && WaterMgr->m_WaterCoastalWaves && WaterMgr->m_VBWaves && !g_AtlasGameLoop->running)
    751752    {
    752753        // Save the post-processing framebuffer.
    753754        GLint fbo;
     
    840841    m->fancyWaterShader->Uniform(str_sunDir, lightEnv.GetSunDir());
    841842    m->fancyWaterShader->Uniform(str_sunColor, lightEnv.m_SunColor.X);
    842843    m->fancyWaterShader->Uniform(str_color, WaterMgr->m_WaterColor);
    843     m->fancyWaterShader->Uniform(str_shininess, WaterMgr->m_Shininess);
    844844    m->fancyWaterShader->Uniform(str_specularStrength, WaterMgr->m_SpecularStrength);
    845845    m->fancyWaterShader->Uniform(str_waviness, WaterMgr->m_Waviness);
    846846    m->fancyWaterShader->Uniform(str_murkiness, WaterMgr->m_Murkiness);
  • source/renderer/WaterManager.cpp

     
    7070    m_ReflectionTextureSize = 0;
    7171    m_RefractionTextureSize = 0;
    7272    m_WaterTexTimer = 0.0;
    73     m_Shininess = 150.0f;
    7473    m_SpecularStrength = 0.6f;
    7574    m_Waviness = 8.0f;
    7675    m_ReflectionTint = CColor(0.28f, 0.3f, 0.59f, 1.0f);
     
    268267    m_WaterHeight = cmpWaterManager->GetExactWaterLevel(0,0);
    269268   
    270269    // Get the square we want to work on.
    271     i32 Xstart = clamp(m_updatei0, 0, (i32)m_MapSize-1);
    272     i32 Xend = clamp(m_updatei1, 0, (i32)m_MapSize-1);
    273     i32 Zstart = clamp(m_updatej0, 0, (i32)m_MapSize-1);
    274     i32 Zend = clamp(m_updatej1, 0, (i32)m_MapSize-1);
     270    ssize_t Xstart = m_updatei0 < 0 ? 0 : (m_updatei0 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : m_updatei0);
     271    ssize_t Xend = m_updatei1 < 0 ? 0 : (m_updatei1 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : m_updatei1);
     272    ssize_t Zstart = m_updatej0 < 0 ? 0 : (m_updatej0 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : m_updatej0);
     273    ssize_t Zend = m_updatej1 < 0 ? 0 : (m_updatej1 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : m_updatej1);
    275274
     275    if (!(Xend > Xstart && Zend > Zstart))
     276    {
     277        // it corrupts every now and then for reasons I don't get.
     278        std::cout << m_updatei0 << " , " << Xstart << std::endl;
     279        std::cout << m_MapSize << "," << (ssize_t)m_MapSize << std::endl;
     280    }
     281   
    276282    if (m_WaveX == NULL)
    277283    {
    278284        m_WaveX = new float[m_MapSize*m_MapSize];
     
    291297    // this might be updated to actually cache in the terrain manager but that's not for now.
    292298    CVector3D* normals = new CVector3D[m_MapSize*m_MapSize];
    293299
    294    
    295300    // taken out of the bottom loop, blurs the normal map
    296301    // To remove if below is reactivated
    297302    ssize_t blurZstart = Zstart-4 < 0 ? 0 : Zstart - 4;
    298303    ssize_t blurZend = Zend+4 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : Zend + 4;
    299304    ssize_t blurXstart = Xstart-4 < 0 ? 0 : Xstart - 4;
    300305    ssize_t blurXend = Xend+4 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : Xend + 4;
     306   
    301307    for (ssize_t j = blurZstart; j < blurZend; ++j)
    302308    {
    303309        for (ssize_t i = blurXstart; i < blurXend; ++i)
     
    339345    {
    340346        for (ssize_t i = Xstart; i < Xend; ++i)
    341347        {
     348            ssize_t index = j*m_MapSize + i;
    342349            if (circular && (i-halfSize)*(i-halfSize)+(j-halfSize)*(j-halfSize) > mSize)
    343350            {
    344                 m_WaveX[j*m_MapSize + i] = 0.0f;
    345                 m_WaveZ[j*m_MapSize + i] = 0.0f;
    346                 m_DistanceToShore[j*m_MapSize + i] = 100;
    347                 m_FoamFactor[j*m_MapSize + i] = 0.0f;
     351                m_WaveX[index] = 0.0f;
     352                m_WaveZ[index] = 0.0f;
     353                m_DistanceToShore[index] = 100;
     354                m_FoamFactor[index] = 0.0f;
    348355                continue;
    349356            }
    350             float depth = m_WaterHeight - heightmap[j*m_MapSize + i]*HEIGHT_SCALE;
    351             int distanceToShore = 10000;
     357            float depth = m_WaterHeight - heightmap[index]*HEIGHT_SCALE;
     358            float distanceToShore = 10000;
    352359           
    353360            // calculation of the distance to the shore.
    354             // TODO: this is fairly dumb, though it returns a good result
    355             // Could be sped up a fair bit.
    356             if (depth >= 0)
     361            if (i > 0 && i < (ssize_t)m_MapSize-1 && j > 0 && j < (ssize_t)m_MapSize-1)
    357362            {
    358                 // check in the square around.
    359                 for (int yy = -5; yy <= 5; ++yy)
     363                // search a 5x5 array with us in the center (do not search me)
     364                // much faster since we spiral search and can just stop once we've found the shore.
     365                // also everything is precomputed and we get exact results instead.
     366                int offset[24] = { -1,1,-m_MapSize,+m_MapSize, -1-m_MapSize,+1-m_MapSize,-1+m_MapSize,1+m_MapSize,
     367                    -2,2,-2*m_MapSize,2*m_MapSize,-2-m_MapSize,-2+m_MapSize,2-m_MapSize,2+m_MapSize,
     368                    -1-2*m_MapSize,+1-2*m_MapSize,-1+2*m_MapSize,1+2*m_MapSize,
     369                    -2-2*m_MapSize,2+2*m_MapSize,-2+2*m_MapSize,2-2*m_MapSize };
     370                float dist[24] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.414f, 1.414f, 1.414f, 1.414f,
     371                    2.0f, 2.0f, 2.0f, 2.0f, 2.236f, 2.236f, 2.236f, 2.236f,
     372                    2.236f, 2.236f, 2.236f, 2.236f,
     373                    2.828f, 2.828f, 2.828f, 2.828f };
     374               
     375                int max = 8;
     376                if (i > 1 && i < (ssize_t)m_MapSize-2 && j > 1 && j < (ssize_t)m_MapSize-2)
     377                    max = 24;
     378               
     379                for(int lookupI = 0; lookupI < max;++lookupI)
    360380                {
    361                     for (int xx = -5; xx <= 5; ++xx)
    362                     {
    363                         if (i+xx >= 0 && i + xx < (long)m_MapSize)
    364                             if (j + yy >= 0 && j + yy < (long)m_MapSize)
    365                             {
    366                                 float hereDepth = m_WaterHeight - heightmap[(j+yy)*m_MapSize + (i+xx)]*HEIGHT_SCALE;
    367                                 if (hereDepth < 0 && xx*xx + yy*yy < distanceToShore)
    368                                     distanceToShore = xx*xx + yy*yy;
    369                             }
    370                     }
     381                    float hereDepth = m_WaterHeight - heightmap[index+offset[lookupI]]*HEIGHT_SCALE;
     382                    distanceToShore = hereDepth <= 0 && depth >= 0 ? dist[lookupI] : (depth < 0 ? 1 : distanceToShore);
     383                    if (distanceToShore != 10000)
     384                        break;
    371385                }
    372                 // refine the calculation if we're close enough
    373                 if (distanceToShore < 9)
    374                 {
    375                     for (float yy = -2.5f; yy <= 2.5f; ++yy)
     386            } else {
     387                // revert to for and if-based because I can't be bothered to special case all that.
     388                for (int xx = -1; xx <= 1;++xx)
     389                    for (int yy = -1; yy <= 1;++yy)
    376390                    {
    377                         for (float xx = -2.5f; xx <= 2.5f; ++xx)
     391                        if (i+xx >= 0 && i+xx < (ssize_t)m_MapSize && j+yy >= 0 && j+yy < (ssize_t)m_MapSize)
    378392                        {
    379                             float hereDepth = m_WaterHeight - terrain->GetExactGroundLevel( (i+xx)*4, (j+yy)*4 );
    380                             if (hereDepth < 0 && xx*xx + yy*yy < distanceToShore)
    381                                 distanceToShore = xx*xx + yy*yy;
     393                            float hereDepth = m_WaterHeight - heightmap[index+xx+yy*m_MapSize]*HEIGHT_SCALE;
     394                            distanceToShore = (hereDepth < 0 && sqrt((double)xx*xx+yy*yy) < distanceToShore) ? sqrt((double)xx*xx+yy*yy) : distanceToShore;
    382395                        }
    383396                    }
    384                 }
    385397            }
    386             else
    387             {
    388                 for (int yy = -2; yy <= 2; ++yy)
    389                 {
    390                     for (int xx = -2; xx <= 2; ++xx)
    391                     {
    392                         float hereDepth = m_WaterHeight - terrain->GetVertexGroundLevel(i+xx, j+yy);
    393                         if (hereDepth > 0)
    394                             distanceToShore = 0;
    395                     }
    396                 }
    397                
    398             }
     398
    399399            // speedup with default values for land squares
    400400            if (distanceToShore == 10000)
    401401            {
    402                 m_WaveX[j*m_MapSize + i] = 0.0f;
    403                 m_WaveZ[j*m_MapSize + i] = 0.0f;
    404                 m_DistanceToShore[j*m_MapSize + i] = 100;
    405                 m_FoamFactor[j*m_MapSize + i] = 0.0f;
     402                m_WaveX[index] = 0.0f;
     403                m_WaveZ[index] = 0.0f;
     404                m_DistanceToShore[index] = 100.0f;
     405                m_FoamFactor[index] = 0.0f;
    406406                continue;
    407407            }
     408                       
    408409            // We'll compute the normals and the "water raise", to know about foam
    409410            // Normals are a pretty good calculation but it's slow since we normalize so much.
    410411            CVector3D normal;
    411412            int waterRaise = 0;
    412             for (int yy = -4; yy <= 4; yy += 2)
     413            for (int yy = -3; yy <= 3; yy += 2)
    413414            {
    414                 for (int xx = -4; xx <= 4; xx += 2) // every 2 tile is good enough.
     415                for (int xx = -3; xx <= 3; xx += 2) // every 2 tile is good enough.
    415416                {
    416417                    if (j+yy < (long)m_MapSize && i+xx < (long)m_MapSize && i+xx >= 0 && j+yy >= 0)
    417418                        normal += normals[(j+yy)*m_MapSize + (i+xx)];
    418                     if (terrain->GetVertexGroundLevel(i+xx,j+yy) < heightmap[j*m_MapSize + i]*HEIGHT_SCALE)
    419                         waterRaise += heightmap[j*m_MapSize + i]*HEIGHT_SCALE - terrain->GetVertexGroundLevel(i+xx,j+yy);
     419                    waterRaise += heightmap[index]*HEIGHT_SCALE - terrain->GetVertexGroundLevel(i+xx,j+yy) > 0 ? heightmap[index]*HEIGHT_SCALE - terrain->GetVertexGroundLevel(i+xx,j+yy) : 0.0f;
    420420                }
    421421            }
    422422            // normalizes the terrain info to avoid foam moving at too different speeds.
    423             normal *= 0.012345679f;
     423            normal *= 0.08f;
    424424            normal[1] = 0.1f;
    425425            normal = normal.Normalized();
    426426
    427             m_WaveX[j*m_MapSize + i] = normal[0];
    428             m_WaveZ[j*m_MapSize + i] = normal[2];
     427            m_WaveX[index] = normal[0];
     428            m_WaveZ[index] = normal[2];
    429429            // distance is /5.0 to be a [0,1] value.
    430430
    431             m_DistanceToShore[j*m_MapSize + i] = sqrtf(distanceToShore)/5.0f; // TODO: this can probably be cached as I'm integer here.
     431            m_DistanceToShore[index] = distanceToShore;
    432432
    433433            // computing the amount of foam I want
    434 
    435434            depth = clamp(depth,0.0f,10.0f);
    436435            float foamAmount = (waterRaise/255.0f) * (1.0f - depth/10.0f) /** (waveForceHQ[j*m_MapSize+i]/255.0f)*/ * (m_Waviness/8.0f);
    437             foamAmount += clamp(m_Waviness/2.0f - distanceToShore,0.0f,m_Waviness/2.0f)/(m_Waviness/2.0f) * clamp(m_Waviness/9.0f,0.3f,1.0f);
    438             foamAmount = foamAmount > 1.0f ? 1.0f: foamAmount;
     436            foamAmount += clamp(m_Waviness/2.0f,0.0f,m_Waviness/2.0f)/(m_Waviness/2.0f) * clamp(m_Waviness/9.0f,0.3f,1.0f);
     437            foamAmount *= (m_Waviness/4.0f - distanceToShore);
     438            foamAmount = foamAmount > 1.0f ? 1.0f: (foamAmount < 0.0f ? 0.0f : foamAmount);
    439439           
    440             m_FoamFactor[j*m_MapSize + i] = foamAmount;
     440            m_FoamFactor[index] = foamAmount;
    441441        }
    442442    }
    443443
    444444    delete[] normals;
    445445    //delete[] waveForceHQ;
    446446   
    447     // TODO: The rest should be cleaned up
    448    
     447    // TODO: reactivate this with something that looks good and is efficient.
     448/*
    449449    // okay let's create the waves squares. i'll divide the map in arbitrary squares
    450450    // For each of these squares, check if waves are needed.
    451451    // If yes, look for the best positionning (in order to have a nice blending with the shore)
     
    604604    // Construct indices buffer
    605605    m_VBWavesIndices = g_VBMan.Allocate(sizeof(GLushort), waves_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
    606606    m_VBWavesIndices->m_Owner->UpdateChunkVertices(m_VBWavesIndices, &waves_indices[0]);
     607 */
    607608}
    608609
    609610////////////////////////////////////////////////////////////////////////
  • source/renderer/WaterManager.h

     
    115115    // Shader parameters for fancy water
    116116    CColor m_WaterTint;
    117117    float m_RepeatPeriod;
    118     float m_Shininess;
    119118    float m_SpecularStrength;
    120119    float m_Waviness;
    121120    float m_Murkiness;
  • source/simulation2/components/CCmpWaterManager.cpp

     
    2626#include "renderer/WaterManager.h"
    2727#include "simulation2/MessageTypes.h"
    2828
     29#include "tools/atlas/GameInterface/GameLoop.h"
     30
    2931class CCmpWaterManager : public ICmpWaterManager
    3032{
    3133public:
     
    8183            case MT_TerrainChanged:
    8284            {
    8385                // Tell the renderer to redraw the map.
    84                 if (CRenderer::IsInitialised())
     86                // TODO: sometimes atlas glitches out.
     87                // I've added a button to recompute on demand but that's not extremely nice.
     88                if (CRenderer::IsInitialised() && !g_AtlasGameLoop->running)
    8589                {
    8690                    const CMessageTerrainChanged& msgData = static_cast<const CMessageTerrainChanged&> (msg);
    8791                    g_Renderer.GetWaterManager()->m_NeedInfoUpdate = true;
     
    97101        }
    98102    }
    99103
     104    virtual void RecomputeWaterData()
     105    {
     106        ssize_t mapSize = GetSimContext().GetTerrain().GetVerticesPerSide();
     107        g_Renderer.GetWaterManager()->m_NeedInfoUpdate = true;
     108        g_Renderer.GetWaterManager()->m_updatei0 = 0;
     109        g_Renderer.GetWaterManager()->m_updatej0 = 0;
     110        g_Renderer.GetWaterManager()->m_updatei1 = mapSize-1;
     111        g_Renderer.GetWaterManager()->m_updatej1 = mapSize-1;
     112
     113        // Tell the terrain it'll need to recompute its cached render data
     114        GetSimContext().GetTerrain().MakeDirty(RENDERDATA_UPDATE_VERTICES);
     115    }
     116
    100117    virtual void SetWaterLevel(entity_pos_t h)
    101118    {
    102119        m_WaterHeight = h;
  • source/simulation2/components/ICmpWaterManager.cpp

     
    2222#include "simulation2/system/InterfaceScripted.h"
    2323
    2424BEGIN_INTERFACE_WRAPPER(WaterManager)
     25DEFINE_INTERFACE_METHOD_0("RecomputeWaterData", void, ICmpWaterManager, RecomputeWaterData)
    2526DEFINE_INTERFACE_METHOD_1("SetWaterLevel", void, ICmpWaterManager, SetWaterLevel, entity_pos_t)
    2627DEFINE_INTERFACE_METHOD_2("GetWaterLevel", entity_pos_t, ICmpWaterManager, GetWaterLevel, entity_pos_t, entity_pos_t)
    2728END_INTERFACE_WRAPPER(WaterManager)
  • source/simulation2/components/ICmpWaterManager.h

     
    2626{
    2727public:
    2828    /**
     29     * Recompute all the water information (foam…)
     30     */
     31    virtual void RecomputeWaterData() = 0;
     32
     33    /**
    2934     * Set the height of the water level, as a constant value across the whole map.
    3035     */
    3136    virtual void SetWaterLevel(entity_pos_t h) = 0;
  • source/soundmanager/SoundManager.cpp

     
    138138                continue;
    139139
    140140            int pauseTime = 500;
    141             if ( g_SoundManager->InDistress() )
    142                 pauseTime = 50;
    143 
    144141            {
    145142                CScopeLock lock(m_WorkerMutex);
    146143       
     144                if ( g_SoundManager->InDistress() )
     145                    pauseTime = 50;
     146
    147147                ItemsList::iterator lstr = m_Items->begin();
    148148                ItemsList* nextItemList = new ItemsList;
    149149
    150 
    151150                while (lstr != m_Items->end()) {
    152151
    153152                    AL_CHECK
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp

     
    197197
    198198//////////////////////////////////////////////////////////////////////////
    199199
     200enum {
     201    ID_RecomputeWaterData
     202};
    200203static void SendToGame(const AtlasMessage::sEnvironmentSettings& settings)
    201204{
    202205    POST_COMMAND(SetEnvironmentSettings, (settings));
     
    213216
    214217    wxSizer* waterSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Water settings"));
    215218    scrollSizer->Add(waterSizer, wxSizerFlags().Expand());
    216 
     219    waterSizer->Add(new wxButton(this, ID_RecomputeWaterData, _("Reset Water Data")), wxSizerFlags().Expand());
    217220    waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water height"), g_EnvironmentSettings.waterheight, 0.f, 1.2f), wxSizerFlags().Expand());
    218     waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water shininess"), g_EnvironmentSettings.watershininess, 0.f, 250.f), wxSizerFlags().Expand());
    219221    waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water waviness"), g_EnvironmentSettings.waterwaviness, 0.f, 10.f), wxSizerFlags().Expand());
    220222    waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water murkiness"), g_EnvironmentSettings.watermurkiness, 0.f, 1.f), wxSizerFlags().Expand());
    221223    waterSizer->Add(new VariableColourBox(scrolledWindow, _("Water colour"), g_EnvironmentSettings.watercolour), wxSizerFlags().Expand());
     
    277279
    278280    g_EnvironmentSettings.NotifyObservers();
    279281}
     282
     283void EnvironmentSidebar::RecomputeWaterData(wxCommandEvent& evt)
     284{
     285    POST_COMMAND(RecalculateWaterData, (0.0f));
     286}
     287
     288BEGIN_EVENT_TABLE(EnvironmentSidebar, Sidebar)
     289    EVT_BUTTON(ID_RecomputeWaterData, EnvironmentSidebar::RecomputeWaterData)
     290END_EVENT_TABLE();
     291
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h

     
    2727    EnvironmentSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
    2828
    2929    virtual void OnMapReload();
     30    virtual void RecomputeWaterData(wxCommandEvent& evt);
    3031
    3132protected:
    3233    virtual void OnFirstDisplay();
     
    3536    VariableListBox* m_PostEffectList;
    3637    VariableListBox* m_SkyList;
    3738    ObservableScopedConnection m_Conn;
     39   
     40    DECLARE_EVENT_TABLE();
    3841};
  • source/tools/atlas/GameInterface/Messages.h

     
    422422struct sEnvironmentSettings
    423423{
    424424    Shareable<float> waterheight; // range 0..1 corresponds to min..max terrain height; out-of-bounds values allowed
    425     Shareable<float> watershininess; // range ???
    426425    Shareable<float> waterwaviness; // range ???
    427426    Shareable<float> watermurkiness; // range ???
    428427   
     
    471470        ((sEnvironmentSettings, settings))
    472471        );
    473472
     473COMMAND(RecalculateWaterData, NOMERGE, ((float,unused)));
     474
    474475QUERY(GetSkySets,
    475476      // no inputs
    476477      ,
  • source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp

     
    4444    s.waterheight = cmpWaterManager->GetExactWaterLevel(0, 0) / (65536.f * HEIGHT_SCALE);
    4545
    4646    WaterManager* wm = g_Renderer.GetWaterManager();
    47     s.watershininess = wm->m_Shininess;
    4847    s.waterwaviness = wm->m_Waviness;
    4948    s.watermurkiness = wm->m_Murkiness;
    5049    s.waterreflectiontintstrength = wm->m_ReflectionTintStrength;
     
    10099    cmpWaterManager->SetWaterLevel(entity_pos_t::FromFloat(s.waterheight * (65536.f * HEIGHT_SCALE)));
    101100
    102101    WaterManager* wm = g_Renderer.GetWaterManager();
    103     wm->m_Shininess = s.watershininess;
    104102    wm->m_Waviness = s.waterwaviness;
    105103    wm->m_Murkiness = s.watermurkiness;
    106104    wm->m_ReflectionTintStrength = s.waterreflectiontintstrength;