diff --git a/doc/classes/NavigationAgent.xml b/doc/classes/NavigationAgent.xml
index 9e3274a83..bc60abacb 100644
--- a/doc/classes/NavigationAgent.xml
+++ b/doc/classes/NavigationAgent.xml
@@ -201,6 +201,12 @@
Additional information to return with the navigation path.
+
+ The path postprocessing applied to the raw path corridor found by the [member pathfinding_algorithm].
+
+
+ The pathfinding algorithm used in the path query.
+
The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by [member neighbor_distance]).
Does not affect normal pathfinding. To change an actor's pathfinding radius bake [NavigationMesh] resources with a different [member NavigationMesh.agent_radius] property and use different navigation maps for each actor size.
diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml
index dd2ca260e..6532b17f5 100644
--- a/doc/classes/NavigationAgent2D.xml
+++ b/doc/classes/NavigationAgent2D.xml
@@ -198,6 +198,12 @@
Additional information to return with the navigation path.
+
+ The path postprocessing applied to the raw path corridor found by the [member pathfinding_algorithm].
+
+
+ The pathfinding algorithm used in the path query.
+
The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by [member neighbor_distance]).
Does not affect normal pathfinding. To change an actor's pathfinding radius bake [NavigationMesh] resources with a different [member NavigationMesh.agent_radius] property and use different navigation maps for each actor size.
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 07d51b176..e51334dc9 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -35,7 +35,6 @@
#include "scene/2d/navigation_2d.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/resources/world_2d.h"
-#include "servers/navigation/navigation_path_query_parameters_2d.h"
#include "servers/navigation/navigation_path_query_result_2d.h"
#include "servers/navigation_2d_server.h"
@@ -81,6 +80,12 @@ void NavigationAgent2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent2D::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent2D::get_navigation_layer_value);
+ ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationAgent2D::set_pathfinding_algorithm);
+ ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationAgent2D::get_pathfinding_algorithm);
+
+ ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationAgent2D::set_path_postprocessing);
+ ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationAgent2D::get_path_postprocessing);
+
ClassDB::bind_method(D_METHOD("set_path_metadata_flags", "flags"), &NavigationAgent2D::set_path_metadata_flags);
ClassDB::bind_method(D_METHOD("get_path_metadata_flags"), &NavigationAgent2D::get_path_metadata_flags);
@@ -124,6 +129,8 @@ void NavigationAgent2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,or_greater,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,or_greater,suffix:px"), "set_path_max_distance", "get_path_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered"), "set_path_postprocessing", "get_path_postprocessing");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_path_metadata_flags", "get_path_metadata_flags");
ADD_GROUP("Avoidance", "");
@@ -283,6 +290,8 @@ NavigationAgent2D::NavigationAgent2D() {
avoidance_mask = 1;
avoidance_priority = 1.0;
navigation_layers = 1;
+ pathfinding_algorithm = NavigationPathQueryParameters2D::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
+ path_postprocessing = NavigationPathQueryParameters2D::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
path_metadata_flags = NavigationPathQueryParameters2D::PATH_METADATA_INCLUDE_ALL;
path_desired_distance = 20.0;
@@ -499,6 +508,26 @@ real_t NavigationAgent2D::get_avoidance_priority() const {
return avoidance_priority;
}
+void NavigationAgent2D::set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm) {
+ if (pathfinding_algorithm == p_pathfinding_algorithm) {
+ return;
+ }
+
+ pathfinding_algorithm = p_pathfinding_algorithm;
+
+ navigation_query->set_pathfinding_algorithm(pathfinding_algorithm);
+}
+
+void NavigationAgent2D::set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing) {
+ if (path_postprocessing == p_path_postprocessing) {
+ return;
+ }
+
+ path_postprocessing = p_path_postprocessing;
+
+ navigation_query->set_path_postprocessing(path_postprocessing);
+}
+
void NavigationAgent2D::set_path_metadata_flags(const int p_flags) {
path_metadata_flags = p_flags;
}
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 7a856c348..6470c3c2c 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -32,6 +32,8 @@
#include "scene/main/node.h"
+#include "servers/navigation/navigation_path_query_parameters_2d.h"
+
class Node2D;
class Navigation2D;
class NavigationPathQueryParameters2D;
@@ -52,6 +54,8 @@ class NavigationAgent2D : public Node {
uint32_t avoidance_mask;
real_t avoidance_priority;
uint32_t navigation_layers;
+ NavigationPathQueryParameters2D::PathfindingAlgorithm pathfinding_algorithm;
+ NavigationPathQueryParameters2D::PathPostProcessing path_postprocessing;
int path_metadata_flags;
real_t path_desired_distance;
@@ -67,7 +71,7 @@ class NavigationAgent2D : public Node {
Vector2 target_position;
bool target_position_submitted;
-
+
Ref navigation_query;
Ref navigation_result;
int nav_path_index;
@@ -130,6 +134,16 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
+ void set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm);
+ NavigationPathQueryParameters2D::PathfindingAlgorithm get_pathfinding_algorithm() const {
+ return pathfinding_algorithm;
+ }
+
+ void set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing);
+ NavigationPathQueryParameters2D::PathPostProcessing get_path_postprocessing() const {
+ return path_postprocessing;
+ }
+
void set_avoidance_layers(uint32_t p_layers);
uint32_t get_avoidance_layers() const;
@@ -213,7 +227,7 @@ public:
Vector2 get_velocity() { return velocity; }
void set_velocity_forced(const Vector2 p_velocity);
-
+
void _avoidance_done(Vector3 p_new_velocity);
virtual String get_configuration_warning() const;
diff --git a/scene/3d/navigation_agent.cpp b/scene/3d/navigation_agent.cpp
index cd5c7b592..18c897e2f 100644
--- a/scene/3d/navigation_agent.cpp
+++ b/scene/3d/navigation_agent.cpp
@@ -37,7 +37,6 @@
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/world_3d.h"
-#include "servers/navigation/navigation_path_query_parameters_3d.h"
#include "servers/navigation/navigation_path_query_result_3d.h"
#include "servers/navigation_server.h"
@@ -95,6 +94,12 @@ void NavigationAgent::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationAgent::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationAgent::get_navigation_layer_value);
+ ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationAgent::set_pathfinding_algorithm);
+ ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationAgent::get_pathfinding_algorithm);
+
+ ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationAgent::set_path_postprocessing);
+ ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationAgent::get_path_postprocessing);
+
ClassDB::bind_method(D_METHOD("set_path_metadata_flags", "flags"), &NavigationAgent::set_path_metadata_flags);
ClassDB::bind_method(D_METHOD("get_path_metadata_flags"), &NavigationAgent::get_path_metadata_flags);
@@ -138,6 +143,8 @@ void NavigationAgent::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,or_greater,suffix:m"), "set_path_height_offset", "get_path_height_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_max_distance", PROPERTY_HINT_RANGE, "0.01,100,0.1,or_greater,suffix:m"), "set_path_max_distance", "get_path_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered"), "set_path_postprocessing", "get_path_postprocessing");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_path_metadata_flags", "get_path_metadata_flags");
ADD_GROUP("Avoidance", "");
@@ -300,6 +307,8 @@ NavigationAgent::NavigationAgent() {
avoidance_mask = 1;
avoidance_priority = 1.0;
navigation_layers = 1;
+ pathfinding_algorithm = NavigationPathQueryParameters3D::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
+ path_postprocessing = NavigationPathQueryParameters3D::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
path_metadata_flags = NavigationPathQueryParameters3D::PATH_METADATA_INCLUDE_ALL;
path_desired_distance = 1.0;
@@ -453,6 +462,26 @@ bool NavigationAgent::get_navigation_layer_value(int p_layer_number) const {
return get_navigation_layers() & (1 << (p_layer_number - 1));
}
+void NavigationAgent::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {
+ if (pathfinding_algorithm == p_pathfinding_algorithm) {
+ return;
+ }
+
+ pathfinding_algorithm = p_pathfinding_algorithm;
+
+ navigation_query->set_pathfinding_algorithm(pathfinding_algorithm);
+}
+
+void NavigationAgent::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
+ if (path_postprocessing == p_path_postprocessing) {
+ return;
+ }
+
+ path_postprocessing = p_path_postprocessing;
+
+ navigation_query->set_path_postprocessing(path_postprocessing);
+}
+
void NavigationAgent::set_path_metadata_flags(const int p_flags) {
path_metadata_flags = p_flags;
}
diff --git a/scene/3d/navigation_agent.h b/scene/3d/navigation_agent.h
index 7ec04d66a..0d79a86c5 100644
--- a/scene/3d/navigation_agent.h
+++ b/scene/3d/navigation_agent.h
@@ -34,6 +34,7 @@
#include "core/containers/vector.h"
#include "scene/main/node.h"
+#include "servers/navigation/navigation_path_query_parameters_3d.h"
class Spatial;
class Navigation;
@@ -57,6 +58,8 @@ class NavigationAgent : public Node {
uint32_t avoidance_mask;
real_t avoidance_priority;
uint32_t navigation_layers;
+ NavigationPathQueryParameters3D::PathfindingAlgorithm pathfinding_algorithm;
+ NavigationPathQueryParameters3D::PathPostProcessing path_postprocessing;
int path_metadata_flags;
real_t path_desired_distance;
@@ -145,6 +148,16 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
+ void set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm);
+ NavigationPathQueryParameters3D::PathfindingAlgorithm get_pathfinding_algorithm() const {
+ return pathfinding_algorithm;
+ }
+
+ void set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing);
+ NavigationPathQueryParameters3D::PathPostProcessing get_path_postprocessing() const {
+ return path_postprocessing;
+ }
+
void set_avoidance_layers(uint32_t p_layers);
uint32_t get_avoidance_layers() const;