mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
- Extend undo/redo to snapshot alpha maps and texture layers alongside heights — texture painting operations are now fully undoable - Bracket paint mode with beginStroke/endStroke like sculpt mode - Fix stale static char buffer in quest objective loop (showed wrong objective's description when editing multiple objectives) - Zero-initialize all quest UI text buffers for null termination safety - Fix unused variable warnings in terrain_editor.cpp
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "pipeline/adt_loader.hpp"
|
|
#include <vector>
|
|
#include <array>
|
|
#include <memory>
|
|
|
|
namespace wowee {
|
|
namespace editor {
|
|
|
|
struct ChunkSnapshot {
|
|
int chunkIndex;
|
|
std::array<float, 145> heights;
|
|
std::vector<uint8_t> alphaMap;
|
|
std::vector<pipeline::TextureLayer> layers;
|
|
};
|
|
|
|
struct EditCommand {
|
|
std::vector<ChunkSnapshot> before;
|
|
std::vector<ChunkSnapshot> after;
|
|
};
|
|
|
|
class EditorHistory {
|
|
public:
|
|
void beginEdit(const pipeline::ADTTerrain& terrain, const std::vector<int>& affectedChunks);
|
|
void endEdit(const pipeline::ADTTerrain& terrain);
|
|
|
|
bool canUndo() const { return !undoStack_.empty(); }
|
|
bool canRedo() const { return !redoStack_.empty(); }
|
|
|
|
void undo(pipeline::ADTTerrain& terrain);
|
|
void redo(pipeline::ADTTerrain& terrain);
|
|
|
|
void clear();
|
|
|
|
size_t undoCount() const { return undoStack_.size(); }
|
|
size_t redoCount() const { return redoStack_.size(); }
|
|
|
|
const std::vector<int>& lastAffectedChunks() const { return lastAffected_; }
|
|
|
|
private:
|
|
static ChunkSnapshot captureChunk(const pipeline::ADTTerrain& terrain, int idx);
|
|
static void restoreChunk(pipeline::ADTTerrain& terrain, const ChunkSnapshot& snap);
|
|
static bool snapshotChanged(const ChunkSnapshot& a, const ChunkSnapshot& b);
|
|
|
|
std::vector<EditCommand> undoStack_;
|
|
std::vector<EditCommand> redoStack_;
|
|
EditCommand pending_;
|
|
std::vector<int> lastAffected_;
|
|
static constexpr size_t MAX_UNDO = 100;
|
|
};
|
|
|
|
} // namespace editor
|
|
} // namespace wowee
|