summaryrefslogtreecommitdiff
path: root/modules/gdnavigation
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnavigation')
-rw-r--r--modules/gdnavigation/SCsub34
-rw-r--r--modules/gdnavigation/config.py1
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp86
-rw-r--r--modules/gdnavigation/gd_navigation_server.h4
-rw-r--r--modules/gdnavigation/nav_map.cpp26
-rw-r--r--modules/gdnavigation/nav_region.cpp4
-rw-r--r--modules/gdnavigation/nav_region.h2
-rw-r--r--modules/gdnavigation/nav_utils.h6
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp22
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h6
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp92
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.h2
-rw-r--r--modules/gdnavigation/register_types.cpp8
-rw-r--r--modules/gdnavigation/rvo_agent.cpp4
14 files changed, 149 insertions, 148 deletions
diff --git a/modules/gdnavigation/SCsub b/modules/gdnavigation/SCsub
index 9d462f92a7..877d601c6a 100644
--- a/modules/gdnavigation/SCsub
+++ b/modules/gdnavigation/SCsub
@@ -1,25 +1,25 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_navigation = env_modules.Clone()
# Recast Thirdparty source files
-if env['builtin_recast']:
+if env["builtin_recast"]:
thirdparty_dir = "#thirdparty/recastnavigation/Recast/"
thirdparty_sources = [
- "Source/Recast.cpp",
- "Source/RecastAlloc.cpp",
- "Source/RecastArea.cpp",
- "Source/RecastAssert.cpp",
- "Source/RecastContour.cpp",
- "Source/RecastFilter.cpp",
- "Source/RecastLayers.cpp",
- "Source/RecastMesh.cpp",
- "Source/RecastMeshDetail.cpp",
- "Source/RecastRasterization.cpp",
- "Source/RecastRegion.cpp",
+ "Source/Recast.cpp",
+ "Source/RecastAlloc.cpp",
+ "Source/RecastArea.cpp",
+ "Source/RecastAssert.cpp",
+ "Source/RecastContour.cpp",
+ "Source/RecastFilter.cpp",
+ "Source/RecastLayers.cpp",
+ "Source/RecastMesh.cpp",
+ "Source/RecastMeshDetail.cpp",
+ "Source/RecastRasterization.cpp",
+ "Source/RecastRegion.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
@@ -31,11 +31,11 @@ if env['builtin_recast']:
# RVO Thirdparty source files
-if env['builtin_rvo2']:
+if env["builtin_rvo2"]:
thirdparty_dir = "#thirdparty/rvo2"
thirdparty_sources = [
- "/src/Agent.cpp",
- "/src/KdTree.cpp",
+ "/src/Agent.cpp",
+ "/src/KdTree.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/gdnavigation/config.py b/modules/gdnavigation/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/gdnavigation/config.py
+++ b/modules/gdnavigation/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
index a1f6ddfedc..278c27ae22 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -114,7 +114,7 @@
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
GdNavigationServer::GdNavigationServer() :
- NavigationServer(),
+ NavigationServer3D(),
active(true) {
}
@@ -141,7 +141,7 @@ RID GdNavigationServer::map_create() const {
COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
if (p_active) {
if (!map_is_active(p_map)) {
@@ -154,84 +154,84 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
bool GdNavigationServer::map_is_active(RID p_map) const {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, false);
+ ERR_FAIL_COND_V(map == nullptr, false);
return active_maps.find(map) >= 0;
}
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_up(p_up);
}
Vector3 GdNavigationServer::map_get_up(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_up();
}
COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_cell_size(p_cell_size);
}
real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, 0);
+ ERR_FAIL_COND_V(map == nullptr, 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.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_edge_connection_margin(p_connection_margin);
}
real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, 0);
+ ERR_FAIL_COND_V(map == nullptr, 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 {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
+ ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>());
return map->get_path(p_origin, p_destination, p_optimize);
}
Vector3 GdNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_to_segment(p_from, p_to, p_use_collision);
}
Vector3 GdNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point(p_point);
}
Vector3 GdNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_normal(p_point);
}
RID GdNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, RID());
+ ERR_FAIL_COND_V(map == nullptr, RID());
return map->get_closest_point_owner(p_point);
}
@@ -247,20 +247,20 @@ RID GdNavigationServer::region_create() const {
COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
NavRegion *region = region_owner.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
- if (region->get_map() != NULL) {
+ if (region->get_map() != nullptr) {
if (region->get_map()->get_self() == p_map)
return; // Pointless
region->get_map()->remove_region(region);
- region->set_map(NULL);
+ region->set_map(nullptr);
}
if (p_map.is_valid()) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->add_region(region);
region->set_map(map);
@@ -269,21 +269,21 @@ 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.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
region->set_transform(p_transform);
}
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
NavRegion *region = region_owner.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
region->set_mesh(p_nav_mesh);
}
void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const {
ERR_FAIL_COND(r_mesh.is_null());
- ERR_FAIL_COND(p_node == NULL);
+ ERR_FAIL_COND(p_node == nullptr);
#ifndef _3D_DISABLED
NavigationMeshGenerator::get_singleton()->clear(r_mesh);
@@ -302,7 +302,7 @@ RID GdNavigationServer::agent_create() const {
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
if (agent->get_map()->get_self() == p_map)
@@ -311,11 +311,11 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
agent->get_map()->remove_agent(agent);
}
- agent->set_map(NULL);
+ agent->set_map(nullptr);
if (p_map.is_valid()) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
agent->set_map(map);
map->add_agent(agent);
@@ -328,82 +328,82 @@ 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.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->neighborDist_ = p_dist;
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxNeighbors_ = p_count;
}
COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->timeHorizon_ = p_time;
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->radius_ = p_radius;
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxSpeed_ = p_max_speed;
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
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.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
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.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
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.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND_V(agent == NULL, false);
+ ERR_FAIL_COND_V(agent == nullptr, 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.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
- agent->set_callback(p_receiver == NULL ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
+ agent->set_callback(p_receiver == nullptr ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
if (agent->get_map()) {
- if (p_receiver == NULL) {
+ if (p_receiver == nullptr) {
agent->get_map()->remove_agent_as_controlled(agent);
} else {
agent->get_map()->set_agent_as_controlled(agent);
@@ -419,14 +419,14 @@ COMMAND_1(free, RID, p_object) {
std::vector<NavRegion *> regions = map->get_regions();
for (size_t i(0); i < regions.size(); i++) {
map->remove_region(regions[i]);
- regions[i]->set_map(NULL);
+ regions[i]->set_map(nullptr);
}
// Remove any assigned agent
std::vector<RvoAgent *> agents = map->get_agents();
for (size_t i(0); i < agents.size(); i++) {
map->remove_agent(agents[i]);
- agents[i]->set_map(NULL);
+ agents[i]->set_map(nullptr);
}
active_maps.erase(map);
@@ -437,9 +437,9 @@ COMMAND_1(free, RID, p_object) {
NavRegion *region = region_owner.getornull(p_object);
// Removes this region from the map if assigned
- if (region->get_map() != NULL) {
+ if (region->get_map() != nullptr) {
region->get_map()->remove_region(region);
- region->set_map(NULL);
+ region->set_map(nullptr);
}
region_owner.free(p_object);
@@ -449,9 +449,9 @@ COMMAND_1(free, RID, p_object) {
RvoAgent *agent = agent_owner.getornull(p_object);
// Removes this agent from the map if assigned
- if (agent->get_map() != NULL) {
+ if (agent->get_map() != nullptr) {
agent->get_map()->remove_agent(agent);
- agent->set_map(NULL);
+ agent->set_map(nullptr);
}
agent_owner.free(p_object);
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
index e9f5c1ffe6..01d1a4fba9 100644
--- a/modules/gdnavigation/gd_navigation_server.h
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -33,7 +33,7 @@
#include "core/rid.h"
#include "core/rid_owner.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#include "nav_map.h"
#include "nav_region.h"
@@ -67,7 +67,7 @@ struct SetCommand {
virtual void exec(GdNavigationServer *server) = 0;
};
-class GdNavigationServer : public NavigationServer {
+class GdNavigationServer : public NavigationServer3D {
Mutex commands_mutex;
/// Mutex used to make any operation threadsafe.
Mutex operations_mutex;
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
index 338e49eb9f..7e6a3f7a26 100644
--- a/modules/gdnavigation/nav_map.cpp
+++ b/modules/gdnavigation/nav_map.cpp
@@ -81,8 +81,8 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const {
Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
- const gd::Polygon *begin_poly = NULL;
- const gd::Polygon *end_poly = NULL;
+ const gd::Polygon *begin_poly = nullptr;
+ const gd::Polygon *end_poly = nullptr;
Vector3 begin_point;
Vector3 end_point;
float begin_d = 1e20;
@@ -146,7 +146,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
open_list.push_back(0);
- const gd::Polygon *reachable_end = NULL;
+ const gd::Polygon *reachable_end = nullptr;
float reachable_d = 1e30;
bool is_reachable = true;
@@ -215,7 +215,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
// so use the further reachable polygon
ERR_BREAK_MSG(is_reachable == false, "It's not expect to not find the most reachable polygons");
is_reachable = false;
- if (reachable_end == NULL) {
+ if (reachable_end == nullptr) {
// The path is not found and there is not a way out.
break;
}
@@ -240,7 +240,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
open_list.clear();
open_list.push_back(0);
- reachable_end = NULL;
+ reachable_end = nullptr;
continue;
}
@@ -249,7 +249,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
least_cost_id = -1;
float least_cost = 1e30;
- for (auto element = open_list.front(); element != NULL; element = element->next()) {
+ for (auto element = open_list.front(); element != nullptr; element = element->next()) {
gd::NavigationPoly *np = &navigation_polys[element->get()];
float cost = np->traveled_distance;
#ifdef USE_ENTRY_POINT
@@ -366,7 +366,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
p = &navigation_polys[p->prev_navigation_poly_id];
else
// The end
- p = NULL;
+ p = nullptr;
}
if (path[path.size() - 1] != begin_point)
@@ -637,12 +637,12 @@ void NavMap::sync() {
gd::Connection c;
c.A = &poly;
c.A_edge = p;
- c.B = NULL;
+ c.B = nullptr;
c.B_edge = -1;
connections[ek] = c;
- } else if (connection->get().B == NULL) {
- CRASH_COND(connection->get().A == NULL); // Unreachable
+ } else if (connection->get().B == nullptr) {
+ CRASH_COND(connection->get().A == nullptr); // Unreachable
// Connect the two Polygons by this edge
connection->get().B = &poly;
@@ -657,7 +657,7 @@ void NavMap::sync() {
connection->get().B->edges[connection->get().B_edge].other_edge = connection->get().A_edge;
} else {
// The edge is already connected with another edge, skip.
- ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem.");
+ ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation3D's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem.");
}
}
}
@@ -667,8 +667,8 @@ void NavMap::sync() {
free_edges.reserve(connections.size());
for (auto connection_element = connections.front(); connection_element; connection_element = connection_element->next()) {
- if (connection_element->get().B == NULL) {
- CRASH_COND(connection_element->get().A == NULL); // Unreachable
+ if (connection_element->get().B == nullptr) {
+ CRASH_COND(connection_element->get().A == nullptr); // Unreachable
CRASH_COND(connection_element->get().A_edge < 0); // Unreachable
// This is a free edge
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
index 0215821305..b91376f761 100644
--- a/modules/gdnavigation/nav_region.cpp
+++ b/modules/gdnavigation/nav_region.cpp
@@ -37,7 +37,7 @@
*/
NavRegion::NavRegion() :
- map(NULL),
+ map(nullptr),
polygons_dirty(true) {
}
@@ -71,7 +71,7 @@ void NavRegion::update_polygons() {
polygons.clear();
polygons_dirty = false;
- if (map == NULL) {
+ if (map == nullptr) {
return;
}
diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h
index d99254d1ad..f35ee4bea0 100644
--- a/modules/gdnavigation/nav_region.h
+++ b/modules/gdnavigation/nav_region.h
@@ -34,7 +34,7 @@
#include "nav_rid.h"
#include "nav_utils.h"
-#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_3d.h"
#include <vector>
/**
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
index bdf9eb34a8..3401284c31 100644
--- a/modules/gdnavigation/nav_utils.h
+++ b/modules/gdnavigation/nav_utils.h
@@ -90,7 +90,7 @@ struct Edge {
Edge() {
this_edge = -1;
- other_polygon = NULL;
+ other_polygon = nullptr;
other_edge = -1;
}
};
@@ -119,8 +119,8 @@ struct Connection {
int B_edge;
Connection() {
- A = NULL;
- B = NULL;
+ A = nullptr;
+ B = nullptr;
A_edge = -1;
B_edge = -1;
}
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index e6ff7a7afa..abaf73ba6a 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
@@ -34,13 +34,13 @@
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "navigation_mesh_generator.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
void NavigationMeshEditor::_node_removed(Node *p_node) {
if (p_node == node) {
- node = NULL;
+ node = nullptr;
hide();
}
@@ -50,8 +50,8 @@ void NavigationMeshEditor::_notification(int p_option) {
if (p_option == NOTIFICATION_ENTER_TREE) {
- button_bake->set_icon(get_icon("Bake", "EditorIcons"));
- button_reset->set_icon(get_icon("Reload", "EditorIcons"));
+ button_bake->set_icon(get_theme_icon("Bake", "EditorIcons"));
+ button_reset->set_icon(get_theme_icon("Reload", "EditorIcons"));
}
}
@@ -61,7 +61,7 @@ void NavigationMeshEditor::_bake_pressed() {
ERR_FAIL_COND(!node);
if (!node->get_navigation_mesh().is_valid()) {
err_dialog->set_text(TTR("A NavigationMesh resource must be set or created for this node to work."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -84,9 +84,9 @@ void NavigationMeshEditor::_clear_pressed() {
}
}
-void NavigationMeshEditor::edit(NavigationRegion *p_nav_region) {
+void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) {
- if (p_nav_region == NULL || node == p_nav_region) {
+ if (p_nav_region == nullptr || node == p_nav_region) {
return;
}
@@ -117,7 +117,7 @@ NavigationMeshEditor::NavigationMeshEditor() {
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
- node = NULL;
+ node = nullptr;
}
NavigationMeshEditor::~NavigationMeshEditor() {
@@ -125,12 +125,12 @@ NavigationMeshEditor::~NavigationMeshEditor() {
void NavigationMeshEditorPlugin::edit(Object *p_object) {
- navigation_mesh_editor->edit(Object::cast_to<NavigationRegion>(p_object));
+ navigation_mesh_editor->edit(Object::cast_to<NavigationRegion3D>(p_object));
}
bool NavigationMeshEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("NavigationRegion");
+ return p_object->is_class("NavigationRegion3D");
}
void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
@@ -142,7 +142,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
navigation_mesh_editor->hide();
navigation_mesh_editor->bake_hbox->hide();
- navigation_mesh_editor->edit(NULL);
+ navigation_mesh_editor->edit(nullptr);
}
}
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h
index 847ad4f63d..434981c9e0 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.h
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h
@@ -36,7 +36,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-class NavigationRegion;
+class NavigationRegion3D;
class NavigationMeshEditor : public Control {
friend class NavigationMeshEditorPlugin;
@@ -50,7 +50,7 @@ class NavigationMeshEditor : public Control {
ToolButton *button_reset;
Label *bake_info;
- NavigationRegion *node;
+ NavigationRegion3D *node;
void _bake_pressed();
void _clear_pressed();
@@ -61,7 +61,7 @@ protected:
void _notification(int p_option);
public:
- void edit(NavigationRegion *p_nav_region);
+ void edit(NavigationRegion3D *p_nav_region);
NavigationMeshEditor();
~NavigationMeshEditor();
};
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index e7038b38a2..acb4f0461f 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -34,18 +34,18 @@
#include "core/math/quick_hull.h"
#include "core/os/thread.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/physics_body.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/cylinder_shape.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
#include "scene/resources/primitive_meshes.h"
-#include "scene/resources/shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
#include "modules/modules_enabled.gen.h"
#ifdef TOOLS_ENABLED
@@ -60,7 +60,7 @@
#include "modules/gridmap/grid_map.h"
#endif
-NavigationMeshGenerator *NavigationMeshGenerator::singleton = NULL;
+NavigationMeshGenerator *NavigationMeshGenerator::singleton = nullptr;
void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
p_verticies.push_back(p_vec3.x);
@@ -140,9 +140,9 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
- if (Object::cast_to<MeshInstance>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
_add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_verticies, p_indices);
@@ -150,9 +150,9 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#ifdef MODULE_CSG_ENABLED
- if (Object::cast_to<CSGShape>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- CSGShape *csg_shape = Object::cast_to<CSGShape>(p_node);
+ CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
Array meshes = csg_shape->get_meshes();
if (!meshes.empty()) {
Ref<Mesh> mesh = meshes[1];
@@ -163,22 +163,22 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<StaticBody>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
- StaticBody *static_body = Object::cast_to<StaticBody>(p_node);
+ if (Object::cast_to<StaticBody3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
+ StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
if (static_body->get_collision_layer() & p_collision_mask) {
for (int i = 0; i < p_node->get_child_count(); ++i) {
Node *child = p_node->get_child(i);
- if (Object::cast_to<CollisionShape>(child)) {
- CollisionShape *col_shape = Object::cast_to<CollisionShape>(child);
+ if (Object::cast_to<CollisionShape3D>(child)) {
+ CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child);
Transform transform = p_accumulated_transform * static_body->get_transform() * col_shape->get_transform();
Ref<Mesh> mesh;
- Ref<Shape> s = col_shape->get_shape();
+ Ref<Shape3D> s = col_shape->get_shape();
- BoxShape *box = Object::cast_to<BoxShape>(*s);
+ BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {
Ref<CubeMesh> cube_mesh;
cube_mesh.instance();
@@ -186,7 +186,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cube_mesh;
}
- CapsuleShape *capsule = Object::cast_to<CapsuleShape>(*s);
+ CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);
if (capsule) {
Ref<CapsuleMesh> capsule_mesh;
capsule_mesh.instance();
@@ -195,7 +195,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = capsule_mesh;
}
- CylinderShape *cylinder = Object::cast_to<CylinderShape>(*s);
+ CylinderShape3D *cylinder = Object::cast_to<CylinderShape3D>(*s);
if (cylinder) {
Ref<CylinderMesh> cylinder_mesh;
cylinder_mesh.instance();
@@ -205,7 +205,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cylinder_mesh;
}
- SphereShape *sphere = Object::cast_to<SphereShape>(*s);
+ SphereShape3D *sphere = Object::cast_to<SphereShape3D>(*s);
if (sphere) {
Ref<SphereMesh> sphere_mesh;
sphere_mesh.instance();
@@ -214,12 +214,12 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = sphere_mesh;
}
- ConcavePolygonShape *concave_polygon = Object::cast_to<ConcavePolygonShape>(*s);
+ ConcavePolygonShape3D *concave_polygon = Object::cast_to<ConcavePolygonShape3D>(*s);
if (concave_polygon) {
_add_faces(concave_polygon->get_faces(), transform, p_verticies, p_indices);
}
- ConvexPolygonShape *convex_polygon = Object::cast_to<ConvexPolygonShape>(*s);
+ ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
if (convex_polygon) {
Vector<Vector3> varr = Variant(convex_polygon->get_points());
Geometry::MeshData md;
@@ -265,8 +265,8 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<Spatial>(p_node)) {
- Spatial *spatial = Object::cast_to<Spatial>(p_node);
+ if (Object::cast_to<Node3D>(p_node)) {
+ Node3D *spatial = Object::cast_to<Node3D>(p_node);
p_accumulated_transform = p_accumulated_transform * spatial->get_transform();
}
@@ -405,7 +405,7 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildCompactHeightfield(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf, *chf));
rcFreeHeightField(hf);
- hf = 0;
+ hf = nullptr;
#ifdef TOOLS_ENABLED
if (ep)
@@ -452,9 +452,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildPolyMeshDetail(&ctx, *poly_mesh, *chf, cfg.detailSampleDist, cfg.detailSampleMaxError, *detail_mesh));
rcFreeCompactHeightfield(chf);
- chf = 0;
+ chf = nullptr;
rcFreeContourSet(cset);
- cset = 0;
+ cset = nullptr;
#ifdef TOOLS_ENABLED
if (ep)
@@ -464,9 +464,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
_convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh);
rcFreePolyMesh(poly_mesh);
- poly_mesh = 0;
+ poly_mesh = nullptr;
rcFreePolyMeshDetail(detail_mesh);
- detail_mesh = 0;
+ detail_mesh = nullptr;
}
NavigationMeshGenerator *NavigationMeshGenerator::get_singleton() {
@@ -485,7 +485,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
ERR_FAIL_COND(!p_nav_mesh.is_valid());
#ifdef TOOLS_ENABLED
- EditorProgress *ep(NULL);
+ EditorProgress *ep(nullptr);
if (Engine::get_singleton()->is_editor_hint()) {
ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11));
}
@@ -505,7 +505,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes);
}
- Transform navmesh_xform = Object::cast_to<Spatial>(p_node)->get_transform().affine_inverse();
+ Transform navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse();
for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) {
int geometry_type = p_nav_mesh->get_parsed_geometry_type();
uint32_t collision_mask = p_nav_mesh->get_collision_mask();
@@ -515,11 +515,11 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
if (vertices.size() > 0 && indices.size() > 0) {
- rcHeightfield *hf = NULL;
- rcCompactHeightfield *chf = NULL;
- rcContourSet *cset = NULL;
- rcPolyMesh *poly_mesh = NULL;
- rcPolyMeshDetail *detail_mesh = NULL;
+ rcHeightfield *hf = nullptr;
+ rcCompactHeightfield *chf = nullptr;
+ rcContourSet *cset = nullptr;
+ rcPolyMesh *poly_mesh = nullptr;
+ rcPolyMeshDetail *detail_mesh = nullptr;
_build_recast_navigation_mesh(
p_nav_mesh,
@@ -535,19 +535,19 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
indices);
rcFreeHeightField(hf);
- hf = 0;
+ hf = nullptr;
rcFreeCompactHeightfield(chf);
- chf = 0;
+ chf = nullptr;
rcFreeContourSet(cset);
- cset = 0;
+ cset = nullptr;
rcFreePolyMesh(poly_mesh);
- poly_mesh = 0;
+ poly_mesh = nullptr;
rcFreePolyMeshDetail(detail_mesh);
- detail_mesh = 0;
+ detail_mesh = nullptr;
}
#ifdef TOOLS_ENABLED
diff --git a/modules/gdnavigation/navigation_mesh_generator.h b/modules/gdnavigation/navigation_mesh_generator.h
index d1f2e4b56f..c5f7b2ab81 100644
--- a/modules/gdnavigation/navigation_mesh_generator.h
+++ b/modules/gdnavigation/navigation_mesh_generator.h
@@ -33,7 +33,7 @@
#ifndef _3D_DISABLED
-#include "scene/3d/navigation_region.h"
+#include "scene/3d/navigation_region_3d.h"
#include <Recast.h>
diff --git a/modules/gdnavigation/register_types.cpp b/modules/gdnavigation/register_types.cpp
index d717733787..088b26bf17 100644
--- a/modules/gdnavigation/register_types.cpp
+++ b/modules/gdnavigation/register_types.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "gd_navigation_server.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#ifndef _3D_DISABLED
#include "navigation_mesh_generator.h"
@@ -47,15 +47,15 @@
*/
#ifndef _3D_DISABLED
-NavigationMeshGenerator *_nav_mesh_generator = NULL;
+NavigationMeshGenerator *_nav_mesh_generator = nullptr;
#endif
-NavigationServer *new_server() {
+NavigationServer3D *new_server() {
return memnew(GdNavigationServer);
}
void register_gdnavigation_types() {
- NavigationServerManager::set_default_server(new_server);
+ NavigationServer3DManager::set_default_server(new_server);
#ifndef _3D_DISABLED
_nav_mesh_generator = memnew(NavigationMeshGenerator);
diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp
index 677e525bbf..3c39f02c26 100644
--- a/modules/gdnavigation/rvo_agent.cpp
+++ b/modules/gdnavigation/rvo_agent.cpp
@@ -37,7 +37,7 @@
*/
RvoAgent::RvoAgent() :
- map(NULL) {
+ map(nullptr) {
callback.id = ObjectID();
}
@@ -70,7 +70,7 @@ void RvoAgent::dispatch_callback() {
return;
}
Object *obj = ObjectDB::get_instance(callback.id);
- if (obj == NULL) {
+ if (obj == nullptr) {
callback.id = ObjectID();
}