Skip to content

Commit 0e9616b

Browse files
Duroxxigaraaronfranke
authored andcommitted
Backport nav server to 3.x
1 parent de3168f commit 0e9616b

112 files changed

Lines changed: 7762 additions & 2033 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

COPYRIGHT.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ Comment: Recast
347347
Copyright: 2009, Mikko Mononen
348348
License: Zlib
349349

350+
Files: ./thirdparty/rvo2/
351+
Comment: RVO2
352+
Copyright: 2016, University of North Carolina at Chapel Hill
353+
License: Apache 2.0
354+
350355
Files: ./thirdparty/squish/
351356
Comment: libSquish
352357
Copyright: 2006, Simon Brown

SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ opts.Add(BoolVariable("builtin_opus", "Use the built-in Opus library", True))
167167
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True))
168168
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
169169
opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True))
170+
opts.Add(BoolVariable("builtin_rvo2", "Use the built-in RVO2 library", True))
170171
opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True))
171172
opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True))
172173
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))

doc/classes/@GlobalScope.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@
5353
<member name="Marshalls" type="Marshalls" setter="" getter="">
5454
The [Marshalls] singleton.
5555
</member>
56-
<member name="NavigationMeshGenerator" type="EditorNavigationMeshGenerator" setter="" getter="">
56+
<member name="Navigation2DServer" type="Navigation2DServer" setter="" getter="">
57+
</member>
58+
<member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter="">
5759
The [EditorNavigationMeshGenerator] singleton.
5860
</member>
61+
<member name="NavigationServer" type="NavigationServer" setter="" getter="">
62+
</member>
5963
<member name="OS" type="OS" setter="" getter="">
6064
The [OS] singleton.
6165
</member>

doc/classes/Navigation.xml

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link>
1111
</tutorials>
1212
<methods>
13-
<method name="get_closest_point">
13+
<method name="get_closest_point" qualifiers="const">
1414
<return type="Vector3">
1515
</return>
1616
<argument index="0" name="to_point" type="Vector3">
@@ -19,7 +19,7 @@
1919
Returns the navigation point closest to the point given. Points are in local coordinate space.
2020
</description>
2121
</method>
22-
<method name="get_closest_point_normal">
22+
<method name="get_closest_point_normal" qualifiers="const">
2323
<return type="Vector3">
2424
</return>
2525
<argument index="0" name="to_point" type="Vector3">
@@ -28,16 +28,16 @@
2828
Returns the surface normal at the navigation point closest to the point given. Useful for rotating a navigation agent according to the navigation mesh it moves on.
2929
</description>
3030
</method>
31-
<method name="get_closest_point_owner">
32-
<return type="Object">
31+
<method name="get_closest_point_owner" qualifiers="const">
32+
<return type="RID">
3333
</return>
3434
<argument index="0" name="to_point" type="Vector3">
3535
</argument>
3636
<description>
3737
Returns the owner of the [NavigationMesh] which contains the navigation point closest to the point given. This is usually a [NavigationMeshInstance]. For meshes added via [method navmesh_add], returns the owner that was given (or [code]null[/code] if the [code]owner[/code] parameter was omitted).
3838
</description>
3939
</method>
40-
<method name="get_closest_point_to_segment">
40+
<method name="get_closest_point_to_segment" qualifiers="const">
4141
<return type="Vector3">
4242
</return>
4343
<argument index="0" name="start" type="Vector3">
@@ -50,7 +50,13 @@
5050
Returns the navigation point closest to the given line segment. When enabling [code]use_collision[/code], only considers intersection points between segment and navigation meshes. If multiple intersection points are found, the one closest to the segment start point is returned.
5151
</description>
5252
</method>
53-
<method name="get_simple_path">
53+
<method name="get_rid" qualifiers="const">
54+
<return type="RID">
55+
</return>
56+
<description>
57+
</description>
58+
</method>
59+
<method name="get_simple_path" qualifiers="const">
5460
<return type="PoolVector3Array">
5561
</return>
5662
<argument index="0" name="start" type="Vector3">
@@ -63,41 +69,12 @@
6369
Returns the path between two given points. Points are in local coordinate space. If [code]optimize[/code] is [code]true[/code] (the default), the agent properties associated with each [NavigationMesh] (radius, height, etc.) are considered in the path calculation, otherwise they are ignored.
6470
</description>
6571
</method>
66-
<method name="navmesh_add">
67-
<return type="int">
68-
</return>
69-
<argument index="0" name="mesh" type="NavigationMesh">
70-
</argument>
71-
<argument index="1" name="xform" type="Transform">
72-
</argument>
73-
<argument index="2" name="owner" type="Object" default="null">
74-
</argument>
75-
<description>
76-
Adds a [NavigationMesh]. Returns an ID for use with [method navmesh_remove] or [method navmesh_set_transform]. If given, a [Transform2D] is applied to the polygon. The optional [code]owner[/code] is used as return value for [method get_closest_point_owner].
77-
</description>
78-
</method>
79-
<method name="navmesh_remove">
80-
<return type="void">
81-
</return>
82-
<argument index="0" name="id" type="int">
83-
</argument>
84-
<description>
85-
Removes the [NavigationMesh] with the given ID.
86-
</description>
87-
</method>
88-
<method name="navmesh_set_transform">
89-
<return type="void">
90-
</return>
91-
<argument index="0" name="id" type="int">
92-
</argument>
93-
<argument index="1" name="xform" type="Transform">
94-
</argument>
95-
<description>
96-
Sets the transform applied to the [NavigationMesh] with the given ID.
97-
</description>
98-
</method>
9972
</methods>
10073
<members>
74+
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="0.3">
75+
</member>
76+
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="5.0">
77+
</member>
10178
<member name="up_vector" type="Vector3" setter="set_up_vector" getter="get_up_vector" default="Vector3( 0, 1, 0 )">
10279
Defines which direction is up. By default, this is [code](0, 1, 0)[/code], which is the world's "up" direction.
10380
</member>

