From 5e4b6182f1238113dbe6b31124da33f23b7e4569 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 17 Mar 2024 14:39:34 +0100 Subject: [PATCH] Enable and fix LayeredTileMap2DNavigationGeometryParser2D. --- ..._tilemap_navigation_geometry_parser_2d.cpp | 55 +------------------ 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/modules/layered_tile_map/geometry_parser/layered_tilemap_navigation_geometry_parser_2d.cpp b/modules/layered_tile_map/geometry_parser/layered_tilemap_navigation_geometry_parser_2d.cpp index 3e190c7aa..daa9904fc 100644 --- a/modules/layered_tile_map/geometry_parser/layered_tilemap_navigation_geometry_parser_2d.cpp +++ b/modules/layered_tile_map/geometry_parser/layered_tilemap_navigation_geometry_parser_2d.cpp @@ -41,62 +41,12 @@ #include "modules/modules_enabled.gen.h" -/* bool LayeredTileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) { return (Object::cast_to(p_node) != nullptr); } void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { - LayeredTileMap *tilemap = Object::cast_to(p_node); - //NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type(); - //uint32_t navigation_polygon_collision_mask = p_navigation_polygon->get_collision_mask(); - if (tilemap) { - Ref tile_set = tilemap->get_tileset(); - if (!tile_set.is_valid()) { - return; - } - - const Transform2D tilemap_xform = tilemap->get_transform(); - Array used_cells = tilemap->get_used_cells(); - - for (int used_cell_index = 0; used_cell_index < used_cells.size(); used_cell_index++) { - Vector2 cell = used_cells[used_cell_index]; - - int cell_id = tilemap->get_cell(cell.x, cell.y); - - Transform2D tile_transform; - tile_transform.set_origin(tilemap->to_local(cell)); - - const Transform2D tile_transform_offset = tilemap_xform * tile_transform; - - Ref navigation_polygon = tile_set->tile_get_navigation_polygon(cell_id); - if (navigation_polygon.is_valid()) { - for (int outline_index = 0; outline_index < navigation_polygon->get_outline_count(); outline_index++) { - PoolVector traversable_outline = navigation_polygon->get_outline(outline_index); - - Vector traversable_outline_new; - traversable_outline_new.resize(traversable_outline.size()); - - for (int traversable_outline_index = 0; traversable_outline_index < traversable_outline.size(); traversable_outline_index++) { - traversable_outline_new.write[traversable_outline_index] = tile_transform_offset.xform(traversable_outline[traversable_outline_index]); - } - - p_source_geometry->_add_traversable_outline(traversable_outline_new); - } - } - } - } -} - -*/ - -bool LayeredTileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) { - return (Object::cast_to(p_node) != nullptr); -} - -void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { -#ifdef CLIPPER_ENABLED LayeredTileMap *tilemap = Object::cast_to(p_node); NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type(); uint32_t navigation_polygon_collision_mask = p_navigation_polygon->get_collision_mask(); @@ -126,7 +76,7 @@ void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Re for (int used_cell_index = 0; used_cell_index < used_cells.size(); used_cell_index++) { const Vector2i &cell = used_cells[used_cell_index]; - const TileData *tile_data = tilemap->get_cell_tile_data(tilemap_layer, cell, false); + const LayeredTileData *tile_data = tilemap->get_cell_tile_data(tilemap_layer, cell, false); Transform2D tile_transform; tile_transform.set_origin(tilemap->map_to_local(cell)); @@ -137,7 +87,7 @@ void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Re Ref navigation_polygon = tile_data->get_navigation_polygon(tilemap_layer); if (navigation_polygon.is_valid()) { for (int outline_index = 0; outline_index < navigation_polygon->get_outline_count(); outline_index++) { - Vector traversable_outline = navigation_polygon->get_outline(outline_index); + Vector traversable_outline = Variant(navigation_polygon->get_outline(outline_index)); for (int traversable_outline_index = 0; traversable_outline_index < traversable_outline.size(); traversable_outline_index++) { traversable_outline.write[traversable_outline_index] = tile_transform_offset.xform(traversable_outline[traversable_outline_index]); @@ -161,5 +111,4 @@ void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Re } } } -#endif // CLIPPER_ENABLED }