mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
feat(editor): terrain mirror X/Y for symmetric zone design
- Mirror X: copies left half of terrain to right half (mirrored) - Mirror Y: copies top half to bottom half (mirrored) - Useful for creating symmetric zones, arenas, or balanced landscapes - Auto-stitches all chunk edges after mirror for seamless results - UI buttons in Sculpt panel under "Mirror Terrain" section
This commit is contained in:
parent
ac88aed250
commit
dd2b9294b5
3 changed files with 61 additions and 0 deletions
|
|
@ -666,6 +666,52 @@ void TerrainEditor::scaleHeights(float factor) {
|
|||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::mirrorX() {
|
||||
if (!terrain_) return;
|
||||
for (int cy = 0; cy < 16; cy++) {
|
||||
for (int cx = 0; cx < 8; cx++) {
|
||||
int srcIdx = cy * 16 + cx;
|
||||
int dstIdx = cy * 16 + (15 - cx);
|
||||
auto& src = terrain_->chunks[srcIdx];
|
||||
auto& dst = terrain_->chunks[dstIdx];
|
||||
if (!src.hasHeightMap() || !dst.hasHeightMap()) continue;
|
||||
for (int v = 0; v < 145; v++) {
|
||||
int row = v / 17, col = v % 17;
|
||||
if (col > 8) continue;
|
||||
int mirrorCol = 8 - col;
|
||||
int mirrorV = row * 17 + mirrorCol;
|
||||
dst.heightMap.heights[mirrorV] = src.heightMap.heights[v];
|
||||
}
|
||||
dirtyChunks_.push_back(dstIdx);
|
||||
}
|
||||
}
|
||||
for (int ci = 0; ci < 256; ci++) stitchEdges(ci);
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::mirrorY() {
|
||||
if (!terrain_) return;
|
||||
for (int cy = 0; cy < 8; cy++) {
|
||||
for (int cx = 0; cx < 16; cx++) {
|
||||
int srcIdx = cy * 16 + cx;
|
||||
int dstIdx = (15 - cy) * 16 + cx;
|
||||
auto& src = terrain_->chunks[srcIdx];
|
||||
auto& dst = terrain_->chunks[dstIdx];
|
||||
if (!src.hasHeightMap() || !dst.hasHeightMap()) continue;
|
||||
for (int v = 0; v < 145; v++) {
|
||||
int row = v / 17, col = v % 17;
|
||||
if (col > 8) continue;
|
||||
int mirrorRow = 8 - row;
|
||||
int mirrorV = mirrorRow * 17 + col;
|
||||
dst.heightMap.heights[mirrorV] = src.heightMap.heights[v];
|
||||
}
|
||||
dirtyChunks_.push_back(dstIdx);
|
||||
}
|
||||
}
|
||||
for (int ci = 0; ci < 256; ci++) stitchEdges(ci);
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
void TerrainEditor::copyStamp(const glm::vec3& center, float radius) {
|
||||
if (!terrain_) return;
|
||||
stampData_.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue