diff --git a/src/noggit/MapChunk.cpp b/src/noggit/MapChunk.cpp index e116df03..1d5f6159 100755 --- a/src/noggit/MapChunk.cpp +++ b/src/noggit/MapChunk.cpp @@ -1084,10 +1084,10 @@ bool MapChunk::blurTerrain ( glm::vec3 const& pos , float radius , int BrushType , flatten_mode const& mode - , std::function (float, float)> height + /*, std::function(float, float)> height*/ ) { - bool changed (false); + bool changed = false; if (BrushType == eFlattenType_Origin) { @@ -1096,7 +1096,7 @@ bool MapChunk::blurTerrain ( glm::vec3 const& pos for (int i (0); i < mapbufsize; ++i) { - float const dist(misc::dist(mVertices[i], pos)); + float const dist = misc::dist(mVertices[i], pos); if (dist >= radius) { @@ -1111,16 +1111,28 @@ bool MapChunk::blurTerrain ( glm::vec3 const& pos float tz = pos.z + j * UNITSIZE / 2; for (int k = -Rad; k <= Rad; ++k) { - float tx = pos.x + k*UNITSIZE + (j % 2) * UNITSIZE / 2.0f; - float dist2 = misc::dist (tx, tz, mVertices[i].x, mVertices[i].z); + float const tx = pos.x + k*UNITSIZE + (j % 2) * UNITSIZE / 2.0f; + float const dist2 = misc::dist (tx, tz, mVertices[i].x, mVertices[i].z); if (dist2 > radius) continue; - auto h (height (tx, tz)); + + glm::vec3 vec; + bool res = mt->getWorld()->GetVertex(tx, tz, &vec); + if (res) + { + // float h = vec.y; + TotalHeight += (1.0f - dist2 / radius) * vec.y; + TotalWeight += (1.0f - dist2 / radius); + } + + /* + // auto h (height (tx, tz)); + auto h = height(tx, tz); if (h) { TotalHeight += (1.0f - dist2 / radius) * h.value(); TotalWeight += (1.0f - dist2 / radius); - } + }*/ } } diff --git a/src/noggit/MapChunk.h b/src/noggit/MapChunk.h index a19744f3..9c4f7a99 100755 --- a/src/noggit/MapChunk.h +++ b/src/noggit/MapChunk.h @@ -150,7 +150,7 @@ public: bool changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius); bool flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation); bool blurTerrain ( glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode - , std::function (float, float)> height + /*, std::function(float, float)> height*/ ); bool changeTerrainProcessVertex(glm::vec3 const& pos, glm::vec3 const& vertex, float& dt, float radiusOuter, float radiusInner, int brushType); diff --git a/src/noggit/World.cpp b/src/noggit/World.cpp index 32d4c837..f9d63f2a 100755 --- a/src/noggit/World.cpp +++ b/src/noggit/World.cpp @@ -1540,12 +1540,12 @@ void World::blurTerrain(glm::vec3 const& pos, float remain, float radius, int Br , radius , BrushType , mode - , [this] (float x, float z) -> std::optional + /*, [this](float x, float z) -> std::optional { glm::vec3 vec; auto res (GetVertex (x, z, &vec)); return res ? std::optional(vec.y) : std::nullopt; - } + }*/ ); } , [this] (MapChunk* chunk)