| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "../nav_rid_3d.h" |
| 34 |
#include "../nav_utils_3d.h" |
| 35 |
#include "nav_mesh_queries_3d.h" |
| 36 |
|
| 37 |
#include "core/math/math_defs.h" |
| 38 |
#include "core/os/semaphore.h" |
| 39 |
|
| 40 |
class NavLinkIteration3D; |
| 41 |
class NavRegion3D; |
| 42 |
class NavRegionIteration3D; |
| 43 |
struct NavMapIteration3D; |
| 44 |
|
| 45 |
struct NavMapIterationBuild3D { |
| 46 |
Vector3 merge_rasterizer_cell_size; |
| 47 |
bool use_edge_connections = true; |
| 48 |
real_t edge_connection_margin; |
| 49 |
real_t link_connection_radius; |
| 50 |
Nav3D::PerformanceData performance_data; |
| 51 |
int polygon_count = 0; |
| 52 |
int free_edge_count = 0; |
| 53 |
|
| 54 |
HashMap<Nav3D::EdgeKey, Nav3D::EdgeConnectionPair, Nav3D::EdgeKey> iter_connection_pairs_map; |
| 55 |
LocalVector<Nav3D::Connection> iter_free_edges; |
| 56 |
|
| 57 |
NavMapIteration3D *map_iteration = nullptr; |
| 58 |
|
| 59 |
int navmesh_polygon_count = 0; |
| 60 |
|
| 61 |
void reset() { |
| 62 |
performance_data.reset(); |
| 63 |
|
| 64 |
iter_connection_pairs_map.clear(); |
| 65 |
iter_free_edges.clear(); |
| 66 |
polygon_count = 0; |
| 67 |
free_edge_count = 0; |
| 68 |
|
| 69 |
navmesh_polygon_count = 0; |
| 70 |
} |
| 71 |
}; |
| 72 |
|
| 73 |
struct NavMapIteration3D { |
| 74 |
mutable SafeNumeric<uint32_t> users; |
| 75 |
RWLock rwlock; |
| 76 |
|
| 77 |
Vector3 map_up; |
| 78 |
|
| 79 |
LocalVector<Ref<NavRegionIteration3D>> region_iterations; |
| 80 |
LocalVector<Ref<NavLinkIteration3D>> link_iterations; |
| 81 |
|
| 82 |
int navmesh_polygon_count = 0; |
| 83 |
|
| 84 |
|
| 85 |
HashMap<const NavBaseIteration3D *, LocalVector<Nav3D::Connection>> external_region_connections; |
| 86 |
HashMap<const NavBaseIteration3D *, LocalVector<LocalVector<Nav3D::Connection>>> navbases_polygons_external_connections; |
| 87 |
|
| 88 |
LocalVector<Nav3D::Polygon> navlink_polygons; |
| 89 |
|
| 90 |
HashMap<NavRegion3D *, Ref<NavRegionIteration3D>> region_ptr_to_region_iteration; |
| 91 |
|
| 92 |
LocalVector<NavMeshQueries3D::PathQuerySlot> path_query_slots; |
| 93 |
Mutex path_query_slots_mutex; |
| 94 |
Semaphore path_query_slots_semaphore; |
| 95 |
|
| 96 |
void clear() { |
| 97 |
map_up = Vector3(); |
| 98 |
navmesh_polygon_count = 0; |
| 99 |
|
| 100 |
region_iterations.clear(); |
| 101 |
link_iterations.clear(); |
| 102 |
external_region_connections.clear(); |
| 103 |
navbases_polygons_external_connections.clear(); |
| 104 |
navlink_polygons.clear(); |
| 105 |
region_ptr_to_region_iteration.clear(); |
| 106 |
} |
| 107 |
}; |
| 108 |
|
| 109 |
class NavMapIterationRead3D { |
| 110 |
const NavMapIteration3D &map_iteration; |
| 111 |
|
| 112 |
public: |
| 113 |
_ALWAYS_INLINE_ NavMapIterationRead3D(const NavMapIteration3D &p_iteration) : |
| 114 |
map_iteration(p_iteration) { |
| 115 |
map_iteration.rwlock.read_lock(); |
| 116 |
map_iteration.users.increment(); |
| 117 |
} |
| 118 |
_ALWAYS_INLINE_ ~NavMapIterationRead3D() { |
| 119 |
map_iteration.users.decrement(); |
| 120 |
map_iteration.rwlock.read_unlock(); |
| 121 |
} |
| 122 |
}; |