diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-18 22:48:29 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-18 22:48:29 +0300 |
commit | 0038e27fc39a422601bc220d8359ff9d98fd604d (patch) | |
tree | 75e24e1959184e3dae79d73947bc615090b8b0af /scene/2d/navigation2d.cpp | |
parent | f10eb8ffa1a7f6bee9b5228ea1204fd93844e4cc (diff) | |
parent | 37af8b413674936518a2ebe180f9e7bfcd5795bb (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'scene/2d/navigation2d.cpp')
-rw-r--r-- | scene/2d/navigation2d.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 5a02501816..5db0e0a9fc 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -91,9 +91,13 @@ void Navigation2D::_navpoly_link(int p_id) { } else { if (C->get().B!=NULL) { - print_line(String()+_get_vertex(ek.a)+" -> "+_get_vertex(ek.b)); + ConnectionPending pending; + pending.polygon=&p; + pending.edge=j; + p.edges[j].P=C->get().pending.push_back(pending); + continue; + //print_line(String()+_get_vertex(ek.a)+" -> "+_get_vertex(ek.b)); } - ERR_CONTINUE(C->get().B!=NULL); //wut C->get().B=&p; C->get().B_edge=j; @@ -133,7 +137,12 @@ void Navigation2D::_navpoly_unlink(int p_id) { EdgeKey ek(edges[i].point,edges[next].point); Map<EdgeKey,Connection>::Element *C=connections.find(ek); ERR_CONTINUE(!C); - if (C->get().B) { + + if (edges[i].P) { + C->get().pending.erase(edges[i].P); + edges[i].P=NULL; + + } else if (C->get().B) { //disconnect C->get().B->edges[C->get().B_edge].C=NULL; @@ -149,6 +158,20 @@ void Navigation2D::_navpoly_unlink(int p_id) { C->get().B=NULL; C->get().B_edge=-1; + if (C->get().pending.size()) { + //reconnect if something is pending + ConnectionPending cp = C->get().pending.front()->get(); + C->get().pending.pop_front(); + + C->get().B=cp.polygon; + C->get().B_edge=cp.edge; + C->get().A->edges[C->get().A_edge].C=cp.polygon; + C->get().A->edges[C->get().A_edge].C_edge=cp.edge; + cp.polygon->edges[cp.edge].C=C->get().A; + cp.polygon->edges[cp.edge].C_edge=C->get().A_edge; + cp.polygon->edges[cp.edge].P=NULL; + } + } else { connections.erase(C); //erase |