feat(editor): scatter texture patches for natural surface variety

- Scatter Patches: randomly places texture circles across the terrain
  for natural-looking surface variation (dirt patches, rock outcrops)
- Configurable count, min/max radius, and seed
- Preset buttons for dirt and rock patches
- Uses the existing paint() method with random positions
- Adds visual variety to otherwise uniform terrain texturing
This commit is contained in:
Kelsi 2026-05-05 08:40:43 -07:00
parent 16a096b25d
commit b00143e8f7
3 changed files with 46 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#include "core/logger.hpp"
#include <algorithm>
#include <cmath>
#include <random>
namespace wowee {
namespace editor {
@ -321,6 +322,25 @@ void TexturePainter::gradientBlend(const std::string& tex1, const std::string& t
}
}
void TexturePainter::scatterPatches(const std::string& texturePath, int count,
float minRadius, float maxRadius, uint32_t seed) {
if (!terrain_ || texturePath.empty()) return;
uint32_t texId = ensureTextureInList(texturePath);
float tileNW_X = (32.0f - static_cast<float>(terrain_->coord.y)) * 533.33333f;
float tileNW_Y = (32.0f - static_cast<float>(terrain_->coord.x)) * 533.33333f;
std::mt19937 rng(seed);
std::uniform_real_distribution<float> distX(tileNW_X - 533.33333f, tileNW_X);
std::uniform_real_distribution<float> distY(tileNW_Y - 533.33333f, tileNW_Y);
std::uniform_real_distribution<float> distR(minRadius, maxRadius);
for (int p = 0; p < count; p++) {
float px = distX(rng), py = distY(rng), pr = distR(rng);
paint(glm::vec3(px, py, 0), pr, 0.8f, 0.5f);
}
}
std::vector<int> TexturePainter::erase(const glm::vec3& center, float radius,
float strength, float falloff) {
if (!terrain_ || activeTexture_.empty()) return {};