initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
12
servers/navigation/SCsub
Normal file
12
servers/navigation/SCsub
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
|
||||
if not env["disable_navigation_2d"]:
|
||||
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_2d.cpp")
|
||||
env.add_source_files(env.servers_sources, "navigation_path_query_result_2d.cpp")
|
||||
|
||||
if not env["disable_navigation_3d"]:
|
||||
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_3d.cpp")
|
||||
env.add_source_files(env.servers_sources, "navigation_path_query_result_3d.cpp")
|
158
servers/navigation/nav_heap.h
Normal file
158
servers/navigation/nav_heap.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/**************************************************************************/
|
||||
/* nav_heap.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/templates/local_vector.h"
|
||||
|
||||
template <typename T>
|
||||
struct NoopIndexer {
|
||||
void operator()(const T &p_value, uint32_t p_index) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* A max-heap implementation that notifies of element index changes.
|
||||
*/
|
||||
template <typename T, typename LessThan = Comparator<T>, typename Indexer = NoopIndexer<T>>
|
||||
class Heap {
|
||||
LocalVector<T> _buffer;
|
||||
|
||||
LessThan _less_than;
|
||||
Indexer _indexer;
|
||||
|
||||
public:
|
||||
static constexpr uint32_t INVALID_INDEX = UINT32_MAX;
|
||||
void reserve(uint32_t p_size) {
|
||||
_buffer.reserve(p_size);
|
||||
}
|
||||
|
||||
uint32_t size() const {
|
||||
return _buffer.size();
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return _buffer.is_empty();
|
||||
}
|
||||
|
||||
void push(const T &p_element) {
|
||||
_buffer.push_back(p_element);
|
||||
_indexer(p_element, _buffer.size() - 1);
|
||||
_shift_up(_buffer.size() - 1);
|
||||
}
|
||||
|
||||
T pop() {
|
||||
ERR_FAIL_COND_V_MSG(_buffer.is_empty(), T(), "Can't pop an empty heap.");
|
||||
T value = _buffer[0];
|
||||
_indexer(value, INVALID_INDEX);
|
||||
if (_buffer.size() > 1) {
|
||||
_buffer[0] = _buffer[_buffer.size() - 1];
|
||||
_indexer(_buffer[0], 0);
|
||||
_buffer.remove_at(_buffer.size() - 1);
|
||||
_shift_down(0);
|
||||
} else {
|
||||
_buffer.remove_at(_buffer.size() - 1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the position of the element in the heap if necessary.
|
||||
*/
|
||||
void shift(uint32_t p_index) {
|
||||
ERR_FAIL_UNSIGNED_INDEX_MSG(p_index, _buffer.size(), "Heap element index is out of range.");
|
||||
if (!_shift_up(p_index)) {
|
||||
_shift_down(p_index);
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
for (const T &value : _buffer) {
|
||||
_indexer(value, INVALID_INDEX);
|
||||
}
|
||||
_buffer.clear();
|
||||
}
|
||||
|
||||
Heap() {}
|
||||
|
||||
Heap(const LessThan &p_less_than) :
|
||||
_less_than(p_less_than) {}
|
||||
|
||||
Heap(const Indexer &p_indexer) :
|
||||
_indexer(p_indexer) {}
|
||||
|
||||
Heap(const LessThan &p_less_than, const Indexer &p_indexer) :
|
||||
_less_than(p_less_than), _indexer(p_indexer) {}
|
||||
|
||||
private:
|
||||
bool _shift_up(uint32_t p_index) {
|
||||
T value = _buffer[p_index];
|
||||
uint32_t current_index = p_index;
|
||||
uint32_t parent_index = (current_index - 1) / 2;
|
||||
while (current_index > 0 && _less_than(_buffer[parent_index], value)) {
|
||||
_buffer[current_index] = _buffer[parent_index];
|
||||
_indexer(_buffer[current_index], current_index);
|
||||
current_index = parent_index;
|
||||
parent_index = (current_index - 1) / 2;
|
||||
}
|
||||
if (current_index != p_index) {
|
||||
_buffer[current_index] = value;
|
||||
_indexer(value, current_index);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool _shift_down(uint32_t p_index) {
|
||||
T value = _buffer[p_index];
|
||||
uint32_t current_index = p_index;
|
||||
uint32_t child_index = 2 * current_index + 1;
|
||||
while (child_index < _buffer.size()) {
|
||||
if (child_index + 1 < _buffer.size() &&
|
||||
_less_than(_buffer[child_index], _buffer[child_index + 1])) {
|
||||
child_index++;
|
||||
}
|
||||
if (_less_than(_buffer[child_index], value)) {
|
||||
break;
|
||||
}
|
||||
_buffer[current_index] = _buffer[child_index];
|
||||
_indexer(_buffer[current_index], current_index);
|
||||
current_index = child_index;
|
||||
child_index = 2 * current_index + 1;
|
||||
}
|
||||
if (current_index != p_index) {
|
||||
_buffer[current_index] = value;
|
||||
_indexer(value, current_index);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
86
servers/navigation/navigation_globals.h
Normal file
86
servers/navigation/navigation_globals.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_globals.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace NavigationDefaults3D {
|
||||
|
||||
// Rasterization.
|
||||
|
||||
// To find the polygons edges the vertices are displaced in a grid where
|
||||
// each cell has the following cell_size and cell_height.
|
||||
constexpr float NAV_MESH_CELL_HEIGHT = 0.25f; // Must match ProjectSettings default 3D cell_height and NavigationMesh cell_height.
|
||||
constexpr float NAV_MESH_CELL_SIZE = 0.25f; // Must match ProjectSettings default 3D cell_size and NavigationMesh cell_size.
|
||||
constexpr float NAV_MESH_CELL_SIZE_MIN = 0.01f;
|
||||
constexpr const char *const NAV_MESH_CELL_SIZE_HINT = "0.001,100,0.001,or_greater";
|
||||
|
||||
// Map.
|
||||
|
||||
constexpr float EDGE_CONNECTION_MARGIN = 0.25f;
|
||||
constexpr float LINK_CONNECTION_RADIUS = 1.0f;
|
||||
constexpr int path_search_max_polygons = 4096;
|
||||
|
||||
// Agent.
|
||||
|
||||
constexpr float AVOIDANCE_AGENT_HEIGHT = 1.0;
|
||||
constexpr float AVOIDANCE_AGENT_RADIUS = 0.5;
|
||||
constexpr float AVOIDANCE_AGENT_MAX_SPEED = 10.0;
|
||||
constexpr float AVOIDANCE_AGENT_TIME_HORIZON_AGENTS = 1.0;
|
||||
constexpr float AVOIDANCE_AGENT_TIME_HORIZON_OBSTACLES = 0.0;
|
||||
constexpr int AVOIDANCE_AGENT_MAX_NEIGHBORS = 10;
|
||||
constexpr float AVOIDANCE_AGENT_NEIGHBOR_DISTANCE = 50.0;
|
||||
|
||||
} //namespace NavigationDefaults3D
|
||||
|
||||
namespace NavigationDefaults2D {
|
||||
|
||||
// Rasterization.
|
||||
|
||||
// Same as in 3D but larger since 1px is treated as 1m.
|
||||
constexpr float NAV_MESH_CELL_SIZE = 1.0f; // Must match ProjectSettings default 2D cell_size.
|
||||
constexpr float NAV_MESH_CELL_SIZE_MIN = 0.01f;
|
||||
constexpr const char *const NAV_MESH_CELL_SIZE_HINT = "0.001,100,0.001,or_greater";
|
||||
|
||||
// Map.
|
||||
|
||||
constexpr float EDGE_CONNECTION_MARGIN = 1.0f;
|
||||
constexpr float LINK_CONNECTION_RADIUS = 4.0f;
|
||||
constexpr int path_search_max_polygons = 4096;
|
||||
|
||||
// Agent.
|
||||
|
||||
constexpr float AVOIDANCE_AGENT_RADIUS = 10.0;
|
||||
constexpr float AVOIDANCE_AGENT_MAX_SPEED = 100.0;
|
||||
constexpr float AVOIDANCE_AGENT_TIME_HORIZON_AGENTS = 1.0;
|
||||
constexpr float AVOIDANCE_AGENT_TIME_HORIZON_OBSTACLES = 0.0;
|
||||
constexpr int AVOIDANCE_AGENT_MAX_NEIGHBORS = 10;
|
||||
constexpr float AVOIDANCE_AGENT_NEIGHBOR_DISTANCE = 500.0;
|
||||
|
||||
} //namespace NavigationDefaults2D
|
242
servers/navigation/navigation_path_query_parameters_2d.cpp
Normal file
242
servers/navigation/navigation_path_query_parameters_2d.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_parameters_2d.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "navigation_path_query_parameters_2d.h"
|
||||
|
||||
void NavigationPathQueryParameters2D::set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm) {
|
||||
pathfinding_algorithm = p_pathfinding_algorithm;
|
||||
}
|
||||
|
||||
NavigationPathQueryParameters2D::PathfindingAlgorithm NavigationPathQueryParameters2D::get_pathfinding_algorithm() const {
|
||||
return pathfinding_algorithm;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing) {
|
||||
path_postprocessing = p_path_postprocessing;
|
||||
}
|
||||
|
||||
NavigationPathQueryParameters2D::PathPostProcessing NavigationPathQueryParameters2D::get_path_postprocessing() const {
|
||||
return path_postprocessing;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_map(RID p_map) {
|
||||
map = p_map;
|
||||
}
|
||||
|
||||
RID NavigationPathQueryParameters2D::get_map() const {
|
||||
return map;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_start_position(Vector2 p_start_position) {
|
||||
start_position = p_start_position;
|
||||
}
|
||||
|
||||
Vector2 NavigationPathQueryParameters2D::get_start_position() const {
|
||||
return start_position;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_target_position(Vector2 p_target_position) {
|
||||
target_position = p_target_position;
|
||||
}
|
||||
|
||||
Vector2 NavigationPathQueryParameters2D::get_target_position() const {
|
||||
return target_position;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_navigation_layers(uint32_t p_navigation_layers) {
|
||||
navigation_layers = p_navigation_layers;
|
||||
}
|
||||
|
||||
uint32_t NavigationPathQueryParameters2D::get_navigation_layers() const {
|
||||
return navigation_layers;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_metadata_flags(BitField<NavigationPathQueryParameters2D::PathMetadataFlags> p_flags) {
|
||||
metadata_flags = (int64_t)p_flags;
|
||||
}
|
||||
|
||||
BitField<NavigationPathQueryParameters2D::PathMetadataFlags> NavigationPathQueryParameters2D::get_metadata_flags() const {
|
||||
return (int64_t)metadata_flags;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_simplify_path(bool p_enabled) {
|
||||
simplify_path = p_enabled;
|
||||
}
|
||||
|
||||
bool NavigationPathQueryParameters2D::get_simplify_path() const {
|
||||
return simplify_path;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_simplify_epsilon(real_t p_epsilon) {
|
||||
simplify_epsilon = MAX(0.0, p_epsilon);
|
||||
}
|
||||
|
||||
real_t NavigationPathQueryParameters2D::get_simplify_epsilon() const {
|
||||
return simplify_epsilon;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_included_regions(const TypedArray<RID> &p_regions) {
|
||||
_included_regions.resize(p_regions.size());
|
||||
for (uint32_t i = 0; i < _included_regions.size(); i++) {
|
||||
_included_regions[i] = p_regions[i];
|
||||
}
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryParameters2D::get_included_regions() const {
|
||||
TypedArray<RID> r_regions;
|
||||
r_regions.resize(_included_regions.size());
|
||||
for (uint32_t i = 0; i < _included_regions.size(); i++) {
|
||||
r_regions[i] = _included_regions[i];
|
||||
}
|
||||
return r_regions;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_excluded_regions(const TypedArray<RID> &p_regions) {
|
||||
_excluded_regions.resize(p_regions.size());
|
||||
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
|
||||
_excluded_regions[i] = p_regions[i];
|
||||
}
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryParameters2D::get_excluded_regions() const {
|
||||
TypedArray<RID> r_regions;
|
||||
r_regions.resize(_excluded_regions.size());
|
||||
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
|
||||
r_regions[i] = _excluded_regions[i];
|
||||
}
|
||||
return r_regions;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_path_return_max_length(float p_length) {
|
||||
path_return_max_length = MAX(0.0, p_length);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters2D::get_path_return_max_length() const {
|
||||
return path_return_max_length;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_path_return_max_radius(float p_radius) {
|
||||
path_return_max_radius = MAX(0.0, p_radius);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters2D::get_path_return_max_radius() const {
|
||||
return path_return_max_radius;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_path_search_max_polygons(int p_max_polygons) {
|
||||
path_search_max_polygons = p_max_polygons;
|
||||
}
|
||||
|
||||
int NavigationPathQueryParameters2D::get_path_search_max_polygons() const {
|
||||
return path_search_max_polygons;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::set_path_search_max_distance(float p_distance) {
|
||||
path_search_max_distance = MAX(0.0, p_distance);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters2D::get_path_search_max_distance() const {
|
||||
return path_search_max_distance;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters2D::set_pathfinding_algorithm);
|
||||
ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters2D::get_pathfinding_algorithm);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters2D::set_path_postprocessing);
|
||||
ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters2D::get_path_postprocessing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters2D::set_map);
|
||||
ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters2D::get_map);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters2D::set_start_position);
|
||||
ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters2D::get_start_position);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters2D::set_target_position);
|
||||
ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters2D::get_target_position);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters2D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters2D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters2D::set_metadata_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters2D::get_metadata_flags);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters2D::set_simplify_path);
|
||||
ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters2D::get_simplify_path);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters2D::set_simplify_epsilon);
|
||||
ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters2D::get_simplify_epsilon);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters2D::set_included_regions);
|
||||
ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters2D::get_included_regions);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters2D::set_excluded_regions);
|
||||
ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters2D::get_excluded_regions);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_return_max_length", "length"), &NavigationPathQueryParameters2D::set_path_return_max_length);
|
||||
ClassDB::bind_method(D_METHOD("get_path_return_max_length"), &NavigationPathQueryParameters2D::get_path_return_max_length);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_return_max_radius", "radius"), &NavigationPathQueryParameters2D::set_path_return_max_radius);
|
||||
ClassDB::bind_method(D_METHOD("get_path_return_max_radius"), &NavigationPathQueryParameters2D::get_path_return_max_radius);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_search_max_polygons", "max_polygons"), &NavigationPathQueryParameters2D::set_path_search_max_polygons);
|
||||
ClassDB::bind_method(D_METHOD("get_path_search_max_polygons"), &NavigationPathQueryParameters2D::get_path_search_max_polygons);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_search_max_distance", "distance"), &NavigationPathQueryParameters2D::set_path_search_max_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_path_search_max_distance"), &NavigationPathQueryParameters2D::get_path_search_max_distance);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_position"), "set_start_position", "get_start_position");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position"), "set_target_position", "get_target_position");
|
||||
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,None"), "set_path_postprocessing", "get_path_postprocessing");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_length"), "set_path_return_max_length", "get_path_return_max_length");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_radius"), "set_path_return_max_radius", "get_path_return_max_radius");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_search_max_polygons"), "set_path_search_max_polygons", "get_path_search_max_polygons");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_search_max_distance"), "set_path_search_max_distance", "get_path_search_max_distance");
|
||||
|
||||
BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
|
||||
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
|
||||
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
|
||||
}
|
130
servers/navigation/navigation_path_query_parameters_2d.h
Normal file
130
servers/navigation/navigation_path_query_parameters_2d.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_parameters_2d.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "servers/navigation/navigation_globals.h"
|
||||
#include "servers/navigation/navigation_utilities.h"
|
||||
|
||||
class NavigationPathQueryParameters2D : public RefCounted {
|
||||
GDCLASS(NavigationPathQueryParameters2D, RefCounted);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum PathfindingAlgorithm {
|
||||
PATHFINDING_ALGORITHM_ASTAR = NavigationUtilities::PATHFINDING_ALGORITHM_ASTAR,
|
||||
};
|
||||
|
||||
enum PathPostProcessing {
|
||||
PATH_POSTPROCESSING_CORRIDORFUNNEL = NavigationUtilities::PATH_POSTPROCESSING_CORRIDORFUNNEL,
|
||||
PATH_POSTPROCESSING_EDGECENTERED = NavigationUtilities::PATH_POSTPROCESSING_EDGECENTERED,
|
||||
PATH_POSTPROCESSING_NONE = NavigationUtilities::PATH_POSTPROCESSING_NONE,
|
||||
};
|
||||
|
||||
enum PathMetadataFlags {
|
||||
PATH_METADATA_INCLUDE_NONE = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_NONE,
|
||||
PATH_METADATA_INCLUDE_TYPES = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_TYPES,
|
||||
PATH_METADATA_INCLUDE_RIDS = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_RIDS,
|
||||
PATH_METADATA_INCLUDE_OWNERS = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_OWNERS,
|
||||
PATH_METADATA_INCLUDE_ALL = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_ALL
|
||||
};
|
||||
|
||||
private:
|
||||
PathfindingAlgorithm pathfinding_algorithm = PATHFINDING_ALGORITHM_ASTAR;
|
||||
PathPostProcessing path_postprocessing = PATH_POSTPROCESSING_CORRIDORFUNNEL;
|
||||
RID map;
|
||||
Vector2 start_position;
|
||||
Vector2 target_position;
|
||||
uint32_t navigation_layers = 1;
|
||||
BitField<PathMetadataFlags> metadata_flags = PATH_METADATA_INCLUDE_ALL;
|
||||
bool simplify_path = false;
|
||||
real_t simplify_epsilon = 0.0;
|
||||
|
||||
LocalVector<RID> _excluded_regions;
|
||||
LocalVector<RID> _included_regions;
|
||||
|
||||
float path_return_max_length = 0.0;
|
||||
float path_return_max_radius = 0.0;
|
||||
int path_search_max_polygons = NavigationDefaults2D::path_search_max_polygons;
|
||||
float path_search_max_distance = 0.0;
|
||||
|
||||
public:
|
||||
void set_pathfinding_algorithm(const PathfindingAlgorithm p_pathfinding_algorithm);
|
||||
PathfindingAlgorithm get_pathfinding_algorithm() const;
|
||||
|
||||
void set_path_postprocessing(const PathPostProcessing p_path_postprocessing);
|
||||
PathPostProcessing get_path_postprocessing() const;
|
||||
|
||||
void set_map(RID p_map);
|
||||
RID get_map() const;
|
||||
|
||||
void set_start_position(const Vector2 p_start_position);
|
||||
Vector2 get_start_position() const;
|
||||
|
||||
void set_target_position(const Vector2 p_target_position);
|
||||
Vector2 get_target_position() const;
|
||||
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_metadata_flags(BitField<NavigationPathQueryParameters2D::PathMetadataFlags> p_flags);
|
||||
BitField<NavigationPathQueryParameters2D::PathMetadataFlags> get_metadata_flags() const;
|
||||
|
||||
void set_simplify_path(bool p_enabled);
|
||||
bool get_simplify_path() const;
|
||||
|
||||
void set_simplify_epsilon(real_t p_epsilon);
|
||||
real_t get_simplify_epsilon() const;
|
||||
|
||||
void set_excluded_regions(const TypedArray<RID> &p_regions);
|
||||
TypedArray<RID> get_excluded_regions() const;
|
||||
|
||||
void set_included_regions(const TypedArray<RID> &p_regions);
|
||||
TypedArray<RID> get_included_regions() const;
|
||||
|
||||
void set_path_return_max_length(float p_length);
|
||||
float get_path_return_max_length() const;
|
||||
|
||||
void set_path_return_max_radius(float p_radius);
|
||||
float get_path_return_max_radius() const;
|
||||
|
||||
void set_path_search_max_polygons(int p_max_polygons);
|
||||
int get_path_search_max_polygons() const;
|
||||
|
||||
void set_path_search_max_distance(float p_distance);
|
||||
float get_path_search_max_distance() const;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryParameters2D::PathfindingAlgorithm);
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryParameters2D::PathPostProcessing);
|
||||
VARIANT_BITFIELD_CAST(NavigationPathQueryParameters2D::PathMetadataFlags);
|
242
servers/navigation/navigation_path_query_parameters_3d.cpp
Normal file
242
servers/navigation/navigation_path_query_parameters_3d.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_parameters_3d.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "navigation_path_query_parameters_3d.h"
|
||||
|
||||
void NavigationPathQueryParameters3D::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {
|
||||
pathfinding_algorithm = p_pathfinding_algorithm;
|
||||
}
|
||||
|
||||
NavigationPathQueryParameters3D::PathfindingAlgorithm NavigationPathQueryParameters3D::get_pathfinding_algorithm() const {
|
||||
return pathfinding_algorithm;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
|
||||
path_postprocessing = p_path_postprocessing;
|
||||
}
|
||||
|
||||
NavigationPathQueryParameters3D::PathPostProcessing NavigationPathQueryParameters3D::get_path_postprocessing() const {
|
||||
return path_postprocessing;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_map(RID p_map) {
|
||||
map = p_map;
|
||||
}
|
||||
|
||||
RID NavigationPathQueryParameters3D::get_map() const {
|
||||
return map;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_start_position(Vector3 p_start_position) {
|
||||
start_position = p_start_position;
|
||||
}
|
||||
|
||||
Vector3 NavigationPathQueryParameters3D::get_start_position() const {
|
||||
return start_position;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_target_position(Vector3 p_target_position) {
|
||||
target_position = p_target_position;
|
||||
}
|
||||
|
||||
Vector3 NavigationPathQueryParameters3D::get_target_position() const {
|
||||
return target_position;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_navigation_layers(uint32_t p_navigation_layers) {
|
||||
navigation_layers = p_navigation_layers;
|
||||
}
|
||||
|
||||
uint32_t NavigationPathQueryParameters3D::get_navigation_layers() const {
|
||||
return navigation_layers;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags) {
|
||||
metadata_flags = (int64_t)p_flags;
|
||||
}
|
||||
|
||||
BitField<NavigationPathQueryParameters3D::PathMetadataFlags> NavigationPathQueryParameters3D::get_metadata_flags() const {
|
||||
return (int64_t)metadata_flags;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_simplify_path(bool p_enabled) {
|
||||
simplify_path = p_enabled;
|
||||
}
|
||||
|
||||
bool NavigationPathQueryParameters3D::get_simplify_path() const {
|
||||
return simplify_path;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_simplify_epsilon(real_t p_epsilon) {
|
||||
simplify_epsilon = MAX(0.0, p_epsilon);
|
||||
}
|
||||
|
||||
real_t NavigationPathQueryParameters3D::get_simplify_epsilon() const {
|
||||
return simplify_epsilon;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_included_regions(const TypedArray<RID> &p_regions) {
|
||||
_included_regions.resize(p_regions.size());
|
||||
for (uint32_t i = 0; i < _included_regions.size(); i++) {
|
||||
_included_regions[i] = p_regions[i];
|
||||
}
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryParameters3D::get_included_regions() const {
|
||||
TypedArray<RID> r_regions;
|
||||
r_regions.resize(_included_regions.size());
|
||||
for (uint32_t i = 0; i < _included_regions.size(); i++) {
|
||||
r_regions[i] = _included_regions[i];
|
||||
}
|
||||
return r_regions;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_excluded_regions(const TypedArray<RID> &p_regions) {
|
||||
_excluded_regions.resize(p_regions.size());
|
||||
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
|
||||
_excluded_regions[i] = p_regions[i];
|
||||
}
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryParameters3D::get_excluded_regions() const {
|
||||
TypedArray<RID> r_regions;
|
||||
r_regions.resize(_excluded_regions.size());
|
||||
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
|
||||
r_regions[i] = _excluded_regions[i];
|
||||
}
|
||||
return r_regions;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_path_return_max_length(float p_length) {
|
||||
path_return_max_length = MAX(0.0, p_length);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters3D::get_path_return_max_length() const {
|
||||
return path_return_max_length;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_path_return_max_radius(float p_radius) {
|
||||
path_return_max_radius = MAX(0.0, p_radius);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters3D::get_path_return_max_radius() const {
|
||||
return path_return_max_radius;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_path_search_max_polygons(int p_max_polygons) {
|
||||
path_search_max_polygons = p_max_polygons;
|
||||
}
|
||||
|
||||
int NavigationPathQueryParameters3D::get_path_search_max_polygons() const {
|
||||
return path_search_max_polygons;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::set_path_search_max_distance(float p_distance) {
|
||||
path_search_max_distance = MAX(0.0, p_distance);
|
||||
}
|
||||
|
||||
float NavigationPathQueryParameters3D::get_path_search_max_distance() const {
|
||||
return path_search_max_distance;
|
||||
}
|
||||
|
||||
void NavigationPathQueryParameters3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
|
||||
ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);
|
||||
ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);
|
||||
ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);
|
||||
ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);
|
||||
ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters3D::set_simplify_path);
|
||||
ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters3D::get_simplify_path);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);
|
||||
ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);
|
||||
ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);
|
||||
ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_return_max_length", "length"), &NavigationPathQueryParameters3D::set_path_return_max_length);
|
||||
ClassDB::bind_method(D_METHOD("get_path_return_max_length"), &NavigationPathQueryParameters3D::get_path_return_max_length);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_return_max_radius", "radius"), &NavigationPathQueryParameters3D::set_path_return_max_radius);
|
||||
ClassDB::bind_method(D_METHOD("get_path_return_max_radius"), &NavigationPathQueryParameters3D::get_path_return_max_radius);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_search_max_polygons", "max_polygons"), &NavigationPathQueryParameters3D::set_path_search_max_polygons);
|
||||
ClassDB::bind_method(D_METHOD("get_path_search_max_polygons"), &NavigationPathQueryParameters3D::get_path_search_max_polygons);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_search_max_distance", "distance"), &NavigationPathQueryParameters3D::set_path_search_max_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_path_search_max_distance"), &NavigationPathQueryParameters3D::get_path_search_max_distance);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
|
||||
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,None"), "set_path_postprocessing", "get_path_postprocessing");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_length"), "set_path_return_max_length", "get_path_return_max_length");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_radius"), "set_path_return_max_radius", "get_path_return_max_radius");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_search_max_polygons"), "set_path_search_max_polygons", "get_path_search_max_polygons");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_search_max_distance"), "set_path_search_max_distance", "get_path_search_max_distance");
|
||||
|
||||
BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
|
||||
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
|
||||
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
|
||||
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
|
||||
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
|
||||
}
|
130
servers/navigation/navigation_path_query_parameters_3d.h
Normal file
130
servers/navigation/navigation_path_query_parameters_3d.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_parameters_3d.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "servers/navigation/navigation_globals.h"
|
||||
#include "servers/navigation/navigation_utilities.h"
|
||||
|
||||
class NavigationPathQueryParameters3D : public RefCounted {
|
||||
GDCLASS(NavigationPathQueryParameters3D, RefCounted);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum PathfindingAlgorithm {
|
||||
PATHFINDING_ALGORITHM_ASTAR = NavigationUtilities::PATHFINDING_ALGORITHM_ASTAR,
|
||||
};
|
||||
|
||||
enum PathPostProcessing {
|
||||
PATH_POSTPROCESSING_CORRIDORFUNNEL = NavigationUtilities::PATH_POSTPROCESSING_CORRIDORFUNNEL,
|
||||
PATH_POSTPROCESSING_EDGECENTERED = NavigationUtilities::PATH_POSTPROCESSING_EDGECENTERED,
|
||||
PATH_POSTPROCESSING_NONE = NavigationUtilities::PATH_POSTPROCESSING_NONE,
|
||||
};
|
||||
|
||||
enum PathMetadataFlags {
|
||||
PATH_METADATA_INCLUDE_NONE = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_NONE,
|
||||
PATH_METADATA_INCLUDE_TYPES = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_TYPES,
|
||||
PATH_METADATA_INCLUDE_RIDS = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_RIDS,
|
||||
PATH_METADATA_INCLUDE_OWNERS = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_OWNERS,
|
||||
PATH_METADATA_INCLUDE_ALL = NavigationUtilities::PathMetadataFlags::PATH_INCLUDE_ALL
|
||||
};
|
||||
|
||||
private:
|
||||
PathfindingAlgorithm pathfinding_algorithm = PATHFINDING_ALGORITHM_ASTAR;
|
||||
PathPostProcessing path_postprocessing = PATH_POSTPROCESSING_CORRIDORFUNNEL;
|
||||
RID map;
|
||||
Vector3 start_position;
|
||||
Vector3 target_position;
|
||||
uint32_t navigation_layers = 1;
|
||||
BitField<PathMetadataFlags> metadata_flags = PATH_METADATA_INCLUDE_ALL;
|
||||
bool simplify_path = false;
|
||||
real_t simplify_epsilon = 0.0;
|
||||
|
||||
LocalVector<RID> _excluded_regions;
|
||||
LocalVector<RID> _included_regions;
|
||||
|
||||
float path_return_max_length = 0.0;
|
||||
float path_return_max_radius = 0.0;
|
||||
int path_search_max_polygons = NavigationDefaults3D::path_search_max_polygons;
|
||||
float path_search_max_distance = 0.0;
|
||||
|
||||
public:
|
||||
void set_pathfinding_algorithm(const PathfindingAlgorithm p_pathfinding_algorithm);
|
||||
PathfindingAlgorithm get_pathfinding_algorithm() const;
|
||||
|
||||
void set_path_postprocessing(const PathPostProcessing p_path_postprocessing);
|
||||
PathPostProcessing get_path_postprocessing() const;
|
||||
|
||||
void set_map(RID p_map);
|
||||
RID get_map() const;
|
||||
|
||||
void set_start_position(Vector3 p_start_position);
|
||||
Vector3 get_start_position() const;
|
||||
|
||||
void set_target_position(Vector3 p_target_position);
|
||||
Vector3 get_target_position() const;
|
||||
|
||||
void set_navigation_layers(uint32_t p_navigation_layers);
|
||||
uint32_t get_navigation_layers() const;
|
||||
|
||||
void set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags);
|
||||
BitField<NavigationPathQueryParameters3D::PathMetadataFlags> get_metadata_flags() const;
|
||||
|
||||
void set_simplify_path(bool p_enabled);
|
||||
bool get_simplify_path() const;
|
||||
|
||||
void set_simplify_epsilon(real_t p_epsilon);
|
||||
real_t get_simplify_epsilon() const;
|
||||
|
||||
void set_excluded_regions(const TypedArray<RID> &p_regions);
|
||||
TypedArray<RID> get_excluded_regions() const;
|
||||
|
||||
void set_included_regions(const TypedArray<RID> &p_regions);
|
||||
TypedArray<RID> get_included_regions() const;
|
||||
|
||||
void set_path_return_max_length(float p_length);
|
||||
float get_path_return_max_length() const;
|
||||
|
||||
void set_path_return_max_radius(float p_radius);
|
||||
float get_path_return_max_radius() const;
|
||||
|
||||
void set_path_search_max_polygons(int p_max_polygons);
|
||||
int get_path_search_max_polygons() const;
|
||||
|
||||
void set_path_search_max_distance(float p_distance);
|
||||
float get_path_search_max_distance() const;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryParameters3D::PathfindingAlgorithm);
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryParameters3D::PathPostProcessing);
|
||||
VARIANT_BITFIELD_CAST(NavigationPathQueryParameters3D::PathMetadataFlags);
|
147
servers/navigation/navigation_path_query_result_2d.cpp
Normal file
147
servers/navigation/navigation_path_query_result_2d.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_result_2d.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "navigation_path_query_result_2d.h"
|
||||
|
||||
void NavigationPathQueryResult2D::set_path(const Vector<Vector2> &p_path) {
|
||||
path = p_path;
|
||||
}
|
||||
|
||||
const Vector<Vector2> &NavigationPathQueryResult2D::get_path() const {
|
||||
return path;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::set_path_types(const Vector<int32_t> &p_path_types) {
|
||||
path_types = p_path_types;
|
||||
}
|
||||
|
||||
const Vector<int32_t> &NavigationPathQueryResult2D::get_path_types() const {
|
||||
return path_types;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::set_path_rids(const TypedArray<RID> &p_path_rids) {
|
||||
path_rids = p_path_rids;
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryResult2D::get_path_rids() const {
|
||||
return path_rids;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {
|
||||
path_owner_ids = p_path_owner_ids;
|
||||
}
|
||||
|
||||
const Vector<int64_t> &NavigationPathQueryResult2D::get_path_owner_ids() const {
|
||||
return path_owner_ids;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::reset() {
|
||||
path.clear();
|
||||
path_types.clear();
|
||||
path_rids.clear();
|
||||
path_owner_ids.clear();
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::set_data(const LocalVector<Vector2> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids) {
|
||||
path.clear();
|
||||
path_types.clear();
|
||||
path_rids.clear();
|
||||
path_owner_ids.clear();
|
||||
|
||||
{
|
||||
path.resize(p_path.size());
|
||||
Vector2 *w = path.ptrw();
|
||||
const Vector2 *r = p_path.ptr();
|
||||
for (uint32_t i = 0; i < p_path.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_types.resize(p_path_types.size());
|
||||
int32_t *w = path_types.ptrw();
|
||||
const int32_t *r = p_path_types.ptr();
|
||||
for (uint32_t i = 0; i < p_path_types.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_rids.resize(p_path_rids.size());
|
||||
for (uint32_t i = 0; i < p_path_rids.size(); i++) {
|
||||
path_rids[i] = p_path_rids[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_owner_ids.resize(p_path_owner_ids.size());
|
||||
int64_t *w = path_owner_ids.ptrw();
|
||||
const int64_t *r = p_path_owner_ids.ptr();
|
||||
for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::set_path_length(float p_length) {
|
||||
path_length = p_length;
|
||||
}
|
||||
|
||||
float NavigationPathQueryResult2D::get_path_length() const {
|
||||
return path_length;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path);
|
||||
ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult2D::set_path_types);
|
||||
ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult2D::get_path_types);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult2D::set_path_rids);
|
||||
ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult2D::get_path_rids);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult2D::set_path_owner_ids);
|
||||
ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult2D::get_path_owner_ids);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult2D::set_path_length);
|
||||
ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult2D::get_path_length);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult2D::reset);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "path"), "set_path", "get_path");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length");
|
||||
|
||||
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);
|
||||
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);
|
||||
}
|
74
servers/navigation/navigation_path_query_result_2d.h
Normal file
74
servers/navigation/navigation_path_query_result_2d.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_result_2d.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "servers/navigation/navigation_utilities.h"
|
||||
|
||||
class NavigationPathQueryResult2D : public RefCounted {
|
||||
GDCLASS(NavigationPathQueryResult2D, RefCounted);
|
||||
|
||||
Vector<Vector2> path;
|
||||
Vector<int32_t> path_types;
|
||||
TypedArray<RID> path_rids;
|
||||
Vector<int64_t> path_owner_ids;
|
||||
float path_length = 0.0;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum PathSegmentType {
|
||||
PATH_SEGMENT_TYPE_REGION = NavigationUtilities::PathSegmentType::PATH_SEGMENT_TYPE_REGION,
|
||||
PATH_SEGMENT_TYPE_LINK = NavigationUtilities::PathSegmentType::PATH_SEGMENT_TYPE_LINK,
|
||||
};
|
||||
|
||||
void set_path(const Vector<Vector2> &p_path);
|
||||
const Vector<Vector2> &get_path() const;
|
||||
|
||||
void set_path_types(const Vector<int32_t> &p_path_types);
|
||||
const Vector<int32_t> &get_path_types() const;
|
||||
|
||||
void set_path_rids(const TypedArray<RID> &p_path_rids);
|
||||
TypedArray<RID> get_path_rids() const;
|
||||
|
||||
void set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids);
|
||||
const Vector<int64_t> &get_path_owner_ids() const;
|
||||
|
||||
void set_path_length(float p_length);
|
||||
float get_path_length() const;
|
||||
|
||||
void reset();
|
||||
|
||||
void set_data(const LocalVector<Vector2> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids);
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryResult2D::PathSegmentType);
|
147
servers/navigation/navigation_path_query_result_3d.cpp
Normal file
147
servers/navigation/navigation_path_query_result_3d.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_result_3d.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "navigation_path_query_result_3d.h"
|
||||
|
||||
void NavigationPathQueryResult3D::set_path(const Vector<Vector3> &p_path) {
|
||||
path = p_path;
|
||||
}
|
||||
|
||||
const Vector<Vector3> &NavigationPathQueryResult3D::get_path() const {
|
||||
return path;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::set_path_types(const Vector<int32_t> &p_path_types) {
|
||||
path_types = p_path_types;
|
||||
}
|
||||
|
||||
const Vector<int32_t> &NavigationPathQueryResult3D::get_path_types() const {
|
||||
return path_types;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::set_path_rids(const TypedArray<RID> &p_path_rids) {
|
||||
path_rids = p_path_rids;
|
||||
}
|
||||
|
||||
TypedArray<RID> NavigationPathQueryResult3D::get_path_rids() const {
|
||||
return path_rids;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {
|
||||
path_owner_ids = p_path_owner_ids;
|
||||
}
|
||||
|
||||
const Vector<int64_t> &NavigationPathQueryResult3D::get_path_owner_ids() const {
|
||||
return path_owner_ids;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::reset() {
|
||||
path.clear();
|
||||
path_types.clear();
|
||||
path_rids.clear();
|
||||
path_owner_ids.clear();
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::set_data(const LocalVector<Vector3> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids) {
|
||||
path.clear();
|
||||
path_types.clear();
|
||||
path_rids.clear();
|
||||
path_owner_ids.clear();
|
||||
|
||||
{
|
||||
path.resize(p_path.size());
|
||||
Vector3 *w = path.ptrw();
|
||||
const Vector3 *r = p_path.ptr();
|
||||
for (uint32_t i = 0; i < p_path.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_types.resize(p_path_types.size());
|
||||
int32_t *w = path_types.ptrw();
|
||||
const int32_t *r = p_path_types.ptr();
|
||||
for (uint32_t i = 0; i < p_path_types.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_rids.resize(p_path_rids.size());
|
||||
for (uint32_t i = 0; i < p_path_rids.size(); i++) {
|
||||
path_rids[i] = p_path_rids[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
path_owner_ids.resize(p_path_owner_ids.size());
|
||||
int64_t *w = path_owner_ids.ptrw();
|
||||
const int64_t *r = p_path_owner_ids.ptr();
|
||||
for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {
|
||||
w[i] = r[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::set_path_length(float p_length) {
|
||||
path_length = p_length;
|
||||
}
|
||||
|
||||
float NavigationPathQueryResult3D::get_path_length() const {
|
||||
return path_length;
|
||||
}
|
||||
|
||||
void NavigationPathQueryResult3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult3D::set_path);
|
||||
ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult3D::get_path);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult3D::set_path_types);
|
||||
ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult3D::get_path_types);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult3D::set_path_rids);
|
||||
ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult3D::get_path_rids);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult3D::set_path_owner_ids);
|
||||
ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult3D::get_path_owner_ids);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult3D::set_path_length);
|
||||
ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult3D::get_path_length);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult3D::reset);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "path"), "set_path", "get_path");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length");
|
||||
|
||||
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);
|
||||
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);
|
||||
}
|
75
servers/navigation/navigation_path_query_result_3d.h
Normal file
75
servers/navigation/navigation_path_query_result_3d.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_path_query_result_3d.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
#include "servers/navigation/navigation_utilities.h"
|
||||
|
||||
class NavigationPathQueryResult3D : public RefCounted {
|
||||
GDCLASS(NavigationPathQueryResult3D, RefCounted);
|
||||
|
||||
Vector<Vector3> path;
|
||||
Vector<int32_t> path_types;
|
||||
TypedArray<RID> path_rids;
|
||||
Vector<int64_t> path_owner_ids;
|
||||
float path_length = 0.0;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum PathSegmentType {
|
||||
PATH_SEGMENT_TYPE_REGION = NavigationUtilities::PathSegmentType::PATH_SEGMENT_TYPE_REGION,
|
||||
PATH_SEGMENT_TYPE_LINK = NavigationUtilities::PathSegmentType::PATH_SEGMENT_TYPE_LINK,
|
||||
};
|
||||
|
||||
void set_path(const Vector<Vector3> &p_path);
|
||||
const Vector<Vector3> &get_path() const;
|
||||
|
||||
void set_path_types(const Vector<int32_t> &p_path_types);
|
||||
const Vector<int32_t> &get_path_types() const;
|
||||
|
||||
void set_path_rids(const TypedArray<RID> &p_path_rids);
|
||||
TypedArray<RID> get_path_rids() const;
|
||||
|
||||
void set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids);
|
||||
const Vector<int64_t> &get_path_owner_ids() const;
|
||||
|
||||
void set_path_length(float p_length);
|
||||
float get_path_length() const;
|
||||
|
||||
void reset();
|
||||
|
||||
void set_data(const LocalVector<Vector3> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids);
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NavigationPathQueryResult3D::PathSegmentType);
|
61
servers/navigation/navigation_utilities.h
Normal file
61
servers/navigation/navigation_utilities.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************/
|
||||
/* navigation_utilities.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
namespace NavigationUtilities {
|
||||
|
||||
enum PathfindingAlgorithm {
|
||||
PATHFINDING_ALGORITHM_ASTAR = 0,
|
||||
};
|
||||
|
||||
enum PathPostProcessing {
|
||||
PATH_POSTPROCESSING_CORRIDORFUNNEL = 0,
|
||||
PATH_POSTPROCESSING_EDGECENTERED,
|
||||
PATH_POSTPROCESSING_NONE,
|
||||
};
|
||||
|
||||
enum PathSegmentType {
|
||||
PATH_SEGMENT_TYPE_REGION = 0,
|
||||
PATH_SEGMENT_TYPE_LINK
|
||||
};
|
||||
|
||||
enum PathMetadataFlags {
|
||||
PATH_INCLUDE_NONE = 0,
|
||||
PATH_INCLUDE_TYPES = 1,
|
||||
PATH_INCLUDE_RIDS = 2,
|
||||
PATH_INCLUDE_OWNERS = 4,
|
||||
PATH_INCLUDE_ALL = PATH_INCLUDE_TYPES | PATH_INCLUDE_RIDS | PATH_INCLUDE_OWNERS
|
||||
};
|
||||
|
||||
} //namespace NavigationUtilities
|
Reference in New Issue
Block a user