Skip to content

Commit

Permalink
Merge pull request #83133 from aaronfranke/2d-navigation
Browse files Browse the repository at this point in the history
Move 2D-only and 3D-only navigation code to its own subfolder
  • Loading branch information
akien-mga committed Feb 26, 2024
2 parents 99addd6 + 138180f commit 2fb99c1
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#ifndef GODOT_NAVIGATION_SERVER_2D_H
#define GODOT_NAVIGATION_SERVER_2D_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 "servers/navigation_server_2d.h"

Expand Down
File renamed without changes.

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.
3 changes: 3 additions & 0 deletions modules/navigation/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ env.modules_sources += thirdparty_obj
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
12 changes: 6 additions & 6 deletions modules/navigation/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

#include "register_types.h"

#include "godot_navigation_server.h"
#include "godot_navigation_server_2d.h"
#include "2d/godot_navigation_server_2d.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 2fb99c1

Please sign in to comment.