From 383c583a0b46b36ab9b0de57d0f3f7bdecb62fc8 Mon Sep 17 00:00:00 2001 From: Duroxxigar Date: Mon, 10 Feb 2020 15:24:00 +0100 Subject: [PATCH] Documented the new NavigationServer and all its associated nodes (2D and 3D) --- doc/classes/Navigation2DServer.xml | 274 +++++++++++++++++++++ doc/classes/NavigationAgent.xml | 163 +++++++++++++ doc/classes/NavigationAgent2D.xml | 157 ++++++++++++ doc/classes/NavigationMeshInstance.xml | 23 ++ doc/classes/NavigationObstacle.xml | 29 +++ doc/classes/NavigationObstacle2D.xml | 29 +++ doc/classes/NavigationServer.xml | 323 +++++++++++++++++++++++++ scene/3d/navigation_agent.cpp | 8 +- scene/3d/navigation_agent.h | 4 +- servers/navigation_2d_server.cpp | 2 +- servers/navigation_server.cpp | 2 +- thirdparty/README.md | 12 +- 12 files changed, 1013 insertions(+), 13 deletions(-) create mode 100644 doc/classes/Navigation2DServer.xml create mode 100644 doc/classes/NavigationAgent.xml create mode 100644 doc/classes/NavigationAgent2D.xml create mode 100644 doc/classes/NavigationObstacle.xml create mode 100644 doc/classes/NavigationObstacle2D.xml create mode 100644 doc/classes/NavigationServer.xml diff --git a/doc/classes/Navigation2DServer.xml b/doc/classes/Navigation2DServer.xml new file mode 100644 index 00000000000..105d6aabf8b --- /dev/null +++ b/doc/classes/Navigation2DServer.xml @@ -0,0 +1,274 @@ + + + + Server interface for low-level 2D navigation access + + + Navigation2DServer is the server responsible for all 2D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + + + + + + + + + Creates the agent. + + + + + + + + + Returns true if the map got changed the previous frame. + + + + + + + + + + + + + + + Callback called at the end of the RVO process. + + + + + + + + + + + Puts the agent in the map. + + + + + + + + + + + Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. + + + + + + + + + + + Sets the maximum speed of the agent. Must be positive. + + + + + + + + + + + Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. + + + + + + + + + + + Sets the position of the agent in world space. + + + + + + + + + + + Sets the radius of the agent. + + + + + + + + + + + Sets the new target velocity. + + + + + + + + + + + The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive. + + + + + + + + + + + Sets the current velocity of the agent. + + + + + + + + + Destroy the RID + + + + + + + Create a new map. + + + + + + + + + Returns the map cell size. + + + + + + + + + Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions. + + + + + + + + + + + + + + + Returns the navigation path to reach the destination from the origin, while avoiding static obstacles. + + + + + + + + + Returns true if the map is active. + + + + + + + + + + + Sets the map active. + + + + + + + + + + + Set the map cell size used to weld the navigation mesh polygons. + + + + + + + + + + + Set the map edge connection margin used to weld the compatible region edges. + + + + + + + Creates a new region. + + + + + + + + + + + Sets the map for the region. + + + + + + + + + + + Sets the navigation mesh for the region. + + + + + + + + + + + Sets the global transformation for the region. + + + + diff --git a/doc/classes/NavigationAgent.xml b/doc/classes/NavigationAgent.xml new file mode 100644 index 00000000000..d0e2a60fbf8 --- /dev/null +++ b/doc/classes/NavigationAgent.xml @@ -0,0 +1,163 @@ + + + + 3D Agent used in navigation for collision avoidance. + + + 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. + + + + + + + + + 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. + + + + + + + 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. + + + + + + + Returns the path from start to finish in global coordinates. + + + + + + + Returns which index the agent is currently on in the navigation path's [PoolVector3Array]. + + + + + + + Returns the [Navigation] node that the agent is using for its navigation system. + + + + + + + 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. + + + + + + + Returns the user defined [Vector3] after setting the target location. + + + + + + + Returns true if the navigation path's final location has been reached. + + + + + + + Returns true if the target location is reachable. The target location is set using [method set_target_location]. + + + + + + + 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]. + + + + + + + + + Sets the [Navigation] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation] node. + + + + + + + + + Sets the user desired final location. This will clear the current navigation path. + + + + + + + + + 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. + + + + + + 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. + + + The radius of the agent. + + + The agent height offset to match the navigation mesh height. + + + The distance to search for other agents. + + + The maximum number of neighbors for the agent to consider. + + + 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. + + + The maximum speed that an agent can move. + + + 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. + + + Ignores collisions on the Y axis. Must be true to move on a horizontal plane. + + + + + + Notifies when the final location is reached. + + + + + Notifies when the navigation path changes. + + + + + Notifies when the player defined target, set with [method set_target_location], is reached. + + + + + + + Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity]. + + + + diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml new file mode 100644 index 00000000000..dd3a8aa011b --- /dev/null +++ b/doc/classes/NavigationAgent2D.xml @@ -0,0 +1,157 @@ + + + + 2D Agent used in navigation for collision avoidance. + + + 2D 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 [Navigation2D] node, or using [method set_navigation]. [NavigationAgent2D] is physics safe. + + + + + + + + + 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. + + + + + + + Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. + + + + + + + Returns the path from start to finish in global coordinates. + + + + + + + Returns which index the agent is currently on in the navigation path's [PoolVector2Array]. + + + + + + + Returns the [Navigation2D] node that the agent is using for its navigation system. + + + + + + + Returns a [Vector2] 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 position of the agent's parent. + + + + + + + Returns the user defined [Vector2] after setting the target location. + + + + + + + Returns true if the navigation path's final location has been reached. + + + + + + + Returns true if the target location is reachable. The target location is set using [method set_target_location]. + + + + + + + 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]. + + + + + + + + + Sets the [Navigation2D] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation2D] node. + + + + + + + + + Sets the user desired final location. This will clear the current navigation path. + + + + + + + + + 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. + + + + + + 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. + + + The radius of the agent. + + + The distance to search for other agents. + + + The maximum number of neighbors for the agent to consider. + + + 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. + + + The maximum speed that an agent can move. + + + 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. + + + + + + Notifies when the final location is reached. + + + + + Notifies when the navigation path changes. + + + + + Notifies when the player defined target, set with [method set_target_location], is reached. + + + + + + + Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity]. + + + + diff --git a/doc/classes/NavigationMeshInstance.xml b/doc/classes/NavigationMeshInstance.xml index a348740fdca..75bd62e2784 100644 --- a/doc/classes/NavigationMeshInstance.xml +++ b/doc/classes/NavigationMeshInstance.xml @@ -1,19 +1,42 @@ + An instance of a [NavigationMesh]. + An instance of a [NavigationMesh]. It tells the [Navigation] node what can be navigated and what cannot, based on the [NavigationMesh] resource. This should be a child of a [Navigation] node. + + + + + Bakes the [NavigationMesh]. The baking is done in a seperate thread because navigation baking is not a cheap operation. This can be done at runtime. When it is completed, it automatically sets the new [NavigationMesh]. + + + Determines if the [NavigationMeshInstance] is enabled or disabled. + The [NavigationMesh] resource to use. + + + + Notifies when the navigation mesh bake operation is completed. + + + + + Notifies when the [NavigationMesh] has changed. + + + diff --git a/doc/classes/NavigationObstacle.xml b/doc/classes/NavigationObstacle.xml new file mode 100644 index 00000000000..307538b77b9 --- /dev/null +++ b/doc/classes/NavigationObstacle.xml @@ -0,0 +1,29 @@ + + + + 3D Obstacle used in navigation for collision avoidance. + + + 3D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation] node, or using [method set_navigation]. [NavigationObstacle] is physics safe. + + + + + + + + + Returns the [Navigation] node that the obstacle is using for its navigation system. + + + + + + + + + Sets the [Navigation] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation] node. + + + + diff --git a/doc/classes/NavigationObstacle2D.xml b/doc/classes/NavigationObstacle2D.xml new file mode 100644 index 00000000000..cf5dd2fa107 --- /dev/null +++ b/doc/classes/NavigationObstacle2D.xml @@ -0,0 +1,29 @@ + + + + 2D Obstacle used in navigation for collision avoidance. + + + 2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation2D] node, or using [method set_navigation]. [NavigationObstacle] is physics safe. + + + + + + + + + Returns the [Navigation2D] node that the obstacle is using for its navigation system. + + + + + + + + + Sets the [Navigation2D] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation2D] node. + + + + diff --git a/doc/classes/NavigationServer.xml b/doc/classes/NavigationServer.xml new file mode 100644 index 00000000000..894a46b8a7d --- /dev/null +++ b/doc/classes/NavigationServer.xml @@ -0,0 +1,323 @@ + + + + Server interface for low-level 3D navigation access + + + NavigationServer is the server responsible for all 3D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + + + + + + + + + Creates the agent. + + + + + + + + + Returns true if the map got changed the previous frame. + + + + + + + + + + + + + + + Callback called at the end of the RVO process. + + + + + + + + + + + Puts the agent in the map. + + + + + + + + + + + Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. + + + + + + + + + + + Sets the maximum speed of the agent. Must be positive. + + + + + + + + + + + Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. + + + + + + + + + + + Sets the position of the agent in world space. + + + + + + + + + + + Sets the radius of the agent. + + + + + + + + + + + Sets the new target velocity. + + + + + + + + + + + The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive. + + + + + + + + + + + Sets the current velocity of the agent. + + + + + + + + + Destroy the RID + + + + + + + Create a new map. + + + + + + + + + Returns the map cell size. + + + + + + + + + Returns the edge connection margin of the map. + + + + + + + + + + + + + + + Returns the navigation path to reach the destination from the origin. + + + + + + + + + Returns the map's up direction. + + + + + + + + + Returns true if the map is active. + + + + + + + + + + + Sets the map active. + + + + + + + + + + + Set the map cell size used to weld the navigation mesh polygons. + + + + + + + + + + + Set the map edge connection margein used to weld the compatible region edges. + + + + + + + + + + + Sets the map up direction. + + + + + + + + + + + Bakes the navigation mesh. + + + + + + + Creates a new region. + + + + + + + + + + + Sets the map for the region. + + + + + + + + + + + Sets the navigation mesh for the region. + + + + + + + + + + + Sets the global transformation for the region. + + + + + + + + + Control activation of this server. + + + + + + + + + Steps the server. This is not threadsafe and must be called in single thread. + + + + diff --git a/scene/3d/navigation_agent.cpp b/scene/3d/navigation_agent.cpp index 80d7aeba8f0..d3f447bc24c 100644 --- a/scene/3d/navigation_agent.cpp +++ b/scene/3d/navigation_agent.cpp @@ -42,8 +42,8 @@ void NavigationAgent::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "radius"), &NavigationAgent::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &NavigationAgent::get_radius); - ClassDB::bind_method(D_METHOD("set_player_center_height", "player_center_height"), &NavigationAgent::set_player_center_height); - ClassDB::bind_method(D_METHOD("get_player_center_height"), &NavigationAgent::get_player_center_height); + ClassDB::bind_method(D_METHOD("set_agent_height_offset", "agent_height_offset"), &NavigationAgent::set_agent_height_offset); + ClassDB::bind_method(D_METHOD("get_agent_height_offset"), &NavigationAgent::get_agent_height_offset); ClassDB::bind_method(D_METHOD("set_ignore_y", "ignore"), &NavigationAgent::set_ignore_y); ClassDB::bind_method(D_METHOD("get_ignore_y"), &NavigationAgent::get_ignore_y); @@ -82,7 +82,7 @@ void NavigationAgent::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_target_desired_distance", "get_target_desired_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,100,0.01"), "set_radius", "get_radius"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "player_center_height", PROPERTY_HINT_RANGE, "-100.0,100,0.01"), "set_player_center_height", "get_player_center_height"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01"), "set_agent_height_offset", "get_agent_height_offset"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "neighbor_dist", PROPERTY_HINT_RANGE, "0.1,10000,0.01"), "set_neighbor_dist", "get_neighbor_dist"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_neighbors", PROPERTY_HINT_RANGE, "1,10000,1"), "set_max_neighbors", "get_max_neighbors"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_horizon", PROPERTY_HINT_RANGE, "0.01,100,0.01"), "set_time_horizon", "get_time_horizon"); @@ -192,7 +192,7 @@ void NavigationAgent::set_radius(real_t p_radius) { NavigationServer::get_singleton()->agent_set_radius(agent, radius); } -void NavigationAgent::set_player_center_height(real_t p_hh) { +void NavigationAgent::set_agent_height_offset(real_t p_hh) { navigation_height_offset = p_hh; } diff --git a/scene/3d/navigation_agent.h b/scene/3d/navigation_agent.h index a0b86d69318..8f181dafe19 100644 --- a/scene/3d/navigation_agent.h +++ b/scene/3d/navigation_agent.h @@ -98,8 +98,8 @@ public: return radius; } - void set_player_center_height(real_t p_hh); - real_t get_player_center_height() const { + void set_agent_height_offset(real_t p_hh); + real_t get_agent_height_offset() const { return navigation_height_offset; } diff --git a/servers/navigation_2d_server.cpp b/servers/navigation_2d_server.cpp index 6df308d0462..d4ca4021362 100644 --- a/servers/navigation_2d_server.cpp +++ b/servers/navigation_2d_server.cpp @@ -146,7 +146,7 @@ void Navigation2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &Navigation2DServer::agent_set_radius); ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &Navigation2DServer::agent_set_max_speed); ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &Navigation2DServer::agent_set_velocity); - ClassDB::bind_method(D_METHOD("agent_set_velocity_target", "agent", "target_velocity"), &Navigation2DServer::agent_set_target_velocity); + ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &Navigation2DServer::agent_set_target_velocity); ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &Navigation2DServer::agent_set_position); ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &Navigation2DServer::agent_is_map_changed); ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &Navigation2DServer::agent_set_callback, DEFVAL(Variant())); diff --git a/servers/navigation_server.cpp b/servers/navigation_server.cpp index 91d765202ca..c4c54cbce10 100644 --- a/servers/navigation_server.cpp +++ b/servers/navigation_server.cpp @@ -63,7 +63,7 @@ void NavigationServer::_bind_methods() { ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer::agent_set_radius); ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer::agent_set_max_speed); ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer::agent_set_velocity); - ClassDB::bind_method(D_METHOD("agent_set_velocity_target", "agent", "target_velocity"), &NavigationServer::agent_set_target_velocity); + ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer::agent_set_target_velocity); ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer::agent_set_position); ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer::agent_is_map_changed); ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer::agent_set_callback, DEFVAL(Variant())); diff --git a/thirdparty/README.md b/thirdparty/README.md index 255f0f6eb71..8143b4af563 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -432,7 +432,7 @@ Files extracted from upstream source: ## recastnavigation - Upstream: https://github.com/recastnavigation/recastnavigation -- version: git (ef3ea40f, 2017) +- Version: git (ef3ea40f, 2017) - License: zlib Files extracted from upstream source: @@ -441,19 +441,21 @@ Files extracted from upstream source: - License.txt -## Rvo2-3D +## Rvo2 - Upstream: http://gamma.cs.unc.edu/RVO2/ -- version: 1.0.1 +- Version: 3D - 1.0.1 - License: Apache 2.0 Files extracted from upstream source: - All .cpp and .h files in the `src/` folder except for RVOSimulator.cpp and RVOSimulator.h - LICENSE -- README -Important: Some files have Godot-made changes; so to enrich the features originally proposed by this library and better integrate this library with Godot. Please check the file to know what's new. +Important: Some files have Godot-made changes; so to enrich the features +originally proposed by this library and better integrate this library with +Godot. Please check the file to know what's new. + ## squish