Skip to content

Commit

Permalink
Merge pull request #87160 from kleonc/tilemap-fix-debug-drawing-trunc…
Browse files Browse the repository at this point in the history
…ations-to-ints

Fix some `TileMap` debug drawing truncating to ints
  • Loading branch information
akien-mga committed Jan 15, 2024
2 parents 85a918d + baa5504 commit fe76b61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions editor/plugins/tiles/tile_set_atlas_source_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
for (int i = 0; i < tile_set_atlas_source->get_tiles_count(); i++) {
Vector2i coords = tile_set_atlas_source->get_tile_id(i);
Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(coords);
Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_data(coords, 0)->get_texture_origin();
Vector2 position = ((Rect2)texture_region).get_center() + tile_set_atlas_source->get_tile_data(coords, 0)->get_texture_origin();

Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
xform.translate_local(position);
Expand All @@ -1892,7 +1892,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
continue;
}
Rect2i texture_region = tile_set_atlas_source->get_tile_texture_region(E.tile);
Vector2i position = texture_region.get_center() + tile_set_atlas_source->get_tile_data(E.tile, 0)->get_texture_origin();
Vector2 position = ((Rect2)texture_region).get_center() + tile_set_atlas_source->get_tile_data(E.tile, 0)->get_texture_origin();

Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
xform.translate_local(position);
Expand Down
8 changes: 4 additions & 4 deletions scene/2d/tile_map_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ void TileMapLayer::_rendering_occluders_update_cell(CellData &r_cell_data) {
}

#ifdef DEBUG_ENABLED
void TileMapLayer::_rendering_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data) {
void TileMapLayer::_rendering_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data) {
const Ref<TileSet> &tile_set = tile_map_node->get_tileset();
ERR_FAIL_COND(!tile_set.is_valid());

Expand Down Expand Up @@ -898,7 +898,7 @@ void TileMapLayer::_physics_update_cell(CellData &r_cell_data) {
}

#ifdef DEBUG_ENABLED
void TileMapLayer::_physics_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data) {
void TileMapLayer::_physics_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data) {
// Draw the debug collision shapes.
const Ref<TileSet> &tile_set = tile_map_node->get_tileset();
ERR_FAIL_COND(!tile_set.is_valid());
Expand Down Expand Up @@ -1117,7 +1117,7 @@ void TileMapLayer::_navigation_update_cell(CellData &r_cell_data) {
}

#ifdef DEBUG_ENABLED
void TileMapLayer::_navigation_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data) {
void TileMapLayer::_navigation_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data) {
// Draw the debug collision shapes.
bool show_navigation = false;
switch (tile_map_node->get_navigation_visibility_mode()) {
Expand Down Expand Up @@ -1302,7 +1302,7 @@ void TileMapLayer::_scenes_update_cell(CellData &r_cell_data) {
}

#ifdef DEBUG_ENABLED
void TileMapLayer::_scenes_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data) {
void TileMapLayer::_scenes_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data) {
const Ref<TileSet> &tile_set = tile_map_node->get_tileset();
ERR_FAIL_COND(!tile_set.is_valid());

Expand Down
8 changes: 4 additions & 4 deletions scene/2d/tile_map_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class TileMapLayer : public RefCounted {
void _rendering_occluders_clear_cell(CellData &r_cell_data);
void _rendering_occluders_update_cell(CellData &r_cell_data);
#ifdef DEBUG_ENABLED
void _rendering_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data);
void _rendering_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data);
#endif // DEBUG_ENABLED

HashMap<RID, Vector2i> bodies_coords; // Mapping for RID to coords.
Expand All @@ -310,23 +310,23 @@ class TileMapLayer : public RefCounted {
void _physics_clear_cell(CellData &r_cell_data);
void _physics_update_cell(CellData &r_cell_data);
#ifdef DEBUG_ENABLED
void _physics_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data);
void _physics_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data);
#endif // DEBUG_ENABLED

bool _navigation_was_cleaned_up = false;
void _navigation_update();
void _navigation_clear_cell(CellData &r_cell_data);
void _navigation_update_cell(CellData &r_cell_data);
#ifdef DEBUG_ENABLED
void _navigation_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data);
void _navigation_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data);
#endif // DEBUG_ENABLED

bool _scenes_was_cleaned_up = false;
void _scenes_update();
void _scenes_clear_cell(CellData &r_cell_data);
void _scenes_update_cell(CellData &r_cell_data);
#ifdef DEBUG_ENABLED
void _scenes_draw_cell_debug(const RID &p_canvas_item, const Vector2i &p_quadrant_pos, const CellData &r_cell_data);
void _scenes_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data);
#endif // DEBUG_ENABLED

// Terrains.
Expand Down

0 comments on commit fe76b61

Please sign in to comment.