mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-02 22:35:55 +01:00
Added the GeometryParsers from the NavigationMeshGenerator pr to a new module.
This commit is contained in:
parent
642b5b7159
commit
b4cc1c3096
16
modules/navigation_geometry_parsers/SCsub
Normal file
16
modules/navigation_geometry_parsers/SCsub
Normal file
@ -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
|
7
modules/navigation_geometry_parsers/config.py
Normal file
7
modules/navigation_geometry_parsers/config.py
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
@ -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<MeshInstance2D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void MeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
#ifdef CLIPPER_ENABLED
|
||||
NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type();
|
||||
|
||||
if (Object::cast_to<MeshInstance2D>(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_STATIC_COLLIDERS) {
|
||||
MeshInstance2D *mesh_instance = Object::cast_to<MeshInstance2D>(p_node);
|
||||
Ref<Mesh> 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<Vector2> mesh_vertices = a[Mesh::ARRAY_VERTEX];
|
||||
|
||||
if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
|
||||
Vector<int> 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<Vector<Vector2>> polypaths;
|
||||
|
||||
for (const Path64 &scaled_path : path_solution) {
|
||||
Vector<Vector2> shape_outline;
|
||||
for (const Point64 &scaled_point : scaled_path) {
|
||||
shape_outline.push_back(Point2(static_cast<real_t>(scaled_point.x), static_cast<real_t>(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
|
||||
}
|
@ -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<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // MESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H
|
@ -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<MultiMeshInstance2D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void MultiMeshInstance2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
#ifdef CLIPPER_ENABLED
|
||||
NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type();
|
||||
|
||||
if (Object::cast_to<MultiMeshInstance2D>(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_STATIC_COLLIDERS) {
|
||||
MultiMeshInstance2D *multimesh_instance = Object::cast_to<MultiMeshInstance2D>(p_node);
|
||||
Ref<MultiMesh> multimesh = multimesh_instance->get_multimesh();
|
||||
if (multimesh.is_valid() && multimesh->get_transform_format() == MultiMesh::TRANSFORM_2D) {
|
||||
Ref<Mesh> 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<Vector2> mesh_vertices = a[Mesh::ARRAY_VERTEX];
|
||||
|
||||
if (mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
|
||||
Vector<int> 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<Vector2> shape_outline;
|
||||
|
||||
for (const Point64 &mesh_path_point : mesh_path) {
|
||||
shape_outline.push_back(Point2(static_cast<real_t>(mesh_path_point.x), static_cast<real_t>(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
|
||||
}
|
@ -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<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // MULTIMESHINSTANCE2D_NAVIGATION_GEOMETRY_PARSER_2D_H
|
@ -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<Polygon2D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void Polygon2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
NavigationPolygon::ParsedGeometryType parsed_geometry_type = p_navigation_polygon->get_parsed_geometry_type();
|
||||
|
||||
if (Object::cast_to<Polygon2D>(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_STATIC_COLLIDERS) {
|
||||
Polygon2D *polygon_2d = Object::cast_to<Polygon2D>(p_node);
|
||||
|
||||
const Transform2D transform = polygon_2d->get_global_transform();
|
||||
|
||||
Vector<Vector2> 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);
|
||||
}
|
||||
}
|
@ -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<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // POLYGON2D_NAVIGATION_GEOMETRY_PARSER_2D_H
|
@ -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<StaticBody2D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void StaticBody2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> 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<StaticBody2D>(p_node) && parsed_geometry_type != NavigationPolygon::PARSED_GEOMETRY_MESH_INSTANCES) {
|
||||
StaticBody2D *static_body = Object::cast_to<StaticBody2D>(p_node);
|
||||
if (static_body->get_collision_layer() & navigation_polygon_collision_mask) {
|
||||
List<uint32_t> 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<Shape2D> 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<RectangleShape2D>(*s);
|
||||
if (rectangle_shape) {
|
||||
Vector<Vector2> 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<CapsuleShape2D>(*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<CircleShape2D>(*s);
|
||||
if (circle_shape) {
|
||||
Vector<Vector2> 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<ConcavePolygonShape2D>(*s);
|
||||
if (concave_polygon_shape) {
|
||||
Vector<Vector2> 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<ConvexPolygonShape2D>(*s);
|
||||
if (convex_polygon_shape) {
|
||||
Vector<Vector2> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // STATICBODY2D_NAVIGATION_GEOMETRY_PARSER_2D_H
|
@ -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<TileMap>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void TileMap2DNavigationGeometryParser2D::parse_geometry(Node *p_node, Ref<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) {
|
||||
#ifdef CLIPPER_ENABLED
|
||||
TileMap *tilemap = Object::cast_to<TileMap>(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<TileSet> 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<Vector2i> 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<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);
|
||||
|
||||
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<Vector2> 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
|
||||
}
|
@ -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<NavigationPolygon> p_navigation_polygon, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // TILEMAP_NAVIGATION_GEOMETRY_PARSER_2D_H
|
@ -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<MeshInstance3D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void MeshInstance3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry) {
|
||||
NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigationmesh->get_parsed_geometry_type();
|
||||
|
||||
if (Object::cast_to<MeshInstance3D>(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
|
||||
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
|
||||
Ref<Mesh> mesh = mesh_instance->get_mesh();
|
||||
if (mesh.is_valid()) {
|
||||
p_source_geometry->add_mesh(mesh, mesh_instance->get_global_transform());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // MESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H
|
@ -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<MultiMeshInstance3D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void MultiMeshInstance3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry) {
|
||||
NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigationmesh->get_parsed_geometry_type();
|
||||
|
||||
if (Object::cast_to<MultiMeshInstance3D>(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
|
||||
MultiMeshInstance3D *multimesh_instance = Object::cast_to<MultiMeshInstance3D>(p_node);
|
||||
Ref<MultiMesh> multimesh = multimesh_instance->get_multimesh();
|
||||
if (multimesh.is_valid()) {
|
||||
Ref<Mesh> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // MULTIMESHINSTANCE3D_NAVIGATION_GEOMETRY_PARSER_3D_H
|
@ -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<StaticBody3D>(p_node) != nullptr);
|
||||
}
|
||||
|
||||
void StaticBody3DNavigationGeometryParser3D::parse_geometry(Node *p_node, Ref<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> 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<StaticBody3D>(p_node) && parsed_geometry_type != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
|
||||
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
|
||||
if (static_body->get_collision_layer() & navigationmesh_collision_mask) {
|
||||
List<uint32_t> 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<Shape3D> 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<BoxShape3D>(*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<CapsuleShape3D>(*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<CylinderShape3D>(*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<SphereShape3D>(*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<ConcavePolygonShape3D>(*s);
|
||||
if (concave_polygon) {
|
||||
p_source_geometry->add_faces(concave_polygon->get_faces(), transform);
|
||||
}
|
||||
|
||||
ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
|
||||
if (convex_polygon) {
|
||||
Vector<Vector3> 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<HeightMapShape3D>(*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<real_t> &map_data = heightmap_shape->get_map_data();
|
||||
|
||||
Vector2 heightmap_gridsize(heightmap_width - 1, heightmap_depth - 1);
|
||||
Vector2 start = heightmap_gridsize * -0.5;
|
||||
|
||||
Vector<Vector3> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NavigationMesh> p_navigationmesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry) override;
|
||||
};
|
||||
|
||||
#endif // STATICBODY3D_NAVIGATION_GEOMETRY_PARSER_3D_H
|
41
modules/navigation_geometry_parsers/register_types.cpp
Normal file
41
modules/navigation_geometry_parsers/register_types.cpp
Normal file
@ -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) {
|
||||
}
|
39
modules/navigation_geometry_parsers/register_types.h
Normal file
39
modules/navigation_geometry_parsers/register_types.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user