mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): auto-paint terrain by height bands
- Auto-Paint by Height: automatically sets base texture per chunk based on average height — configurable thresholds for sand/grass/rock/snow - Uses Tanaris sand, Elwynn grass, Barrens rock, Dragonblight snow - One-click to texture an entire procedurally generated terrain - Adjustable height thresholds via drag floats - Workflow: noise → smooth → clamp → auto-paint for instant biome
This commit is contained in:
parent
1ba1a50112
commit
aa9a6a87a8
3 changed files with 59 additions and 0 deletions
|
|
@ -165,6 +165,35 @@ std::vector<int> TexturePainter::paint(const glm::vec3& center, float radius,
|
|||
return modified;
|
||||
}
|
||||
|
||||
void TexturePainter::autoPaintByHeight(const std::vector<HeightBand>& bands) {
|
||||
if (!terrain_ || bands.empty()) return;
|
||||
|
||||
// Ensure all band textures are in the texture list
|
||||
for (const auto& band : bands)
|
||||
ensureTextureInList(band.texturePath);
|
||||
|
||||
for (int ci = 0; ci < 256; ci++) {
|
||||
auto& chunk = terrain_->chunks[ci];
|
||||
if (!chunk.hasHeightMap()) continue;
|
||||
|
||||
// Find average height of this chunk
|
||||
float avgH = chunk.position[2];
|
||||
float sum = 0;
|
||||
for (int v = 0; v < 145; v++) sum += chunk.heightMap.heights[v];
|
||||
avgH += sum / 145.0f;
|
||||
|
||||
// Find which band this chunk falls into
|
||||
for (const auto& band : bands) {
|
||||
if (avgH <= band.maxHeight) {
|
||||
uint32_t texId = ensureTextureInList(band.texturePath);
|
||||
if (!chunk.layers.empty())
|
||||
chunk.layers[0].textureId = texId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> TexturePainter::erase(const glm::vec3& center, float radius,
|
||||
float strength, float falloff) {
|
||||
if (!terrain_ || activeTexture_.empty()) return {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue