Rename GdNavigationServer to GodotNavigationServer

And rename `gdnavigation` module to simply `navigation`.
This commit is contained in:
Rémi Verschelde 2021-06-30 00:16:35 +02:00
parent 03788e9f18
commit 74dc5e27c8
No known key found for this signature in database
GPG Key ID: C3336907360768E1
18 changed files with 116 additions and 128 deletions

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* gd_navigation_server.cpp */
/* godot_navigation_server.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_navigation_server.h"
#include "godot_navigation_server.h"
#include "core/os/mutex.h"
@ -44,93 +44,93 @@
/// an instance of that struct with the submitted parameters.
/// Then, that struct is stored in an array; the `sync` function consume that array.
#define COMMAND_1(F_NAME, T_0, D_0) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
MERGE(F_NAME, _command) \
(T_0 p_d_0) : \
d_0(p_d_0) {} \
virtual void exec(GdNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0); \
} \
}; \
void GdNavigationServer::F_NAME(T_0 D_0) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0)); \
add_command(cmd); \
} \
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0)
#define COMMAND_1(F_NAME, T_0, D_0) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
MERGE(F_NAME, _command) \
(T_0 p_d_0) : \
d_0(p_d_0) {} \
virtual void exec(GodotNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0); \
} \
}; \
void GodotNavigationServer::F_NAME(T_0 D_0) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0)); \
add_command(cmd); \
} \
void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0)
#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
T_1 d_1; \
MERGE(F_NAME, _command) \
( \
T_0 p_d_0, \
T_1 p_d_1) : \
d_0(p_d_0), \
d_1(p_d_1) {} \
virtual void exec(GdNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0, d_1); \
} \
}; \
void GdNavigationServer::F_NAME(T_0 D_0, T_1 D_1) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0, \
D_1)); \
add_command(cmd); \
} \
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1)
#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
T_1 d_1; \
MERGE(F_NAME, _command) \
( \
T_0 p_d_0, \
T_1 p_d_1) : \
d_0(p_d_0), \
d_1(p_d_1) {} \
virtual void exec(GodotNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0, d_1); \
} \
}; \
void GodotNavigationServer::F_NAME(T_0 D_0, T_1 D_1) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0, \
D_1)); \
add_command(cmd); \
} \
void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1)
#define COMMAND_4(F_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
T_1 d_1; \
T_2 d_2; \
T_3 d_3; \
MERGE(F_NAME, _command) \
( \
T_0 p_d_0, \
T_1 p_d_1, \
T_2 p_d_2, \
T_3 p_d_3) : \
d_0(p_d_0), \
d_1(p_d_1), \
d_2(p_d_2), \
d_3(p_d_3) {} \
virtual void exec(GdNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0, d_1, d_2, d_3); \
} \
}; \
void GdNavigationServer::F_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0, \
D_1, \
D_2, \
D_3)); \
add_command(cmd); \
} \
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
#define COMMAND_4(F_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3) \
struct MERGE(F_NAME, _command) : public SetCommand { \
T_0 d_0; \
T_1 d_1; \
T_2 d_2; \
T_3 d_3; \
MERGE(F_NAME, _command) \
( \
T_0 p_d_0, \
T_1 p_d_1, \
T_2 p_d_2, \
T_3 p_d_3) : \
d_0(p_d_0), \
d_1(p_d_1), \
d_2(p_d_2), \
d_3(p_d_3) {} \
virtual void exec(GodotNavigationServer *server) { \
server->MERGE(_cmd_, F_NAME)(d_0, d_1, d_2, d_3); \
} \
}; \
void GodotNavigationServer::F_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) const { \
auto cmd = memnew(MERGE(F_NAME, _command)( \
D_0, \
D_1, \
D_2, \
D_3)); \
add_command(cmd); \
} \
void GodotNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
GdNavigationServer::GdNavigationServer() :
GodotNavigationServer::GodotNavigationServer() :
NavigationServer3D() {
}
GdNavigationServer::~GdNavigationServer() {
GodotNavigationServer::~GodotNavigationServer() {
flush_queries();
}
void GdNavigationServer::add_command(SetCommand *command) const {
GdNavigationServer *mut_this = const_cast<GdNavigationServer *>(this);
void GodotNavigationServer::add_command(SetCommand *command) const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
{
MutexLock lock(commands_mutex);
mut_this->commands.push_back(command);
}
}
RID GdNavigationServer::map_create() const {
GdNavigationServer *mut_this = const_cast<GdNavigationServer *>(this);
RID GodotNavigationServer::map_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = map_owner.make_rid();
NavMap *space = map_owner.getornull(rid);
@ -155,7 +155,7 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
}
}
bool GdNavigationServer::map_is_active(RID p_map) const {
bool GodotNavigationServer::map_is_active(RID p_map) const {
NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == nullptr, false);
@ -169,7 +169,7 @@ COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
map->set_up(p_up);
}
Vector3 GdNavigationServer::map_get_up(RID p_map) const {
Vector3 GodotNavigationServer::map_get_up(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector3());
@ -183,7 +183,7 @@ COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
map->set_cell_size(p_cell_size);
}
real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
real_t GodotNavigationServer::map_get_cell_size(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == nullptr, 0);
@ -197,50 +197,50 @@ COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margi
map->set_edge_connection_margin(p_connection_margin);
}
real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
real_t GodotNavigationServer::map_get_edge_connection_margin(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
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, uint32_t p_layers) const {
Vector<Vector3> GodotNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_layers) const {
const NavMap *map = map_owner.getornull(p_map);
ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>());
return map->get_path(p_origin, p_destination, p_optimize, p_layers);
}
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 {
Vector3 GodotNavigationServer::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 == 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 {
Vector3 GodotNavigationServer::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 == nullptr, Vector3());
return map->get_closest_point(p_point);
}
Vector3 GdNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
Vector3 GodotNavigationServer::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 == 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 {
RID GodotNavigationServer::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 == nullptr, RID());
return map->get_closest_point_owner(p_point);
}
RID GdNavigationServer::region_create() const {
GdNavigationServer *mut_this = const_cast<GdNavigationServer *>(this);
RID GodotNavigationServer::region_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = region_owner.make_rid();
NavRegion *reg = region_owner.getornull(rid);
@ -284,7 +284,7 @@ COMMAND_2(region_set_layers, RID, p_region, uint32_t, p_layers) {
region->set_layers(p_layers);
}
uint32_t GdNavigationServer::region_get_layers(RID p_region) const {
uint32_t GodotNavigationServer::region_get_layers(RID p_region) const {
NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND_V(region == nullptr, 0);
@ -298,7 +298,7 @@ COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
region->set_mesh(p_nav_mesh);
}
void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const {
void GodotNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const {
ERR_FAIL_COND(r_mesh.is_null());
ERR_FAIL_COND(p_node == nullptr);
@ -308,29 +308,29 @@ void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p
#endif
}
int GdNavigationServer::region_get_connections_count(RID p_region) const {
int GodotNavigationServer::region_get_connections_count(RID p_region) const {
NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND_V(!region, 0);
return region->get_connections_count();
}
Vector3 GdNavigationServer::region_get_connection_pathway_start(RID p_region, int p_connection_id) const {
Vector3 GodotNavigationServer::region_get_connection_pathway_start(RID p_region, int p_connection_id) const {
NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND_V(!region, Vector3());
return region->get_connection_pathway_start(p_connection_id);
}
Vector3 GdNavigationServer::region_get_connection_pathway_end(RID p_region, int p_connection_id) const {
Vector3 GodotNavigationServer::region_get_connection_pathway_end(RID p_region, int p_connection_id) const {
NavRegion *region = region_owner.getornull(p_region);
ERR_FAIL_COND_V(!region, Vector3());
return region->get_connection_pathway_end(p_connection_id);
}
RID GdNavigationServer::agent_create() const {
GdNavigationServer *mut_this = const_cast<GdNavigationServer *>(this);
RID GodotNavigationServer::agent_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
RID rid = agent_owner.make_rid();
RvoAgent *agent = agent_owner.getornull(rid);
@ -428,7 +428,7 @@ COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const {
RvoAgent *agent = agent_owner.getornull(p_agent);
ERR_FAIL_COND_V(agent == nullptr, false);
@ -500,13 +500,13 @@ COMMAND_1(free, RID, p_object) {
}
}
void GdNavigationServer::set_active(bool p_active) const {
GdNavigationServer *mut_this = const_cast<GdNavigationServer *>(this);
void GodotNavigationServer::set_active(bool p_active) const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
mut_this->active = p_active;
}
void GdNavigationServer::flush_queries() {
void GodotNavigationServer::flush_queries() {
// In c++ we can't be sure that this is performed in the main thread
// even with mutable functions.
MutexLock lock(commands_mutex);
@ -518,7 +518,7 @@ void GdNavigationServer::flush_queries() {
commands.clear();
}
void GdNavigationServer::process(real_t p_delta_time) {
void GodotNavigationServer::process(real_t p_delta_time) {
flush_queries();
if (!active) {

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* gd_navigation_server.h */
/* godot_navigation_server.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GD_NAVIGATION_SERVER_H
#define GD_NAVIGATION_SERVER_H
#ifndef GODOT_NAVIGATION_SERVER_H
#define GODOT_NAVIGATION_SERVER_H
#include "core/templates/local_vector.h"
#include "core/templates/rid.h"
@ -61,14 +61,14 @@
virtual void F_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3 = D_3_DEF) const; \
void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
class GdNavigationServer;
class GodotNavigationServer;
struct SetCommand {
virtual ~SetCommand() {}
virtual void exec(GdNavigationServer *server) = 0;
virtual void exec(GodotNavigationServer *server) = 0;
};
class GdNavigationServer : public NavigationServer3D {
class GodotNavigationServer : public NavigationServer3D {
Mutex commands_mutex;
/// Mutex used to make any operation threadsafe.
Mutex operations_mutex;
@ -84,8 +84,8 @@ class GdNavigationServer : public NavigationServer3D {
LocalVector<uint32_t> active_maps_update_id;
public:
GdNavigationServer();
virtual ~GdNavigationServer();
GodotNavigationServer();
virtual ~GodotNavigationServer();
void add_command(SetCommand *command) const;
@ -146,4 +146,4 @@ public:
#undef COMMAND_2
#undef COMMAND_4_DEF
#endif // GD_NAVIGATION_SERVER_H
#endif // GODOT_NAVIGATION_SERVER_H

View File

@ -31,9 +31,10 @@
#include "register_types.h"
#include "core/config/engine.h"
#include "gd_navigation_server.h"
#include "servers/navigation_server_3d.h"
#include "godot_navigation_server.h"
#ifndef _3D_DISABLED
#include "navigation_mesh_generator.h"
#endif
@ -42,19 +43,15 @@
#include "navigation_mesh_editor_plugin.h"
#endif
/**
@author AndreaCatania
*/
#ifndef _3D_DISABLED
NavigationMeshGenerator *_nav_mesh_generator = nullptr;
#endif
NavigationServer3D *new_server() {
return memnew(GdNavigationServer);
return memnew(GodotNavigationServer);
}
void register_gdnavigation_types() {
void register_navigation_types() {
NavigationServer3DManager::set_default_server(new_server);
#ifndef _3D_DISABLED
@ -65,15 +62,10 @@ void register_gdnavigation_types() {
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
ClassDB::set_current_api(prev_api);
#endif
}
void unregister_gdnavigation_types() {
void unregister_navigation_types() {
#ifndef _3D_DISABLED
if (_nav_mesh_generator) {
memdelete(_nav_mesh_generator);

View File

@ -28,14 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
/**
@author AndreaCatania
*/
#ifndef NAVIGATION_REGISTER_TYPES_H
#define NAVIGATION_REGISTER_TYPES_H
#ifndef GDNAVIGATION_REGISTER_TYPES_H
#define GDNAVIGATION_REGISTER_TYPES_H
void register_navigation_types();
void unregister_navigation_types();
void register_gdnavigation_types();
void unregister_gdnavigation_types();
#endif // GDNAVIGATION_REGISTER_TYPES_H
#endif // NAVIGATION_REGISTER_TYPES_H