mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): smooth beaches tool for natural water-land transitions
- Smooth Beaches button in Water panel: creates gentle beach slopes near water level by blending terrain toward waterline height - Configurable beach width (15 units default) - Quadratic falloff creates natural concave beach profile - Use after filling water to soften harsh land-water edges - Workflow: sculpt → fill water → smooth beaches → paint sand
This commit is contained in:
parent
c8897eca83
commit
426863f19a
3 changed files with 30 additions and 0 deletions
|
|
@ -962,6 +962,29 @@ void TerrainEditor::fillWater(float height, uint16_t liquidType) {
|
|||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::smoothBeaches(float waterHeight, float beachWidth) {
|
||||
if (!terrain_) return;
|
||||
for (int ci = 0; ci < 256; ci++) {
|
||||
auto& chunk = terrain_->chunks[ci];
|
||||
if (!chunk.hasHeightMap()) continue;
|
||||
bool modified = false;
|
||||
for (int v = 0; v < 145; v++) {
|
||||
float absH = chunk.position[2] + chunk.heightMap.heights[v];
|
||||
float distToWater = std::abs(absH - waterHeight);
|
||||
if (distToWater < beachWidth) {
|
||||
// Smooth toward water level with gentle slope
|
||||
float t = distToWater / beachWidth;
|
||||
float target = waterHeight + (absH > waterHeight ? 1.0f : -1.0f) * beachWidth * t * t;
|
||||
float relTarget = target - chunk.position[2];
|
||||
chunk.heightMap.heights[v] = chunk.heightMap.heights[v] * 0.3f + relTarget * 0.7f;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
if (modified) { stitchEdges(ci); dirtyChunks_.push_back(ci); }
|
||||
}
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::thermalErosion(int iterations, float talusAngle) {
|
||||
if (!terrain_) return;
|
||||
float unitSize = CHUNK_SIZE / 8.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue