From b4cc1c3096c3fc36a7d76eb5cc26f54dc1e9fbbb Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 5 Jun 2023 12:43:27 +0200 Subject: [PATCH] Added the GeometryParsers from the NavigationMeshGenerator pr to a new module. --- modules/navigation_geometry_parsers/SCsub | 16 ++ modules/navigation_geometry_parsers/config.py | 7 + ...stance2d_navigation_geometry_parser_2d.cpp | 122 ++++++++++++ ...instance2d_navigation_geometry_parser_2d.h | 43 +++++ ...stance2d_navigation_geometry_parser_2d.cpp | 125 ++++++++++++ ...instance2d_navigation_geometry_parser_2d.h | 43 +++++ ...olygon2d_navigation_geometry_parser_2d.cpp | 54 ++++++ .../polygon2d_navigation_geometry_parser_2d.h | 43 +++++ ...icbody2d_navigation_geometry_parser_2d.cpp | 133 +++++++++++++ ...aticbody2d_navigation_geometry_parser_2d.h | 43 +++++ .../tilemap_navigation_geometry_parser_2d.cpp | 110 +++++++++++ .../tilemap_navigation_geometry_parser_2d.h | 43 +++++ ...stance3d_navigation_geometry_parser_3d.cpp | 49 +++++ ...instance3d_navigation_geometry_parser_3d.h | 43 +++++ ...stance3d_navigation_geometry_parser_3d.cpp | 58 ++++++ ...instance3d_navigation_geometry_parser_3d.h | 43 +++++ ...icbody3d_navigation_geometry_parser_3d.cpp | 179 ++++++++++++++++++ ...aticbody3d_navigation_geometry_parser_3d.h | 43 +++++ .../register_types.cpp | 41 ++++ .../register_types.h | 39 ++++ 20 files changed, 1277 insertions(+) create mode 100644 modules/navigation_geometry_parsers/SCsub create mode 100644 modules/navigation_geometry_parsers/config.py create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.h create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.cpp create mode 100644 modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.h create mode 100644 modules/navigation_geometry_parsers/register_types.cpp create mode 100644 modules/navigation_geometry_parsers/register_types.h diff --git a/modules/navigation_geometry_parsers/SCsub b/modules/navigation_geometry_parsers/SCsub new file mode 100644 index 000000000..32e337bd4 --- /dev/null +++ b/modules/navigation_geometry_parsers/SCsub @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +Import("env") +Import("env_modules") + +env_navigation = env_modules.Clone() + +# Pandemonium source files + +module_obj = [] + +env_navigation.add_source_files(module_obj, "*.cpp") +#env_navigation.add_source_files(module_obj, "geometry_parser_2d/*.cpp") +#env_navigation.add_source_files(module_obj, "geometry_parser_3d/*.cpp") + +env.modules_sources += module_obj diff --git a/modules/navigation_geometry_parsers/config.py b/modules/navigation_geometry_parsers/config.py new file mode 100644 index 000000000..c6f699c9d --- /dev/null +++ b/modules/navigation_geometry_parsers/config.py @@ -0,0 +1,7 @@ + +def can_build(env, platform): + return True + + +def configure(env): + pass 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 new file mode 100644 index 000000000..0aff02929 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.cpp @@ -0,0 +1,122 @@ +/**************************************************************************/ +/* meshinstance2d_navigation_geometry_parser_2d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "meshinstance2d_navigation_geometry_parser_2d.h" + +#include "scene/2d/mesh_instance_2d.h" + +#ifdef CLIPPER_ENABLED +#include "thirdparty/clipper2/include/clipper2/clipper.h" +#endif // CLIPPER_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 + 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) { + MeshInstance2D *mesh_instance = Object::cast_to(p_node); + Ref mesh = mesh_instance->get_mesh(); + if (!mesh.is_valid()) { + return; + } + + const Transform2D transform = mesh_instance->get_transform(); + + using namespace Clipper2Lib; + + Paths64 subject_paths, dummy_clip_paths; + + for (int i = 0; i < mesh->get_surface_count(); i++) { + if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { + continue; + } + + if (!(mesh->surface_get_format(i) & Mesh::ARRAY_FLAG_USE_2D_VERTICES)) { + continue; + } + + Path64 subject_path; + + int index_count = 0; + if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { + index_count = mesh->surface_get_array_index_len(i); + } else { + index_count = mesh->surface_get_array_len(i); + } + + ERR_CONTINUE((index_count == 0 || (index_count % 3) != 0)); + + Array a = mesh->surface_get_arrays(i); + + Vector mesh_vertices = a[Mesh::ARRAY_VERTEX]; + + if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { + Vector mesh_indices = a[Mesh::ARRAY_INDEX]; + for (int vertex_index : mesh_indices) { + 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) { + const Point64 &point = Point64(vertex.x, vertex.y); + subject_path.push_back(point); + } + } + subject_paths.push_back(subject_path); + } + + Paths64 path_solution; + + path_solution = Union(subject_paths, dummy_clip_paths, FillRule::NonZero); + + //path_solution = RamerDouglasPeucker(path_solution, 0.025); + + Vector> polypaths; + + for (const Path64 &scaled_path : path_solution) { + Vector 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]); + } + + p_source_geometry->add_obstruction_outline(shape_outline); + } + } +#endif // CLIPPER_ENABLED +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.h b/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.h new file mode 100644 index 000000000..fb7c5534a --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/meshinstance2d_navigation_geometry_parser_2d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* meshinstance2d_navigation_geometry_parser_2d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef MESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H +#define MESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H + +#include "scene/2d/navigation_geometry_parser_2d.h" + +class MeshInstance2DNavigationGeometryParser2D : public NavigationGeometryParser2D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) override; +}; + +#endif // MESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H 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 new file mode 100644 index 000000000..fb1c26abf --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.cpp @@ -0,0 +1,125 @@ +/**************************************************************************/ +/* multimeshinstance2d_navigation_geometry_parser_2d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "multimeshinstance2d_navigation_geometry_parser_2d.h" + +#include "scene/2d/multimesh_instance_2d.h" + +#ifdef CLIPPER_ENABLED +#include "thirdparty/clipper2/include/clipper2/clipper.h" +#endif // CLIPPER_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 + 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) { + MultiMeshInstance2D *multimesh_instance = Object::cast_to(p_node); + Ref multimesh = multimesh_instance->get_multimesh(); + if (multimesh.is_valid() && multimesh->get_transform_format() == MultiMesh::TRANSFORM_2D) { + Ref mesh = multimesh->get_mesh(); + if (mesh.is_valid()) { + using namespace Clipper2Lib; + + Paths64 mesh_subject_paths, dummy_clip_paths; + + for (int i = 0; i < mesh->get_surface_count(); i++) { + if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { + continue; + } + + if (!(mesh->surface_get_format(i) & Mesh::ARRAY_FLAG_USE_2D_VERTICES)) { + continue; + } + + Path64 subject_path; + + int index_count = 0; + if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { + index_count = mesh->surface_get_array_index_len(i); + } else { + index_count = mesh->surface_get_array_len(i); + } + + ERR_CONTINUE((index_count == 0 || (index_count % 3) != 0)); + + Array a = mesh->surface_get_arrays(i); + + Vector mesh_vertices = a[Mesh::ARRAY_VERTEX]; + + if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) { + Vector mesh_indices = a[Mesh::ARRAY_INDEX]; + for (int vertex_index : mesh_indices) { + 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) { + const Point64 &point = Point64(vertex.x, vertex.y); + subject_path.push_back(point); + } + } + mesh_subject_paths.push_back(subject_path); + } + + Paths64 mesh_path_solution = Union(mesh_subject_paths, dummy_clip_paths, FillRule::NonZero); + + //path_solution = RamerDouglasPeucker(path_solution, 0.025); + + int multimesh_instance_count = multimesh->get_visible_instance_count(); + if (multimesh_instance_count == -1) { + multimesh_instance_count = multimesh->get_instance_count(); + } + for (int i = 0; i < multimesh_instance_count; i++) { + 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; + + 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]); + } + p_source_geometry->add_obstruction_outline(shape_outline); + } + } + } + } + } +#endif // CLIPPER_ENABLED +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.h b/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.h new file mode 100644 index 000000000..453963dda --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/multimeshinstance2d_navigation_geometry_parser_2d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* multimeshinstance2d_navigation_geometry_parser_2d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef MULTIMESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H +#define MULTIMESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H + +#include "scene/2d/navigation_geometry_parser_2d.h" + +class MultiMeshInstance2DNavigationGeometryParser2D : public NavigationGeometryParser2D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) override; +}; + +#endif // MULTIMESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.cpp b/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.cpp new file mode 100644 index 000000000..362db68a3 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.cpp @@ -0,0 +1,54 @@ +/**************************************************************************/ +/* polygon2d_navigation_geometry_parser_2d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "polygon2d_navigation_geometry_parser_2d.h" + +#include "scene/2d/polygon_2d.h" + +bool Polygon2DNavigationGeometryParser2D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void Polygon2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { + 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) { + Polygon2D *polygon_2d = Object::cast_to(p_node); + + const Transform2D transform = polygon_2d->get_global_transform(); + + Vector shape_outline = polygon_2d->get_polygon(); + for (int i = 0; i < shape_outline.size(); i++) { + shape_outline.write[i] = transform.xform(shape_outline[i]); + } + + p_source_geometry->add_obstruction_outline(shape_outline); + } +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.h b/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.h new file mode 100644 index 000000000..017e1b470 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/polygon2d_navigation_geometry_parser_2d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* polygon2d_navigation_geometry_parser_2d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef POLYGON2D_NAVIGATION_GEOMETRY_PARSER_2D_H +#define POLYGON2D_NAVIGATION_GEOMETRY_PARSER_2D_H + +#include "scene/2d/navigation_geometry_parser_2d.h" + +class Polygon2DNavigationGeometryParser2D : public NavigationGeometryParser2D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) override; +}; + +#endif // POLYGON2D_NAVIGATION_GEOMETRY_PARSER_2D_H diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.cpp b/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.cpp new file mode 100644 index 000000000..00cc99565 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.cpp @@ -0,0 +1,133 @@ +/**************************************************************************/ +/* staticbody2d_navigation_geometry_parser_2d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "staticbody2d_navigation_geometry_parser_2d.h" + +#include "core/math/convex_hull.h" +#include "scene/2d/mesh_instance_2d.h" +#include "scene/2d/physics_body_2d.h" +#include "scene/resources/capsule_shape_2d.h" +#include "scene/resources/circle_shape_2d.h" +#include "scene/resources/concave_polygon_shape_2d.h" +#include "scene/resources/convex_polygon_shape_2d.h" +#include "scene/resources/rectangle_shape_2d.h" +#include "scene/resources/shape_2d.h" + +bool StaticBody2DNavigationGeometryParser2D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void StaticBody2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { + 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 (Object::cast_to(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_MESH_INSTANCES) { + StaticBody2D *static_body = Object::cast_to(p_node); + if (static_body->get_collision_layer() & navigation_polygon_collision_mask) { + List shape_owners; + static_body->get_shape_owners(&shape_owners); + for (uint32_t shape_owner : shape_owners) { + if (static_body->is_shape_owner_disabled(shape_owner)) { + continue; + } + const int shape_count = static_body->shape_owner_get_shape_count(shape_owner); + for (int shape_index = 0; shape_index < shape_count; shape_index++) { + Ref s = static_body->shape_owner_get_shape(shape_owner, shape_index); + + if (s.is_null()) { + continue; + } + + const Transform2D transform = static_body->get_transform() * static_body->shape_owner_get_transform(shape_owner); + + RectangleShape2D *rectangle_shape = Object::cast_to(*s); + if (rectangle_shape) { + Vector shape_outline; + + const Vector2 &rectangle_size = rectangle_shape->get_size(); + + shape_outline.resize(5); + shape_outline.write[0] = transform.xform(-rectangle_size * 0.5); + shape_outline.write[1] = transform.xform(Vector2(rectangle_size.x, -rectangle_size.y) * 0.5); + shape_outline.write[2] = transform.xform(rectangle_size * 0.5); + shape_outline.write[3] = transform.xform(Vector2(-rectangle_size.x, rectangle_size.y) * 0.5); + shape_outline.write[4] = transform.xform(-rectangle_size * 0.5); + + p_source_geometry->add_obstruction_outline(shape_outline); + } + + CapsuleShape2D *capsule_shape = Object::cast_to(*s); + if (capsule_shape) { + //const real_t capsule_height = capsule_shape->get_height(); + //const real_t capsule_radius = capsule_shape->get_radius(); + + //p_source_geometry->add_mesh_array(arr, transform); + } + + CircleShape2D *circle_shape = Object::cast_to(*s); + if (circle_shape) { + Vector shape_outline; + int circle_edge_count = 12; + shape_outline.resize(circle_edge_count); + + const real_t turn_step = Math_TAU / real_t(circle_edge_count); + for (int i = 0; i < circle_edge_count; i++) { + shape_outline.write[i] = transform.xform(Vector2(Math::cos(i * turn_step), Math::sin(i * turn_step)) * circle_shape->get_radius()); + } + + p_source_geometry->add_obstruction_outline(shape_outline); + } + + ConcavePolygonShape2D *concave_polygon_shape = Object::cast_to(*s); + if (concave_polygon_shape) { + Vector shape_outline = concave_polygon_shape->get_segments(); + + for (int i = 0; i < shape_outline.size(); i++) { + shape_outline.write[i] = transform.xform(shape_outline[i]); + } + + p_source_geometry->add_obstruction_outline(shape_outline); + } + + ConvexPolygonShape2D *convex_polygon_shape = Object::cast_to(*s); + if (convex_polygon_shape) { + Vector shape_outline = convex_polygon_shape->get_points(); + + for (int i = 0; i < shape_outline.size(); i++) { + shape_outline.write[i] = transform.xform(shape_outline[i]); + } + + p_source_geometry->add_obstruction_outline(shape_outline); + } + } + } + } + } +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.h b/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.h new file mode 100644 index 000000000..8e7af2596 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/staticbody2d_navigation_geometry_parser_2d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* staticbody2d_navigation_geometry_parser_2d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef STATICBODY2D_NAVIGATION_GEOMETRY_PARSER_2D_H +#define STATICBODY2D_NAVIGATION_GEOMETRY_PARSER_2D_H + +#include "scene/2d/navigation_geometry_parser_2d.h" + +class StaticBody2DNavigationGeometryParser2D : public NavigationGeometryParser2D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) override; +}; + +#endif // STATICBODY2D_NAVIGATION_GEOMETRY_PARSER_2D_H 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 new file mode 100644 index 000000000..626311ec9 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.cpp @@ -0,0 +1,110 @@ +/**************************************************************************/ +/* tilemap_navigation_geometry_parser_2d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "tilemap_navigation_geometry_parser_2d.h" + +#include "scene/2d/tile_map.h" + +#ifdef CLIPPER_ENABLED +#include "thirdparty/clipper2/include/clipper2/clipper.h" +#endif // CLIPPER_ENABLED + +bool TileMap2DNavigationGeometryParser2D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) { +#ifdef CLIPPER_ENABLED + TileMap *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) { + if (tilemap->get_layers_count() <= 0) { + return; + } + + int tilemap_layer = 0; // only main tile map layer is supported + + Ref tile_set = tilemap->get_tileset(); + if (!tile_set.is_valid()) { + return; + } + + int physics_layers_count = tile_set->get_physics_layers_count(); + int navigation_layers_count = tile_set->get_navigation_layers_count(); + + if (physics_layers_count <= 0 && navigation_layers_count <= 0) { + return; + } + + const Transform2D tilemap_xform = tilemap->get_transform(); + TypedArray used_cells = tilemap->get_used_cells(tilemap_layer); + + 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); + + Transform2D tile_transform; + tile_transform.set_origin(tilemap->map_to_local(cell)); + + const Transform2D tile_transform_offset = tilemap_xform * tile_transform; + + if (navigation_layers_count > 0) { + 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); + + 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]); + } + + p_source_geometry->_add_traversable_outline(traversable_outline); + } + } + } + + if (physics_layers_count > 0 && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_MESH_INSTANCES && (tile_set->get_physics_layer_collision_layer(tilemap_layer) & navigation_polygon_collision_mask)) { + for (int collision_polygon_index = 0; collision_polygon_index < tile_data->get_collision_polygons_count(tilemap_layer); collision_polygon_index++) { + Vector obstruction_outline = tile_data->get_collision_polygon_points(tilemap_layer, collision_polygon_index); + + for (int obstruction_outline_index = 0; obstruction_outline_index < obstruction_outline.size(); obstruction_outline_index++) { + obstruction_outline.write[obstruction_outline_index] = tile_transform_offset.xform(obstruction_outline[obstruction_outline_index]); + } + + p_source_geometry->_add_obstruction_outline(obstruction_outline); + } + } + } + } +#endif // CLIPPER_ENABLED +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.h b/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.h new file mode 100644 index 000000000..cba1e3671 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_2d/tilemap_navigation_geometry_parser_2d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* tilemap_navigation_geometry_parser_2d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef TILEMAP_NAVIGATION_GEOMETRY_PARSER_2D_H +#define TILEMAP_NAVIGATION_GEOMETRY_PARSER_2D_H + +#include "scene/2d/navigation_geometry_parser_2d.h" + +class TileMap2DNavigationGeometryParser2D : public NavigationGeometryParser2D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigation_polygon, Ref p_source_geometry) override; +}; + +#endif // TILEMAP_NAVIGATION_GEOMETRY_PARSER_2D_H diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.cpp b/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.cpp new file mode 100644 index 000000000..264308898 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.cpp @@ -0,0 +1,49 @@ +/**************************************************************************/ +/* meshinstance3d_navigation_geometry_parser_3d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "meshinstance3d_navigation_geometry_parser_3d.h" + +#include "scene/3d/mesh_instance_3d.h" + +bool MeshInstance3DNavigationGeometryParser3D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void MeshInstance3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) { + NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigationmesh->get_parsed_geometry_type(); + + if (Object::cast_to(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { + MeshInstance3D *mesh_instance = Object::cast_to(p_node); + Ref mesh = mesh_instance->get_mesh(); + if (mesh.is_valid()) { + p_source_geometry->add_mesh(mesh, mesh_instance->get_global_transform()); + } + } +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.h b/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.h new file mode 100644 index 000000000..9e50d9401 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/meshinstance3d_navigation_geometry_parser_3d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* meshinstance3d_navigation_geometry_parser_3d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef MESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H +#define MESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H + +#include "scene/3d/navigation_geometry_parser_3d.h" + +class MeshInstance3DNavigationGeometryParser3D : public NavigationGeometryParser3D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) override; +}; + +#endif // MESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.cpp b/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.cpp new file mode 100644 index 000000000..6a934bfc8 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.cpp @@ -0,0 +1,58 @@ +/**************************************************************************/ +/* multimeshinstance3d_navigation_geometry_parser_3d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "multimeshinstance3d_navigation_geometry_parser_3d.h" + +#include "scene/3d/multimesh_instance_3d.h" + +bool MultiMeshInstance3DNavigationGeometryParser3D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void MultiMeshInstance3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) { + NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigationmesh->get_parsed_geometry_type(); + + if (Object::cast_to(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { + MultiMeshInstance3D *multimesh_instance = Object::cast_to(p_node); + Ref multimesh = multimesh_instance->get_multimesh(); + if (multimesh.is_valid()) { + Ref mesh = multimesh->get_mesh(); + if (mesh.is_valid()) { + int n = multimesh->get_visible_instance_count(); + if (n == -1) { + n = multimesh->get_instance_count(); + } + for (int i = 0; i < n; i++) { + p_source_geometry->add_mesh(mesh, multimesh_instance->get_global_transform() * multimesh->get_instance_transform(i)); + } + } + } + } +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.h b/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.h new file mode 100644 index 000000000..822710755 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/multimeshinstance3d_navigation_geometry_parser_3d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* multimeshinstance3d_navigation_geometry_parser_3d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef MULTIMESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H +#define MULTIMESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H + +#include "scene/3d/navigation_geometry_parser_3d.h" + +class MultiMeshInstance3DNavigationGeometryParser3D : public NavigationGeometryParser3D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) override; +}; + +#endif // MULTIMESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.cpp b/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.cpp new file mode 100644 index 000000000..796b16461 --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.cpp @@ -0,0 +1,179 @@ +/**************************************************************************/ +/* staticbody3d_navigation_geometry_parser_3d.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "staticbody3d_navigation_geometry_parser_3d.h" + +#include "core/math/convex_hull.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/resources/box_shape_3d.h" +#include "scene/resources/capsule_shape_3d.h" +#include "scene/resources/concave_polygon_shape_3d.h" +#include "scene/resources/convex_polygon_shape_3d.h" +#include "scene/resources/cylinder_shape_3d.h" +#include "scene/resources/height_map_shape_3d.h" +#include "scene/resources/primitive_meshes.h" +#include "scene/resources/shape_3d.h" +#include "scene/resources/sphere_shape_3d.h" +#include "scene/resources/world_boundary_shape_3d.h" + +bool StaticBody3DNavigationGeometryParser3D::parses_node(Node *p_node) { + return (Object::cast_to(p_node) != nullptr); +} + +void StaticBody3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) { + NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigationmesh->get_parsed_geometry_type(); + uint32_t navigationmesh_collision_mask = p_navigationmesh->get_collision_mask(); + + if (Object::cast_to(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) { + StaticBody3D *static_body = Object::cast_to(p_node); + if (static_body->get_collision_layer() & navigationmesh_collision_mask) { + List shape_owners; + static_body->get_shape_owners(&shape_owners); + for (uint32_t shape_owner : shape_owners) { + if (static_body->is_shape_owner_disabled(shape_owner)) { + continue; + } + const int shape_count = static_body->shape_owner_get_shape_count(shape_owner); + for (int shape_index = 0; shape_index < shape_count; shape_index++) { + Ref s = static_body->shape_owner_get_shape(shape_owner, shape_index); + if (s.is_null()) { + continue; + } + + const Transform3D transform = static_body->get_global_transform() * static_body->shape_owner_get_transform(shape_owner); + + BoxShape3D *box = Object::cast_to(*s); + if (box) { + Array arr; + arr.resize(RS::ARRAY_MAX); + BoxMesh::create_mesh_array(arr, box->get_size()); + p_source_geometry->add_mesh_array(arr, transform); + } + + CapsuleShape3D *capsule = Object::cast_to(*s); + if (capsule) { + Array arr; + arr.resize(RS::ARRAY_MAX); + CapsuleMesh::create_mesh_array(arr, capsule->get_radius(), capsule->get_height()); + p_source_geometry->add_mesh_array(arr, transform); + } + + CylinderShape3D *cylinder = Object::cast_to(*s); + if (cylinder) { + Array arr; + arr.resize(RS::ARRAY_MAX); + CylinderMesh::create_mesh_array(arr, cylinder->get_radius(), cylinder->get_radius(), cylinder->get_height()); + p_source_geometry->add_mesh_array(arr, transform); + } + + SphereShape3D *sphere = Object::cast_to(*s); + if (sphere) { + Array arr; + arr.resize(RS::ARRAY_MAX); + SphereMesh::create_mesh_array(arr, sphere->get_radius(), sphere->get_radius() * 2.0); + p_source_geometry->add_mesh_array(arr, transform); + } + + ConcavePolygonShape3D *concave_polygon = Object::cast_to(*s); + if (concave_polygon) { + p_source_geometry->add_faces(concave_polygon->get_faces(), transform); + } + + ConvexPolygonShape3D *convex_polygon = Object::cast_to(*s); + if (convex_polygon) { + Vector varr = Variant(convex_polygon->get_points()); + Geometry3D::MeshData md; + + Error err = ConvexHullComputer::convex_hull(varr, md); + + if (err == OK) { + PackedVector3Array faces; + + for (const Geometry3D::MeshData::Face &face : md.faces) { + for (uint32_t k = 2; k < face.indices.size(); ++k) { + faces.push_back(md.vertices[face.indices[0]]); + faces.push_back(md.vertices[face.indices[k - 1]]); + faces.push_back(md.vertices[face.indices[k]]); + } + } + + p_source_geometry->add_faces(faces, transform); + } + } + + HeightMapShape3D *heightmap_shape = Object::cast_to(*s); + if (heightmap_shape) { + int heightmap_depth = heightmap_shape->get_map_depth(); + int heightmap_width = heightmap_shape->get_map_width(); + + if (heightmap_depth >= 2 && heightmap_width >= 2) { + const Vector &map_data = heightmap_shape->get_map_data(); + + Vector2 heightmap_gridsize(heightmap_width - 1, heightmap_depth - 1); + Vector2 start = heightmap_gridsize * -0.5; + + Vector vertex_array; + vertex_array.resize((heightmap_depth - 1) * (heightmap_width - 1) * 6); + int map_data_current_index = 0; + + for (int d = 0; d < heightmap_depth; d++) { + for (int w = 0; w < heightmap_width; w++) { + if (map_data_current_index + 1 + heightmap_depth < map_data.size()) { + float top_left_height = map_data[map_data_current_index]; + float top_right_height = map_data[map_data_current_index + 1]; + float bottom_left_height = map_data[map_data_current_index + heightmap_depth]; + float bottom_right_height = map_data[map_data_current_index + 1 + heightmap_depth]; + + Vector3 top_left = Vector3(start.x + w, top_left_height, start.y + d); + Vector3 top_right = Vector3(start.x + w + 1.0, top_right_height, start.y + d); + Vector3 bottom_left = Vector3(start.x + w, bottom_left_height, start.y + d + 1.0); + Vector3 bottom_right = Vector3(start.x + w + 1.0, bottom_right_height, start.y + d + 1.0); + + vertex_array.push_back(top_right); + vertex_array.push_back(bottom_left); + vertex_array.push_back(top_left); + vertex_array.push_back(top_right); + vertex_array.push_back(bottom_right); + vertex_array.push_back(bottom_left); + } + map_data_current_index += 1; + } + } + if (vertex_array.size() > 0) { + p_source_geometry->add_faces(vertex_array, transform); + } + } + } + } + } + } + } +} diff --git a/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.h b/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.h new file mode 100644 index 000000000..1576cadbd --- /dev/null +++ b/modules/navigation_geometry_parsers/geometry_parser_3d/staticbody3d_navigation_geometry_parser_3d.h @@ -0,0 +1,43 @@ +/**************************************************************************/ +/* staticbody3d_navigation_geometry_parser_3d.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef STATICBODY3D_NAVIGATION_GEOMETRY_PARSER_3D_H +#define STATICBODY3D_NAVIGATION_GEOMETRY_PARSER_3D_H + +#include "scene/3d/navigation_geometry_parser_3d.h" + +class StaticBody3DNavigationGeometryParser3D : public NavigationGeometryParser3D { +public: + virtual bool parses_node(Node *p_node) override; + + virtual void parse_geometry(Node *p_node, Ref p_navigationmesh, Ref p_source_geometry) override; +}; + +#endif // STATICBODY3D_NAVIGATION_GEOMETRY_PARSER_3D_H diff --git a/modules/navigation_geometry_parsers/register_types.cpp b/modules/navigation_geometry_parsers/register_types.cpp new file mode 100644 index 000000000..c1902c1ef --- /dev/null +++ b/modules/navigation_geometry_parsers/register_types.cpp @@ -0,0 +1,41 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "register_types.h" + +#include "core/config/engine.h" + +void register_navigation_geometry_parsers_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { + } +} + +void unregister_navigation_geometry_parsers_types(ModuleRegistrationLevel p_level) { +} diff --git a/modules/navigation_geometry_parsers/register_types.h b/modules/navigation_geometry_parsers/register_types.h new file mode 100644 index 000000000..a0c6a916e --- /dev/null +++ b/modules/navigation_geometry_parsers/register_types.h @@ -0,0 +1,39 @@ +#ifndef NAVIGATION_GEOMETRY_PARSERS_H +#define NAVIGATION_GEOMETRY_PARSERS_H + +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "modules/register_module_types.h" + +void register_navigation_geometry_parsers_types(ModuleRegistrationLevel p_level); +void unregister_navigation_geometry_parsers_types(ModuleRegistrationLevel p_level); + +#endif \ No newline at end of file