Skip to content
0.2.0-dev Download ZIP
91 lines ·3.6 KB Raw
1/**************************************************************************/
2/* nav_region_iteration_3d.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#pragma once
32
33#include "../nav_utils_3d.h"
34#include "nav_base_iteration_3d.h"
35
36#include "core/math/aabb.h"
37
38class NavRegion3D;
39class NavRegionIteration3D;
40
41struct NavRegionIterationBuild3D {
42 Nav3D::PerformanceData performance_data;
43
44 NavRegion3D *region = nullptr;
45
46 Vector3 map_cell_size;
47 Transform3D region_transform;
48
49 struct NavMeshData {
50 Vector<Vector3> vertices;
51 Vector<Vector<int>> polygons;
52
53 void clear() {
54 vertices.clear();
55 polygons.clear();
56 }
57 } navmesh_data;
58
59 Ref<NavRegionIteration3D> region_iteration;
60
61 HashMap<Nav3D::EdgeKey, Nav3D::EdgeConnectionPair, Nav3D::EdgeKey> iter_connection_pairs_map;
62
63 void reset() {
64 performance_data.reset();
65
66 navmesh_data.clear();
67 region_iteration = Ref<NavRegionIteration3D>();
68 iter_connection_pairs_map.clear();
69 }
70};
71
72class NavRegionIteration3D : public NavBaseIteration3D {
73 GDCLASS(NavRegionIteration3D, NavBaseIteration3D);
74
75public:
76 Transform3D transform;
77 real_t surface_area = 0.0;
78 AABB bounds;
79 LocalVector<Nav3D::ConnectableEdge> external_edges;
80
81 const Transform3D &get_transform() const { return transform; }
82 real_t get_surface_area() const { return surface_area; }
83 AABB get_bounds() const { return bounds; }
84 const LocalVector<Nav3D::ConnectableEdge> &get_external_edges() const { return external_edges; }
85
86 virtual ~NavRegionIteration3D() override {
87 external_edges.clear();
88 navmesh_polygons.clear();
89 internal_connections.clear();
90 }
91};