载入中...
搜索中...
未找到
Brush.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <string>
8#include <vector>
9
10namespace eve::level_editing {
11
17public:
20
22 void setTool(const std::string &tool);
24 std::string getTool() const { return tool_; }
25
27 void setSize(int size);
29 int getSize() const { return size_; }
30
32 void setShape(const std::string &shape);
34 std::string getShape() const { return shape_; }
35
37 void setTile(int gid);
39 int getTile() const { return tile_; }
40
42 void setEraseTile(int gid);
44 int getEraseTile() const { return eraseTile_; }
45
47 void setStampSize(int width, int height);
49 int getStampWidth() const { return stampW_; }
51 int getStampHeight() const { return stampH_; }
53 void setStampTile(int lx, int ly, int gid);
55 int getStampTile(int lx, int ly) const;
57 void clearStamp();
58
60 int paintAt(TileBuffer *buffer, int tx, int ty);
62 int eraseAt(TileBuffer *buffer, int tx, int ty);
64 int floodFill(TileBuffer *buffer, int tx, int ty);
66 int paintLine(TileBuffer *buffer, int x0, int y0, int x1, int y1);
68 int paintRect(TileBuffer *buffer, int x0, int y0, int x1, int y1, bool filled);
69
71 int previewAt(TileBuffer *buffer, int tx, int ty);
73 int previewLine(TileBuffer *buffer, int x0, int y0, int x1, int y1);
75 int previewRect(TileBuffer *buffer, int x0, int y0, int x1, int y1, bool filled);
76
78 int getPreviewCount() const { return static_cast<int>(preview_.size()); }
80 int getPreviewX(int index) const;
82 int getPreviewY(int index) const;
84 int getPreviewGid(int index) const;
85
87 int getChangeCount() const { return static_cast<int>(changes_.size()); }
89 int getChangeX(int index) const;
91 int getChangeY(int index) const;
93 int getChangeOldGid(int index) const;
95 int getChangeNewGid(int index) const;
96
97private:
98 struct Cell {
99 int x = 0;
100 int y = 0;
101 int gid = 0;
102 int oldGid = 0;
103 };
104
105 void clearChanges();
106 void clearPreview();
107 void collectBrushCells(int tx, int ty, std::vector<std::pair<int, int>> &out) const;
108 void collectLineCells(int x0, int y0, int x1, int y1, std::vector<std::pair<int, int>> &out) const;
109 void collectRectCells(int x0, int y0, int x1, int y1, bool filled,
110 std::vector<std::pair<int, int>> &out) const;
111 int applyCells(TileBuffer *buffer, const std::vector<std::pair<int, int>> &cells, int gid);
112 int applyStamp(TileBuffer *buffer, int tx, int ty);
113 int previewCells(TileBuffer *buffer, const std::vector<std::pair<int, int>> &cells, int gid);
114 bool validChange(int index) const;
115 bool validPreview(int index) const;
116
117 std::string tool_ = "paint";
118 std::string shape_ = "square";
119 int size_ = 1;
120 int tile_ = 1;
121 int eraseTile_ = 0;
122 int stampW_ = 0;
123 int stampH_ = 0;
124 std::vector<int> stamp_;
125
126 std::vector<Cell> changes_;
127 std::vector<Cell> preview_;
128};
129
130} // namespace eve::level_editing
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#define EVENGINE_API_DOMAINS
Definition Export.h:110
ShaderImageInput shape
std::uint32_t height
std::uint32_t width
std::unique_ptr< gpgpu::GpuBuffer > buffer
Definition OnnxGpgpu.cpp:26
std::array< PixelCell, kPixelChunkSize *kPixelChunkSize > cells
float size
Definition TreeMesh.cpp:156
uint32_t index
Unity GridBrushBase-inspired tile brush. Operates on TileBuffer; exposes preview + change list for UI...
Definition Brush.h:16
int getTile() const
Returns the tile.
Definition Brush.h:39
std::string getTool() const
Returns the tool.
Definition Brush.h:24
int getSize() const
Returns the size.
Definition Brush.h:29
int getStampHeight() const
Returns the stamp height.
Definition Brush.h:51
int getEraseTile() const
Returns the erase tile.
Definition Brush.h:44
int getPreviewCount() const
Returns the preview count.
Definition Brush.h:78
std::string getShape() const
Returns the shape.
Definition Brush.h:34
int getChangeCount() const
Returns the change count.
Definition Brush.h:87
int getStampWidth() const
Returns the stamp width.
Definition Brush.h:49
Independent GID grid for map brushes (no hard dependency on map.TileLayer).
Definition TileBuffer.h:11