15enum class TileSculptMode : uint8_t
41struct TileSculptOptions
43 TileSculptMode mMode = TileSculptMode::Pencil;
44 int32_t mSelectedTileIndex = 0;
45 int32_t mActiveLayer = 0;
48 int32_t mActiveNineBoxIndex = -1;
51 int32_t mActiveAutotileIndex = -1;
54 bool mShowCollisionOverlay =
false;
55 bool mShowTagOverlay =
false;
56 bool mShowCellGrid =
false;
57 std::string mTagOverlayName =
"";
65 std::vector<TileCell> mCells;
67 bool IsValid()
const {
return mWidth > 0 && mHeight > 0 && !mCells.empty(); }
68 void Clear() { mWidth = 0; mHeight = 0; mCells.clear(); }
79 void HandleNodeDestroy(
Node* node);
81 TileSculptOptions mOptions;
84 bool mHoverValid =
false;
85 glm::ivec2 mHoverCell = { 0, 0 };
88 bool mPreviewActive =
false;
89 glm::ivec2 mDragStartCell = { 0, 0 };
95 bool mStrokeActive =
false;
96 bool mLastStrokeCellValid =
false;
97 glm::ivec2 mLastStrokeCell = { 0, 0 };
104 bool mHasSelection =
false;
105 glm::ivec2 mSelectionMin = { 0, 0 };
106 glm::ivec2 mSelectionMax = { 0, 0 };
107 std::set<int64_t> mSelectedCells;
109 static int64_t SelectionCellKey(int32_t cellX, int32_t cellY)
111 return int64_t(uint32_t(cellX)) | (int64_t(uint32_t(cellY)) << 32);
113 static void DecodeSelectionCellKey(int64_t key, int32_t& outX, int32_t& outY)
115 outX = int32_t(uint32_t(key & 0xFFFFFFFFu));
116 outY = int32_t(uint32_t((key >> 32) & 0xFFFFFFFFu));
118 bool IsCellSelected(int32_t cellX, int32_t cellY)
const
120 return mSelectedCells.count(SelectionCellKey(cellX, cellY)) > 0;
122 void RecomputeSelectionBounds();
127 void DoPaste(glm::ivec2 destOrigin);
128 void DoPasteAtCursor();
129 void DoFlipClipboardX();
130 void DoFlipClipboardY();
131 void DoRotateClipboard90();
134 void DoApply9BoxToSelection();
135 bool HasClipboard()
const {
return mClipboard.IsValid(); }
136 bool HasSelection()
const {
return mHasSelection; }
137 glm::ivec2 GetSelectionMin()
const {
return mSelectionMin; }
138 glm::ivec2 GetSelectionMax()
const {
return mSelectionMax; }
139 void ClearSelection() { mHasSelection =
false; mSelectedCells.clear(); }
149 void DrawGridOverlay();
150 void DrawSelectionOutline();
151 void ApplyPencilOrEraser(
TileMap2D* node, glm::ivec2 cell);
152 void StrokePencilOrEraserInterp(
TileMap2D* node, glm::ivec2 from, glm::ivec2 to);
153 void CommitRectFill(
TileMap2D* node, glm::ivec2 a, glm::ivec2 b);
154 void CommitLine(
TileMap2D* node, glm::ivec2 a, glm::ivec2 b);
155 void CommitFloodFill(
TileMap2D* node, glm::ivec2 origin);
156 void CommitNineBox(
TileMap2D* node, glm::ivec2 a, glm::ivec2 b);
157 void CommitAutotileAt(
TileMap2D* node, glm::ivec2 cell);
158 void StageCellChange(int32_t cellX, int32_t cellY, int32_t layer,
161 int32_t PickNineBoxSlot(int32_t cx, int32_t cy,
162 int32_t minX, int32_t maxX,
163 int32_t minY, int32_t maxY)
const;
167 uint8_t ComputeAutotileSelfMask(
TileMap2D* node, int32_t cellX, int32_t cellY,
168 int32_t layer, int32_t autotileIdx,
169 const std::set<int64_t>& pendingSelfCells)
const;
171 static int64_t CellKey(int32_t cellX, int32_t cellY, int32_t layer);
174 std::vector<TilePaintChange> mPendingChanges;
175 std::set<int64_t> mModifiedSet;
177 TileClipboard mClipboard;
bool Update()
Definition Engine.cpp:710
Definition TileMap2d.h:23