diff options
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/particles_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 24 | ||||
-rw-r--r-- | scene/2d/tile_map.h | 4 |
3 files changed, 19 insertions, 11 deletions
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index aee5d89150..7d53557216 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -291,7 +291,7 @@ void Particles2D::_notification(int p_what) { texture_rid = texture->get_rid(); RID normal_rid; if (normal_map.is_valid()) - normal_rid = texture->get_rid(); + normal_rid = normal_map->get_rid(); VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index c7b656b5fc..c0d0a6e011 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -716,7 +716,7 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_ } else { ERR_FAIL_COND(!Q); // quadrant should exist... - if (E->get().id == p_tile && E->get().flip_h == p_flip_x && E->get().flip_v == p_flip_y && E->get().transpose == p_transpose) + if (E->get().id == p_tile && E->get().flip_h == p_flip_x && E->get().flip_v == p_flip_y && E->get().transpose == p_transpose && E->get().autotile_coord_x == (uint16_t)p_autotile_coord.x && E->get().autotile_coord_y == (uint16_t)p_autotile_coord.y) return; //nothing changed } @@ -741,7 +741,7 @@ int TileMap::get_cellv(const Vector2 &p_pos) const { void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) { for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) { - for (int y = p_pos.y - 1; x <= p_pos.y + 1; y++) { + for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) { PosKey p(x, y); if (dirty_bitmask.find(p) == NULL) { dirty_bitmask.push_back(p); @@ -810,6 +810,10 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) { Vector2 coord = tile_set->autotile_get_subtile_for_bitmask(id, mask, this, Vector2(p_x, p_y)); E->get().autotile_coord_x = (int)coord.x; E->get().autotile_coord_y = (int)coord.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 { E->get().autotile_coord_x = 0; E->get().autotile_coord_y = 0; @@ -870,28 +874,31 @@ bool TileMap::is_cell_transposed(int p_x, int p_y) const { return E->get().transpose; } -int TileMap::get_cell_autotile_coord_x(int p_x, int p_y) const { +void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord) { PosKey pk(p_x, p_y); const Map<PosKey, Cell>::Element *E = tile_map.find(pk); if (!E) - return 0; + return; - return E->get().autotile_coord_x; + Cell c = E->get(); + c.autotile_coord_x = p_coord.x; + c.autotile_coord_y = p_coord.y; + tile_map[pk] = c; } -int TileMap::get_cell_autotile_coord_y(int p_x, int p_y) const { +Vector2 TileMap::get_cell_autotile_coord(int p_x, int p_y) const { PosKey pk(p_x, p_y); const Map<PosKey, Cell>::Element *E = tile_map.find(pk); if (!E) - return 0; + return Vector2(); - return E->get().autotile_coord_y; + return Vector2(E->get().autotile_coord_x, E->get().autotile_coord_y); } void TileMap::_recreate_quadrants() { @@ -963,6 +970,7 @@ void TileMap::_set_tile_data(const PoolVector<int> &p_data) { int offset = (format == FORMAT_2_1_5) ? 3 : 2; + clear(); for (int i = 0; i < c; i += offset) { const uint8_t *ptr = (const uint8_t *)&r[i]; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index a0ca2e6a35..8eecf48df2 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -241,8 +241,8 @@ public: bool is_cell_x_flipped(int p_x, int p_y) const; bool is_cell_y_flipped(int p_x, int p_y) const; bool is_cell_transposed(int p_x, int p_y) const; - int get_cell_autotile_coord_x(int p_x, int p_y) const; - int get_cell_autotile_coord_y(int p_x, int p_y) const; + void set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord); + Vector2 get_cell_autotile_coord(int p_x, int p_y) const; void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false); int get_cellv(const Vector2 &p_pos) const; |