1/**************************************************************************/
2/* nav_region.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef NAV_REGION_H
32#define NAV_REGION_H
33
34#include "nav_base.h"
35#include "nav_utils.h"
36
37#include "scene/resources/navigation_mesh.h"
38
39class NavRegion : public NavBase {
40 NavMap *map = nullptr;
41 Transform3D transform;
42 Ref<NavigationMesh> mesh;
43 Vector<gd::Edge::Connection> connections;
44 bool enabled = true;
45
46 bool use_edge_connections = true;
47
48 bool polygons_dirty = true;
49
50 /// Cache
51 LocalVector<gd::Polygon> polygons;
52
53public:
54 NavRegion() {
55 type = NavigationUtilities::PathSegmentType::PATH_SEGMENT_TYPE_REGION;
56 }
57
58 void scratch_polygons() {
59 polygons_dirty = true;
60 }
61
62 void set_enabled(bool p_enabled);
63 bool get_enabled() const { return enabled; }
64
65 void set_map(NavMap *p_map);
66 NavMap *get_map() const {
67 return map;
68 }
69
70 void set_use_edge_connections(bool p_enabled);
71 bool get_use_edge_connections() const {
72 return use_edge_connections;
73 }
74
75 void set_transform(Transform3D transform);
76 const Transform3D &get_transform() const {
77 return transform;
78 }
79
80 void set_mesh(Ref<NavigationMesh> p_mesh);
81 const Ref<NavigationMesh> get_mesh() const {
82 return mesh;
83 }
84
85 Vector<gd::Edge::Connection> &get_connections() {
86 return connections;
87 }
88 int get_connections_count() const;
89 Vector3 get_connection_pathway_start(int p_connection_id) const;
90 Vector3 get_connection_pathway_end(int p_connection_id) const;
91
92 LocalVector<gd::Polygon> const &get_polygons() const {
93 return polygons;
94 }
95
96 bool sync();
97
98private:
99 void update_polygons();
100};
101
102#endif // NAV_REGION_H
103