Ticket #1743: WaterFix.patch
File WaterFix.patch, 24.7 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/maps/random/rmgen/environment.js
56 56 WATER_LEVEL_CHANGED = true; 57 57 } 58 58 59 // Set water shininess60 function setWaterShininess(s)61 {62 g_Environment.Water.WaterBody.Shininess = s;63 }64 65 59 // Set water waviness 66 60 function setWaterWaviness(w) 67 61 { -
binaries/data/mods/public/maps/random/rmgen/mapgen.js
15 15 Type: "default", 16 16 Colour: {r: 0.3, g: 0.35, b: 0.7, a: 0}, 17 17 Height: 5, 18 Shininess: 150,19 18 Waviness: 8, 20 19 Murkiness: 0.45, 21 20 Tint: {r: 0.28, g: 0.3, b: 0.59, a: 0}, -
binaries/data/mods/public/shaders/glsl/model_water.fs
34 34 uniform vec3 sunDir; 35 35 uniform vec3 cameraPos; 36 36 37 38 uniform float shininess;39 37 uniform float specularStrength; 40 38 uniform float waviness; 41 39 uniform vec3 waterTint; … … 124 122 refrColor = (0.5 + 0.5*ndotl) * mix(vec3(0.3), sunColor * waterTint, 125 123 murkiness * clamp(waterDepth / fullDepth, 0.0, 1.0)); // Murkiness and tint at this pixel (tweaked based on lighting and depth) 126 124 127 specular = pow(max(0.0, ndoth), shininess) * sunColor * specularStrength;125 specular = pow(max(0.0, ndoth), 150.0f) * sunColor * specularStrength; 128 126 129 127 losMod = texture2D(losTex, v_los).a; 130 128 -
binaries/data/mods/public/shaders/glsl/water_high.fs
5 5 uniform vec3 sunColor; 6 6 uniform vec3 cameraPos; 7 7 uniform sampler2D losMap; 8 uniform float shininess; // Blinn-Phong specular strength9 8 uniform float specularStrength; // Scaling for specular reflection (specular color is (this,this,this)) 10 9 uniform float waviness; // "Wildness" of the reflections and refractions; choose based on texture 11 10 uniform vec3 tint; // Tint for refraction (used to simulate particles in water) … … 102 101 vec2 beachOrientation = heightmapval.rg; 103 102 float distToShore = heightmapval.b; 104 103 #endif 105 106 104 107 105 vec3 n, l, h, v; // Normal, light vector, half-vector and view vector (vector to eye) 108 106 float ndotl, ndoth, ndotv; 109 107 float fresnel; … … 185 183 // texture is not rotated, moves twice faster in the opposite direction, translated. 186 184 vec2 foam2RC = gl_TexCoord[0].st*1.8 + vec2(time*-0.019,time*-0.012) - 0.012*n.xz + vec2(0.4,0.2); 187 185 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; 189 187 vec4 foam1 = texture2D(Foam, foam1RC + vec2(-WaveRocking.t,WaveRocking.s)); 190 188 vec4 foam2 = foam1.r*texture2D(Foam, foam2RC + WaveRocking); 191 189 -
source/graphics/MapReader.cpp
583 583 EL(type); 584 584 EL(colour); 585 585 EL(height); 586 EL(shininess); 586 EL(shininess); // for compatibility 587 587 EL(waviness); 588 588 EL(murkiness); 589 589 EL(tint); … … 718 718 if (!m_MapReader.pWaterMan) 719 719 continue; 720 720 721 float this_avoids_a_warning_about_unused_variables = 0; 722 721 723 if (element_name == el_type) 722 724 { 723 725 // TODO: implement this, when WaterManager supports it … … 740 742 } \ 741 743 742 744 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) 744 746 READ_FLOAT(el_waviness, m_MapReader.pWaterMan->m_Waviness) 745 747 READ_FLOAT(el_murkiness, m_MapReader.pWaterMan->m_Murkiness) 746 748 READ_COLOUR(el_tint, m_MapReader.pWaterMan->m_WaterTint) … … 1461 1463 // TODO: Water type not implemented 1462 1464 1463 1465 GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Colour, pWaterMan->m_WaterColor) 1464 GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Shininess, pWaterMan->m_Shininess)1465 1466 GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Waviness, pWaterMan->m_Waviness) 1466 1467 GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Murkiness, pWaterMan->m_Murkiness) 1467 1468 GET_ENVIRONMENT_PROPERTY(waterBodyObj.get(), Tint, pWaterMan->m_WaterTint) -
source/graphics/MapWriter.cpp
256 256 CmpPtr<ICmpWaterManager> cmpWaterManager(*pSimulation2, SYSTEM_ENTITY); 257 257 ENSURE(cmpWaterManager); 258 258 XML_Setting("Height", cmpWaterManager->GetExactWaterLevel(0, 0)); 259 XML_Setting("Shininess", pWaterMan->m_Shininess);260 259 XML_Setting("Waviness", pWaterMan->m_Waviness); 261 260 XML_Setting("Murkiness", pWaterMan->m_Murkiness); 262 261 { -
source/ps/CStrInternStatic.h
126 126 X(shadowScale) 127 127 X(shadowTex) 128 128 X(shadowTransform) 129 X(shininess)130 129 X(skinBlendMatrices) 131 130 X2(skinBlendMatrices_0, "skinBlendMatrices[0]") 132 131 X(skyCube) -
source/renderer/TerrainRenderer.cpp
658 658 defines.Add(str_USE_NORMALS, str_1); 659 659 if (WaterMgr->m_WaterRealDepth) 660 660 defines.Add(str_USE_REAL_DEPTH, str_1); 661 if (WaterMgr->m_WaterFoam && !g_AtlasGameLoop->running)661 if (WaterMgr->m_WaterFoam) 662 662 defines.Add(str_USE_FOAM, str_1); 663 663 if (WaterMgr->m_WaterCoastalWaves && !g_AtlasGameLoop->running) 664 664 defines.Add(str_USE_WAVES, str_1); … … 747 747 GLuint FramebufferName = 0; 748 748 749 749 // 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) 751 752 { 752 753 // Save the post-processing framebuffer. 753 754 GLint fbo; … … 840 841 m->fancyWaterShader->Uniform(str_sunDir, lightEnv.GetSunDir()); 841 842 m->fancyWaterShader->Uniform(str_sunColor, lightEnv.m_SunColor.X); 842 843 m->fancyWaterShader->Uniform(str_color, WaterMgr->m_WaterColor); 843 m->fancyWaterShader->Uniform(str_shininess, WaterMgr->m_Shininess);844 844 m->fancyWaterShader->Uniform(str_specularStrength, WaterMgr->m_SpecularStrength); 845 845 m->fancyWaterShader->Uniform(str_waviness, WaterMgr->m_Waviness); 846 846 m->fancyWaterShader->Uniform(str_murkiness, WaterMgr->m_Murkiness); -
source/renderer/WaterManager.cpp
70 70 m_ReflectionTextureSize = 0; 71 71 m_RefractionTextureSize = 0; 72 72 m_WaterTexTimer = 0.0; 73 m_Shininess = 150.0f;74 73 m_SpecularStrength = 0.6f; 75 74 m_Waviness = 8.0f; 76 75 m_ReflectionTint = CColor(0.28f, 0.3f, 0.59f, 1.0f); … … 268 267 m_WaterHeight = cmpWaterManager->GetExactWaterLevel(0,0); 269 268 270 269 // 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); 275 274 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 276 282 if (m_WaveX == NULL) 277 283 { 278 284 m_WaveX = new float[m_MapSize*m_MapSize]; … … 291 297 // this might be updated to actually cache in the terrain manager but that's not for now. 292 298 CVector3D* normals = new CVector3D[m_MapSize*m_MapSize]; 293 299 294 295 300 // taken out of the bottom loop, blurs the normal map 296 301 // To remove if below is reactivated 297 302 ssize_t blurZstart = Zstart-4 < 0 ? 0 : Zstart - 4; 298 303 ssize_t blurZend = Zend+4 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : Zend + 4; 299 304 ssize_t blurXstart = Xstart-4 < 0 ? 0 : Xstart - 4; 300 305 ssize_t blurXend = Xend+4 >= (ssize_t)m_MapSize ? (ssize_t)m_MapSize-1 : Xend + 4; 306 301 307 for (ssize_t j = blurZstart; j < blurZend; ++j) 302 308 { 303 309 for (ssize_t i = blurXstart; i < blurXend; ++i) … … 339 345 { 340 346 for (ssize_t i = Xstart; i < Xend; ++i) 341 347 { 348 ssize_t index = j*m_MapSize + i; 342 349 if (circular && (i-halfSize)*(i-halfSize)+(j-halfSize)*(j-halfSize) > mSize) 343 350 { 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; 348 355 continue; 349 356 } 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; 352 359 353 360 // 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) 357 362 { 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) 360 380 { 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; 371 385 } 372 // refine the calculation if we're close enough373 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) 376 390 { 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) 378 392 { 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; 382 395 } 383 396 } 384 }385 397 } 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 399 399 // speedup with default values for land squares 400 400 if (distanceToShore == 10000) 401 401 { 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; 406 406 continue; 407 407 } 408 408 409 // We'll compute the normals and the "water raise", to know about foam 409 410 // Normals are a pretty good calculation but it's slow since we normalize so much. 410 411 CVector3D normal; 411 412 int waterRaise = 0; 412 for (int yy = - 4; yy <= 4; yy += 2)413 for (int yy = -3; yy <= 3; yy += 2) 413 414 { 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. 415 416 { 416 417 if (j+yy < (long)m_MapSize && i+xx < (long)m_MapSize && i+xx >= 0 && j+yy >= 0) 417 418 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; 420 420 } 421 421 } 422 422 // normalizes the terrain info to avoid foam moving at too different speeds. 423 normal *= 0.0 12345679f;423 normal *= 0.08f; 424 424 normal[1] = 0.1f; 425 425 normal = normal.Normalized(); 426 426 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]; 429 429 // distance is /5.0 to be a [0,1] value. 430 430 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; 432 432 433 433 // computing the amount of foam I want 434 435 434 depth = clamp(depth,0.0f,10.0f); 436 435 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); 439 439 440 m_FoamFactor[ j*m_MapSize + i] = foamAmount;440 m_FoamFactor[index] = foamAmount; 441 441 } 442 442 } 443 443 444 444 delete[] normals; 445 445 //delete[] waveForceHQ; 446 446 447 // TODO: The rest should be cleaned up448 447 // TODO: reactivate this with something that looks good and is efficient. 448 /* 449 449 // okay let's create the waves squares. i'll divide the map in arbitrary squares 450 450 // For each of these squares, check if waves are needed. 451 451 // If yes, look for the best positionning (in order to have a nice blending with the shore) … … 604 604 // Construct indices buffer 605 605 m_VBWavesIndices = g_VBMan.Allocate(sizeof(GLushort), waves_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER); 606 606 m_VBWavesIndices->m_Owner->UpdateChunkVertices(m_VBWavesIndices, &waves_indices[0]); 607 */ 607 608 } 608 609 609 610 //////////////////////////////////////////////////////////////////////// -
source/renderer/WaterManager.h
115 115 // Shader parameters for fancy water 116 116 CColor m_WaterTint; 117 117 float m_RepeatPeriod; 118 float m_Shininess;119 118 float m_SpecularStrength; 120 119 float m_Waviness; 121 120 float m_Murkiness; -
source/simulation2/components/CCmpWaterManager.cpp
26 26 #include "renderer/WaterManager.h" 27 27 #include "simulation2/MessageTypes.h" 28 28 29 #include "tools/atlas/GameInterface/GameLoop.h" 30 29 31 class CCmpWaterManager : public ICmpWaterManager 30 32 { 31 33 public: … … 81 83 case MT_TerrainChanged: 82 84 { 83 85 // 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) 85 89 { 86 90 const CMessageTerrainChanged& msgData = static_cast<const CMessageTerrainChanged&> (msg); 87 91 g_Renderer.GetWaterManager()->m_NeedInfoUpdate = true; … … 97 101 } 98 102 } 99 103 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 100 117 virtual void SetWaterLevel(entity_pos_t h) 101 118 { 102 119 m_WaterHeight = h; -
source/simulation2/components/ICmpWaterManager.cpp
22 22 #include "simulation2/system/InterfaceScripted.h" 23 23 24 24 BEGIN_INTERFACE_WRAPPER(WaterManager) 25 DEFINE_INTERFACE_METHOD_0("RecomputeWaterData", void, ICmpWaterManager, RecomputeWaterData) 25 26 DEFINE_INTERFACE_METHOD_1("SetWaterLevel", void, ICmpWaterManager, SetWaterLevel, entity_pos_t) 26 27 DEFINE_INTERFACE_METHOD_2("GetWaterLevel", entity_pos_t, ICmpWaterManager, GetWaterLevel, entity_pos_t, entity_pos_t) 27 28 END_INTERFACE_WRAPPER(WaterManager) -
source/simulation2/components/ICmpWaterManager.h
26 26 { 27 27 public: 28 28 /** 29 * Recompute all the water information (foam…) 30 */ 31 virtual void RecomputeWaterData() = 0; 32 33 /** 29 34 * Set the height of the water level, as a constant value across the whole map. 30 35 */ 31 36 virtual void SetWaterLevel(entity_pos_t h) = 0; -
source/soundmanager/SoundManager.cpp
138 138 continue; 139 139 140 140 int pauseTime = 500; 141 if ( g_SoundManager->InDistress() )142 pauseTime = 50;143 144 141 { 145 142 CScopeLock lock(m_WorkerMutex); 146 143 144 if ( g_SoundManager->InDistress() ) 145 pauseTime = 50; 146 147 147 ItemsList::iterator lstr = m_Items->begin(); 148 148 ItemsList* nextItemList = new ItemsList; 149 149 150 151 150 while (lstr != m_Items->end()) { 152 151 153 152 AL_CHECK -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp
197 197 198 198 ////////////////////////////////////////////////////////////////////////// 199 199 200 enum { 201 ID_RecomputeWaterData 202 }; 200 203 static void SendToGame(const AtlasMessage::sEnvironmentSettings& settings) 201 204 { 202 205 POST_COMMAND(SetEnvironmentSettings, (settings)); … … 213 216 214 217 wxSizer* waterSizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _T("Water settings")); 215 218 scrollSizer->Add(waterSizer, wxSizerFlags().Expand()); 216 219 waterSizer->Add(new wxButton(this, ID_RecomputeWaterData, _("Reset Water Data")), wxSizerFlags().Expand()); 217 220 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());219 221 waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water waviness"), g_EnvironmentSettings.waterwaviness, 0.f, 10.f), wxSizerFlags().Expand()); 220 222 waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water murkiness"), g_EnvironmentSettings.watermurkiness, 0.f, 1.f), wxSizerFlags().Expand()); 221 223 waterSizer->Add(new VariableColourBox(scrolledWindow, _("Water colour"), g_EnvironmentSettings.watercolour), wxSizerFlags().Expand()); … … 277 279 278 280 g_EnvironmentSettings.NotifyObservers(); 279 281 } 282 283 void EnvironmentSidebar::RecomputeWaterData(wxCommandEvent& evt) 284 { 285 POST_COMMAND(RecalculateWaterData, (0.0f)); 286 } 287 288 BEGIN_EVENT_TABLE(EnvironmentSidebar, Sidebar) 289 EVT_BUTTON(ID_RecomputeWaterData, EnvironmentSidebar::RecomputeWaterData) 290 END_EVENT_TABLE(); 291 -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h
27 27 EnvironmentSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); 28 28 29 29 virtual void OnMapReload(); 30 virtual void RecomputeWaterData(wxCommandEvent& evt); 30 31 31 32 protected: 32 33 virtual void OnFirstDisplay(); … … 35 36 VariableListBox* m_PostEffectList; 36 37 VariableListBox* m_SkyList; 37 38 ObservableScopedConnection m_Conn; 39 40 DECLARE_EVENT_TABLE(); 38 41 }; -
source/tools/atlas/GameInterface/Messages.h
422 422 struct sEnvironmentSettings 423 423 { 424 424 Shareable<float> waterheight; // range 0..1 corresponds to min..max terrain height; out-of-bounds values allowed 425 Shareable<float> watershininess; // range ???426 425 Shareable<float> waterwaviness; // range ??? 427 426 Shareable<float> watermurkiness; // range ??? 428 427 … … 471 470 ((sEnvironmentSettings, settings)) 472 471 ); 473 472 473 COMMAND(RecalculateWaterData, NOMERGE, ((float,unused))); 474 474 475 QUERY(GetSkySets, 475 476 // no inputs 476 477 , -
source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
44 44 s.waterheight = cmpWaterManager->GetExactWaterLevel(0, 0) / (65536.f * HEIGHT_SCALE); 45 45 46 46 WaterManager* wm = g_Renderer.GetWaterManager(); 47 s.watershininess = wm->m_Shininess;48 47 s.waterwaviness = wm->m_Waviness; 49 48 s.watermurkiness = wm->m_Murkiness; 50 49 s.waterreflectiontintstrength = wm->m_ReflectionTintStrength; … … 100 99 cmpWaterManager->SetWaterLevel(entity_pos_t::FromFloat(s.waterheight * (65536.f * HEIGHT_SCALE))); 101 100 102 101 WaterManager* wm = g_Renderer.GetWaterManager(); 103 wm->m_Shininess = s.watershininess;104 102 wm->m_Waviness = s.waterwaviness; 105 103 wm->m_Murkiness = s.watermurkiness; 106 104 wm->m_ReflectionTintStrength = s.waterreflectiontintstrength;