summaryrefslogtreecommitdiff
path: root/scene/2d/navigation2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/navigation2d.cpp')
-rw-r--r--scene/2d/navigation2d.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index b7d51730a0..fe1760b84a 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -494,7 +494,29 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
open_list.erase(least_cost_poly);
}
-
+#if 0
+debug path
+ {
+ Polygon *p=end_poly;
+ int idx=0;
+
+ while(true) {
+ int prev = p->prev_edge;
+ int prev_n = (p->prev_edge+1)%p->edges.size();
+ Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5;
+ String points;
+ for(int i=0;i<p->edges.size();i++) {
+ if (i>0)
+ points+=", ";
+ points+=_get_vertex(p->edges[i].point);
+ }
+ //print_line("poly "+itos(idx++)+" - "+points);
+ p = p->edges[prev].C;
+ if (p==begin_poly)
+ break;
+ }
+ }
+#endif
if (found_route) {
Vector<Vector2> path;
@@ -538,22 +560,29 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
bool skip=false;
- /* print_line("-----\nAPEX: "+(apex_point-end_point));
+ /*
+ print_line("-----\nAPEX: "+(apex_point-end_point));
print_line("LEFT:");
print_line("\tPortal: "+(portal_left-end_point));
print_line("\tPoint: "+(left-end_point));
- print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_left,left) >= 0));
+ print_line("\tLeft Tangent: "+rtos(CLOCK_TANGENT(apex_point,portal_left,left)));
+ print_line("\tLeft Distance: "+rtos(portal_left.distance_squared_to(apex_point)));
+ print_line("\tLeft Test: "+rtos(CLOCK_TANGENT(apex_point,left,portal_right)));
print_line("RIGHT:");
print_line("\tPortal: "+(portal_right-end_point));
print_line("\tPoint: "+(right-end_point));
- print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_right,right) <= 0));
-*/
+ print_line("\tRight Tangent: "+rtos(CLOCK_TANGENT(apex_point,portal_right,right)));
+ print_line("\tRight Distance: "+rtos(portal_right.distance_squared_to(apex_point)));
+ print_line("\tRight Test: "+rtos(CLOCK_TANGENT(apex_point,right,portal_left)));
+ */
+
if (CLOCK_TANGENT(apex_point,portal_left,left) >= 0){
//process
if (portal_left.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,left,portal_right) > 0) {
left_poly=p;
portal_left=left;
+ //print_line("***ADVANCE LEFT");
} else {
//_clip_path(path,apex_poly,portal_right,right_poly);
@@ -568,6 +597,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
path.push_back(apex_point);
skip=true;
//print_line("addpoint left");
+ //print_line("***CLIP LEFT");
}
}
@@ -576,6 +606,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
if (portal_right.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,right,portal_left) < 0) {
right_poly=p;
portal_right=right;
+ //print_line("***ADVANCE RIGHT");
} else {
//_clip_path(path,apex_poly,portal_left,left_poly);
@@ -589,6 +620,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON)
path.push_back(apex_point);
//print_line("addpoint right");
+ //print_line("***CLIP RIGHT");
}
}