summaryrefslogtreecommitdiff
path: root/scene/2d/tile_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/tile_map.cpp')
-rw-r--r--scene/2d/tile_map.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 8fe65f53a9..d61296b13f 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -327,6 +327,11 @@ void TileMap::update_dirty_quadrants() {
Ref<ShaderMaterial> mat = tile_set->tile_get_material(c.id);
int z_index = tile_set->tile_get_z_index(c.id);
+ if (tile_set->tile_get_tile_mode(c.id) == TileSet::AUTO_TILE ||
+ tile_set->tile_get_tile_mode(c.id) == TileSet::ATLAS_TILE) {
+ z_index += tile_set->autotile_get_z_index(c.id, Vector2(c.autotile_coord_x, c.autotile_coord_y));
+ }
+
RID canvas_item;
RID debug_canvas_item;
@@ -372,13 +377,12 @@ void TileMap::update_dirty_quadrants() {
r.size = tile_set->autotile_get_size(c.id);
r.position += (r.size + Vector2(spacing, spacing)) * Vector2(c.autotile_coord_x, c.autotile_coord_y);
}
- Size2 s = tex->get_size();
+ Size2 s;
if (r == Rect2())
s = tex->get_size();
- else {
+ else
s = r.size;
- }
Rect2 rect;
rect.position = offset.floor();
@@ -835,7 +839,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
Map<PosKey, Cell>::Element *E = tile_map.find(p);
if (E != NULL) {
int id = get_cell(p_x, p_y);
- if (tile_set->tile_get_tile_mode(id) == TileSet::AUTO_TILE || tile_set->tile_get_tile_mode(id) == TileSet::ATLAS_TILE) {
+ if (tile_set->tile_get_tile_mode(id) == TileSet::AUTO_TILE) {
uint16_t mask = 0;
if (tile_set->autotile_get_bitmask_mode(id) == TileSet::BITMASK_2X2) {
if (tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x, p_y - 1)) && tile_set->is_tile_bound(id, get_cell(p_x - 1, p_y))) {
@@ -899,7 +903,8 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
PosKey qk(p_x / _get_quadrant_size(), p_y / _get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
_make_quadrant_dirty(Q);
- } else {
+
+ } else if (tile_set->tile_get_tile_mode(id) == TileSet::SINGLE_TILE) {
E->get().autotile_coord_x = 0;
E->get().autotile_coord_y = 0;
}
@@ -1625,6 +1630,8 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_cell_y_flipped", "x", "y"), &TileMap::is_cell_y_flipped);
ClassDB::bind_method(D_METHOD("is_cell_transposed", "x", "y"), &TileMap::is_cell_transposed);
+ ClassDB::bind_method(D_METHOD("get_cell_autotile_coord", "x", "y"), &TileMap::get_cell_autotile_coord);
+
ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles);
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);