Path: blob/master/servers/navigation_3d/navigation_path_query_parameters_3d.cpp
11322 views
/**************************************************************************/1/* navigation_path_query_parameters_3d.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "navigation_path_query_parameters_3d.h"3132#include "core/variant/typed_array.h"3334void NavigationPathQueryParameters3D::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {35pathfinding_algorithm = p_pathfinding_algorithm;36}3738NavigationPathQueryParameters3D::PathfindingAlgorithm NavigationPathQueryParameters3D::get_pathfinding_algorithm() const {39return pathfinding_algorithm;40}4142void NavigationPathQueryParameters3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {43path_postprocessing = p_path_postprocessing;44}4546NavigationPathQueryParameters3D::PathPostProcessing NavigationPathQueryParameters3D::get_path_postprocessing() const {47return path_postprocessing;48}4950void NavigationPathQueryParameters3D::set_map(RID p_map) {51map = p_map;52}5354RID NavigationPathQueryParameters3D::get_map() const {55return map;56}5758void NavigationPathQueryParameters3D::set_start_position(Vector3 p_start_position) {59start_position = p_start_position;60}6162Vector3 NavigationPathQueryParameters3D::get_start_position() const {63return start_position;64}6566void NavigationPathQueryParameters3D::set_target_position(Vector3 p_target_position) {67target_position = p_target_position;68}6970Vector3 NavigationPathQueryParameters3D::get_target_position() const {71return target_position;72}7374void NavigationPathQueryParameters3D::set_navigation_layers(uint32_t p_navigation_layers) {75navigation_layers = p_navigation_layers;76}7778uint32_t NavigationPathQueryParameters3D::get_navigation_layers() const {79return navigation_layers;80}8182void NavigationPathQueryParameters3D::set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags) {83metadata_flags = (int64_t)p_flags;84}8586BitField<NavigationPathQueryParameters3D::PathMetadataFlags> NavigationPathQueryParameters3D::get_metadata_flags() const {87return (int64_t)metadata_flags;88}8990void NavigationPathQueryParameters3D::set_simplify_path(bool p_enabled) {91simplify_path = p_enabled;92}9394bool NavigationPathQueryParameters3D::get_simplify_path() const {95return simplify_path;96}9798void NavigationPathQueryParameters3D::set_simplify_epsilon(real_t p_epsilon) {99simplify_epsilon = MAX(0.0, p_epsilon);100}101102real_t NavigationPathQueryParameters3D::get_simplify_epsilon() const {103return simplify_epsilon;104}105106void NavigationPathQueryParameters3D::set_included_regions(const TypedArray<RID> &p_regions) {107_included_regions.resize(p_regions.size());108for (uint32_t i = 0; i < _included_regions.size(); i++) {109_included_regions[i] = p_regions[i];110}111}112113TypedArray<RID> NavigationPathQueryParameters3D::get_included_regions() const {114TypedArray<RID> r_regions;115r_regions.resize(_included_regions.size());116for (uint32_t i = 0; i < _included_regions.size(); i++) {117r_regions[i] = _included_regions[i];118}119return r_regions;120}121122void NavigationPathQueryParameters3D::set_excluded_regions(const TypedArray<RID> &p_regions) {123_excluded_regions.resize(p_regions.size());124for (uint32_t i = 0; i < _excluded_regions.size(); i++) {125_excluded_regions[i] = p_regions[i];126}127}128129TypedArray<RID> NavigationPathQueryParameters3D::get_excluded_regions() const {130TypedArray<RID> r_regions;131r_regions.resize(_excluded_regions.size());132for (uint32_t i = 0; i < _excluded_regions.size(); i++) {133r_regions[i] = _excluded_regions[i];134}135return r_regions;136}137138void NavigationPathQueryParameters3D::set_path_return_max_length(float p_length) {139path_return_max_length = MAX(0.0, p_length);140}141142float NavigationPathQueryParameters3D::get_path_return_max_length() const {143return path_return_max_length;144}145146void NavigationPathQueryParameters3D::set_path_return_max_radius(float p_radius) {147path_return_max_radius = MAX(0.0, p_radius);148}149150float NavigationPathQueryParameters3D::get_path_return_max_radius() const {151return path_return_max_radius;152}153154void NavigationPathQueryParameters3D::set_path_search_max_polygons(int p_max_polygons) {155path_search_max_polygons = p_max_polygons;156}157158int NavigationPathQueryParameters3D::get_path_search_max_polygons() const {159return path_search_max_polygons;160}161162void NavigationPathQueryParameters3D::set_path_search_max_distance(float p_distance) {163path_search_max_distance = MAX(0.0, p_distance);164}165166float NavigationPathQueryParameters3D::get_path_search_max_distance() const {167return path_search_max_distance;168}169170void NavigationPathQueryParameters3D::_bind_methods() {171ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);172ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);173174ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);175ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);176177ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);178ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);179180ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);181ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);182183ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);184ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);185186ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);187ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);188189ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);190ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);191192ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters3D::set_simplify_path);193ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters3D::get_simplify_path);194195ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);196ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);197198ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);199ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);200201ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);202ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);203204ClassDB::bind_method(D_METHOD("set_path_return_max_length", "length"), &NavigationPathQueryParameters3D::set_path_return_max_length);205ClassDB::bind_method(D_METHOD("get_path_return_max_length"), &NavigationPathQueryParameters3D::get_path_return_max_length);206207ClassDB::bind_method(D_METHOD("set_path_return_max_radius", "radius"), &NavigationPathQueryParameters3D::set_path_return_max_radius);208ClassDB::bind_method(D_METHOD("get_path_return_max_radius"), &NavigationPathQueryParameters3D::get_path_return_max_radius);209210ClassDB::bind_method(D_METHOD("set_path_search_max_polygons", "max_polygons"), &NavigationPathQueryParameters3D::set_path_search_max_polygons);211ClassDB::bind_method(D_METHOD("get_path_search_max_polygons"), &NavigationPathQueryParameters3D::get_path_search_max_polygons);212213ClassDB::bind_method(D_METHOD("set_path_search_max_distance", "distance"), &NavigationPathQueryParameters3D::set_path_search_max_distance);214ClassDB::bind_method(D_METHOD("get_path_search_max_distance"), &NavigationPathQueryParameters3D::get_path_search_max_distance);215216ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");217ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");218ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");219ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");220ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");221ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered,None"), "set_path_postprocessing", "get_path_postprocessing");222ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");223ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");224ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");225ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");226ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");227ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_length"), "set_path_return_max_length", "get_path_return_max_length");228ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_radius"), "set_path_return_max_radius", "get_path_return_max_radius");229ADD_PROPERTY(PropertyInfo(Variant::INT, "path_search_max_polygons"), "set_path_search_max_polygons", "get_path_search_max_polygons");230ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_search_max_distance"), "set_path_search_max_distance", "get_path_search_max_distance");231232BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);233234BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);235BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);236BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);237238BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);239BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);240BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);241BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);242BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);243}244245246