Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/navigation_3d/navigation_path_query_result_3d.cpp
23317 views
1
/**************************************************************************/
2
/* navigation_path_query_result_3d.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "navigation_path_query_result_3d.h"
32
33
#include "core/object/class_db.h"
34
35
void NavigationPathQueryResult3D::set_path(const Vector<Vector3> &p_path) {
36
path = p_path;
37
}
38
39
const Vector<Vector3> &NavigationPathQueryResult3D::get_path() const {
40
return path;
41
}
42
43
void NavigationPathQueryResult3D::set_path_types(const Vector<int32_t> &p_path_types) {
44
path_types = p_path_types;
45
}
46
47
const Vector<int32_t> &NavigationPathQueryResult3D::get_path_types() const {
48
return path_types;
49
}
50
51
void NavigationPathQueryResult3D::set_path_rids(const TypedArray<RID> &p_path_rids) {
52
path_rids = p_path_rids;
53
}
54
55
TypedArray<RID> NavigationPathQueryResult3D::get_path_rids() const {
56
return path_rids;
57
}
58
59
void NavigationPathQueryResult3D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {
60
path_owner_ids = p_path_owner_ids;
61
}
62
63
const Vector<int64_t> &NavigationPathQueryResult3D::get_path_owner_ids() const {
64
return path_owner_ids;
65
}
66
67
void NavigationPathQueryResult3D::reset() {
68
path.clear();
69
path_types.clear();
70
path_rids.clear();
71
path_owner_ids.clear();
72
}
73
74
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) {
75
path.clear();
76
path_types.clear();
77
path_rids.clear();
78
path_owner_ids.clear();
79
80
{
81
path.resize(p_path.size());
82
Vector3 *w = path.ptrw();
83
const Vector3 *r = p_path.ptr();
84
for (uint32_t i = 0; i < p_path.size(); i++) {
85
w[i] = r[i];
86
}
87
}
88
89
{
90
path_types.resize(p_path_types.size());
91
int32_t *w = path_types.ptrw();
92
const int32_t *r = p_path_types.ptr();
93
for (uint32_t i = 0; i < p_path_types.size(); i++) {
94
w[i] = r[i];
95
}
96
}
97
98
{
99
path_rids.resize(p_path_rids.size());
100
for (uint32_t i = 0; i < p_path_rids.size(); i++) {
101
path_rids[i] = p_path_rids[i];
102
}
103
}
104
105
{
106
path_owner_ids.resize(p_path_owner_ids.size());
107
int64_t *w = path_owner_ids.ptrw();
108
const int64_t *r = p_path_owner_ids.ptr();
109
for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {
110
w[i] = r[i];
111
}
112
}
113
}
114
115
void NavigationPathQueryResult3D::set_path_length(float p_length) {
116
path_length = p_length;
117
}
118
119
float NavigationPathQueryResult3D::get_path_length() const {
120
return path_length;
121
}
122
123
void NavigationPathQueryResult3D::_bind_methods() {
124
ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult3D::set_path);
125
ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult3D::get_path);
126
127
ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult3D::set_path_types);
128
ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult3D::get_path_types);
129
130
ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult3D::set_path_rids);
131
ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult3D::get_path_rids);
132
133
ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult3D::set_path_owner_ids);
134
ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult3D::get_path_owner_ids);
135
136
ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult3D::set_path_length);
137
ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult3D::get_path_length);
138
139
ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult3D::reset);
140
141
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "path"), "set_path", "get_path");
142
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");
143
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");
144
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");
145
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length");
146
147
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);
148
BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);
149
}
150
151