mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 03:46:50 +01:00
Backported from godot4: Expose NavigationAgent path postprocessing and pathfinding algorithm options
Exposes the path postprocessing and pathfinding algorithm options of the NavigationAgent internal NavigationPathQueryParameters object.
- smix8
6e324bb341
This commit is contained in:
parent
a516cf2e1b
commit
b4dbd26415
@ -201,6 +201,12 @@
|
||||
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" default="7">
|
||||
Additional information to return with the navigation path.
|
||||
</member>
|
||||
<member name="path_postprocessing" type="int" setter="set_path_postprocessing" getter="get_path_postprocessing" enum="NavigationPathQueryParameters3D.PathPostProcessing" default="0">
|
||||
The path postprocessing applied to the raw path corridor found by the [member pathfinding_algorithm].
|
||||
</member>
|
||||
<member name="pathfinding_algorithm" type="int" setter="set_pathfinding_algorithm" getter="get_pathfinding_algorithm" enum="NavigationPathQueryParameters3D.PathfindingAlgorithm" default="0">
|
||||
The pathfinding algorithm used in the path query.
|
||||
</member>
|
||||
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="0.5">
|
||||
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.
|
||||
|
@ -198,6 +198,12 @@
|
||||
<member name="path_metadata_flags" type="int" setter="set_path_metadata_flags" getter="get_path_metadata_flags" default="7">
|
||||
Additional information to return with the navigation path.
|
||||
</member>
|
||||
<member name="path_postprocessing" type="int" setter="set_path_postprocessing" getter="get_path_postprocessing" enum="NavigationPathQueryParameters2D.PathPostProcessing" default="0">
|
||||
The path postprocessing applied to the raw path corridor found by the [member pathfinding_algorithm].
|
||||
</member>
|
||||
<member name="pathfinding_algorithm" type="int" setter="set_pathfinding_algorithm" getter="get_pathfinding_algorithm" enum="NavigationPathQueryParameters2D.PathfindingAlgorithm" default="0">
|
||||
The pathfinding algorithm used in the path query.
|
||||
</member>
|
||||
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="10.0">
|
||||
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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<NavigationPathQueryParameters2D> navigation_query;
|
||||
Ref<NavigationPathQueryResult2D> 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user