doc/classes/Navigation2D.xml

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
1111
</tutorials>
1212
<methods>
13-
<method name="get_closest_point">
13+
<method name="get_closest_point" qualifiers="const">
1414
<return type="Vector2">
1515
</return>
1616
<argument index="0" name="to_point" type="Vector2">
@@ -19,16 +19,22 @@
1919
Returns the navigation point closest to the point given. Points are in local coordinate space.
2020
</description>
2121
</method>
22-
<method name="get_closest_point_owner">
23-
<return type="Object">
22+
<method name="get_closest_point_owner" qualifiers="const">
23+
<return type="RID">
2424
</return>
2525
<argument index="0" name="to_point" type="Vector2">
2626
</argument>
2727
<description>
2828
Returns the owner of the [NavigationPolygon] which contains the navigation point closest to the point given. This is usually a [NavigationPolygonInstance]. For polygons added via [method navpoly_add], returns the owner that was given (or [code]null[/code] if the [code]owner[/code] parameter was omitted).
2929
</description>
3030
</method>
31-
<method name="get_simple_path">
31+
<method name="get_rid" qualifiers="const">
32+
<return type="RID">
33+
</return>
34+
<description>
35+
</description>
36+
</method>
37+
<method name="get_simple_path" qualifiers="const">
3238
<return type="PoolVector2Array">
3339
</return>
3440
<argument index="0" name="start" type="Vector2">
@@ -41,40 +47,13 @@
4147
Returns the path between two given points. Points are in local coordinate space. If [code]optimize[/code] is [code]true[/code] (the default), the path is smoothed by merging path segments where possible.
4248
</description>
4349
</method>
44-
<method name="navpoly_add">
45-
<return type="int">
46-
</return>
47-
<argument index="0" name="mesh" type="NavigationPolygon">
48-
</argument>
49-
<argument index="1" name="xform" type="Transform2D">
50-
</argument>
51-
<argument index="2" name="owner" type="Object" default="null">
52-
</argument>
53-
<description>
54-
Adds a [NavigationPolygon]. Returns an ID for use with [method navpoly_remove] or [method navpoly_set_transform]. If given, a [Transform2D] is applied to the polygon. The optional [code]owner[/code] is used as return value for [method get_closest_point_owner].
55-
</description>
56-
</method>
57-
<method name="navpoly_remove">
58-
<return type="void">
59-
</return>
60-
<argument index="0" name="id" type="int">
61-
</argument>
62-
<description>
63-
Removes the [NavigationPolygon] with the given ID.
64-
</description>
65-
</method>
66-
<method name="navpoly_set_transform">
67-
<return type="void">
68-
</return>
69-
<argument index="0" name="id" type="int">
70-
</argument>
71-
<argument index="1" name="xform" type="Transform2D">
72-
</argument>
73-
<description>
74-
Sets the transform applied to the [NavigationPolygon] with the given ID.
75-
</description>
76-
</method>
7750
</methods>
51+
<members>
52+
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="10.0">
53+
</member>
54+
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="100.0">
55+
</member>
56+
</members>
7857
<constants>
7958
</constants>
8059
</class>

