Skip to content

Commit

Permalink
Backport nav server to 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Duroxxigar authored and aaronfranke committed May 4, 2021
1 parent de3168f commit 0e9616b
Show file tree
Hide file tree
Showing 112 changed files with 7,762 additions and 2,033 deletions.
5 changes: 5 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ Comment: Recast
Copyright: 2009, Mikko Mononen
License: Zlib

Files: ./thirdparty/rvo2/
Comment: RVO2
Copyright: 2016, University of North Carolina at Chapel Hill
License: Apache 2.0

Files: ./thirdparty/squish/
Comment: libSquish
Copyright: 2006, Simon Brown
Expand Down
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ opts.Add(BoolVariable("builtin_opus", "Use the built-in Opus library", True))
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True))
opts.Add(BoolVariable("builtin_rvo2", "Use the built-in RVO2 library", True))
opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True))
opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True))
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))
Expand Down
6 changes: 5 additions & 1 deletion doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@
<member name="Marshalls" type="Marshalls" setter="" getter="">
The [Marshalls] singleton.
</member>
<member name="NavigationMeshGenerator" type="EditorNavigationMeshGenerator" setter="" getter="">
<member name="Navigation2DServer" type="Navigation2DServer" setter="" getter="">
</member>
<member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter="">
The [EditorNavigationMeshGenerator] singleton.
</member>
<member name="NavigationServer" type="NavigationServer" setter="" getter="">
</member>
<member name="OS" type="OS" setter="" getter="">
The [OS] singleton.
</member>
Expand Down
55 changes: 16 additions & 39 deletions doc/classes/Navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link>
</tutorials>
<methods>
<method name="get_closest_point">
<method name="get_closest_point" qualifiers="const">
<return type="Vector3">
</return>
<argument index="0" name="to_point" type="Vector3">
Expand All @@ -19,7 +19,7 @@
Returns the navigation point closest to the point given. Points are in local coordinate space.
</description>
</method>
<method name="get_closest_point_normal">
<method name="get_closest_point_normal" qualifiers="const">
<return type="Vector3">
</return>
<argument index="0" name="to_point" type="Vector3">
Expand All @@ -28,16 +28,16 @@
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.
</description>
</method>
<method name="get_closest_point_owner">
<return type="Object">
<method name="get_closest_point_owner" qualifiers="const">
<return type="RID">
</return>
<argument index="0" name="to_point" type="Vector3">
</argument>
<description>
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).
</description>
</method>
<method name="get_closest_point_to_segment">
<method name="get_closest_point_to_segment" qualifiers="const">
<return type="Vector3">
</return>
<argument index="0" name="start" type="Vector3">
Expand All @@ -50,7 +50,13 @@
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.
</description>
</method>
<method name="get_simple_path">
<method name="get_rid" qualifiers="const">
<return type="RID">
</return>
<description>
</description>
</method>
<method name="get_simple_path" qualifiers="const">
<return type="PoolVector3Array">
</return>
<argument index="0" name="start" type="Vector3">
Expand All @@ -63,41 +69,12 @@
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.
</description>
</method>
<method name="navmesh_add">
<return type="int">
</return>
<argument index="0" name="mesh" type="NavigationMesh">
</argument>
<argument index="1" name="xform" type="Transform">
</argument>
<argument index="2" name="owner" type="Object" default="null">
</argument>
<description>
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].
</description>
</method>
<method name="navmesh_remove">
<return type="void">
</return>
<argument index="0" name="id" type="int">
</argument>
<description>
Removes the [NavigationMesh] with the given ID.
</description>
</method>
<method name="navmesh_set_transform">
<return type="void">
</return>
<argument index="0" name="id" type="int">
</argument>
<argument index="1" name="xform" type="Transform">
</argument>
<description>
Sets the transform applied to the [NavigationMesh] with the given ID.
</description>
</method>
</methods>
<members>
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="0.3">
</member>
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="5.0">
</member>
<member name="up_vector" type="Vector3" setter="set_up_vector" getter="get_up_vector" default="Vector3( 0, 1, 0 )">
Defines which direction is up. By default, this is [code](0, 1, 0)[/code], which is the world's "up" direction.
</member>
Expand Down
53 changes: 16 additions & 37 deletions doc/classes/Navigation2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
</tutorials>
<methods>
<method name="get_closest_point">
<method name="get_closest_point" qualifiers="const">
<return type="Vector2">
</return>
<argument index="0" name="to_point" type="Vector2">
Expand All @@ -19,16 +19,22 @@
Returns the navigation point closest to the point given. Points are in local coordinate space.
</description>
</method>
<method name="get_closest_point_owner">
<return type="Object">
<method name="get_closest_point_owner" qualifiers="const">
<return type="RID">
</return>
<argument index="0" name="to_point" type="Vector2">
</argument>
<description>
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).
</description>
</method>
<method name="get_simple_path">
<method name="get_rid" qualifiers="const">
<return type="RID">
</return>
<description>
</description>
</method>
<method name="get_simple_path" qualifiers="const">
<return type="PoolVector2Array">
</return>
<argument index="0" name="start" type="Vector2">
Expand All @@ -41,40 +47,13 @@
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.
</description>
</method>
<method name="navpoly_add">
<return type="int">
</return>
<argument index="0" name="mesh" type="NavigationPolygon">
</argument>
<argument index="1" name="xform" type="Transform2D">
</argument>
<argument index="2" name="owner" type="Object" default="null">
</argument>
<description>
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].
</description>
</method>
<method name="navpoly_remove">
<return type="void">
</return>
<argument index="0" name="id" type="int">
</argument>
<description>
Removes the [NavigationPolygon] with the given ID.
</description>
</method>
<method name="navpoly_set_transform">
<return type="void">
</return>
<argument index="0" name="id" type="int">
</argument>
<argument index="1" name="xform" type="Transform2D">
</argument>
<description>
Sets the transform applied to the [NavigationPolygon] with the given ID.
</description>
</method>
</methods>
<members>
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size" default="10.0">
</member>
<member name="edge_connection_margin" type="float" setter="set_edge_connection_margin" getter="get_edge_connection_margin" default="100.0">
</member>
</members>
<constants>
</constants>
</class>
165 changes: 165 additions & 0 deletions doc/classes/NavigationAgent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="NavigationAgent" inherits="Node" version="3.4">
<brief_description>
3D Agent used in navigation for collision avoidance.
</brief_description>
<description>
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.
</description>
<tutorials>
</tutorials>
<methods>
<method name="distance_to_target" qualifiers="const">
<return type="float">
</return>
<description>
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.
</description>
</method>
<method name="get_final_location">
<return type="Vector3">
</return>
<description>
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.
</description>
</method>
<method name="get_nav_path" qualifiers="const">
<return type="PoolVector3Array">
</return>
<description>
Returns the path from start to finish in global coordinates.
</description>
</method>
<method name="get_nav_path_index" qualifiers="const">
<return type="int">
</return>
<description>
Returns which index the agent is currently on in the navigation path's [PoolVector3Array].
</description>
</method>
<method name="get_navigation" qualifiers="const">
<return type="Node">
</return>
<description>
Returns the [Navigation] node that the agent is using for its navigation system.
</description>
</method>
<method name="get_next_location">
<return type="Vector3">
</return>
<description>
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.
</description>
</method>
<method name="get_target_location" qualifiers="const">
<return type="Vector3">
</return>
<description>
Returns the user defined [Vector3] after setting the target location.
</description>
</method>
<method name="is_navigation_finished">
<return type="bool">
</return>
<description>
Returns true if the navigation path's final location has been reached.
</description>
</method>
<method name="is_target_reachable">
<return type="bool">
</return>
<description>
Returns true if the target location is reachable. The target location is set using [method set_target_location].
</description>
</method>
<method name="is_target_reached" qualifiers="const">
<return type="bool">
</return>
<description>
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].
</description>
</method>
<method name="set_navigation">
<return type="void">
</return>
<argument index="0" name="navigation" type="Node">
</argument>
<description>
Sets the [Navigation] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation] node.
</description>
</method>
<method name="set_target_location">
<return type="void">
</return>
<argument index="0" name="location" type="Vector3">
</argument>
<description>
Sets the user desired final location. This will clear the current navigation path.
</description>
</method>
<method name="set_velocity">
<return type="void">
</return>
<argument index="0" name="velocity" type="Vector3">
</argument>
<description>
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.
</description>
</method>
</methods>
<members>
<member name="agent_height_offset" type="float" setter="set_agent_height_offset" getter="get_agent_height_offset" default="0.0">
The agent height offset to match the navigation mesh height.
</member>
<member name="ignore_y" type="bool" setter="set_ignore_y" getter="get_ignore_y" default="true">
Ignores collisions on the Y axis. Must be true to move on a horizontal plane.
</member>
<member name="max_neighbors" type="int" setter="set_max_neighbors" getter="get_max_neighbors" default="10">
The maximum number of neighbors for the agent to consider.
</member>
<member name="max_speed" type="float" setter="set_max_speed" getter="get_max_speed" default="10.0">
The maximum speed that an agent can move.
</member>
<member name="neighbor_dist" type="float" setter="set_neighbor_dist" getter="get_neighbor_dist" default="50.0">
The distance to search for other agents.
</member>
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="3.0">
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.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
The radius of the agent.
</member>
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="1.0">
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.
</member>
<member name="time_horizon" type="float" setter="set_time_horizon" getter="get_time_horizon" default="5.0">
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.
</member>
</members>
<signals>
<signal name="navigation_finished">
<description>
Notifies when the final location is reached.
</description>
</signal>
<signal name="path_changed">
<description>
Notifies when the navigation path changes.
</description>
</signal>
<signal name="target_reached">
<description>
Notifies when the player defined target, set with [method set_target_location], is reached.
</description>
</signal>
<signal name="velocity_computed">
<argument index="0" name="safe_velocity" type="Vector3">
</argument>
<description>
Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity].
</description>
</signal>
</signals>
<constants>
</constants>
</class>
Loading

0 comments on commit 0e9616b

Please sign in to comment.