Skip to content

Commit 09bc9eb

Browse files
Duroxxigarakien-mga
authored andcommitted
Backport NavigationServer with RVO2 to 3.x
Change the entire navigation system. Remove editor prefix from nav mesh generator class. It is now used for baking at runtime as well. Navigation supports obstacle avoidance now with the RVO2 library. Nav system will also automatically link all nav meshes together to form one overall complete nav map.
1 parent 571e05d commit 09bc9eb

109 files changed

Lines changed: 7894 additions & 1986 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
@@ -360,6 +360,11 @@ Comment: Recast
360360
Copyright: 2009, Mikko Mononen
361361
License: Zlib
362362

363+
Files: ./thirdparty/rvo2/
364+
Comment: RVO2
365+
Copyright: 2016, University of North Carolina at Chapel Hill
366+
License: Apache-2.0
367+
363368
Files: ./thirdparty/squish/
364369
Comment: libSquish
365370
Copyright: 2006, Simon Brown

SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ opts.Add(BoolVariable("builtin_opus", "Use the built-in Opus library", True))
178178
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True))
179179
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
180180
opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True))
181+
opts.Add(BoolVariable("builtin_rvo2", "Use the built-in RVO2 library", True))
181182
opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True))
182183
opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True))
183184
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))

doc/classes/@GlobalScope.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@
5353
<member name="Marshalls" type="Marshalls" setter="" getter="">
5454
The [Marshalls] singleton.
5555
</member>
56-
<member name="NavigationMeshGenerator" type="EditorNavigationMeshGenerator" setter="" getter="">
57-
The [EditorNavigationMeshGenerator] singleton.
56+
<member name="Navigation2DServer" type="Navigation2DServer" setter="" getter="">
57+
The [Navigation2DServer] singleton.
58+
</member>
59+
<member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter="">
60+
The [NavigationMeshGenerator] singleton.
61+
</member>
62+
<member name="NavigationServer" type="NavigationServer" setter="" getter="">
63+
The [NavigationServer] singleton.
5864
</member>
5965
<member name="OS" type="OS" setter="" getter="">
6066
The [OS] singleton.

doc/classes/Navigation.xml

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,34 @@
44
Mesh-based navigation and pathfinding node.
55
</brief_description>
66
<description>
7-
Provides navigation and pathfinding within a collection of [NavigationMesh]es. By default, these will be automatically collected from child [NavigationMeshInstance] nodes, but they can also be added on the fly with [method navmesh_add]. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.
8-
[b]Note:[/b] The current navigation system has many known issues and will not always return optimal paths as expected. These issues will be fixed in Godot 4.0.
7+
Provides navigation and pathfinding within a collection of [NavigationMesh]es. By default, these will be automatically collected from child [NavigationMeshInstance] nodes. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.
98
</description>
109
<tutorials>
1110
<link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link>
1211
</tutorials>
1312
<methods>
14-
<method name="get_closest_point">
13+
<method name="get_closest_point" qualifiers="const">
1514
<return type="Vector3" />
1615
<argument index="0" name="to_point" type="Vector3" />
1716
<description>
1817
Returns the navigation point closest to the point given. Points are in local coordinate space.
1918
</description>
2019
</method>
21-
<method name="get_closest_point_normal">
20+
<method name="get_closest_point_normal" qualifiers="const">
2221
<return type="Vector3" />
2322
<argument index="0" name="to_point" type="Vector3" />
2423
<description>
2524
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.
2625
</description>
2726
</method>
28-
<method name="get_closest_point_owner">
29-
<return type="Object" />
27+
<method name="get_closest_point_owner" qualifiers="const">
28+
<return type="RID" />
3029
<argument index="0" name="to_point" type="Vector3" />
3130
<description>
32-
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).
31+
Returns the owner of the [NavigationMesh] which contains the navigation point closest to the point given. This is usually a [NavigationMeshInstance].
3332
</description>
3433
</method>
35-
<method name="get_closest_point_to_segment">
34+
<method name="get_closest_point_to_segment" qualifiers="const">
3635
<return type="Vector3" />
3736
<argument index="0" name="start" type="Vector3" />
3837
<argument index="1" name="end" type="Vector3" />
@@ -41,42 +40,29 @@
4140
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.
4241
</description>
4342
</method>
44-
<method name="get_simple_path">
43+
<method name="get_rid" qualifiers="const">
44+
<return type="RID" />
45+
<description>
46+
Returns the object's [RID].
47+
</description>
48+
</method>
49+
<method name="get_simple_path" qualifiers="const">
4550
<return type="PoolVector3Array" />
4651
<argument index="0" name="start" type="Vector3" />
4752
<argument index="1" name="end" type="Vector3" />
4853
<argument index="2" name="optimize" type="bool" default="true" />
4954
<description>
5055
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.
51-
[b]Note:[/b] This method has known issues and will often return non-optimal paths. These issues will be fixed in Godot 4.0.
52-
</description>
53-
</method>
54-
<method name="navmesh_add">
55-
<return type="int" />
56-
<argument index="0" name="mesh" type="NavigationMesh" />
57-
<argument index="1" name="xform" type="Transform" />
58-
<argument index="2" name="owner" type="Object" default="null" />
59-
<description>
60-
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].
61-
</description>
62-
</method>
63-
<method name="navmesh_remove">
64-
<return type="void" />
65-
<argument index="0" name="id" type="int" />
66-
<description>
67-
Removes the [NavigationMesh] with the given ID.
68-
</description>
69-
</method>
70-
<method name="navmesh_set_transform">
71-
<return type="void" />
72-
<argument index="0" name="id" type="int" />
73-
<argument index="1" name="xform" type="Transform" />
74-
<description>
75-
Sets the transform applied to the [NavigationMesh] with the given ID.
7656
</description>
7757
</method>
7858
</methods>
7959
<members>
60+
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="0.3">
61+
The XZ plane cell size to use for fields.
62+
</member>
63+
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="5.0">
64+
This value is used to detect the near edges to connect compatible regions.
65+
</member>
8066
<member name="up_vector" type="Vector3" setter="set_up_vector" getter="get_up_vector" default="Vector3( 0, 1, 0 )">
8167
Defines which direction is up. By default, this is [code](0, 1, 0)[/code], which is the world's "up" direction.
8268
</member>

