Path: blob/master/servers/navigation/navigation_path_query_result_2d.cpp
10277 views
/**************************************************************************/1/* navigation_path_query_result_2d.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_result_2d.h"3132void NavigationPathQueryResult2D::set_path(const Vector<Vector2> &p_path) {33path = p_path;34}3536const Vector<Vector2> &NavigationPathQueryResult2D::get_path() const {37return path;38}3940void NavigationPathQueryResult2D::set_path_types(const Vector<int32_t> &p_path_types) {41path_types = p_path_types;42}4344const Vector<int32_t> &NavigationPathQueryResult2D::get_path_types() const {45return path_types;46}4748void NavigationPathQueryResult2D::set_path_rids(const TypedArray<RID> &p_path_rids) {49path_rids = p_path_rids;50}5152TypedArray<RID> NavigationPathQueryResult2D::get_path_rids() const {53return path_rids;54}5556void NavigationPathQueryResult2D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {57path_owner_ids = p_path_owner_ids;58}5960const Vector<int64_t> &NavigationPathQueryResult2D::get_path_owner_ids() const {61return path_owner_ids;62}6364void NavigationPathQueryResult2D::reset() {65path.clear();66path_types.clear();67path_rids.clear();68path_owner_ids.clear();69}7071void 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) {72path.clear();73path_types.clear();74path_rids.clear();75path_owner_ids.clear();7677{78path.resize(p_path.size());79Vector2 *w = path.ptrw();80const Vector2 *r = p_path.ptr();81for (uint32_t i = 0; i < p_path.size(); i++) {82w[i] = r[i];83}84}8586{87path_types.resize(p_path_types.size());88int32_t *w = path_types.ptrw();89const int32_t *r = p_path_types.ptr();90for (uint32_t i = 0; i < p_path_types.size(); i++) {91w[i] = r[i];92}93}9495{96path_rids.resize(p_path_rids.size());97for (uint32_t i = 0; i < p_path_rids.size(); i++) {98path_rids[i] = p_path_rids[i];99}100}101102{103path_owner_ids.resize(p_path_owner_ids.size());104int64_t *w = path_owner_ids.ptrw();105const int64_t *r = p_path_owner_ids.ptr();106for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {107w[i] = r[i];108}109}110}111112void NavigationPathQueryResult2D::set_path_length(float p_length) {113path_length = p_length;114}115116float NavigationPathQueryResult2D::get_path_length() const {117return path_length;118}119120void NavigationPathQueryResult2D::_bind_methods() {121ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path);122ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path);123124ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult2D::set_path_types);125ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult2D::get_path_types);126127ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult2D::set_path_rids);128ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult2D::get_path_rids);129130ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult2D::set_path_owner_ids);131ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult2D::get_path_owner_ids);132133ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult2D::set_path_length);134ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult2D::get_path_length);135136ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult2D::reset);137138ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "path"), "set_path", "get_path");139ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");140ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");141ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");142ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length");143144BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);145BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);146}147148149