summaryrefslogtreecommitdiff
path: root/scene/3d/navigation.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-06-06 11:09:00 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-06-06 11:09:00 -0300
commit954256268afe89b648d356ee0b296a9e97a07373 (patch)
tree36c42fb01f05d26bbae438d470676c9487b47a04 /scene/3d/navigation.cpp
parent0e1510214a7585d5446f06344468ab52298cfa81 (diff)
parentab99671bb835a5fe24a092ec34afe1ad862ac254 (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Conflicts: demos/2d/motion/engine.cfg
Diffstat (limited to 'scene/3d/navigation.cpp')
-rw-r--r--scene/3d/navigation.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 48820706dd..bfa8add09c 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -85,9 +85,14 @@ void Navigation::_navmesh_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
+ //ERR_CONTINUE(C->get().B!=NULL); //wut
C->get().B=&p;
C->get().B_edge=j;
@@ -126,8 +131,13 @@ void Navigation::_navmesh_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;
@@ -143,6 +153,20 @@ void Navigation::_navmesh_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