Fix logic for showing tilemap debug collision

In editor: only when show_collision property is enabled
In game: only when 'Visible collision shapes' is enabled

(cherry picked from commit 114da550ec)
This commit is contained in:
PouleyKetchoupp 2021-05-25 11:44:43 -07:00 committed by Rémi Verschelde
parent c680057dad
commit b9492b2659
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 11 additions and 4 deletions

View file

@ -327,7 +327,7 @@
The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
</member>
<member name="show_collision" type="bool" setter="set_show_collision" getter="is_show_collision_enabled" default="false">
If [code]true[/code], collision shapes are shown in the editor and at run-time. Requires [b]Visible Collision Shapes[/b] to be enabled in the [b]Debug[/b] menu for collision shapes to be visible at run-time.
If [code]true[/code], collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable [b]Visible Collision Shapes[/b] in the [b]Debug[/b] menu instead.
</member>
<member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset">
The assigned [TileSet].

View file

@ -346,10 +346,17 @@ void TileMap::update_dirty_quadrants() {
Color debug_collision_color;
Color debug_navigation_color;
bool debug_shapes = show_collision && (Engine::get_singleton()->is_editor_hint() || (st && st->is_debugging_collisions_hint()));
bool debug_shapes = false;
if (st) {
if (Engine::get_singleton()->is_editor_hint()) {
debug_shapes = show_collision;
} else {
debug_shapes = st->is_debugging_collisions_hint();
}
if (debug_shapes) {
debug_collision_color = st->get_debug_collisions_color();
if (debug_shapes) {
debug_collision_color = st->get_debug_collisions_color();
}
}
bool debug_navigation = st && st->is_debugging_navigation_hint();