Rename Navigation uses of 'location' to 'position'
Contrary to the entire rest of the engine NavigationAgent's and NavigationLinks decided to deal with locations instead of positions.
This commit is contained in:
parent
a3a42159e3
commit
bf1571979c
|
@ -4,8 +4,8 @@
|
||||||
2D Agent used in navigation for collision avoidance.
|
2D Agent used in navigation for collision avoidance.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
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. [NavigationAgent2D] is physics safe.
|
2D Agent that is used in navigation to reach a position while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. [NavigationAgent2D] is physics safe.
|
||||||
[b]Note:[/b] After setting [member target_location] it is required to use the [method get_next_location] function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
|
[b]Note:[/b] After setting [member target_position] it is required to use the [method get_next_path_position] function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link title="Using NavigationAgents">$DOCS_URL/tutorials/navigation/navigation_using_navigationagents.html</link>
|
<link title="Using NavigationAgents">$DOCS_URL/tutorials/navigation/navigation_using_navigationagents.html</link>
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
<method name="distance_to_target" qualifiers="const">
|
<method name="distance_to_target" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns the distance to the target location, using the agent's global position. The user must set [member target_location] in order for this to be accurate.
|
Returns the distance to the target position, using the agent's global position. The user must set [member target_position] in order for this to be accurate.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_current_navigation_path" qualifiers="const">
|
<method name="get_current_navigation_path" qualifiers="const">
|
||||||
<return type="PackedVector2Array" />
|
<return type="PackedVector2Array" />
|
||||||
<description>
|
<description>
|
||||||
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target location is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended [method get_next_location] once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
|
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target position is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended [method get_next_path_position] once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_current_navigation_path_index" qualifiers="const">
|
<method name="get_current_navigation_path_index" qualifiers="const">
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
Returns the path query result for the path the agent is currently following.
|
Returns the path query result for the path the agent is currently following.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_final_location">
|
<method name="get_final_position">
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<description>
|
<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.
|
Returns the reachable final position 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>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_navigation_layer_value" qualifiers="const">
|
<method name="get_navigation_layer_value" qualifiers="const">
|
||||||
|
@ -54,10 +54,10 @@
|
||||||
Returns the [RID] of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use [method set_navigation_map] to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
|
Returns the [RID] of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use [method set_navigation_map] to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_next_location">
|
<method name="get_next_path_position">
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<description>
|
<description>
|
||||||
Returns the next location 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. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
|
Returns the next position 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. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_rid" qualifiers="const">
|
<method name="get_rid" qualifiers="const">
|
||||||
|
@ -69,19 +69,19 @@
|
||||||
<method name="is_navigation_finished">
|
<method name="is_navigation_finished">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if the navigation path's final location has been reached.
|
Returns true if the navigation path's final position has been reached.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_target_reachable">
|
<method name="is_target_reachable">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if [member target_location] is reachable.
|
Returns true if [member target_position] is reachable.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_target_reached" qualifiers="const">
|
<method name="is_target_reached" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if [member target_location] is reached. 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].
|
Returns true if [member target_position] is reached. It may not always be possible to reach the target position. It should always be possible to reach the final position though. See [method get_final_position].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="set_navigation_layer_value">
|
<method name="set_navigation_layer_value">
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
|
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
|
||||||
</member>
|
</member>
|
||||||
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="100.0">
|
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="100.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 exceeded, it recalculates the ideal path.
|
The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
|
||||||
</member>
|
</member>
|
||||||
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" enum="NavigationPathQueryParameters2D.PathMetadataFlags" default="7">
|
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" enum="NavigationPathQueryParameters2D.PathMetadataFlags" default="7">
|
||||||
Additional information to return with the navigation path.
|
Additional information to return with the navigation path.
|
||||||
|
@ -139,8 +139,8 @@
|
||||||
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="10.0">
|
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="10.0">
|
||||||
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
|
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
|
||||||
</member>
|
</member>
|
||||||
<member name="target_location" type="Vector2" setter="set_target_location" getter="get_target_location" default="Vector2(0, 0)">
|
<member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2(0, 0)">
|
||||||
The user-defined target location. Setting this property will clear the current navigation path.
|
The user-defined target position. Setting this property will clear the current navigation path.
|
||||||
</member>
|
</member>
|
||||||
<member name="time_horizon" type="float" setter="set_time_horizon" getter="get_time_horizon" default="1.0">
|
<member name="time_horizon" type="float" setter="set_time_horizon" getter="get_time_horizon" default="1.0">
|
||||||
The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, 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 minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, 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.
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
<description>
|
<description>
|
||||||
Notifies when a navigation link has been reached.
|
Notifies when a navigation link has been reached.
|
||||||
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
||||||
- [code]location[/code]: The start location of the link that was reached.
|
- [code]position[/code]: The start position of the link that was reached.
|
||||||
- [code]type[/code]: Always [constant NavigationPathQueryResult2D.PATH_SEGMENT_TYPE_LINK].
|
- [code]type[/code]: Always [constant NavigationPathQueryResult2D.PATH_SEGMENT_TYPE_LINK].
|
||||||
- [code]rid[/code]: The [RID] of the link.
|
- [code]rid[/code]: The [RID] of the link.
|
||||||
- [code]owner[/code]: The object which manages the link (usually [NavigationLink2D]).
|
- [code]owner[/code]: The object which manages the link (usually [NavigationLink2D]).
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="navigation_finished">
|
<signal name="navigation_finished">
|
||||||
<description>
|
<description>
|
||||||
Notifies when the final location is reached.
|
Notifies when the final position is reached.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="path_changed">
|
<signal name="path_changed">
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="target_reached">
|
<signal name="target_reached">
|
||||||
<description>
|
<description>
|
||||||
Notifies when the player-defined [member target_location] is reached.
|
Notifies when the player-defined [member target_position] is reached.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="velocity_computed">
|
<signal name="velocity_computed">
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
<description>
|
<description>
|
||||||
Notifies when a waypoint along the path has been reached.
|
Notifies when a waypoint along the path has been reached.
|
||||||
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
||||||
- [code]location[/code]: The location of the waypoint that was reached.
|
- [code]position[/code]: The position of the waypoint that was reached.
|
||||||
- [code]type[/code]: The type of navigation primitive (region or link) that contains this waypoint.
|
- [code]type[/code]: The type of navigation primitive (region or link) that contains this waypoint.
|
||||||
- [code]rid[/code]: The [RID] of the containing navigation primitive (region or link).
|
- [code]rid[/code]: The [RID] of the containing navigation primitive (region or link).
|
||||||
- [code]owner[/code]: The object which manages the containing navigation primitive (region or link).
|
- [code]owner[/code]: The object which manages the containing navigation primitive (region or link).
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
3D Agent used in navigation for collision avoidance.
|
3D Agent used in navigation for collision avoidance.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<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. [NavigationAgent3D] is physics safe.
|
3D Agent that is used in navigation to reach a position while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. [NavigationAgent3D] is physics safe.
|
||||||
[b]Note:[/b] After setting [member target_location] it is required to use the [method get_next_location] function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
|
[b]Note:[/b] After setting [member target_position] it is required to use the [method get_next_path_position] function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link title="Using NavigationAgents">$DOCS_URL/tutorials/navigation/navigation_using_navigationagents.html</link>
|
<link title="Using NavigationAgents">$DOCS_URL/tutorials/navigation/navigation_using_navigationagents.html</link>
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
<method name="distance_to_target" qualifiers="const">
|
<method name="distance_to_target" qualifiers="const">
|
||||||
<return type="float" />
|
<return type="float" />
|
||||||
<description>
|
<description>
|
||||||
Returns the distance to the target location, using the agent's global position. The user must set [member target_location] in order for this to be accurate.
|
Returns the distance to the target position, using the agent's global position. The user must set [member target_position] in order for this to be accurate.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_current_navigation_path" qualifiers="const">
|
<method name="get_current_navigation_path" qualifiers="const">
|
||||||
<return type="PackedVector3Array" />
|
<return type="PackedVector3Array" />
|
||||||
<description>
|
<description>
|
||||||
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target location is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended [method get_next_location] once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
|
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target position is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended [method get_next_path_position] once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_current_navigation_path_index" qualifiers="const">
|
<method name="get_current_navigation_path_index" qualifiers="const">
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
Returns the path query result for the path the agent is currently following.
|
Returns the path query result for the path the agent is currently following.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_final_location">
|
<method name="get_final_position">
|
||||||
<return type="Vector3" />
|
<return type="Vector3" />
|
||||||
<description>
|
<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.
|
Returns the reachable final position 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>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_navigation_layer_value" qualifiers="const">
|
<method name="get_navigation_layer_value" qualifiers="const">
|
||||||
|
@ -54,10 +54,10 @@
|
||||||
Returns the [RID] of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use [method set_navigation_map] to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
|
Returns the [RID] of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use [method set_navigation_map] to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_next_location">
|
<method name="get_next_path_position">
|
||||||
<return type="Vector3" />
|
<return type="Vector3" />
|
||||||
<description>
|
<description>
|
||||||
Returns the next location 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. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
|
Returns the next position 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. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_rid" qualifiers="const">
|
<method name="get_rid" qualifiers="const">
|
||||||
|
@ -69,19 +69,19 @@
|
||||||
<method name="is_navigation_finished">
|
<method name="is_navigation_finished">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if the navigation path's final location has been reached.
|
Returns true if the navigation path's final position has been reached.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_target_reachable">
|
<method name="is_target_reachable">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if [member target_location] is reachable.
|
Returns true if [member target_position] is reachable.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="is_target_reached" qualifiers="const">
|
<method name="is_target_reached" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<description>
|
<description>
|
||||||
Returns true if [member target_location] is reached. 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].
|
Returns true if [member target_position] is reached. It may not always be possible to reach the target position. It should always be possible to reach the final position though. See [method get_final_position].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="set_navigation_layer_value">
|
<method name="set_navigation_layer_value">
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
|
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
|
||||||
</member>
|
</member>
|
||||||
<member name="path_max_distance" type="float" setter="set_path_max_distance" getter="get_path_max_distance" default="3.0">
|
<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 exceeded, it recalculates the ideal path.
|
The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
|
||||||
</member>
|
</member>
|
||||||
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" enum="NavigationPathQueryParameters3D.PathMetadataFlags" default="7">
|
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" enum="NavigationPathQueryParameters3D.PathMetadataFlags" default="7">
|
||||||
Additional information to return with the navigation path.
|
Additional information to return with the navigation path.
|
||||||
|
@ -145,8 +145,8 @@
|
||||||
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="1.0">
|
<member name="target_desired_distance" type="float" setter="set_target_desired_distance" getter="get_target_desired_distance" default="1.0">
|
||||||
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
|
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
|
||||||
</member>
|
</member>
|
||||||
<member name="target_location" type="Vector3" setter="set_target_location" getter="get_target_location" default="Vector3(0, 0, 0)">
|
<member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3(0, 0, 0)">
|
||||||
The user-defined target location. Setting this property will clear the current navigation path.
|
The user-defined target position. Setting this property will clear the current navigation path.
|
||||||
</member>
|
</member>
|
||||||
<member name="time_horizon" type="float" setter="set_time_horizon" getter="get_time_horizon" default="5.0">
|
<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 algorithm, 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 minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, 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.
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
<description>
|
<description>
|
||||||
Notifies when a navigation link has been reached.
|
Notifies when a navigation link has been reached.
|
||||||
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
||||||
- [code]location[/code]: The start location of the link that was reached.
|
- [code]position[/code]: The start position of the link that was reached.
|
||||||
- [code]type[/code]: Always [constant NavigationPathQueryResult3D.PATH_SEGMENT_TYPE_LINK].
|
- [code]type[/code]: Always [constant NavigationPathQueryResult3D.PATH_SEGMENT_TYPE_LINK].
|
||||||
- [code]rid[/code]: The [RID] of the link.
|
- [code]rid[/code]: The [RID] of the link.
|
||||||
- [code]owner[/code]: The object which manages the link (usually [NavigationLink3D]).
|
- [code]owner[/code]: The object which manages the link (usually [NavigationLink3D]).
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="navigation_finished">
|
<signal name="navigation_finished">
|
||||||
<description>
|
<description>
|
||||||
Notifies when the final location is reached.
|
Notifies when the final position is reached.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="path_changed">
|
<signal name="path_changed">
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="target_reached">
|
<signal name="target_reached">
|
||||||
<description>
|
<description>
|
||||||
Notifies when the player-defined [member target_location] is reached.
|
Notifies when the player-defined [member target_position] is reached.
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="velocity_computed">
|
<signal name="velocity_computed">
|
||||||
|
@ -190,7 +190,7 @@
|
||||||
<description>
|
<description>
|
||||||
Notifies when a waypoint along the path has been reached.
|
Notifies when a waypoint along the path has been reached.
|
||||||
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
The details dictionary may contain the following keys depending on the value of [member path_metadata_flags]:
|
||||||
- [code]location[/code]: The location of the waypoint that was reached.
|
- [code]position[/code]: The position of the waypoint that was reached.
|
||||||
- [code]type[/code]: The type of navigation primitive (region or link) that contains this waypoint.
|
- [code]type[/code]: The type of navigation primitive (region or link) that contains this waypoint.
|
||||||
- [code]rid[/code]: The [RID] of the containing navigation primitive (region or link).
|
- [code]rid[/code]: The [RID] of the containing navigation primitive (region or link).
|
||||||
- [code]owner[/code]: The object which manages the containing navigation primitive (region or link).
|
- [code]owner[/code]: The object which manages the containing navigation primitive (region or link).
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<class name="NavigationLink2D" inherits="Node2D" is_experimental="true" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
<class name="NavigationLink2D" inherits="Node2D" is_experimental="true" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||||
<brief_description>
|
<brief_description>
|
||||||
Creates a link between two locations that [NavigationServer2D] can route agents through.
|
Creates a link between two positions that [NavigationServer2D] can route agents through.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Creates a link between two locations that [NavigationServer2D] can route agents through. Links can be used to express navigation methods that aren't just traveling along the surface of the navigation mesh, like zip-lines, teleporters, or jumping across gaps.
|
Creates a link between two positions that [NavigationServer2D] can route agents through. Links can be used to express navigation methods that aren't just traveling along the surface of the navigation mesh, like zip-lines, teleporters, or jumping across gaps.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link title="Using NavigationLinks">$DOCS_URL/tutorials/navigation/navigation_using_navigationlinks.html</link>
|
<link title="Using NavigationLinks">$DOCS_URL/tutorials/navigation/navigation_using_navigationlinks.html</link>
|
||||||
|
@ -28,12 +28,12 @@
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="bidirectional" type="bool" setter="set_bidirectional" getter="is_bidirectional" default="true">
|
<member name="bidirectional" type="bool" setter="set_bidirectional" getter="is_bidirectional" default="true">
|
||||||
Whether this link can be traveled in both directions or only from [member start_location] to [member end_location].
|
Whether this link can be traveled in both directions or only from [member start_position] to [member end_position].
|
||||||
</member>
|
</member>
|
||||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||||
Whether this link is currently active. If [code]false[/code], [method NavigationServer2D.map_get_path] will ignore this link.
|
Whether this link is currently active. If [code]false[/code], [method NavigationServer2D.map_get_path] will ignore this link.
|
||||||
</member>
|
</member>
|
||||||
<member name="end_location" type="Vector2" setter="set_end_location" getter="get_end_location" default="Vector2(0, 0)">
|
<member name="end_position" type="Vector2" setter="set_end_position" getter="get_end_position" default="Vector2(0, 0)">
|
||||||
Ending position of the link.
|
Ending position of the link.
|
||||||
This position will search out the nearest polygon in the navigation mesh to attach to.
|
This position will search out the nearest polygon in the navigation mesh to attach to.
|
||||||
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
|
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||||
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer2D.map_get_path].
|
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer2D.map_get_path].
|
||||||
</member>
|
</member>
|
||||||
<member name="start_location" type="Vector2" setter="set_start_location" getter="get_start_location" default="Vector2(0, 0)">
|
<member name="start_position" type="Vector2" setter="set_start_position" getter="get_start_position" default="Vector2(0, 0)">
|
||||||
Starting position of the link.
|
Starting position of the link.
|
||||||
This position will search out the nearest polygon in the navigation mesh to attach to.
|
This position will search out the nearest polygon in the navigation mesh to attach to.
|
||||||
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
|
The distance the link will search is controlled by [method NavigationServer2D.map_set_link_connection_radius].
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<class name="NavigationLink3D" inherits="Node3D" is_experimental="true" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
<class name="NavigationLink3D" inherits="Node3D" is_experimental="true" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||||
<brief_description>
|
<brief_description>
|
||||||
Creates a link between two locations that [NavigationServer3D] can route agents through.
|
Creates a link between two positions that [NavigationServer3D] can route agents through.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Creates a link between two locations that [NavigationServer3D] can route agents through. Links can be used to express navigation methods that aren't just traveling along the surface of the navigation mesh, like zip-lines, teleporters, or jumping across gaps.
|
Creates a link between two positions that [NavigationServer3D] can route agents through. Links can be used to express navigation methods that aren't just traveling along the surface of the navigation mesh, like zip-lines, teleporters, or jumping across gaps.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link title="Using NavigationLinks">$DOCS_URL/tutorials/navigation/navigation_using_navigationlinks.html</link>
|
<link title="Using NavigationLinks">$DOCS_URL/tutorials/navigation/navigation_using_navigationlinks.html</link>
|
||||||
|
@ -28,12 +28,12 @@
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="bidirectional" type="bool" setter="set_bidirectional" getter="is_bidirectional" default="true">
|
<member name="bidirectional" type="bool" setter="set_bidirectional" getter="is_bidirectional" default="true">
|
||||||
Whether this link can be traveled in both directions or only from [member start_location] to [member end_location].
|
Whether this link can be traveled in both directions or only from [member start_position] to [member end_position].
|
||||||
</member>
|
</member>
|
||||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||||
Whether this link is currently active. If [code]false[/code], [method NavigationServer3D.map_get_path] will ignore this link.
|
Whether this link is currently active. If [code]false[/code], [method NavigationServer3D.map_get_path] will ignore this link.
|
||||||
</member>
|
</member>
|
||||||
<member name="end_location" type="Vector3" setter="set_end_location" getter="get_end_location" default="Vector3(0, 0, 0)">
|
<member name="end_position" type="Vector3" setter="set_end_position" getter="get_end_position" default="Vector3(0, 0, 0)">
|
||||||
Ending position of the link.
|
Ending position of the link.
|
||||||
This position will search out the nearest polygon in the navigation mesh to attach to.
|
This position will search out the nearest polygon in the navigation mesh to attach to.
|
||||||
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
|
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
<member name="navigation_layers" type="int" setter="set_navigation_layers" getter="get_navigation_layers" default="1">
|
||||||
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer3D.map_get_path].
|
A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with [method NavigationServer3D.map_get_path].
|
||||||
</member>
|
</member>
|
||||||
<member name="start_location" type="Vector3" setter="set_start_location" getter="get_start_location" default="Vector3(0, 0, 0)">
|
<member name="start_position" type="Vector3" setter="set_start_position" getter="get_start_position" default="Vector3(0, 0, 0)">
|
||||||
Starting position of the link.
|
Starting position of the link.
|
||||||
This position will search out the nearest polygon in the navigation mesh to attach to.
|
This position will search out the nearest polygon in the navigation mesh to attach to.
|
||||||
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
|
The distance the link will search is controlled by [method NavigationServer3D.map_set_link_connection_radius].
|
||||||
|
|
|
@ -137,14 +137,14 @@
|
||||||
<method name="link_create">
|
<method name="link_create">
|
||||||
<return type="RID" />
|
<return type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Create a new link between two locations on a map.
|
Create a new link between two positions on a map.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_end_location" qualifiers="const">
|
<method name="link_get_end_position" qualifiers="const">
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Returns the ending location of this [code]link[/code].
|
Returns the ending position of this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_enter_cost" qualifiers="const">
|
<method name="link_get_enter_cost" qualifiers="const">
|
||||||
|
@ -175,11 +175,11 @@
|
||||||
Returns the [code]ObjectID[/code] of the object which manages this link.
|
Returns the [code]ObjectID[/code] of the object which manages this link.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_start_location" qualifiers="const">
|
<method name="link_get_start_position" qualifiers="const">
|
||||||
<return type="Vector2" />
|
<return type="Vector2" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Returns the starting location of this [code]link[/code].
|
Returns the starting position of this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_travel_cost" qualifiers="const">
|
<method name="link_get_travel_cost" qualifiers="const">
|
||||||
|
@ -204,12 +204,12 @@
|
||||||
Sets whether this [code]link[/code] can be travelled in both directions.
|
Sets whether this [code]link[/code] can be travelled in both directions.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_end_location">
|
<method name="link_set_end_position">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<param index="1" name="location" type="Vector2" />
|
<param index="1" name="position" type="Vector2" />
|
||||||
<description>
|
<description>
|
||||||
Sets the exit location for the [code]link[/code].
|
Sets the exit position for the [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_enter_cost">
|
<method name="link_set_enter_cost">
|
||||||
|
@ -244,12 +244,12 @@
|
||||||
Set the [code]ObjectID[/code] of the object which manages this link.
|
Set the [code]ObjectID[/code] of the object which manages this link.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_start_location">
|
<method name="link_set_start_position">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<param index="1" name="location" type="Vector2" />
|
<param index="1" name="position" type="Vector2" />
|
||||||
<description>
|
<description>
|
||||||
Sets the entry location for this [code]link[/code].
|
Sets the entry position for this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_travel_cost">
|
<method name="link_set_travel_cost">
|
||||||
|
|
|
@ -144,14 +144,14 @@
|
||||||
<method name="link_create">
|
<method name="link_create">
|
||||||
<return type="RID" />
|
<return type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Create a new link between two locations on a map.
|
Create a new link between two positions on a map.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_end_location" qualifiers="const">
|
<method name="link_get_end_position" qualifiers="const">
|
||||||
<return type="Vector3" />
|
<return type="Vector3" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Returns the ending location of this [code]link[/code].
|
Returns the ending position of this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_enter_cost" qualifiers="const">
|
<method name="link_get_enter_cost" qualifiers="const">
|
||||||
|
@ -182,11 +182,11 @@
|
||||||
Returns the [code]ObjectID[/code] of the object which manages this link.
|
Returns the [code]ObjectID[/code] of the object which manages this link.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_start_location" qualifiers="const">
|
<method name="link_get_start_position" qualifiers="const">
|
||||||
<return type="Vector3" />
|
<return type="Vector3" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<description>
|
<description>
|
||||||
Returns the starting location of this [code]link[/code].
|
Returns the starting position of this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_get_travel_cost" qualifiers="const">
|
<method name="link_get_travel_cost" qualifiers="const">
|
||||||
|
@ -211,12 +211,12 @@
|
||||||
Sets whether this [code]link[/code] can be travelled in both directions.
|
Sets whether this [code]link[/code] can be travelled in both directions.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_end_location">
|
<method name="link_set_end_position">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<param index="1" name="location" type="Vector3" />
|
<param index="1" name="position" type="Vector3" />
|
||||||
<description>
|
<description>
|
||||||
Sets the exit location for the [code]link[/code].
|
Sets the exit position for the [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_enter_cost">
|
<method name="link_set_enter_cost">
|
||||||
|
@ -251,12 +251,12 @@
|
||||||
Set the [code]ObjectID[/code] of the object which manages this link.
|
Set the [code]ObjectID[/code] of the object which manages this link.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_start_location">
|
<method name="link_set_start_position">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="link" type="RID" />
|
<param index="0" name="link" type="RID" />
|
||||||
<param index="1" name="location" type="Vector3" />
|
<param index="1" name="position" type="Vector3" />
|
||||||
<description>
|
<description>
|
||||||
Sets the entry location for this [code]link[/code].
|
Sets the entry position for this [code]link[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="link_set_travel_cost">
|
<method name="link_set_travel_cost">
|
||||||
|
|
|
@ -65,20 +65,20 @@ bool NavigationLink2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
Ref<InputEventMouseButton> mb = p_event;
|
Ref<InputEventMouseButton> mb = p_event;
|
||||||
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
// Start location
|
// Start position
|
||||||
if (xform.xform(node->get_start_location()).distance_to(mb->get_position()) < grab_threshold) {
|
if (xform.xform(node->get_start_position()).distance_to(mb->get_position()) < grab_threshold) {
|
||||||
start_grabbed = true;
|
start_grabbed = true;
|
||||||
original_start_location = node->get_start_location();
|
original_start_position = node->get_start_position();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
start_grabbed = false;
|
start_grabbed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// End location
|
// End position
|
||||||
if (xform.xform(node->get_end_location()).distance_to(mb->get_position()) < grab_threshold) {
|
if (xform.xform(node->get_end_position()).distance_to(mb->get_position()) < grab_threshold) {
|
||||||
end_grabbed = true;
|
end_grabbed = true;
|
||||||
original_end_location = node->get_end_location();
|
original_end_position = node->get_end_position();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,10 +87,10 @@ bool NavigationLink2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
} else {
|
} else {
|
||||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||||
if (start_grabbed) {
|
if (start_grabbed) {
|
||||||
undo_redo->create_action(TTR("Set start_location"));
|
undo_redo->create_action(TTR("Set start_position"));
|
||||||
undo_redo->add_do_method(node, "set_start_location", node->get_start_location());
|
undo_redo->add_do_method(node, "set_start_position", node->get_start_position());
|
||||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->add_undo_method(node, "set_start_location", original_start_location);
|
undo_redo->add_undo_method(node, "set_start_position", original_start_position);
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ bool NavigationLink2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_grabbed) {
|
if (end_grabbed) {
|
||||||
undo_redo->create_action(TTR("Set end_location"));
|
undo_redo->create_action(TTR("Set end_position"));
|
||||||
undo_redo->add_do_method(node, "set_end_location", node->get_end_location());
|
undo_redo->add_do_method(node, "set_end_position", node->get_end_position());
|
||||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->add_undo_method(node, "set_end_location", original_end_location);
|
undo_redo->add_undo_method(node, "set_end_position", original_end_position);
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
|
||||||
|
@ -120,14 +120,14 @@ bool NavigationLink2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
point = node->get_global_transform().affine_inverse().xform(point);
|
point = node->get_global_transform().affine_inverse().xform(point);
|
||||||
|
|
||||||
if (start_grabbed) {
|
if (start_grabbed) {
|
||||||
node->set_start_location(point);
|
node->set_start_position(point);
|
||||||
canvas_item_editor->update_viewport();
|
canvas_item_editor->update_viewport();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_grabbed) {
|
if (end_grabbed) {
|
||||||
node->set_end_location(point);
|
node->set_end_position(point);
|
||||||
canvas_item_editor->update_viewport();
|
canvas_item_editor->update_viewport();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -143,13 +143,13 @@ void NavigationLink2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
|
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
|
||||||
Vector2 global_start_location = gt.xform(node->get_start_location());
|
Vector2 global_start_position = gt.xform(node->get_start_position());
|
||||||
Vector2 global_end_location = gt.xform(node->get_end_location());
|
Vector2 global_end_position = gt.xform(node->get_end_position());
|
||||||
|
|
||||||
// Only drawing the handles here, since the debug rendering will fill in the rest.
|
// Only drawing the handles here, since the debug rendering will fill in the rest.
|
||||||
const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
|
const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
|
||||||
p_overlay->draw_texture(handle, global_start_location - handle->get_size() / 2);
|
p_overlay->draw_texture(handle, global_start_position - handle->get_size() / 2);
|
||||||
p_overlay->draw_texture(handle, global_end_location - handle->get_size() / 2);
|
p_overlay->draw_texture(handle, global_end_position - handle->get_size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink2DEditor::edit(NavigationLink2D *p_node) {
|
void NavigationLink2DEditor::edit(NavigationLink2D *p_node) {
|
||||||
|
|
|
@ -43,10 +43,10 @@ class NavigationLink2DEditor : public Control {
|
||||||
NavigationLink2D *node = nullptr;
|
NavigationLink2D *node = nullptr;
|
||||||
|
|
||||||
bool start_grabbed = false;
|
bool start_grabbed = false;
|
||||||
Vector2 original_start_location;
|
Vector2 original_start_position;
|
||||||
|
|
||||||
bool end_grabbed = false;
|
bool end_grabbed = false;
|
||||||
Vector2 original_end_location;
|
Vector2 original_end_position;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
|
@ -5057,8 +5057,8 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||||
Vector3 up_vector = NavigationServer3D::get_singleton()->map_get_up(nav_map);
|
Vector3 up_vector = NavigationServer3D::get_singleton()->map_get_up(nav_map);
|
||||||
Vector3::Axis up_axis = up_vector.max_axis_index();
|
Vector3::Axis up_axis = up_vector.max_axis_index();
|
||||||
|
|
||||||
Vector3 start_location = link->get_start_location();
|
Vector3 start_position = link->get_start_position();
|
||||||
Vector3 end_location = link->get_end_location();
|
Vector3 end_position = link->get_end_position();
|
||||||
|
|
||||||
Ref<Material> link_material = get_material("navigation_link_material", p_gizmo);
|
Ref<Material> link_material = get_material("navigation_link_material", p_gizmo);
|
||||||
Ref<Material> link_material_disabled = get_material("navigation_link_material_disabled", p_gizmo);
|
Ref<Material> link_material_disabled = get_material("navigation_link_material_disabled", p_gizmo);
|
||||||
|
@ -5068,10 +5068,10 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||||
|
|
||||||
// Draw line between the points.
|
// Draw line between the points.
|
||||||
Vector<Vector3> lines;
|
Vector<Vector3> lines;
|
||||||
lines.append(start_location);
|
lines.append(start_position);
|
||||||
lines.append(end_location);
|
lines.append(end_position);
|
||||||
|
|
||||||
// Draw start location search radius
|
// Draw start position search radius
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
// Create a circle
|
// Create a circle
|
||||||
const float ra = Math::deg_to_rad((float)(i * 12));
|
const float ra = Math::deg_to_rad((float)(i * 12));
|
||||||
|
@ -5082,21 +5082,21 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||||
// Draw axis-aligned circle
|
// Draw axis-aligned circle
|
||||||
switch (up_axis) {
|
switch (up_axis) {
|
||||||
case Vector3::AXIS_X:
|
case Vector3::AXIS_X:
|
||||||
lines.append(start_location + Vector3(0, a.x, a.y));
|
lines.append(start_position + Vector3(0, a.x, a.y));
|
||||||
lines.append(start_location + Vector3(0, b.x, b.y));
|
lines.append(start_position + Vector3(0, b.x, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Y:
|
case Vector3::AXIS_Y:
|
||||||
lines.append(start_location + Vector3(a.x, 0, a.y));
|
lines.append(start_position + Vector3(a.x, 0, a.y));
|
||||||
lines.append(start_location + Vector3(b.x, 0, b.y));
|
lines.append(start_position + Vector3(b.x, 0, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Z:
|
case Vector3::AXIS_Z:
|
||||||
lines.append(start_location + Vector3(a.x, a.y, 0));
|
lines.append(start_position + Vector3(a.x, a.y, 0));
|
||||||
lines.append(start_location + Vector3(b.x, b.y, 0));
|
lines.append(start_position + Vector3(b.x, b.y, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw end location search radius
|
// Draw end position search radius
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
// Create a circle
|
// Create a circle
|
||||||
const float ra = Math::deg_to_rad((float)(i * 12));
|
const float ra = Math::deg_to_rad((float)(i * 12));
|
||||||
|
@ -5107,16 +5107,16 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||||
// Draw axis-aligned circle
|
// Draw axis-aligned circle
|
||||||
switch (up_axis) {
|
switch (up_axis) {
|
||||||
case Vector3::AXIS_X:
|
case Vector3::AXIS_X:
|
||||||
lines.append(end_location + Vector3(0, a.x, a.y));
|
lines.append(end_position + Vector3(0, a.x, a.y));
|
||||||
lines.append(end_location + Vector3(0, b.x, b.y));
|
lines.append(end_position + Vector3(0, b.x, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Y:
|
case Vector3::AXIS_Y:
|
||||||
lines.append(end_location + Vector3(a.x, 0, a.y));
|
lines.append(end_position + Vector3(a.x, 0, a.y));
|
||||||
lines.append(end_location + Vector3(b.x, 0, b.y));
|
lines.append(end_position + Vector3(b.x, 0, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Z:
|
case Vector3::AXIS_Z:
|
||||||
lines.append(end_location + Vector3(a.x, a.y, 0));
|
lines.append(end_position + Vector3(a.x, a.y, 0));
|
||||||
lines.append(end_location + Vector3(b.x, b.y, 0));
|
lines.append(end_position + Vector3(b.x, b.y, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5125,8 +5125,8 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||||
p_gizmo->add_collision_segments(lines);
|
p_gizmo->add_collision_segments(lines);
|
||||||
|
|
||||||
Vector<Vector3> handles;
|
Vector<Vector3> handles;
|
||||||
handles.append(start_location);
|
handles.append(start_position);
|
||||||
handles.append(end_location);
|
handles.append(end_position);
|
||||||
p_gizmo->add_handles(handles, handles_material);
|
p_gizmo->add_handles(handles, handles_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5136,7 +5136,7 @@ String NavigationLink3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
|
||||||
|
|
||||||
Variant NavigationLink3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
|
Variant NavigationLink3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
|
||||||
NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
|
NavigationLink3D *link = Object::cast_to<NavigationLink3D>(p_gizmo->get_node_3d());
|
||||||
return p_id == 0 ? link->get_start_location() : link->get_end_location();
|
return p_id == 0 ? link->get_start_position() : link->get_end_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
|
void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
|
||||||
|
@ -5151,8 +5151,8 @@ void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
|
||||||
Vector3 ray_from = p_camera->project_ray_origin(p_point);
|
Vector3 ray_from = p_camera->project_ray_origin(p_point);
|
||||||
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
|
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
|
||||||
|
|
||||||
Vector3 location = p_id == 0 ? link->get_start_location() : link->get_end_location();
|
Vector3 position = p_id == 0 ? link->get_start_position() : link->get_end_position();
|
||||||
Plane move_plane = Plane(cam_dir, gt.xform(location));
|
Plane move_plane = Plane(cam_dir, gt.xform(position));
|
||||||
|
|
||||||
Vector3 intersection;
|
Vector3 intersection;
|
||||||
if (!move_plane.intersects_ray(ray_from, ray_dir, &intersection)) {
|
if (!move_plane.intersects_ray(ray_from, ray_dir, &intersection)) {
|
||||||
|
@ -5164,11 +5164,11 @@ void NavigationLink3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
|
||||||
intersection.snap(Vector3(snap, snap, snap));
|
intersection.snap(Vector3(snap, snap, snap));
|
||||||
}
|
}
|
||||||
|
|
||||||
location = gi.xform(intersection);
|
position = gi.xform(intersection);
|
||||||
if (p_id == 0) {
|
if (p_id == 0) {
|
||||||
link->set_start_location(location);
|
link->set_start_position(position);
|
||||||
} else if (p_id == 1) {
|
} else if (p_id == 1) {
|
||||||
link->set_end_location(location);
|
link->set_end_position(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5177,22 +5177,22 @@ void NavigationLink3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo
|
||||||
|
|
||||||
if (p_cancel) {
|
if (p_cancel) {
|
||||||
if (p_id == 0) {
|
if (p_id == 0) {
|
||||||
link->set_start_location(p_restore);
|
link->set_start_position(p_restore);
|
||||||
} else {
|
} else {
|
||||||
link->set_end_location(p_restore);
|
link->set_end_position(p_restore);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
||||||
if (p_id == 0) {
|
if (p_id == 0) {
|
||||||
ur->create_action(TTR("Change Start Location"));
|
ur->create_action(TTR("Change Start Position"));
|
||||||
ur->add_do_method(link, "set_start_location", link->get_start_location());
|
ur->add_do_method(link, "set_start_position", link->get_start_position());
|
||||||
ur->add_undo_method(link, "set_start_location", p_restore);
|
ur->add_undo_method(link, "set_start_position", p_restore);
|
||||||
} else {
|
} else {
|
||||||
ur->create_action(TTR("Change End Location"));
|
ur->create_action(TTR("Change End Position"));
|
||||||
ur->add_do_method(link, "set_end_location", link->get_end_location());
|
ur->add_do_method(link, "set_end_position", link->get_end_position());
|
||||||
ur->add_undo_method(link, "set_end_location", p_restore);
|
ur->add_undo_method(link, "set_end_position", p_restore);
|
||||||
}
|
}
|
||||||
|
|
||||||
ur->commit_action();
|
ur->commit_action();
|
||||||
|
|
|
@ -535,32 +535,32 @@ uint32_t GodotNavigationServer::link_get_navigation_layers(const RID p_link) con
|
||||||
return link->get_navigation_layers();
|
return link->get_navigation_layers();
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_2(link_set_start_location, RID, p_link, Vector3, p_location) {
|
COMMAND_2(link_set_start_position, RID, p_link, Vector3, p_position) {
|
||||||
NavLink *link = link_owner.get_or_null(p_link);
|
NavLink *link = link_owner.get_or_null(p_link);
|
||||||
ERR_FAIL_COND(link == nullptr);
|
ERR_FAIL_COND(link == nullptr);
|
||||||
|
|
||||||
link->set_start_location(p_location);
|
link->set_start_position(p_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 GodotNavigationServer::link_get_start_location(RID p_link) const {
|
Vector3 GodotNavigationServer::link_get_start_position(RID p_link) const {
|
||||||
const NavLink *link = link_owner.get_or_null(p_link);
|
const NavLink *link = link_owner.get_or_null(p_link);
|
||||||
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
||||||
|
|
||||||
return link->get_start_location();
|
return link->get_start_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_2(link_set_end_location, RID, p_link, Vector3, p_location) {
|
COMMAND_2(link_set_end_position, RID, p_link, Vector3, p_position) {
|
||||||
NavLink *link = link_owner.get_or_null(p_link);
|
NavLink *link = link_owner.get_or_null(p_link);
|
||||||
ERR_FAIL_COND(link == nullptr);
|
ERR_FAIL_COND(link == nullptr);
|
||||||
|
|
||||||
link->set_end_location(p_location);
|
link->set_end_position(p_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 GodotNavigationServer::link_get_end_location(RID p_link) const {
|
Vector3 GodotNavigationServer::link_get_end_position(RID p_link) const {
|
||||||
const NavLink *link = link_owner.get_or_null(p_link);
|
const NavLink *link = link_owner.get_or_null(p_link);
|
||||||
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
||||||
|
|
||||||
return link->get_end_location();
|
return link->get_end_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost) {
|
COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost) {
|
||||||
|
|
|
@ -158,10 +158,10 @@ public:
|
||||||
virtual bool link_is_bidirectional(RID p_link) const override;
|
virtual bool link_is_bidirectional(RID p_link) const override;
|
||||||
COMMAND_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers);
|
COMMAND_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers);
|
||||||
virtual uint32_t link_get_navigation_layers(RID p_link) const override;
|
virtual uint32_t link_get_navigation_layers(RID p_link) const override;
|
||||||
COMMAND_2(link_set_start_location, RID, p_link, Vector3, p_location);
|
COMMAND_2(link_set_start_position, RID, p_link, Vector3, p_position);
|
||||||
virtual Vector3 link_get_start_location(RID p_link) const override;
|
virtual Vector3 link_get_start_position(RID p_link) const override;
|
||||||
COMMAND_2(link_set_end_location, RID, p_link, Vector3, p_location);
|
COMMAND_2(link_set_end_position, RID, p_link, Vector3, p_position);
|
||||||
virtual Vector3 link_get_end_location(RID p_link) const override;
|
virtual Vector3 link_get_end_position(RID p_link) const override;
|
||||||
COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost);
|
COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost);
|
||||||
virtual real_t link_get_enter_cost(RID p_link) const override;
|
virtual real_t link_get_enter_cost(RID p_link) const override;
|
||||||
COMMAND_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost);
|
COMMAND_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost);
|
||||||
|
|
|
@ -42,13 +42,13 @@ void NavLink::set_bidirectional(bool p_bidirectional) {
|
||||||
link_dirty = true;
|
link_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavLink::set_start_location(const Vector3 p_location) {
|
void NavLink::set_start_position(const Vector3 p_position) {
|
||||||
start_location = p_location;
|
start_position = p_position;
|
||||||
link_dirty = true;
|
link_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavLink::set_end_location(const Vector3 p_location) {
|
void NavLink::set_end_position(const Vector3 p_position) {
|
||||||
end_location = p_location;
|
end_position = p_position;
|
||||||
link_dirty = true;
|
link_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
class NavLink : public NavBase {
|
class NavLink : public NavBase {
|
||||||
NavMap *map = nullptr;
|
NavMap *map = nullptr;
|
||||||
bool bidirectional = true;
|
bool bidirectional = true;
|
||||||
Vector3 start_location;
|
Vector3 start_position;
|
||||||
Vector3 end_location;
|
Vector3 end_position;
|
||||||
|
|
||||||
bool link_dirty = true;
|
bool link_dirty = true;
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ public:
|
||||||
return bidirectional;
|
return bidirectional;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_start_location(Vector3 p_location);
|
void set_start_position(Vector3 p_position);
|
||||||
Vector3 get_start_location() const {
|
Vector3 get_start_position() const {
|
||||||
return start_location;
|
return start_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_end_location(Vector3 p_location);
|
void set_end_position(Vector3 p_position);
|
||||||
Vector3 get_end_location() const {
|
Vector3 get_end_position() const {
|
||||||
return end_location;
|
return end_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_dirty();
|
bool check_dirty();
|
||||||
|
|
|
@ -780,8 +780,8 @@ void NavMap::sync() {
|
||||||
|
|
||||||
// Search for polygons within range of a nav link.
|
// Search for polygons within range of a nav link.
|
||||||
for (const NavLink *link : links) {
|
for (const NavLink *link : links) {
|
||||||
const Vector3 start = link->get_start_location();
|
const Vector3 start = link->get_start_position();
|
||||||
const Vector3 end = link->get_end_location();
|
const Vector3 end = link->get_end_position();
|
||||||
|
|
||||||
gd::Polygon *closest_start_polygon = nullptr;
|
gd::Polygon *closest_start_polygon = nullptr;
|
||||||
real_t closest_start_distance = link_connection_radius;
|
real_t closest_start_distance = link_connection_radius;
|
||||||
|
|
|
@ -125,7 +125,7 @@ struct NavigationPoly {
|
||||||
Vector3 back_navigation_edge_pathway_start;
|
Vector3 back_navigation_edge_pathway_start;
|
||||||
Vector3 back_navigation_edge_pathway_end;
|
Vector3 back_navigation_edge_pathway_end;
|
||||||
|
|
||||||
/// The entry location of this poly.
|
/// The entry position of this poly.
|
||||||
Vector3 entry;
|
Vector3 entry;
|
||||||
/// The distance to the destination.
|
/// The distance to the destination.
|
||||||
float traveled_distance = 0.0;
|
float traveled_distance = 0.0;
|
||||||
|
|
|
@ -76,10 +76,10 @@ void NavigationAgent2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent2D::set_navigation_map);
|
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent2D::set_navigation_map);
|
||||||
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent2D::get_navigation_map);
|
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent2D::get_navigation_map);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent2D::set_target_location);
|
ClassDB::bind_method(D_METHOD("set_target_position", "position"), &NavigationAgent2D::set_target_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent2D::get_target_location);
|
ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationAgent2D::get_target_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent2D::get_next_location);
|
ClassDB::bind_method(D_METHOD("get_next_path_position"), &NavigationAgent2D::get_next_path_position);
|
||||||
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent2D::distance_to_target);
|
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent2D::distance_to_target);
|
||||||
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent2D::set_velocity);
|
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent2D::set_velocity);
|
||||||
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent2D::get_current_navigation_result);
|
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent2D::get_current_navigation_result);
|
||||||
|
@ -88,12 +88,12 @@ void NavigationAgent2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent2D::is_target_reached);
|
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent2D::is_target_reached);
|
||||||
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent2D::is_target_reachable);
|
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent2D::is_target_reachable);
|
||||||
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent2D::is_navigation_finished);
|
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent2D::is_navigation_finished);
|
||||||
ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent2D::get_final_location);
|
ClassDB::bind_method(D_METHOD("get_final_position"), &NavigationAgent2D::get_final_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent2D::_avoidance_done);
|
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent2D::_avoidance_done);
|
||||||
|
|
||||||
ADD_GROUP("Pathfinding", "");
|
ADD_GROUP("Pathfinding", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_location", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_location", "get_target_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_position", "get_target_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_path_desired_distance", "get_path_desired_distance");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_path_desired_distance", "get_path_desired_distance");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,suffix:px"), "set_path_max_distance", "get_path_max_distance");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,suffix:px"), "set_path_max_distance", "get_path_max_distance");
|
||||||
|
@ -328,17 +328,17 @@ real_t NavigationAgent2D::get_path_max_distance() {
|
||||||
return path_max_distance;
|
return path_max_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationAgent2D::set_target_location(Vector2 p_location) {
|
void NavigationAgent2D::set_target_position(Vector2 p_position) {
|
||||||
target_location = p_location;
|
target_position = p_position;
|
||||||
target_position_submitted = true;
|
target_position_submitted = true;
|
||||||
_request_repath();
|
_request_repath();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 NavigationAgent2D::get_target_location() const {
|
Vector2 NavigationAgent2D::get_target_position() const {
|
||||||
return target_location;
|
return target_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 NavigationAgent2D::get_next_location() {
|
Vector2 NavigationAgent2D::get_next_path_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
||||||
|
@ -352,7 +352,7 @@ Vector2 NavigationAgent2D::get_next_location() {
|
||||||
|
|
||||||
real_t NavigationAgent2D::distance_to_target() const {
|
real_t NavigationAgent2D::distance_to_target() const {
|
||||||
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
|
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
|
||||||
return agent_parent->get_global_position().distance_to(target_location);
|
return agent_parent->get_global_position().distance_to(target_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent2D::is_target_reached() const {
|
bool NavigationAgent2D::is_target_reached() const {
|
||||||
|
@ -360,7 +360,7 @@ bool NavigationAgent2D::is_target_reached() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent2D::is_target_reachable() {
|
bool NavigationAgent2D::is_target_reachable() {
|
||||||
return target_desired_distance >= get_final_location().distance_to(target_location);
|
return target_desired_distance >= get_final_position().distance_to(target_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent2D::is_navigation_finished() {
|
bool NavigationAgent2D::is_navigation_finished() {
|
||||||
|
@ -368,7 +368,7 @@ bool NavigationAgent2D::is_navigation_finished() {
|
||||||
return navigation_finished;
|
return navigation_finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 NavigationAgent2D::get_final_location() {
|
Vector2 NavigationAgent2D::get_final_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
||||||
|
@ -450,7 +450,7 @@ void NavigationAgent2D::update_navigation() {
|
||||||
|
|
||||||
if (reload_path) {
|
if (reload_path) {
|
||||||
navigation_query->set_start_position(origin);
|
navigation_query->set_start_position(origin);
|
||||||
navigation_query->set_target_position(target_location);
|
navigation_query->set_target_position(target_position);
|
||||||
navigation_query->set_navigation_layers(navigation_layers);
|
navigation_query->set_navigation_layers(navigation_layers);
|
||||||
navigation_query->set_metadata_flags(path_metadata_flags);
|
navigation_query->set_metadata_flags(path_metadata_flags);
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ void NavigationAgent2D::update_navigation() {
|
||||||
|
|
||||||
// Check if we can advance the navigation path
|
// Check if we can advance the navigation path
|
||||||
if (navigation_finished == false) {
|
if (navigation_finished == false) {
|
||||||
// Advances to the next far away location.
|
// Advances to the next far away position.
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
||||||
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
||||||
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
|
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
|
||||||
|
@ -482,7 +482,7 @@ void NavigationAgent2D::update_navigation() {
|
||||||
Dictionary details;
|
Dictionary details;
|
||||||
|
|
||||||
const Vector2 waypoint = navigation_path[navigation_path_index];
|
const Vector2 waypoint = navigation_path[navigation_path_index];
|
||||||
details[SNAME("location")] = waypoint;
|
details[SNAME("position")] = waypoint;
|
||||||
|
|
||||||
int waypoint_type = -1;
|
int waypoint_type = -1;
|
||||||
if (path_metadata_flags.has_flag(NavigationPathQueryParameters2D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
|
if (path_metadata_flags.has_flag(NavigationPathQueryParameters2D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class NavigationAgent2D : public Node {
|
||||||
|
|
||||||
real_t path_max_distance = 100.0;
|
real_t path_max_distance = 100.0;
|
||||||
|
|
||||||
Vector2 target_location;
|
Vector2 target_position;
|
||||||
bool target_position_submitted = false;
|
bool target_position_submitted = false;
|
||||||
Ref<NavigationPathQueryParameters2D> navigation_query;
|
Ref<NavigationPathQueryParameters2D> navigation_query;
|
||||||
Ref<NavigationPathQueryResult2D> navigation_result;
|
Ref<NavigationPathQueryResult2D> navigation_result;
|
||||||
|
@ -143,10 +143,10 @@ public:
|
||||||
void set_path_max_distance(real_t p_pmd);
|
void set_path_max_distance(real_t p_pmd);
|
||||||
real_t get_path_max_distance();
|
real_t get_path_max_distance();
|
||||||
|
|
||||||
void set_target_location(Vector2 p_location);
|
void set_target_position(Vector2 p_position);
|
||||||
Vector2 get_target_location() const;
|
Vector2 get_target_position() const;
|
||||||
|
|
||||||
Vector2 get_next_location();
|
Vector2 get_next_path_position();
|
||||||
|
|
||||||
Ref<NavigationPathQueryResult2D> get_current_navigation_result() const {
|
Ref<NavigationPathQueryResult2D> get_current_navigation_result() const {
|
||||||
return navigation_result;
|
return navigation_result;
|
||||||
|
@ -162,7 +162,7 @@ public:
|
||||||
bool is_target_reached() const;
|
bool is_target_reached() const;
|
||||||
bool is_target_reachable();
|
bool is_target_reachable();
|
||||||
bool is_navigation_finished();
|
bool is_navigation_finished();
|
||||||
Vector2 get_final_location();
|
Vector2 get_final_position();
|
||||||
|
|
||||||
void set_velocity(Vector2 p_velocity);
|
void set_velocity(Vector2 p_velocity);
|
||||||
void _avoidance_done(Vector3 p_new_velocity);
|
void _avoidance_done(Vector3 p_new_velocity);
|
||||||
|
|
|
@ -48,11 +48,11 @@ void NavigationLink2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink2D::set_navigation_layer_value);
|
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink2D::set_navigation_layer_value);
|
||||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink2D::get_navigation_layer_value);
|
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink2D::get_navigation_layer_value);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_start_location", "location"), &NavigationLink2D::set_start_location);
|
ClassDB::bind_method(D_METHOD("set_start_position", "position"), &NavigationLink2D::set_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_start_location"), &NavigationLink2D::get_start_location);
|
ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationLink2D::get_start_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_end_location", "location"), &NavigationLink2D::set_end_location);
|
ClassDB::bind_method(D_METHOD("set_end_position", "position"), &NavigationLink2D::set_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_end_location"), &NavigationLink2D::get_end_location);
|
ClassDB::bind_method(D_METHOD("get_end_position"), &NavigationLink2D::get_end_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink2D::set_enter_cost);
|
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink2D::set_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink2D::get_enter_cost);
|
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink2D::get_enter_cost);
|
||||||
|
@ -63,12 +63,38 @@ void NavigationLink2D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_location"), "set_start_location", "get_start_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_position"), "set_start_position", "get_start_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "end_location"), "set_end_location", "get_end_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "end_position"), "set_end_position", "get_end_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool NavigationLink2D::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "start_location") {
|
||||||
|
set_start_position(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (p_name == "end_location") {
|
||||||
|
set_end_position(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NavigationLink2D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (p_name == "start_location") {
|
||||||
|
r_ret = get_start_position();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (p_name == "end_location") {
|
||||||
|
r_ret = get_end_position();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void NavigationLink2D::_notification(int p_what) {
|
void NavigationLink2D::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
@ -77,15 +103,15 @@ void NavigationLink2D::_notification(int p_what) {
|
||||||
|
|
||||||
// Update global positions for the link.
|
// Update global positions for the link.
|
||||||
Transform2D gt = get_global_transform();
|
Transform2D gt = get_global_transform();
|
||||||
NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||||
// Update global positions for the link.
|
// Update global positions for the link.
|
||||||
Transform2D gt = get_global_transform();
|
Transform2D gt = get_global_transform();
|
||||||
NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
NavigationServer2D::get_singleton()->link_set_map(link, RID());
|
NavigationServer2D::get_singleton()->link_set_map(link, RID());
|
||||||
|
@ -102,9 +128,9 @@ void NavigationLink2D::_notification(int p_what) {
|
||||||
|
|
||||||
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
|
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
|
||||||
|
|
||||||
draw_line(get_start_location(), get_end_location(), color);
|
draw_line(get_start_position(), get_end_position(), color);
|
||||||
draw_arc(get_start_location(), radius, 0, Math_TAU, 10, color);
|
draw_arc(get_start_position(), radius, 0, Math_TAU, 10, color);
|
||||||
draw_arc(get_end_location(), radius, 0, Math_TAU, 10, color);
|
draw_arc(get_end_position(), radius, 0, Math_TAU, 10, color);
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
} break;
|
} break;
|
||||||
|
@ -119,14 +145,14 @@ Rect2 NavigationLink2D::_edit_get_rect() const {
|
||||||
|
|
||||||
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
|
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
|
||||||
|
|
||||||
Rect2 rect(get_start_location(), Size2());
|
Rect2 rect(get_start_position(), Size2());
|
||||||
rect.expand_to(get_end_location());
|
rect.expand_to(get_end_position());
|
||||||
rect.grow_by(radius);
|
rect.grow_by(radius);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||||
Point2 segment[2] = { get_start_location(), get_end_location() };
|
Point2 segment[2] = { get_start_position(), get_end_position() };
|
||||||
|
|
||||||
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, segment);
|
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, segment);
|
||||||
return p_point.distance_to(closest_point) < p_tolerance;
|
return p_point.distance_to(closest_point) < p_tolerance;
|
||||||
|
@ -199,19 +225,19 @@ bool NavigationLink2D::get_navigation_layer_value(int p_layer_number) const {
|
||||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink2D::set_start_location(Vector2 p_location) {
|
void NavigationLink2D::set_start_position(Vector2 p_position) {
|
||||||
if (start_location.is_equal_approx(p_location)) {
|
if (start_position.is_equal_approx(p_position)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_location = p_location;
|
start_position = p_position;
|
||||||
|
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D gt = get_global_transform();
|
Transform2D gt = get_global_transform();
|
||||||
NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
|
|
||||||
update_configuration_warnings();
|
update_configuration_warnings();
|
||||||
|
|
||||||
|
@ -222,19 +248,19 @@ void NavigationLink2D::set_start_location(Vector2 p_location) {
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink2D::set_end_location(Vector2 p_location) {
|
void NavigationLink2D::set_end_position(Vector2 p_position) {
|
||||||
if (end_location.is_equal_approx(p_location)) {
|
if (end_position.is_equal_approx(p_position)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
end_location = p_location;
|
end_position = p_position;
|
||||||
|
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D gt = get_global_transform();
|
Transform2D gt = get_global_transform();
|
||||||
NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
|
|
||||||
update_configuration_warnings();
|
update_configuration_warnings();
|
||||||
|
|
||||||
|
@ -270,8 +296,8 @@ void NavigationLink2D::set_travel_cost(real_t p_travel_cost) {
|
||||||
PackedStringArray NavigationLink2D::get_configuration_warnings() const {
|
PackedStringArray NavigationLink2D::get_configuration_warnings() const {
|
||||||
PackedStringArray warnings = Node::get_configuration_warnings();
|
PackedStringArray warnings = Node::get_configuration_warnings();
|
||||||
|
|
||||||
if (start_location.is_equal_approx(end_location)) {
|
if (start_position.is_equal_approx(end_position)) {
|
||||||
warnings.push_back(RTR("NavigationLink2D start location should be different than the end location to be useful."));
|
warnings.push_back(RTR("NavigationLink2D start position should be different than the end position to be useful."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return warnings;
|
return warnings;
|
||||||
|
|
|
@ -40,8 +40,8 @@ class NavigationLink2D : public Node2D {
|
||||||
RID link;
|
RID link;
|
||||||
bool bidirectional = true;
|
bool bidirectional = true;
|
||||||
uint32_t navigation_layers = 1;
|
uint32_t navigation_layers = 1;
|
||||||
Vector2 end_location;
|
Vector2 end_position;
|
||||||
Vector2 start_location;
|
Vector2 start_position;
|
||||||
real_t enter_cost = 0.0;
|
real_t enter_cost = 0.0;
|
||||||
real_t travel_cost = 1.0;
|
real_t travel_cost = 1.0;
|
||||||
|
|
||||||
|
@ -49,6 +49,11 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
virtual Rect2 _edit_get_rect() const override;
|
virtual Rect2 _edit_get_rect() const override;
|
||||||
|
@ -67,11 +72,11 @@ public:
|
||||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||||
bool get_navigation_layer_value(int p_layer_number) const;
|
bool get_navigation_layer_value(int p_layer_number) const;
|
||||||
|
|
||||||
void set_start_location(Vector2 p_location);
|
void set_start_position(Vector2 p_position);
|
||||||
Vector2 get_start_location() const { return start_location; }
|
Vector2 get_start_position() const { return start_position; }
|
||||||
|
|
||||||
void set_end_location(Vector2 p_location);
|
void set_end_position(Vector2 p_position);
|
||||||
Vector2 get_end_location() const { return end_location; }
|
Vector2 get_end_position() const { return end_position; }
|
||||||
|
|
||||||
void set_enter_cost(real_t p_enter_cost);
|
void set_enter_cost(real_t p_enter_cost);
|
||||||
real_t get_enter_cost() const { return enter_cost; }
|
real_t get_enter_cost() const { return enter_cost; }
|
||||||
|
|
|
@ -80,10 +80,10 @@ void NavigationAgent3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent3D::set_navigation_map);
|
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent3D::set_navigation_map);
|
||||||
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent3D::get_navigation_map);
|
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent3D::get_navigation_map);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent3D::set_target_location);
|
ClassDB::bind_method(D_METHOD("set_target_position", "position"), &NavigationAgent3D::set_target_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent3D::get_target_location);
|
ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationAgent3D::get_target_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent3D::get_next_location);
|
ClassDB::bind_method(D_METHOD("get_next_path_position"), &NavigationAgent3D::get_next_path_position);
|
||||||
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent3D::distance_to_target);
|
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent3D::distance_to_target);
|
||||||
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent3D::set_velocity);
|
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent3D::set_velocity);
|
||||||
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent3D::get_current_navigation_result);
|
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent3D::get_current_navigation_result);
|
||||||
|
@ -92,12 +92,12 @@ void NavigationAgent3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent3D::is_target_reached);
|
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent3D::is_target_reached);
|
||||||
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent3D::is_target_reachable);
|
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent3D::is_target_reachable);
|
||||||
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent3D::is_navigation_finished);
|
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent3D::is_navigation_finished);
|
||||||
ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent3D::get_final_location);
|
ClassDB::bind_method(D_METHOD("get_final_position"), &NavigationAgent3D::get_final_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent3D::_avoidance_done);
|
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent3D::_avoidance_done);
|
||||||
|
|
||||||
ADD_GROUP("Pathfinding", "");
|
ADD_GROUP("Pathfinding", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_location", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_location", "get_target_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_position", "get_target_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_path_desired_distance", "get_path_desired_distance");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_path_desired_distance", "get_path_desired_distance");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_target_desired_distance", "get_target_desired_distance");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_target_desired_distance", "get_target_desired_distance");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,suffix:m"), "set_agent_height_offset", "get_agent_height_offset");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,suffix:m"), "set_agent_height_offset", "get_agent_height_offset");
|
||||||
|
@ -344,17 +344,17 @@ real_t NavigationAgent3D::get_path_max_distance() {
|
||||||
return path_max_distance;
|
return path_max_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationAgent3D::set_target_location(Vector3 p_location) {
|
void NavigationAgent3D::set_target_position(Vector3 p_position) {
|
||||||
target_location = p_location;
|
target_position = p_position;
|
||||||
target_position_submitted = true;
|
target_position_submitted = true;
|
||||||
_request_repath();
|
_request_repath();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 NavigationAgent3D::get_target_location() const {
|
Vector3 NavigationAgent3D::get_target_position() const {
|
||||||
return target_location;
|
return target_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 NavigationAgent3D::get_next_location() {
|
Vector3 NavigationAgent3D::get_next_path_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
||||||
|
@ -368,7 +368,7 @@ Vector3 NavigationAgent3D::get_next_location() {
|
||||||
|
|
||||||
real_t NavigationAgent3D::distance_to_target() const {
|
real_t NavigationAgent3D::distance_to_target() const {
|
||||||
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
|
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
|
||||||
return agent_parent->get_global_transform().origin.distance_to(target_location);
|
return agent_parent->get_global_transform().origin.distance_to(target_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent3D::is_target_reached() const {
|
bool NavigationAgent3D::is_target_reached() const {
|
||||||
|
@ -376,7 +376,7 @@ bool NavigationAgent3D::is_target_reached() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent3D::is_target_reachable() {
|
bool NavigationAgent3D::is_target_reachable() {
|
||||||
return target_desired_distance >= get_final_location().distance_to(target_location);
|
return target_desired_distance >= get_final_position().distance_to(target_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationAgent3D::is_navigation_finished() {
|
bool NavigationAgent3D::is_navigation_finished() {
|
||||||
|
@ -384,7 +384,7 @@ bool NavigationAgent3D::is_navigation_finished() {
|
||||||
return navigation_finished;
|
return navigation_finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 NavigationAgent3D::get_final_location() {
|
Vector3 NavigationAgent3D::get_final_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
||||||
|
@ -467,7 +467,7 @@ void NavigationAgent3D::update_navigation() {
|
||||||
|
|
||||||
if (reload_path) {
|
if (reload_path) {
|
||||||
navigation_query->set_start_position(origin);
|
navigation_query->set_start_position(origin);
|
||||||
navigation_query->set_target_position(target_location);
|
navigation_query->set_target_position(target_position);
|
||||||
navigation_query->set_navigation_layers(navigation_layers);
|
navigation_query->set_navigation_layers(navigation_layers);
|
||||||
navigation_query->set_metadata_flags(path_metadata_flags);
|
navigation_query->set_metadata_flags(path_metadata_flags);
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ void NavigationAgent3D::update_navigation() {
|
||||||
|
|
||||||
// Check if we can advance the navigation path
|
// Check if we can advance the navigation path
|
||||||
if (navigation_finished == false) {
|
if (navigation_finished == false) {
|
||||||
// Advances to the next far away location.
|
// Advances to the next far away position.
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
||||||
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
||||||
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
|
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
|
||||||
|
@ -499,7 +499,7 @@ void NavigationAgent3D::update_navigation() {
|
||||||
Dictionary details;
|
Dictionary details;
|
||||||
|
|
||||||
const Vector3 waypoint = navigation_path[navigation_path_index];
|
const Vector3 waypoint = navigation_path[navigation_path_index];
|
||||||
details[SNAME("location")] = waypoint;
|
details[SNAME("position")] = waypoint;
|
||||||
|
|
||||||
int waypoint_type = -1;
|
int waypoint_type = -1;
|
||||||
if (path_metadata_flags.has_flag(NavigationPathQueryParameters3D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
|
if (path_metadata_flags.has_flag(NavigationPathQueryParameters3D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class NavigationAgent3D : public Node {
|
||||||
|
|
||||||
real_t path_max_distance = 3.0;
|
real_t path_max_distance = 3.0;
|
||||||
|
|
||||||
Vector3 target_location;
|
Vector3 target_position;
|
||||||
bool target_position_submitted = false;
|
bool target_position_submitted = false;
|
||||||
Ref<NavigationPathQueryParameters3D> navigation_query;
|
Ref<NavigationPathQueryParameters3D> navigation_query;
|
||||||
Ref<NavigationPathQueryResult3D> navigation_result;
|
Ref<NavigationPathQueryResult3D> navigation_result;
|
||||||
|
@ -155,10 +155,10 @@ public:
|
||||||
void set_path_max_distance(real_t p_pmd);
|
void set_path_max_distance(real_t p_pmd);
|
||||||
real_t get_path_max_distance();
|
real_t get_path_max_distance();
|
||||||
|
|
||||||
void set_target_location(Vector3 p_location);
|
void set_target_position(Vector3 p_position);
|
||||||
Vector3 get_target_location() const;
|
Vector3 get_target_position() const;
|
||||||
|
|
||||||
Vector3 get_next_location();
|
Vector3 get_next_path_position();
|
||||||
|
|
||||||
Ref<NavigationPathQueryResult3D> get_current_navigation_result() const {
|
Ref<NavigationPathQueryResult3D> get_current_navigation_result() const {
|
||||||
return navigation_result;
|
return navigation_result;
|
||||||
|
@ -174,7 +174,7 @@ public:
|
||||||
bool is_target_reached() const;
|
bool is_target_reached() const;
|
||||||
bool is_target_reachable();
|
bool is_target_reachable();
|
||||||
bool is_navigation_finished();
|
bool is_navigation_finished();
|
||||||
Vector3 get_final_location();
|
Vector3 get_final_position();
|
||||||
|
|
||||||
void set_velocity(Vector3 p_velocity);
|
void set_velocity(Vector3 p_velocity);
|
||||||
void _avoidance_done(Vector3 p_new_velocity);
|
void _avoidance_done(Vector3 p_new_velocity);
|
||||||
|
|
|
@ -70,10 +70,10 @@ void NavigationLink3D::_update_debug_mesh() {
|
||||||
Vector<Vector3> lines;
|
Vector<Vector3> lines;
|
||||||
|
|
||||||
// Draw line between the points.
|
// Draw line between the points.
|
||||||
lines.push_back(start_location);
|
lines.push_back(start_position);
|
||||||
lines.push_back(end_location);
|
lines.push_back(end_position);
|
||||||
|
|
||||||
// Draw start location search radius
|
// Draw start position search radius
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
// Create a circle
|
// Create a circle
|
||||||
const float ra = Math::deg_to_rad((float)(i * 12));
|
const float ra = Math::deg_to_rad((float)(i * 12));
|
||||||
|
@ -84,21 +84,21 @@ void NavigationLink3D::_update_debug_mesh() {
|
||||||
// Draw axis-aligned circle
|
// Draw axis-aligned circle
|
||||||
switch (up_axis) {
|
switch (up_axis) {
|
||||||
case Vector3::AXIS_X:
|
case Vector3::AXIS_X:
|
||||||
lines.append(start_location + Vector3(0, a.x, a.y));
|
lines.append(start_position + Vector3(0, a.x, a.y));
|
||||||
lines.append(start_location + Vector3(0, b.x, b.y));
|
lines.append(start_position + Vector3(0, b.x, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Y:
|
case Vector3::AXIS_Y:
|
||||||
lines.append(start_location + Vector3(a.x, 0, a.y));
|
lines.append(start_position + Vector3(a.x, 0, a.y));
|
||||||
lines.append(start_location + Vector3(b.x, 0, b.y));
|
lines.append(start_position + Vector3(b.x, 0, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Z:
|
case Vector3::AXIS_Z:
|
||||||
lines.append(start_location + Vector3(a.x, a.y, 0));
|
lines.append(start_position + Vector3(a.x, a.y, 0));
|
||||||
lines.append(start_location + Vector3(b.x, b.y, 0));
|
lines.append(start_position + Vector3(b.x, b.y, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw end location search radius
|
// Draw end position search radius
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
// Create a circle
|
// Create a circle
|
||||||
const float ra = Math::deg_to_rad((float)(i * 12));
|
const float ra = Math::deg_to_rad((float)(i * 12));
|
||||||
|
@ -109,16 +109,16 @@ void NavigationLink3D::_update_debug_mesh() {
|
||||||
// Draw axis-aligned circle
|
// Draw axis-aligned circle
|
||||||
switch (up_axis) {
|
switch (up_axis) {
|
||||||
case Vector3::AXIS_X:
|
case Vector3::AXIS_X:
|
||||||
lines.append(end_location + Vector3(0, a.x, a.y));
|
lines.append(end_position + Vector3(0, a.x, a.y));
|
||||||
lines.append(end_location + Vector3(0, b.x, b.y));
|
lines.append(end_position + Vector3(0, b.x, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Y:
|
case Vector3::AXIS_Y:
|
||||||
lines.append(end_location + Vector3(a.x, 0, a.y));
|
lines.append(end_position + Vector3(a.x, 0, a.y));
|
||||||
lines.append(end_location + Vector3(b.x, 0, b.y));
|
lines.append(end_position + Vector3(b.x, 0, b.y));
|
||||||
break;
|
break;
|
||||||
case Vector3::AXIS_Z:
|
case Vector3::AXIS_Z:
|
||||||
lines.append(end_location + Vector3(a.x, a.y, 0));
|
lines.append(end_position + Vector3(a.x, a.y, 0));
|
||||||
lines.append(end_location + Vector3(b.x, b.y, 0));
|
lines.append(end_position + Vector3(b.x, b.y, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,11 @@ void NavigationLink3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink3D::set_navigation_layer_value);
|
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink3D::set_navigation_layer_value);
|
||||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink3D::get_navigation_layer_value);
|
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink3D::get_navigation_layer_value);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_start_location", "location"), &NavigationLink3D::set_start_location);
|
ClassDB::bind_method(D_METHOD("set_start_position", "position"), &NavigationLink3D::set_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_start_location"), &NavigationLink3D::get_start_location);
|
ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationLink3D::get_start_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_end_location", "location"), &NavigationLink3D::set_end_location);
|
ClassDB::bind_method(D_METHOD("set_end_position", "position"), &NavigationLink3D::set_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_end_location"), &NavigationLink3D::get_end_location);
|
ClassDB::bind_method(D_METHOD("get_end_position"), &NavigationLink3D::get_end_position);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink3D::set_enter_cost);
|
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink3D::set_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink3D::get_enter_cost);
|
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink3D::get_enter_cost);
|
||||||
|
@ -172,12 +172,38 @@ void NavigationLink3D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_location"), "set_start_location", "get_start_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end_location"), "set_end_location", "get_end_location");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end_position"), "set_end_position", "get_end_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool NavigationLink3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
|
if (p_name == "start_location") {
|
||||||
|
set_start_position(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (p_name == "end_location") {
|
||||||
|
set_end_position(p_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NavigationLink3D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (p_name == "start_location") {
|
||||||
|
r_ret = get_start_position();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (p_name == "end_location") {
|
||||||
|
r_ret = get_end_position();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
void NavigationLink3D::_notification(int p_what) {
|
void NavigationLink3D::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
@ -186,8 +212,8 @@ void NavigationLink3D::_notification(int p_what) {
|
||||||
|
|
||||||
// Update global positions for the link.
|
// Update global positions for the link.
|
||||||
Transform3D gt = get_global_transform();
|
Transform3D gt = get_global_transform();
|
||||||
NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
@ -197,8 +223,8 @@ void NavigationLink3D::_notification(int p_what) {
|
||||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||||
// Update global positions for the link.
|
// Update global positions for the link.
|
||||||
Transform3D gt = get_global_transform();
|
Transform3D gt = get_global_transform();
|
||||||
NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (is_inside_tree() && debug_instance.is_valid()) {
|
if (is_inside_tree() && debug_instance.is_valid()) {
|
||||||
|
@ -316,19 +342,19 @@ bool NavigationLink3D::get_navigation_layer_value(int p_layer_number) const {
|
||||||
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
return get_navigation_layers() & (1 << (p_layer_number - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink3D::set_start_location(Vector3 p_location) {
|
void NavigationLink3D::set_start_position(Vector3 p_position) {
|
||||||
if (start_location.is_equal_approx(p_location)) {
|
if (start_position.is_equal_approx(p_position)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_location = p_location;
|
start_position = p_position;
|
||||||
|
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform3D gt = get_global_transform();
|
Transform3D gt = get_global_transform();
|
||||||
NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
|
NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
_update_debug_mesh();
|
_update_debug_mesh();
|
||||||
|
@ -338,19 +364,19 @@ void NavigationLink3D::set_start_location(Vector3 p_location) {
|
||||||
update_configuration_warnings();
|
update_configuration_warnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationLink3D::set_end_location(Vector3 p_location) {
|
void NavigationLink3D::set_end_position(Vector3 p_position) {
|
||||||
if (end_location.is_equal_approx(p_location)) {
|
if (end_position.is_equal_approx(p_position)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
end_location = p_location;
|
end_position = p_position;
|
||||||
|
|
||||||
if (!is_inside_tree()) {
|
if (!is_inside_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform3D gt = get_global_transform();
|
Transform3D gt = get_global_transform();
|
||||||
NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
|
NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
_update_debug_mesh();
|
_update_debug_mesh();
|
||||||
|
@ -385,8 +411,8 @@ void NavigationLink3D::set_travel_cost(real_t p_travel_cost) {
|
||||||
PackedStringArray NavigationLink3D::get_configuration_warnings() const {
|
PackedStringArray NavigationLink3D::get_configuration_warnings() const {
|
||||||
PackedStringArray warnings = Node::get_configuration_warnings();
|
PackedStringArray warnings = Node::get_configuration_warnings();
|
||||||
|
|
||||||
if (start_location.is_equal_approx(end_location)) {
|
if (start_position.is_equal_approx(end_position)) {
|
||||||
warnings.push_back(RTR("NavigationLink3D start location should be different than the end location to be useful."));
|
warnings.push_back(RTR("NavigationLink3D start position should be different than the end position to be useful."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return warnings;
|
return warnings;
|
||||||
|
|
|
@ -40,8 +40,8 @@ class NavigationLink3D : public Node3D {
|
||||||
RID link;
|
RID link;
|
||||||
bool bidirectional = true;
|
bool bidirectional = true;
|
||||||
uint32_t navigation_layers = 1;
|
uint32_t navigation_layers = 1;
|
||||||
Vector3 end_location;
|
Vector3 end_position;
|
||||||
Vector3 start_location;
|
Vector3 start_position;
|
||||||
real_t enter_cost = 0.0;
|
real_t enter_cost = 0.0;
|
||||||
real_t travel_cost = 1.0;
|
real_t travel_cost = 1.0;
|
||||||
|
|
||||||
|
@ -56,6 +56,11 @@ protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEPRECATED
|
||||||
|
bool _set(const StringName &p_name, const Variant &p_value);
|
||||||
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
#endif // DISABLE_DEPRECATED
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NavigationLink3D();
|
NavigationLink3D();
|
||||||
~NavigationLink3D();
|
~NavigationLink3D();
|
||||||
|
@ -72,11 +77,11 @@ public:
|
||||||
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
void set_navigation_layer_value(int p_layer_number, bool p_value);
|
||||||
bool get_navigation_layer_value(int p_layer_number) const;
|
bool get_navigation_layer_value(int p_layer_number) const;
|
||||||
|
|
||||||
void set_start_location(Vector3 p_location);
|
void set_start_position(Vector3 p_position);
|
||||||
Vector3 get_start_location() const { return start_location; }
|
Vector3 get_start_position() const { return start_position; }
|
||||||
|
|
||||||
void set_end_location(Vector3 p_location);
|
void set_end_position(Vector3 p_position);
|
||||||
Vector3 get_end_location() const { return end_location; }
|
Vector3 get_end_position() const { return end_position; }
|
||||||
|
|
||||||
void set_enter_cost(real_t p_enter_cost);
|
void set_enter_cost(real_t p_enter_cost);
|
||||||
real_t get_enter_cost() const { return enter_cost; }
|
real_t get_enter_cost() const { return enter_cost; }
|
||||||
|
|
|
@ -285,10 +285,10 @@ void NavigationServer2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("link_is_bidirectional", "link"), &NavigationServer2D::link_is_bidirectional);
|
ClassDB::bind_method(D_METHOD("link_is_bidirectional", "link"), &NavigationServer2D::link_is_bidirectional);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_navigation_layers", "link", "navigation_layers"), &NavigationServer2D::link_set_navigation_layers);
|
ClassDB::bind_method(D_METHOD("link_set_navigation_layers", "link", "navigation_layers"), &NavigationServer2D::link_set_navigation_layers);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_navigation_layers", "link"), &NavigationServer2D::link_get_navigation_layers);
|
ClassDB::bind_method(D_METHOD("link_get_navigation_layers", "link"), &NavigationServer2D::link_get_navigation_layers);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_start_location", "link", "location"), &NavigationServer2D::link_set_start_location);
|
ClassDB::bind_method(D_METHOD("link_set_start_position", "link", "position"), &NavigationServer2D::link_set_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_start_location", "link"), &NavigationServer2D::link_get_start_location);
|
ClassDB::bind_method(D_METHOD("link_get_start_position", "link"), &NavigationServer2D::link_get_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_end_location", "link", "location"), &NavigationServer2D::link_set_end_location);
|
ClassDB::bind_method(D_METHOD("link_set_end_position", "link", "position"), &NavigationServer2D::link_set_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_end_location", "link"), &NavigationServer2D::link_get_end_location);
|
ClassDB::bind_method(D_METHOD("link_get_end_position", "link"), &NavigationServer2D::link_get_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_enter_cost", "link", "enter_cost"), &NavigationServer2D::link_set_enter_cost);
|
ClassDB::bind_method(D_METHOD("link_set_enter_cost", "link", "enter_cost"), &NavigationServer2D::link_set_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_enter_cost", "link"), &NavigationServer2D::link_get_enter_cost);
|
ClassDB::bind_method(D_METHOD("link_get_enter_cost", "link"), &NavigationServer2D::link_get_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_travel_cost", "link", "travel_cost"), &NavigationServer2D::link_set_travel_cost);
|
ClassDB::bind_method(D_METHOD("link_set_travel_cost", "link", "travel_cost"), &NavigationServer2D::link_set_travel_cost);
|
||||||
|
@ -392,10 +392,10 @@ void FORWARD_2(link_set_bidirectional, RID, p_link, bool, p_bidirectional, rid_t
|
||||||
bool FORWARD_1_C(link_is_bidirectional, RID, p_link, rid_to_rid);
|
bool FORWARD_1_C(link_is_bidirectional, RID, p_link, rid_to_rid);
|
||||||
void FORWARD_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers, rid_to_rid, uint32_to_uint32);
|
void FORWARD_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers, rid_to_rid, uint32_to_uint32);
|
||||||
uint32_t FORWARD_1_C(link_get_navigation_layers, RID, p_link, rid_to_rid);
|
uint32_t FORWARD_1_C(link_get_navigation_layers, RID, p_link, rid_to_rid);
|
||||||
void FORWARD_2(link_set_start_location, RID, p_link, Vector2, p_location, rid_to_rid, v2_to_v3);
|
void FORWARD_2(link_set_start_position, RID, p_link, Vector2, p_position, rid_to_rid, v2_to_v3);
|
||||||
Vector2 FORWARD_1_R_C(v3_to_v2, link_get_start_location, RID, p_link, rid_to_rid);
|
Vector2 FORWARD_1_R_C(v3_to_v2, link_get_start_position, RID, p_link, rid_to_rid);
|
||||||
void FORWARD_2(link_set_end_location, RID, p_link, Vector2, p_location, rid_to_rid, v2_to_v3);
|
void FORWARD_2(link_set_end_position, RID, p_link, Vector2, p_position, rid_to_rid, v2_to_v3);
|
||||||
Vector2 FORWARD_1_R_C(v3_to_v2, link_get_end_location, RID, p_link, rid_to_rid);
|
Vector2 FORWARD_1_R_C(v3_to_v2, link_get_end_position, RID, p_link, rid_to_rid);
|
||||||
void FORWARD_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost, rid_to_rid, real_to_real);
|
void FORWARD_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost, rid_to_rid, real_to_real);
|
||||||
real_t FORWARD_1_C(link_get_enter_cost, RID, p_link, rid_to_rid);
|
real_t FORWARD_1_C(link_get_enter_cost, RID, p_link, rid_to_rid);
|
||||||
void FORWARD_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost, rid_to_rid, real_to_real);
|
void FORWARD_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost, rid_to_rid, real_to_real);
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
virtual Vector2 region_get_connection_pathway_start(RID p_region, int p_connection_id) const;
|
virtual Vector2 region_get_connection_pathway_start(RID p_region, int p_connection_id) const;
|
||||||
virtual Vector2 region_get_connection_pathway_end(RID p_region, int p_connection_id) const;
|
virtual Vector2 region_get_connection_pathway_end(RID p_region, int p_connection_id) const;
|
||||||
|
|
||||||
/// Creates a new link between locations in the nav map.
|
/// Creates a new link between positions in the nav map.
|
||||||
virtual RID link_create();
|
virtual RID link_create();
|
||||||
|
|
||||||
/// Set the map of this link.
|
/// Set the map of this link.
|
||||||
|
@ -145,13 +145,13 @@ public:
|
||||||
virtual void link_set_navigation_layers(RID p_link, uint32_t p_navigation_layers);
|
virtual void link_set_navigation_layers(RID p_link, uint32_t p_navigation_layers);
|
||||||
virtual uint32_t link_get_navigation_layers(RID p_link) const;
|
virtual uint32_t link_get_navigation_layers(RID p_link) const;
|
||||||
|
|
||||||
/// Set the start location of the link.
|
/// Set the start position of the link.
|
||||||
virtual void link_set_start_location(RID p_link, Vector2 p_location);
|
virtual void link_set_start_position(RID p_link, Vector2 p_position);
|
||||||
virtual Vector2 link_get_start_location(RID p_link) const;
|
virtual Vector2 link_get_start_position(RID p_link) const;
|
||||||
|
|
||||||
/// Set the end location of the link.
|
/// Set the end position of the link.
|
||||||
virtual void link_set_end_location(RID p_link, Vector2 p_location);
|
virtual void link_set_end_position(RID p_link, Vector2 p_position);
|
||||||
virtual Vector2 link_get_end_location(RID p_link) const;
|
virtual Vector2 link_get_end_position(RID p_link) const;
|
||||||
|
|
||||||
/// Set the enter cost of the link.
|
/// Set the enter cost of the link.
|
||||||
virtual void link_set_enter_cost(RID p_link, real_t p_enter_cost);
|
virtual void link_set_enter_cost(RID p_link, real_t p_enter_cost);
|
||||||
|
|
|
@ -90,10 +90,10 @@ void NavigationServer3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("link_is_bidirectional", "link"), &NavigationServer3D::link_is_bidirectional);
|
ClassDB::bind_method(D_METHOD("link_is_bidirectional", "link"), &NavigationServer3D::link_is_bidirectional);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_navigation_layers", "link", "navigation_layers"), &NavigationServer3D::link_set_navigation_layers);
|
ClassDB::bind_method(D_METHOD("link_set_navigation_layers", "link", "navigation_layers"), &NavigationServer3D::link_set_navigation_layers);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_navigation_layers", "link"), &NavigationServer3D::link_get_navigation_layers);
|
ClassDB::bind_method(D_METHOD("link_get_navigation_layers", "link"), &NavigationServer3D::link_get_navigation_layers);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_start_location", "link", "location"), &NavigationServer3D::link_set_start_location);
|
ClassDB::bind_method(D_METHOD("link_set_start_position", "link", "position"), &NavigationServer3D::link_set_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_start_location", "link"), &NavigationServer3D::link_get_start_location);
|
ClassDB::bind_method(D_METHOD("link_get_start_position", "link"), &NavigationServer3D::link_get_start_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_end_location", "link", "location"), &NavigationServer3D::link_set_end_location);
|
ClassDB::bind_method(D_METHOD("link_set_end_position", "link", "position"), &NavigationServer3D::link_set_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_end_location", "link"), &NavigationServer3D::link_get_end_location);
|
ClassDB::bind_method(D_METHOD("link_get_end_position", "link"), &NavigationServer3D::link_get_end_position);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_enter_cost", "link", "enter_cost"), &NavigationServer3D::link_set_enter_cost);
|
ClassDB::bind_method(D_METHOD("link_set_enter_cost", "link", "enter_cost"), &NavigationServer3D::link_set_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("link_get_enter_cost", "link"), &NavigationServer3D::link_get_enter_cost);
|
ClassDB::bind_method(D_METHOD("link_get_enter_cost", "link"), &NavigationServer3D::link_get_enter_cost);
|
||||||
ClassDB::bind_method(D_METHOD("link_set_travel_cost", "link", "travel_cost"), &NavigationServer3D::link_set_travel_cost);
|
ClassDB::bind_method(D_METHOD("link_set_travel_cost", "link", "travel_cost"), &NavigationServer3D::link_set_travel_cost);
|
||||||
|
|
|
@ -145,7 +145,7 @@ public:
|
||||||
virtual Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const = 0;
|
virtual Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const = 0;
|
||||||
virtual Vector3 region_get_connection_pathway_end(RID p_region, int p_connection_id) const = 0;
|
virtual Vector3 region_get_connection_pathway_end(RID p_region, int p_connection_id) const = 0;
|
||||||
|
|
||||||
/// Creates a new link between locations in the nav map.
|
/// Creates a new link between positions in the nav map.
|
||||||
virtual RID link_create() = 0;
|
virtual RID link_create() = 0;
|
||||||
|
|
||||||
/// Set the map of this link.
|
/// Set the map of this link.
|
||||||
|
@ -160,13 +160,13 @@ public:
|
||||||
virtual void link_set_navigation_layers(RID p_link, uint32_t p_navigation_layers) = 0;
|
virtual void link_set_navigation_layers(RID p_link, uint32_t p_navigation_layers) = 0;
|
||||||
virtual uint32_t link_get_navigation_layers(RID p_link) const = 0;
|
virtual uint32_t link_get_navigation_layers(RID p_link) const = 0;
|
||||||
|
|
||||||
/// Set the start location of the link.
|
/// Set the start position of the link.
|
||||||
virtual void link_set_start_location(RID p_link, Vector3 p_location) = 0;
|
virtual void link_set_start_position(RID p_link, Vector3 p_position) = 0;
|
||||||
virtual Vector3 link_get_start_location(RID p_link) const = 0;
|
virtual Vector3 link_get_start_position(RID p_link) const = 0;
|
||||||
|
|
||||||
/// Set the end location of the link.
|
/// Set the end position of the link.
|
||||||
virtual void link_set_end_location(RID p_link, Vector3 p_location) = 0;
|
virtual void link_set_end_position(RID p_link, Vector3 p_position) = 0;
|
||||||
virtual Vector3 link_get_end_location(RID p_link) const = 0;
|
virtual Vector3 link_get_end_position(RID p_link) const = 0;
|
||||||
|
|
||||||
/// Set the enter cost of the link.
|
/// Set the enter cost of the link.
|
||||||
virtual void link_set_enter_cost(RID p_link, real_t p_enter_cost) = 0;
|
virtual void link_set_enter_cost(RID p_link, real_t p_enter_cost) = 0;
|
||||||
|
|
Loading…
Reference in New Issue