doc/classes/NavigationAgent.xml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="NavigationAgent" inherits="Node" version="3.4">
3+
<brief_description>
4+
3D Agent used in navigation for collision avoidance.
5+
</brief_description>
6+
<description>
7+
3D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. This can be done by having the agent as a child of a [Navigation] node, or using [method set_navigation]. [NavigationAgent] is physics safe.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="distance_to_target" qualifiers="const">
13+
<return type="float">
14+
</return>
15+
<description>
16+
Returns the distance to the target location, using the agent's global position. The user must set the target location with [method set_target_location] in order for this to be accurate.
17+
</description>
18+
</method>
19+
<method name="get_final_location">
20+
<return type="Vector3">
21+
</return>
22+
<description>
23+
Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame.
24+
</description>
25+
</method>
26+
<method name="get_nav_path" qualifiers="const">
27+
<return type="PoolVector3Array">
28+
</return>
29+
<description>
30+
Returns the path from start to finish in global coordinates.
31+
</description>
32+
</method>
33+
<method name="get_nav_path_index" qualifiers="const">
34+
<return type="int">
35+
</return>
36+
<description>
37+
Returns which index the agent is currently on in the navigation path's [PoolVector3Array].
38+
</description>
39+
</method>
40+
<method name="get_navigation" qualifiers="const">
41+
<return type="Node">
42+
</return>
43+
<description>
44+
Returns the [Navigation] node that the agent is using for its navigation system.
45+
</description>
46+
</method>
47+
<method name="get_next_location">
48+
<return type="Vector3">
49+
</return>
50+
<description>
51+
Returns a [Vector3] in global coordinates, that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the origin of the agent's parent.
52+
</description>
53+
</method>
54+
<method name="get_target_location" qualifiers="const">
55+
<return type="Vector3">
56+
</return>
57+
<description>
58+
Returns the user defined [Vector3] after setting the target location.
59+
</description>
60+
</method>
61+
<method name="is_navigation_finished">
62+
<return type="bool">
63+
</return>
64+
<description>
65+
Returns true if the navigation path's final location has been reached.
66+
</description>
67+
</method>
68+
<method name="is_target_reachable">
69+
<return type="bool">
70+
</return>
71+
<description>
72+
Returns true if the target location is reachable. The target location is set using [method set_target_location].
73+
</description>
74+
</method>
75+
<method name="is_target_reached" qualifiers="const">
76+
<return type="bool">
77+
</return>
78+
<description>
79+
Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location].
80+
</description>
81+
</method>
82+
<method name="set_navigation">
83+
<return type="void">
84+
</return>
85+
<argument index="0" name="navigation" type="Node">
86+
</argument>
87+
<description>
88+
Sets the [Navigation] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation] node.
89+
</description>
90+
</method>
91+
<method name="set_target_location">
92+
<return type="void">
93+
</return>
94+
<argument index="0" name="location" type="Vector3">
95+
</argument>
96+
<description>
97+
Sets the user desired final location. This will clear the current navigation path.
98+
</description>
99+
</method>
100+
<method name="set_velocity">
101+
<return type="void">
102+
</return>
103+
<argument index="0" name="velocity" type="Vector3">
104+
</argument>
105+
<description>
106+
Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the [signal velocity_computed] signal.
107+
</description>
108+
</method>
109+
</methods>
110+
<members>
111+
<member name="agent_height_offset" type="float" setter="set_agent_height_offset" getter="get_agent_height_offset" default="0.0">
112+
The agent height offset to match the navigation mesh height.
113+
</member>
114+
<member name="ignore_y" type="bool" setter="set_ignore_y" getter="get_ignore_y" default="true">
115+
Ignores collisions on the Y axis. Must be true to move on a horizontal plane.
116+
</member>
117+
<member name="max_neighbors" type="int" setter="set_max_neighbors" getter="get_max_neighbors" default="10">
118+
The maximum number of neighbors for the agent to consider.
119+
</member>
120+
<member name="max_speed" type="float" setter="set_max_speed" getter="get_max_speed" default="10.0">
121+
The maximum speed that an agent can move.
122+
</member>
123+
<member name="neighbor_dist" type="float" setter="set_neighbor_dist" getter="get_neighbor_dist" default="50.0">
124+
The distance to search for other agents.
125+
</member>
126+
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="3.0">
127+
The maximum distance the agent is allowed away from the ideal path to the final location. This can happen due to trying to avoid collisions. When the maximum distance is exceded, it recalculates the ideal path.
128+
</member>
129+
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
130+
The radius of the agent.
131+
</member>
132+
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="1.0">
133+
The distance threshold before a target is considered to be reached. This will allow an agent to not have to hit a point on the path exactly, but in the area.
134+
</member>
135+
<member name="time_horizon" type="float" setter="set_time_horizon" getter="get_time_horizon" default="5.0">
136+
The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithim, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but less freedom in choosing its velocities. Must be positive.
137+
</member>
138+
</members>
139+
<signals>
140+
<signal name="navigation_finished">
141+
<description>
142+
Notifies when the final location is reached.
143+
</description>
144+
</signal>
145+
<signal name="path_changed">
146+
<description>
147+
Notifies when the navigation path changes.
148+
</description>
149+
</signal>
150+
<signal name="target_reached">
151+
<description>
152+
Notifies when the player defined target, set with [method set_target_location], is reached.
153+
</description>
154+
</signal>
155+
<signal name="velocity_computed">
156+
<argument index="0" name="safe_velocity" type="Vector3">
157+
</argument>
158+
<description>
159+
Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity].
160+
</description>
161+
</signal>
162+
</signals>
163+
<constants>
164+
</constants>
165+
</class>

0 commit comments

Comments
 (0)