doc/classes/Navigation2D.xml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,50 @@
44
2D navigation and pathfinding node.
55
</brief_description>
66
<description>
7-
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of [NavigationPolygon] resources. By default, these are automatically collected from child [NavigationPolygonInstance] nodes, but they can also be added on the fly with [method navpoly_add].
8-
[b]Note:[/b] The current navigation system has many known issues and will not always return optimal paths as expected. These issues will be fixed in Godot 4.0.
7+
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of [NavigationPolygon] resources. By default, these are automatically collected from child [NavigationPolygonInstance] nodes.
98
</description>
109
<tutorials>
1110
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
1211
</tutorials>
1312
<methods>
14-
<method name="get_closest_point">
13+
<method name="get_closest_point" qualifiers="const">
1514
<return type="Vector2" />
1615
<argument index="0" name="to_point" type="Vector2" />
1716
<description>
1817
Returns the navigation point closest to the point given. Points are in local coordinate space.
1918
</description>
2019
</method>
21-
<method name="get_closest_point_owner">
22-
<return type="Object" />
20+
<method name="get_closest_point_owner" qualifiers="const">
21+
<return type="RID" />
2322
<argument index="0" name="to_point" type="Vector2" />
2423
<description>
25-
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).
24+
Returns the owner of the [NavigationPolygon] which contains the navigation point closest to the point given. This is usually a [NavigationPolygonInstance].
2625
</description>
2726
</method>
28-
<method name="get_simple_path">
27+
<method name="get_rid" qualifiers="const">
28+
<return type="RID" />
29+
<description>
30+
Returns the object's [RID].
31+
</description>
32+
</method>
33+
<method name="get_simple_path" qualifiers="const">
2934
<return type="PoolVector2Array" />
3035
<argument index="0" name="start" type="Vector2" />
3136
<argument index="1" name="end" type="Vector2" />
3237
<argument index="2" name="optimize" type="bool" default="true" />
3338
<description>
3439
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.
35-
[b]Note:[/b] This method has known issues and will often return non-optimal paths. These issues will be fixed in Godot 4.0.
36-
</description>
37-
</method>
38-
<method name="navpoly_add">
39-
<return type="int" />
40-
<argument index="0" name="mesh" type="NavigationPolygon" />
41-
<argument index="1" name="xform" type="Transform2D" />
42-
<argument index="2" name="owner" type="Object" default="null" />
43-
<description>
44-
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].
45-
</description>
46-
</method>
47-
<method name="navpoly_remove">
48-
<return type="void" />
49-
<argument index="0" name="id" type="int" />
50-
<description>
51-
Removes the [NavigationPolygon] with the given ID.
52-
</description>
53-
</method>
54-
<method name="navpoly_set_transform">
55-
<return type="void" />
56-
<argument index="0" name="id" type="int" />
57-
<argument index="1" name="xform" type="Transform2D" />
58-
<description>
59-
Sets the transform applied to the [NavigationPolygon] with the given ID.
6040
</description>
6141
</method>
6242
</methods>
43+
<members>
44+
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="10.0">
45+
The XY plane cell size to use for fields.
46+
</member>
47+
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="100.0">
48+
This value is used to detect the near edges to connect compatible regions.
49+
</member>
50+
</members>
6351
<constants>
6452
</constants>
6553
</class>

0 commit comments

Comments
 (0)