Implement atlas merging and tile proxies

This commit is contained in:
Gilles Roudière 2021-07-06 14:43:03 +02:00
parent b2187797df
commit 5d34a81e52
19 changed files with 1773 additions and 175 deletions

View file

@ -120,6 +120,8 @@ public:
#endif // DISABLE_DEPRECATED
public:
static const int INVALID_SOURCE; // -1;
enum CellNeighbor {
CELL_NEIGHBOR_RIGHT_SIDE = 0,
CELL_NEIGHBOR_RIGHT_CORNER,
@ -169,7 +171,6 @@ public:
TILE_OFFSET_AXIS_VERTICAL,
};
public:
struct PackedSceneSource {
Ref<PackedScene> scene;
Vector2 offset;
@ -250,6 +251,11 @@ private:
void _compute_next_source_id();
void _source_changed();
// Tile proxies
Map<int, int> source_level_proxies;
Map<Array, Array> coords_level_proxies;
Map<Array, Array> alternative_level_proxies;
// Helpers
Vector<Point2> _get_square_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
Vector<Point2> _get_square_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit);
@ -345,6 +351,31 @@ public:
void set_custom_data_type(int p_layer_id, Variant::Type p_value);
Variant::Type get_custom_data_type(int p_layer_id) const;
// Tiles proxies.
void set_source_level_tile_proxy(int p_source_from, int p_source_to);
int get_source_level_tile_proxy(int p_source_from);
bool has_source_level_tile_proxy(int p_source_from);
void remove_source_level_tile_proxy(int p_source_from);
void set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_source_to, Vector2i p_coords_to);
Array get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from);
bool has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from);
void remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from);
void set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from, int p_source_to, Vector2i p_coords_to, int p_alternative_to);
Array get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from);
bool has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from);
void remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from);
Array get_source_level_tile_proxies() const;
Array get_coords_level_tile_proxies() const;
Array get_alternative_level_tile_proxies() const;
Array map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const;
void cleanup_invalid_tile_proxies();
void clear_tile_proxies();
// Helpers
Vector<Vector2> get_tile_shape_polygon();
void draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled = false, Ref<Texture2D> p_texture = Ref<Texture2D>());