diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 00:31:00 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 00:31:00 -0300 |
commit | fd836cad270f7eb9645356cd583c8f11bf737b0f (patch) | |
tree | cf3c430537b27cf0dc902e6a1c12906b93771611 /scene/2d/navigation2d.cpp | |
parent | 9bf7adfc1fcf1e57b5279f3d56983bc222366562 (diff) | |
download | redot-engine-fd836cad270f7eb9645356cd583c8f11bf737b0f.tar.gz |
-Ensure .tscn and .tres always save in a deterministic way, fixes #2495
-Scene edit state is saved outside the scene now, to avoid changes .tscn files when nothing really changed
-Created a VariantWriter helper to unify all variant to text writing
-Moved SceneFormatText writing to VariantWriter
-Moved ConfigFile to use VariantWriter and VariantParser, added compatibility mode for old .cfg files that use engine.cfg format
Diffstat (limited to 'scene/2d/navigation2d.cpp')
-rw-r--r-- | scene/2d/navigation2d.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index b7d51730a0..e2a4de5fac 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -494,7 +494,26 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect open_list.erase(least_cost_poly); } - + { + 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; + } + } if (found_route) { Vector<Vector2> path; @@ -538,22 +557,27 @@ 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 +592,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 +601,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 +615,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"); } } |