Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
6611dfbd
Commit
6611dfbd
authored
Aug 30, 2017
by
Rémi Verschelde
Committed by
GitHub
Aug 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10378 from RandomShaper/nav-keep-start-end
Guarantee start & end points are returned by Navigation2D
parents
a469bb02
ef6e1252
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
navigation2d.cpp
scene/2d/navigation2d.cpp
+14
-12
No files found.
scene/2d/navigation2d.cpp
View file @
6611dfbd
...
...
@@ -476,7 +476,6 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
Polygon
*
left_poly
=
end_poly
;
Polygon
*
right_poly
=
end_poly
;
Polygon
*
p
=
end_poly
;
path
.
push_back
(
end_point
);
while
(
p
)
{
...
...
@@ -534,7 +533,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
left_poly
=
p
;
portal_left
=
apex_point
;
portal_right
=
apex_point
;
if
(
path
[
path
.
size
()
-
1
].
distance_to
(
apex_point
)
>
CMP_EPSILON
)
if
(
!
path
.
size
()
||
path
[
path
.
size
()
-
1
].
distance_to
(
apex_point
)
>
CMP_EPSILON
)
path
.
push_back
(
apex_point
);
skip
=
true
;
//print_line("addpoint left");
...
...
@@ -555,7 +554,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
right_poly
=
p
;
portal_right
=
apex_point
;
portal_left
=
apex_point
;
if
(
path
[
path
.
size
()
-
1
].
distance_to
(
apex_point
)
>
CMP_EPSILON
)
if
(
!
path
.
size
()
||
path
[
path
.
size
()
-
1
].
distance_to
(
apex_point
)
>
CMP_EPSILON
)
path
.
push_back
(
apex_point
);
//print_line("addpoint right");
//print_line("***CLIP RIGHT");
...
...
@@ -568,16 +567,10 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
p
=
NULL
;
}
if
(
path
[
path
.
size
()
-
1
].
distance_to
(
begin_point
)
>
CMP_EPSILON
)
path
.
push_back
(
begin_point
);
path
.
invert
();
}
else
{
//midpoints
Polygon
*
p
=
end_poly
;
path
.
push_back
(
end_point
);
while
(
true
)
{
int
prev
=
p
->
prev_edge
;
int
prev_n
=
(
p
->
prev_edge
+
1
)
%
p
->
edges
.
size
();
...
...
@@ -587,11 +580,20 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
if
(
p
==
begin_poly
)
break
;
}
}
if
(
path
[
path
.
size
()
-
1
].
distance_to
(
begin_point
)
>
CMP_EPSILON
)
path
.
push_back
(
begin_point
);
if
(
!
path
.
size
()
||
path
[
path
.
size
()
-
1
].
distance_squared_to
(
begin_point
)
>
CMP_EPSILON
)
{
path
.
push_back
(
begin_point
);
// Add the begin point
}
else
{
path
[
path
.
size
()
-
1
]
=
begin_point
;
// Replace first midpoint by the exact begin point
}
path
.
invert
();
path
.
invert
();
if
(
path
.
size
()
<=
1
||
path
[
path
.
size
()
-
1
].
distance_squared_to
(
end_point
)
>
CMP_EPSILON
)
{
path
.
push_back
(
end_point
);
// Add the end point
}
else
{
path
[
path
.
size
()
-
1
]
=
end_point
;
// Replace last midpoint by the exact end point
}
return
path
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment