diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp b/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp index c869ca16e..7a593727d 100644 --- a/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp @@ -31,22 +31,23 @@ #include "meshinstance2d_navigation_geometry_parser_2d.h" #include "scene/2d/mesh_instance_2d.h" +#include "scene/resources/mesh.h" #include "scene/resources/navigation_mesh_source_geometry_data_2d.h" #include "scene/resources/navigation_polygon.h" #include "modules/modules_enabled.gen.h" -#ifdef CLIPPER_ENABLED -#include "thirdparty/clipper2/include/clipper2/clipper.h" -#endif // CLIPPER_ENABLED +#ifdef MODULE_CLIPPER2_ENABLED +#include "modules/clipper2/lib/include/clipper2/clipper.h" +#endif // MODULE_CLIPPER2_ENABLED bool MeshInstance2DNavigationGeometryParser2D::parses_node(Node *p_node) { return (Object::cast_to(p_node) != nullptr); } void MeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { -#ifdef CLIPPER_ENABLED +#ifdef MODULE_CLIPPER2_ENABLED NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type(); if (Object::cast_to(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_STATIC_COLLIDERS) { @@ -88,13 +89,17 @@ void MeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref< if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { Vector mesh_indices = a[Mesh::ARRAY_INDEX]; - for (int vertex_index : mesh_indices) { + for (int j = 0; j < mesh_indices.size(); ++j) { + int vertex_index = mesh_indices[j]; + const Vector2 &vertex = mesh_vertices[vertex_index]; const Point64 &point = Point64(vertex.x, vertex.y); subject_path.push_back(point); } } else { - for (const Vector2 &vertex : mesh_vertices) { + for (int j = 0; j < mesh_vertices.size(); ++j) { + const Vector2 &vertex = mesh_vertices[j]; + const Point64 &point = Point64(vertex.x, vertex.y); subject_path.push_back(point); } @@ -110,18 +115,21 @@ void MeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref< Vector> polypaths; - for (const Path64 &scaled_path : path_solution) { - Vector shape_outline; + for (uint32_t i = 0; i < path_solution.size(); i++) { + const Path64 &scaled_path = path_solution[i]; + + PoolVector shape_outline; + for (const Point64 &scaled_point : scaled_path) { shape_outline.push_back(Point2(static_cast(scaled_point.x), static_cast(scaled_point.y))); } - for (int i = 0; i < shape_outline.size(); i++) { - shape_outline.write[i] = transform.xform(shape_outline[i]); + for (int j = 0; j < shape_outline.size(); j++) { + shape_outline.set(j, transform.xform(shape_outline[j])); } p_source_geometry->add_obstruction_outline(shape_outline); } } -#endif // CLIPPER_ENABLED +#endif // MODULE_CLIPPER2_ENABLED } diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp b/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp index 1cc8ca99e..4f3868f3d 100644 --- a/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp @@ -31,22 +31,23 @@ #include "multimeshinstance2d_navigation_geometry_parser_2d.h" #include "scene/2d/multimesh_instance_2d.h" +#include "scene/resources/multimesh.h" #include "scene/resources/navigation_mesh_source_geometry_data_2d.h" #include "scene/resources/navigation_polygon.h" #include "modules/modules_enabled.gen.h" -#ifdef CLIPPER_ENABLED -#include "thirdparty/clipper2/include/clipper2/clipper.h" -#endif // CLIPPER_ENABLED +#ifdef MODULE_CLIPPER2_ENABLED +#include "modules/clipper2/lib/include/clipper2/clipper.h" +#endif // MODULE_CLIPPER2_ENABLED bool MultiMeshInstance2DNavigationGeometryParser2D::parses_node(Node *p_node) { return (Object::cast_to(p_node) != nullptr); } void MultiMeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { -#ifdef CLIPPER_ENABLED +#ifdef MODULE_CLIPPER2_ENABLED NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type(); if (Object::cast_to(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_STATIC_COLLIDERS) { @@ -85,13 +86,18 @@ void MultiMeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { Vector mesh_indices = a[Mesh::ARRAY_INDEX]; - for (int vertex_index : mesh_indices) { + + for (int j = 0; j < mesh_indices.size(); ++j) { + int vertex_index = mesh_indices[j]; + const Vector2 &vertex = mesh_vertices[vertex_index]; const Point64 &point = Point64(vertex.x, vertex.y); subject_path.push_back(point); } } else { - for (const Vector2 &vertex : mesh_vertices) { + for (int j = 0; j < mesh_vertices.size(); ++j) { + const Vector2 &vertex = mesh_vertices[j]; + const Point64 &point = Point64(vertex.x, vertex.y); subject_path.push_back(point); } @@ -111,20 +117,21 @@ void MultiMeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, const Transform2D multimesh_instance_transform = multimesh_instance->get_transform() * multimesh->get_instance_transform_2d(i); for (const Path64 &mesh_path : mesh_path_solution) { - Vector shape_outline; + PoolVector shape_outline; for (const Point64 &mesh_path_point : mesh_path) { shape_outline.push_back(Point2(static_cast(mesh_path_point.x), static_cast(mesh_path_point.y))); } for (int j = 0; j < shape_outline.size(); j++) { - shape_outline.write[j] = multimesh_instance_transform.xform(shape_outline[j]); + shape_outline.set(j, multimesh_instance_transform.xform(shape_outline[j])); } + p_source_geometry->add_obstruction_outline(shape_outline); } } } } } -#endif // CLIPPER_ENABLED +#endif // MODULE_CLIPPER2_ENABLED } diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp b/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp index d2316c43e..57eac82c9 100644 --- a/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp @@ -44,8 +44,7 @@ #endif // MODULE_CLIPPER2_ENABLED bool TileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) { - //return (Object::cast_to(p_node) != nullptr); - return false; + return (Object::cast_to(p_node) != nullptr); } void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) {