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

Method disconnect_points

core/math/a_star.cpp:172–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void AStar3D::disconnect_points(int64_t p_id, int64_t p_with_id, bool bidirectional) {
173 Point **a_entry = points.getptr(p_id);
174 ERR_FAIL_COND_MSG(!a_entry, vformat("Can't disconnect points. Point with id: %d doesn't exist.", p_id));
175 Point *a = *a_entry;
176
177 Point **b_entry = points.getptr(p_with_id);
178 ERR_FAIL_COND_MSG(!b_entry, vformat("Can't disconnect points. Point with id: %d doesn't exist.", p_with_id));
179 Point *b = *b_entry;
180
181 Segment s(p_id, p_with_id);
182 int remove_direction = bidirectional ? (int)Segment::BIDIRECTIONAL : (int)s.direction;
183
184 HashSet<Segment, Segment>::Iterator element = segments.find(s);
185 if (element) {
186 // s is the new segment
187 // Erase the directions to be removed
188 s.direction = (element->direction & ~remove_direction);
189
190 a->neighbors.erase(b->id);
191 if (bidirectional) {
192 b->neighbors.erase(a->id);
193 if (element->direction != Segment::BIDIRECTIONAL) {
194 a->unlinked_neighbours.erase(b->id);
195 b->unlinked_neighbours.erase(a->id);
196 }
197 } else {
198 if (s.direction == Segment::NONE) {
199 b->unlinked_neighbours.erase(a->id);
200 } else {
201 a->unlinked_neighbours.insert(b->id, b);
202 }
203 }
204
205 segments.remove(element);
206 if (s.direction != Segment::NONE) {
207 segments.insert(s);
208 }
209 }
210}
211
212bool AStar3D::has_point(int64_t p_id) const {
213 return points.has(p_id);

Callers 1

test_astar.hFile · 0.80

Calls 6

vformatFunction · 0.85
getptrMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected