summaryrefslogtreecommitdiff
path: root/modules/gdnavigation
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnavigation')
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp60
-rw-r--r--modules/gdnavigation/gd_navigation_server.h10
-rw-r--r--modules/gdnavigation/nav_map.cpp4
-rw-r--r--modules/gdnavigation/nav_map.h4
-rw-r--r--modules/gdnavigation/nav_region.cpp4
-rw-r--r--modules/gdnavigation/nav_region.h4
-rw-r--r--modules/gdnavigation/nav_rid.h6
-rw-r--r--modules/gdnavigation/nav_utils.h4
-rw-r--r--modules/gdnavigation/rvo_agent.cpp2
-rw-r--r--modules/gdnavigation/rvo_agent.h2
10 files changed, 51 insertions, 49 deletions
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
index f3ffd93c9c..ddfb3c10fa 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -140,7 +140,7 @@ RID GdNavigationServer::map_create() const {
}
COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
if (p_active) {
@@ -153,56 +153,56 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
}
bool GdNavigationServer::map_is_active(RID p_map) const {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == NULL, false);
return active_maps.find(map) >= 0;
}
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
map->set_up(p_up);
}
Vector3 GdNavigationServer::map_get_up(RID p_map) const {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == NULL, Vector3());
return map->get_up();
}
COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
map->set_cell_size(p_cell_size);
}
real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == NULL, 0);
return map->get_cell_size();
}
COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
map->set_edge_connection_margin(p_connection_margin);
}
real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == NULL, 0);
return map->get_edge_connection_margin();
}
Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
return map->get_path(p_origin, p_destination, p_optimize);
@@ -219,7 +219,7 @@ RID GdNavigationServer::region_create() const {
}
COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
- NavRegion *region = region_owner.get(p_region);
+ NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND(region == NULL);
if (region->get_map() != NULL) {
@@ -232,7 +232,7 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
}
if (p_map.is_valid()) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
map->add_region(region);
@@ -241,14 +241,14 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
}
COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) {
- NavRegion *region = region_owner.get(p_region);
+ NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND(region == NULL);
region->set_transform(p_transform);
}
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
- NavRegion *region = region_owner.get(p_region);
+ NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND(region == NULL);
region->set_mesh(p_nav_mesh);
@@ -275,7 +275,7 @@ RID GdNavigationServer::agent_create() const {
}
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
if (agent->get_map()) {
@@ -288,7 +288,7 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
agent->set_map(NULL);
if (p_map.is_valid()) {
- NavMap *map = map_owner.get(p_map);
+ NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND(map == NULL);
agent->set_map(map);
@@ -301,77 +301,77 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
}
COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->neighborDist_ = p_dist;
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->maxNeighbors_ = p_count;
}
COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->timeHorizon_ = p_time;
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->radius_ = p_radius;
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->maxSpeed_ = p_max_speed;
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
}
COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND_V(agent == NULL, false);
return agent->is_map_changed();
}
COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
- RvoAgent *agent = agent_owner.get(p_agent);
+ RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND(agent == NULL);
agent->set_callback(p_receiver == NULL ? 0 : p_receiver->get_instance_id(), p_method, p_udata);
@@ -387,7 +387,7 @@ COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_
COMMAND_1(free, RID, p_object) {
if (map_owner.owns(p_object)) {
- NavMap *map = map_owner.get(p_object);
+ NavMap *map = map_owner.getornull(p_object);
// Removes any assigned region
std::vector<NavRegion *> regions = map->get_regions();
@@ -408,7 +408,7 @@ COMMAND_1(free, RID, p_object) {
memdelete(map);
} else if (region_owner.owns(p_object)) {
- NavRegion *region = region_owner.get(p_object);
+ NavRegion *region = region_owner.getornull(p_object);
// Removes this region from the map if assigned
if (region->get_map() != NULL) {
@@ -420,7 +420,7 @@ COMMAND_1(free, RID, p_object) {
memdelete(region);
} else if (agent_owner.owns(p_object)) {
- RvoAgent *agent = agent_owner.get(p_object);
+ RvoAgent *agent = agent_owner.getornull(p_object);
// Removes this agent from the map if assigned
if (agent->get_map() != NULL) {
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
index 80ba06880c..564e9870a0 100644
--- a/modules/gdnavigation/gd_navigation_server.h
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,8 @@
#ifndef GD_NAVIGATION_SERVER_H
#define GD_NAVIGATION_SERVER_H
+#include "core/rid.h"
+#include "core/rid_owner.h"
#include "servers/navigation_server.h"
#include "nav_map.h"
@@ -73,9 +75,9 @@ class GdNavigationServer : public NavigationServer {
std::vector<SetCommand *> commands;
- mutable RID_Owner<NavMap> map_owner;
- mutable RID_Owner<NavRegion> region_owner;
- mutable RID_Owner<RvoAgent> agent_owner;
+ mutable RID_PtrOwner<NavMap> map_owner;
+ mutable RID_PtrOwner<NavRegion> region_owner;
+ mutable RID_PtrOwner<RvoAgent> agent_owner;
bool active;
Vector<NavMap *> active_maps;
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
index 3d0e02c77d..d1765f4da9 100644
--- a/modules/gdnavigation/nav_map.cpp
+++ b/modules/gdnavigation/nav_map.cpp
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* rvo_space.cpp */
+/* nav_map.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h
index 636c07e437..128a82580c 100644
--- a/modules/gdnavigation/nav_map.h
+++ b/modules/gdnavigation/nav_map.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* rvo_space.h */
+/* nav_map.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
index 03477085ce..d2d9d8b517 100644
--- a/modules/gdnavigation/nav_region.cpp
+++ b/modules/gdnavigation/nav_region.cpp
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* nav_region.h */
+/* nav_region.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h
index c961257163..d99254d1ad 100644
--- a/modules/gdnavigation/nav_region.h
+++ b/modules/gdnavigation/nav_region.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* nav_region.cpp */
+/* nav_region.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/nav_rid.h b/modules/gdnavigation/nav_rid.h
index 96e22800c2..c119ecc5e0 100644
--- a/modules/gdnavigation/nav_rid.h
+++ b/modules/gdnavigation/nav_rid.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* rvo_rid.h */
+/* nav_rid.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
@author AndreaCatania
*/
-class NavRid : public RID_Data {
+class NavRid {
RID self;
public:
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
index 1048f58294..bdf9eb34a8 100644
--- a/modules/gdnavigation/nav_utils.h
+++ b/modules/gdnavigation/nav_utils.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* utils.h */
+/* nav_utils.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp
index 37a9b31351..eb66eb3a05 100644
--- a/modules/gdnavigation/rvo_agent.cpp
+++ b/modules/gdnavigation/rvo_agent.cpp
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h
index 6a84c1b95c..914cbaa7d9 100644
--- a/modules/gdnavigation/rvo_agent.h
+++ b/modules/gdnavigation/rvo_agent.h
@@ -6,7 +6,7 @@
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */