feat(editor): reset-to-flat button for terrain, consolidation

- "Reset to Flat" button in Noise Generator section: zeroes all heights
  across entire tile for starting over without creating a new terrain
- Useful workflow: reset → noise → smooth → scale → clamp → auto-paint
This commit is contained in:
Kelsi 2026-05-05 06:40:26 -07:00
parent 3ac40d27ad
commit f593606251
3 changed files with 20 additions and 1 deletions

View file

@ -479,8 +479,12 @@ void EditorUI::renderBrushPanel(EditorApp& app) {
app.getTerrainEditor().scaleHeights(hScale);
app.showToast("Heights scaled");
}
if (ImGui::Button("Reset to Flat", ImVec2(-1, 0))) {
app.getTerrainEditor().resetToFlat();
app.showToast("Terrain reset to flat");
}
ImGui::TextColored(ImVec4(0.6f, 0.6f, 0.6f, 1),
"Exaggerate (>1) or flatten (<1) terrain relief");
"Scale: exaggerate (>1) or flatten (<1) relief");
}
ImGui::Separator();

View file

@ -652,6 +652,18 @@ void TerrainEditor::smoothEntireTile(int iterations) {
dirty_ = true;
}
void TerrainEditor::resetToFlat() {
if (!terrain_) return;
for (int ci = 0; ci < 256; ci++) {
auto& chunk = terrain_->chunks[ci];
if (!chunk.hasHeightMap()) continue;
chunk.heightMap.heights.fill(0.0f);
dirtyChunks_.push_back(ci);
}
for (int ci = 0; ci < 256; ci++) stitchEdges(ci);
dirty_ = true;
}
void TerrainEditor::scaleHeights(float factor) {
if (!terrain_) return;
for (int ci = 0; ci < 256; ci++) {

View file

@ -60,6 +60,9 @@ public:
// Clamp all heights to a min/max range
void clampHeights(float minH, float maxH);
// Reset all heights to zero (flat terrain)
void resetToFlat();
// Scale all heights by a factor (useful for exaggerating or flattening)
void scaleHeights(float factor);