Skip to content

Commit

Permalink
Move 3D-only navigation code to its own subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Feb 26, 2024
1 parent fd582dc commit 138180f
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 156 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* godot_navigation_server.h */
/* godot_navigation_server_3d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef GODOT_NAVIGATION_SERVER_H
#define GODOT_NAVIGATION_SERVER_H
#ifndef GODOT_NAVIGATION_SERVER_3D_H
#define GODOT_NAVIGATION_SERVER_3D_H

#include "nav_agent.h"
#include "nav_link.h"
#include "nav_map.h"
#include "nav_obstacle.h"
#include "nav_region.h"
#include "../nav_agent.h"
#include "../nav_link.h"
#include "../nav_map.h"
#include "../nav_obstacle.h"
#include "../nav_region.h"

#include "core/templates/local_vector.h"
#include "core/templates/rid.h"
Expand All @@ -55,17 +55,17 @@
virtual void F_NAME(T_0 D_0, T_1 D_1) override; \
void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1)

class GodotNavigationServer;
class GodotNavigationServer3D;
#ifndef _3D_DISABLED
class NavMeshGenerator3D;
#endif // _3D_DISABLED

struct SetCommand {
virtual ~SetCommand() {}
virtual void exec(GodotNavigationServer *server) = 0;
virtual void exec(GodotNavigationServer3D *server) = 0;
};

class GodotNavigationServer : public NavigationServer3D {
class GodotNavigationServer3D : public NavigationServer3D {
Mutex commands_mutex;
/// Mutex used to make any operation threadsafe.
Mutex operations_mutex;
Expand Down Expand Up @@ -97,8 +97,8 @@ class GodotNavigationServer : public NavigationServer3D {
int pm_edge_free_count = 0;

public:
GodotNavigationServer();
virtual ~GodotNavigationServer();
GodotNavigationServer3D();
virtual ~GodotNavigationServer3D();

void add_command(SetCommand *command);

Expand Down Expand Up @@ -286,4 +286,4 @@ class GodotNavigationServer : public NavigationServer3D {
#undef COMMAND_1
#undef COMMAND_2

#endif // GODOT_NAVIGATION_SERVER_H
#endif // GODOT_NAVIGATION_SERVER_3D_H
File renamed without changes.
2 changes: 2 additions & 0 deletions modules/navigation/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ module_obj = []

env_navigation.add_source_files(module_obj, "*.cpp")
env_navigation.add_source_files(module_obj, "2d/*.cpp")
if not env["disable_3d"]:
env_navigation.add_source_files(module_obj, "3d/*.cpp")
if env.editor_build:
env_navigation.add_source_files(module_obj, "editor/*.cpp")
env.modules_sources += module_obj
Expand Down
10 changes: 5 additions & 5 deletions modules/navigation/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include "register_types.h"

#include "2d/godot_navigation_server_2d.h"
#include "godot_navigation_server.h"
#include "3d/godot_navigation_server_3d.h"

#ifndef DISABLE_DEPRECATED
#ifndef _3D_DISABLED
#include "navigation_mesh_generator.h"
#include "3d/navigation_mesh_generator.h"
#endif
#endif // DISABLE_DEPRECATED

Expand All @@ -53,8 +53,8 @@ NavigationMeshGenerator *_nav_mesh_generator = nullptr;
#endif
#endif // DISABLE_DEPRECATED

NavigationServer3D *new_server() {
return memnew(GodotNavigationServer);
NavigationServer3D *new_navigation_server_3d() {
return memnew(GodotNavigationServer3D);
}

NavigationServer2D *new_navigation_server_2d() {
Expand All @@ -63,7 +63,7 @@ NavigationServer2D *new_navigation_server_2d() {

void initialize_navigation_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
NavigationServer3DManager::set_default_server(new_server);
NavigationServer3DManager::set_default_server(new_navigation_server_3d);
NavigationServer2DManager::set_default_server(new_navigation_server_2d);

#ifndef DISABLE_DEPRECATED
Expand Down

0 comments on commit 138180f

Please sign in to comment.