Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some TileMap debug drawing truncating to ints #87160

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Jan 14, 2024

Fixes part of #87138 (besides the incorrect generation of the navigation polygon (see #87138 (comment))).

  • quadrant_pos was correctly calculated as Vector2 but it was converted to Vector2i when passing to _X_draw_cell_debug methods:

    const Vector2 quadrant_pos = tile_map_node->map_to_local(debug_quadrant.quadrant_coords * TILE_MAP_DEBUG_QUADRANT_SIZE);
    Transform2D xform(0, quadrant_pos);
    rs->canvas_item_set_transform(ci, xform);
    for (SelfList<CellData> *cell_data_list_element = debug_quadrant.cells.first(); cell_data_list_element; cell_data_list_element = cell_data_list_element->next()) {
    CellData &cell_data = *cell_data_list_element->self();
    if (cell_data.cell.source_id != TileSet::INVALID_SOURCE) {
    _rendering_draw_cell_debug(ci, quadrant_pos, cell_data);
    _physics_draw_cell_debug(ci, quadrant_pos, cell_data);
    _navigation_draw_cell_debug(ci, quadrant_pos, cell_data);
    _scenes_draw_cell_debug(ci, quadrant_pos, cell_data);

  • Rect2i::get_center returning Vector2i instead of Vector2 strikes again. This time making the offset for the texture region center being calculated incorrectly.
    Still no idea why this method works like that. For me it's like if Vector2i::length would be returning int instead of float etc. 🙃 Maybe we could/should add something like Rect2i::get_centerf? 🤔 (assuming Rect2i::get_center can't be changed because of compat)

debug drawing Before
(v4.3.dev1.official [9d1cbab])
After
(this PR)
Physics
- rendering offsets fixed
Godot_v4 3-dev1_win64_m0yNeSm9AH AUAudD4WTr
Navigation
- rendering offsets fixed
- still incorrect polygon generated
TJOynU8MBc WapiwxvbWN

Haven't tested this thoroughly so not sure if maybe something else got broken/revealed incorrect offset calculation or something like that.

@kleonc kleonc added this to the 4.3 milestone Jan 14, 2024
@kleonc kleonc requested a review from groud January 14, 2024 01:27
@kleonc kleonc requested a review from a team as a code owner January 14, 2024 01:27
@JekSun97
Copy link

I hope the Godot team will no longer rewrite the entire engine :D

@akien-mga akien-mga merged commit fe76b61 into godotengine:master Jan 15, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@kleonc kleonc deleted the tilemap-fix-debug-drawing-truncations-to-ints branch January 15, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants