[Navigation] Create a dedicated 2D navigation server
* Add a dedicated 2D server * Create dedicated tests * Split performance metrics between 2D and 3D * Rename the 3D only server module
This commit is contained in:
@ -54,6 +54,7 @@ namespace NavigationDefaults2D {
|
||||
|
||||
// Same as in 3D but larger since 1px is treated as 1m.
|
||||
constexpr float navmesh_cell_size{ 1.0f }; // Must match ProjectSettings default 2D cell_size.
|
||||
constexpr float navmesh_cell_size_min{ 0.01f };
|
||||
constexpr auto navmesh_cell_size_hint{ "0.001,100,0.001,or_greater" };
|
||||
|
||||
// Map.
|
||||
|
||||
@ -69,6 +69,47 @@ void NavigationPathQueryResult2D::reset() {
|
||||
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::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path);
|
||||
ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path);
|
||||
|
||||
@ -63,6 +63,8 @@ public:
|
||||
const Vector<int64_t> &get_path_owner_ids() 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);
|
||||
|
||||
Reference in New Issue
Block a user