Path: blob/master/servers/navigation_3d/navigation_path_query_result_3d.cpp
23317 views
/**************************************************************************/1/* navigation_path_query_result_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_result_3d.h"3132#include "core/object/class_db.h"3334void NavigationPathQueryResult3D::set_path(const Vector<Vector3> &p_path) {35path = p_path;36}3738const Vector<Vector3> &NavigationPathQueryResult3D::get_path() const {39return path;40}4142void NavigationPathQueryResult3D::set_path_types(const Vector<int32_t> &p_path_types) {43path_types = p_path_types;44}4546const Vector<int32_t> &NavigationPathQueryResult3D::get_path_types() const {47return path_types;48}4950void NavigationPathQueryResult3D::set_path_rids(const TypedArray<RID> &p_path_rids) {51path_rids = p_path_rids;52}5354TypedArray<RID> NavigationPathQueryResult3D::get_path_rids() const {55return path_rids;56}5758void NavigationPathQueryResult3D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {59path_owner_ids = p_path_owner_ids;60}6162const Vector<int64_t> &NavigationPathQueryResult3D::get_path_owner_ids() const {63return path_owner_ids;64}6566void NavigationPathQueryResult3D::reset() {67path.clear();68path_types.clear();69path_rids.clear();70path_owner_ids.clear();71}7273void 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) {74path.clear();75path_types.clear();76path_rids.clear();77path_owner_ids.clear();7879{80path.resize(p_path.size());81Vector3 *w = path.ptrw();82const Vector3 *r = p_path.ptr();83for (uint32_t i = 0; i < p_path.size(); i++) {84w[i] = r[i];85}86}8788{89path_types.resize(p_path_types.size());90int32_t *w = path_types.ptrw();91const int32_t *r = p_path_types.ptr();92for (uint32_t i = 0; i < p_path_types.size(); i++) {93w[i] = r[i];94}95}9697{98path_rids.resize(p_path_rids.size());99for (uint32_t i = 0; i < p_path_rids.size(); i++) {100path_rids[i] = p_path_rids[i];101}102}103104{105path_owner_ids.resize(p_path_owner_ids.size());106int64_t *w = path_owner_ids.ptrw();107const int64_t *r = p_path_owner_ids.ptr();108for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {109w[i] = r[i];110}111}112}113114void NavigationPathQueryResult3D::set_path_length(float p_length) {115path_length = p_length;116}117118float NavigationPathQueryResult3D::get_path_length() const {119return path_length;120}121122void NavigationPathQueryResult3D::_bind_methods() {123ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult3D::set_path);124ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult3D::get_path);125126ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult3D::set_path_types);127ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult3D::get_path_types);128129ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult3D::set_path_rids);130ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult3D::get_path_rids);131132ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult3D::set_path_owner_ids);133ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult3D::get_path_owner_ids);134135ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult3D::set_path_length);136ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult3D::get_path_length);137138ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult3D::reset);139140ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "path"), "set_path", "get_path");141ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");142ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");143ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");144ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length");145146BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);147BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);148}149150151