mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
feat(editor): height clamp tool for controlled terrain range
- Clamp Heights: sets min/max height bounds across entire tile (DragFloatRange2 slider for min/max, -500 to 2000 range) - Useful workflow: Generate noise → Smooth → Clamp to desired range - Prevents terrain from going underground or too high - All affected chunks marked dirty for mesh regeneration
This commit is contained in:
parent
c93a997424
commit
d59d69b0c5
3 changed files with 32 additions and 1 deletions
|
|
@ -652,6 +652,27 @@ void TerrainEditor::smoothEntireTile(int iterations) {
|
|||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::clampHeights(float minH, float maxH) {
|
||||
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];
|
||||
if (absH < minH) {
|
||||
chunk.heightMap.heights[v] = minH - chunk.position[2];
|
||||
modified = true;
|
||||
} else if (absH > maxH) {
|
||||
chunk.heightMap.heights[v] = maxH - chunk.position[2];
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
if (modified) dirtyChunks_.push_back(ci);
|
||||
}
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::applyErode(float dt) {
|
||||
float factor = std::min(1.0f, brush_.settings().strength * dt * 0.3f);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue