mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-08 20:09:36 +01:00
Enable and fix LayeredTileMap2DNavigationGeometryParser2D.
This commit is contained in:
parent
d395657ee1
commit
5e4b6182f1
@ -41,62 +41,12 @@
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
/*
|
||||
bool LayeredTileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) {
|
||||
return (Object::cast_to<LayeredTileMap>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
LayeredTileMap *tilemap = Object::cast_to<LayeredTileMap>(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<LayeredTileSet> 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<NavigationPolygon> 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<Vector2> traversable_outline = navigation_polygon->get_outline(outline_index);
|
||||
|
||||
Vector<Vector2> 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<LayeredTileMap>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void LayeredTileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
#ifdef CLIPPER_ENABLED
|
||||
LayeredTileMap *tilemap = Object::cast_to<LayeredTileMap>(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<NavigationPolygon> 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<Vector2> traversable_outline = navigation_polygon->get_outline(outline_index);
|
||||
Vector<Vector2> 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user