MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / query_path

Method query_path

modules/navigation_2d/nav_map_2d.cpp:135–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void NavMap2D::query_path(NavMeshQueries2D::NavMeshPathQueryTask2D &p_query_task) {
136 if (iteration_id == 0) {
137 return;
138 }
139
140 GET_MAP_ITERATION();
141
142 map_iteration.path_query_slots_semaphore.wait();
143
144 map_iteration.path_query_slots_mutex.lock();
145 for (NavMeshQueries2D::PathQuerySlot &p_path_query_slot : map_iteration.path_query_slots) {
146 if (!p_path_query_slot.in_use) {
147 p_path_query_slot.in_use = true;
148 p_query_task.path_query_slot = &p_path_query_slot;
149 break;
150 }
151 }
152 map_iteration.path_query_slots_mutex.unlock();
153
154 if (p_query_task.path_query_slot == nullptr) {
155 map_iteration.path_query_slots_semaphore.post();
156 ERR_FAIL_NULL_MSG(p_query_task.path_query_slot, "No unused NavMap2D path query slot found! This should never happen :(.");
157 }
158
159 NavMeshQueries2D::query_task_map_iteration_get_path(p_query_task, map_iteration);
160
161 map_iteration.path_query_slots_mutex.lock();
162 uint32_t used_slot_index = p_query_task.path_query_slot->slot_index;
163 map_iteration.path_query_slots[used_slot_index].in_use = false;
164 p_query_task.path_query_slot = nullptr;
165 map_iteration.path_query_slots_mutex.unlock();
166
167 map_iteration.path_query_slots_semaphore.post();
168}
169
170Vector2 NavMap2D::get_closest_point(const Vector2 &p_point) const {
171 if (iteration_id == 0) {

Calls 4

waitMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected