Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guards to enable Godot builds with disabled Navigation module #65562

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "editor_node.h"

#include "modules/modules_enabled.gen.h"
#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/io/config_file.h"
Expand Down Expand Up @@ -65,8 +66,10 @@
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "servers/display_server.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "servers/physics_server_2d.h"
#include "servers/rendering/rendering_device.h"

Expand Down Expand Up @@ -170,8 +173,10 @@
#include "editor/plugins/mesh_instance_3d_editor_plugin.h"
#include "editor/plugins/mesh_library_editor_plugin.h"
#include "editor/plugins/multimesh_editor_plugin.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "editor/plugins/navigation_link_2d_editor_plugin.h"
#include "editor/plugins/navigation_polygon_editor_plugin.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/plugins/occluder_instance_3d_editor_plugin.h"
#include "editor/plugins/packed_scene_translation_parser_plugin.h"
Expand Down Expand Up @@ -568,6 +573,7 @@ void EditorNode::_update_from_settings() {
tree->set_debug_collision_contact_color(GLOBAL_GET("debug/shapes/collision/contact_color"));

#ifdef DEBUG_ENABLED
#ifdef MODULE_NAVIGATION_ENABLED
NavigationServer3D::get_singleton_mut()->set_debug_navigation_edge_connection_color(GLOBAL_GET("debug/shapes/navigation/edge_connection_color"));
NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_edge_color(GLOBAL_GET("debug/shapes/navigation/geometry_edge_color"));
NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_face_color(GLOBAL_GET("debug/shapes/navigation/geometry_face_color"));
Expand All @@ -578,6 +584,7 @@ void EditorNode::_update_from_settings() {
NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_lines(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines"));
NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_lines_xray(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines_xray"));
NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_geometry_face_random_color(GLOBAL_GET("debug/shapes/navigation/enable_geometry_face_random_color"));
#endif // MODULE_NAVIGATION_ENABLED
#endif // DEBUG_ENABLED
}

Expand Down Expand Up @@ -6087,12 +6094,14 @@ EditorNode::EditorNode() {

AudioServer::get_singleton()->set_enable_tagging_used_audio_streams(true);

#ifdef MODULE_NAVIGATION_ENABLED
// No navigation server by default if in editor.
if (NavigationServer3D::get_singleton()->get_debug_enabled()) {
NavigationServer3D::get_singleton()->set_active(true);
} else {
NavigationServer3D::get_singleton()->set_active(false);
}
#endif // MODULE_NAVIGATION_ENABLED

// No physics by default if in editor.
PhysicsServer3D::get_singleton()->set_active(false);
Expand Down Expand Up @@ -7354,8 +7363,10 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(GPUParticles2DEditorPlugin));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin));
add_editor_plugin(memnew(Line2DEditorPlugin));
#ifdef MODULE_NAVIGATION_ENABLED
add_editor_plugin(memnew(NavigationLink2DEditorPlugin));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin));
#endif // MODULE_NAVIGATION_ENABLED
add_editor_plugin(memnew(Path2DEditorPlugin));
add_editor_plugin(memnew(Polygon2DEditorPlugin));
add_editor_plugin(memnew(Cast2DEditorPlugin));
Expand Down
8 changes: 8 additions & 0 deletions editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "resource_importer_scene.h"

#include "modules/modules_enabled.gen.h"

#include "core/error/error_macros.h"
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
Expand All @@ -38,7 +40,9 @@
#include "scene/3d/collision_shape_3d.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "scene/3d/navigation_region_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "scene/3d/occluder_instance_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/3d/vehicle_body_3d.h"
Expand Down Expand Up @@ -795,6 +799,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R
}
}

#ifdef MODULE_NAVIGATION_ENABLED
} else if (_teststr(name, "navmesh") && Object::cast_to<ImporterMeshInstance3D>(p_node)) {
if (isroot) {
return p_node;
Expand All @@ -813,6 +818,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R
p_node->replace_by(nmi);
memdelete(p_node);
p_node = nmi;
#endif // MODULE_NAVIGATION_ENABLED
} else if (_teststr(name, "occ") || _teststr(name, "occonly")) {
if (isroot) {
return p_node;
Expand Down Expand Up @@ -1285,6 +1291,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<
}
}

#ifdef MODULE_NAVIGATION_ENABLED
//navmesh (node may have changed type above)
if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
Expand Down Expand Up @@ -1314,6 +1321,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<
}
}
}
#endif // MODULE_NAVIGATION_ENABLED

if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
Expand Down
9 changes: 9 additions & 0 deletions editor/plugins/debugger_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "editor/editor_settings.h"
#include "editor/fileserver/editor_file_server.h"
#include "editor/plugins/script_editor_plugin.h"
#include "modules/modules_enabled.gen.h"
#include "scene/gui/menu_button.h"

DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
Expand Down Expand Up @@ -75,9 +76,11 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
debug_menu->add_check_shortcut(ED_SHORTCUT("editor/visible_paths", TTR("Visible Paths")), RUN_DEBUG_PATHS);
debug_menu->set_item_tooltip(-1,
TTR("When this option is enabled, curve resources used by path nodes will be visible in the running project."));
#ifdef MODULE_NAVIGATION_ENABLED
debug_menu->add_check_shortcut(ED_SHORTCUT("editor/visible_navigation", TTR("Visible Navigation")), RUN_DEBUG_NAVIGATION);
debug_menu->set_item_tooltip(-1,
TTR("When this option is enabled, navigation meshes and polygons will be visible in the running project."));
#endif // MODULE_NAVIGATION_ENABLED
debug_menu->add_separator();
debug_menu->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Synchronize Scene Changes")), RUN_LIVE_DEBUG);
debug_menu->set_item_tooltip(-1,
Expand Down Expand Up @@ -161,11 +164,13 @@ void DebuggerEditorPlugin::_menu_option(int p_option) {
debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_PATHS), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_paths", !ischecked);

#ifdef MODULE_NAVIGATION_ENABLED
} break;
case RUN_DEBUG_NAVIGATION: {
bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_NAVIGATION));
debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked);
#endif // MODULE_NAVIGATION_ENABLED

} break;
case RUN_RELOAD_SCRIPTS: {
Expand All @@ -192,7 +197,9 @@ void DebuggerEditorPlugin::_update_debug_options() {
bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false);
bool check_debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
bool check_debug_paths = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_paths", false);
#ifdef MODULE_NAVIGATION_ENABLED
bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false);
#endif // MODULE_NAVIGATION_ENABLED
bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", true);
bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", true);
int instances = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_instances", 1);
Expand All @@ -209,9 +216,11 @@ void DebuggerEditorPlugin::_update_debug_options() {
if (check_debug_paths) {
_menu_option(RUN_DEBUG_PATHS);
}
#ifdef MODULE_NAVIGATION_ENABLED
if (check_debug_navigation) {
_menu_option(RUN_DEBUG_NAVIGATION);
}
#endif // MODULE_NAVIGATION_ENABLED
if (check_live_debug) {
_menu_option(RUN_LIVE_DEBUG);
}
Expand Down
3 changes: 3 additions & 0 deletions editor/plugins/debugger_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define DEBUGGER_EDITOR_PLUGIN_H

#include "editor/editor_plugin.h"
#include "modules/modules_enabled.gen.h"

class EditorFileServer;
class MenuButton;
Expand All @@ -50,7 +51,9 @@ class DebuggerEditorPlugin : public EditorPlugin {
RUN_LIVE_DEBUG,
RUN_DEBUG_COLLISONS,
RUN_DEBUG_PATHS,
#ifdef MODULE_NAVIGATION_ENABLED
RUN_DEBUG_NAVIGATION,
#endif // MODULE_NAVIGATION_ENABLED
RUN_DEPLOY_REMOTE_DEBUG,
RUN_RELOAD_SCRIPTS,
};
Expand Down
7 changes: 7 additions & 0 deletions editor/plugins/mesh_instance_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
#include "editor/editor_undo_redo_manager.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/collision_shape_3d.h"
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "scene/3d/navigation_region_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "scene/3d/physics_body_3d.h"
#include "scene/gui/box_container.h"

Expand Down Expand Up @@ -242,6 +245,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {

} break;

#ifdef MODULE_NAVIGATION_ENABLED
case MENU_OPTION_CREATE_NAVMESH: {
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);

Expand All @@ -266,6 +270,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
ur->add_undo_method(node, "remove_child", nmi);
ur->commit_action();
} break;
#endif // MODULE_NAVIGATION_ENABLED

case MENU_OPTION_CREATE_OUTLINE_MESH: {
outline_dialog->popup_centered(Vector2(200, 90));
Expand Down Expand Up @@ -506,8 +511,10 @@ MeshInstance3DEditor::MeshInstance3DEditor() {
options->get_popup()->set_item_tooltip(-1, TTR("Creates a simplified convex collision shape.\nThis is similar to single collision shape, but can result in a simpler geometry in some cases, at the cost of accuracy."));
options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES);
options->get_popup()->set_item_tooltip(-1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between a single convex collision and a polygon-based collision."));
#ifdef MODULE_NAVIGATION_ENABLED
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
#endif // MODULE_NAVIGATION_ENABLED
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the StandardMaterial Grow property when using that property isn't possible."));
Expand Down
5 changes: 5 additions & 0 deletions editor/plugins/mesh_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "main/main.h"
#include "modules/modules_enabled.gen.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/mesh_instance_3d.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "scene/3d/navigation_region_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "scene/3d/physics_body_3d.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
Expand Down Expand Up @@ -158,6 +161,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,

p_library->set_item_shapes(id, collisions);

#ifdef MODULE_NAVIGATION_ENABLED
Ref<NavigationMesh> navmesh;
Transform3D navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Expand All @@ -176,6 +180,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
p_library->set_item_navmesh(id, navmesh);
p_library->set_item_navmesh_transform(id, navmesh_transform);
}
#endif // MODULE_NAVIGATION_ENABLED
}

//generate previews!
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/navigation_link_2d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "navigation_link_2d_editor_plugin.h"

#ifdef MODULE_NAVIGATION_ENABLED
#include "canvas_item_editor_plugin.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
Expand Down Expand Up @@ -189,3 +190,4 @@ NavigationLink2DEditorPlugin::NavigationLink2DEditorPlugin() {
editor = memnew(NavigationLink2DEditor);
EditorNode::get_singleton()->get_gui_base()->add_child(editor);
}
#endif // MODULE_NAVIGATION_ENABLED
4 changes: 4 additions & 0 deletions editor/plugins/navigation_link_2d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#ifndef NAVIGATION_LINK_2D_EDITOR_PLUGIN_H
#define NAVIGATION_LINK_2D_EDITOR_PLUGIN_H

#include "modules/modules_enabled.gen.h"

#ifdef MODULE_NAVIGATION_ENABLED
#include "editor/editor_plugin.h"
#include "scene/2d/navigation_link_2d.h"

Expand Down Expand Up @@ -79,5 +82,6 @@ class NavigationLink2DEditorPlugin : public EditorPlugin {

NavigationLink2DEditorPlugin();
};
#endif // MODULE_NAVIGATION_ENABLED

#endif // NAVIGATION_LINK_2D_EDITOR_PLUGIN_H
2 changes: 2 additions & 0 deletions editor/plugins/navigation_polygon_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "navigation_polygon_editor_plugin.h"

#ifdef MODULE_NAVIGATION_ENABLED
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
if (!navpoly.is_valid()) {
Expand Down Expand Up @@ -117,3 +118,4 @@ NavigationPolygonEditor::NavigationPolygonEditor() {}
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin() :
AbstractPolygon2DEditorPlugin(memnew(NavigationPolygonEditor), "NavigationRegion2D") {
}
#endif // MODULE_NAVIGATION_ENABLED
3 changes: 3 additions & 0 deletions editor/plugins/navigation_polygon_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef NAVIGATION_POLYGON_EDITOR_PLUGIN_H
#define NAVIGATION_POLYGON_EDITOR_PLUGIN_H

#include "modules/modules_enabled.gen.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "editor/plugins/abstract_polygon_2d_editor.h"
#include "scene/2d/navigation_region_2d.h"

Expand Down Expand Up @@ -66,5 +68,6 @@ class NavigationPolygonEditorPlugin : public AbstractPolygon2DEditorPlugin {
public:
NavigationPolygonEditorPlugin();
};
#endif // MODULE_NAVIGATION_ENABLED

#endif // NAVIGATION_POLYGON_EDITOR_PLUGIN_H
12 changes: 12 additions & 0 deletions editor/plugins/node_3d_editor_gizmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@
#include "scene/3d/lightmap_probe.h"
#include "scene/3d/marker_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#ifdef MODULE_NAVIGATION_ENABLED
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation_region_3d.h"
#endif // MODULE_NAVIGATION_ENABLED
#include "scene/3d/occluder_instance_3d.h"
#include "scene/3d/ray_cast_3d.h"
#include "scene/3d/reflection_probe.h"
Expand Down Expand Up @@ -4841,25 +4843,34 @@ void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {

////

#ifdef MODULE_NAVIGATION_ENABLED
NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() {
create_material("face_material", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_color(), false, false, true);
create_material("face_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_face_disabled_color(), false, false, true);
create_material("edge_material", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_color());
create_material("edge_material_disabled", NavigationServer3D::get_singleton()->get_debug_navigation_geometry_edge_disabled_color());
}
#endif // MODULE_NAVIGATION_ENABLED

#ifdef MODULE_NAVIGATION_ENABLED
bool NavigationRegion3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<NavigationRegion3D>(p_spatial) != nullptr;
}
#endif // MODULE_NAVIGATION_ENABLED

#ifdef MODULE_NAVIGATION_ENABLED
String NavigationRegion3DGizmoPlugin::get_gizmo_name() const {
return "NavigationRegion3D";
}
#endif // MODULE_NAVIGATION_ENABLED

#ifdef MODULE_NAVIGATION_ENABLED
int NavigationRegion3DGizmoPlugin::get_priority() const {
return -1;
}
#endif // MODULE_NAVIGATION_ENABLED

#ifdef MODULE_NAVIGATION_ENABLED
void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
NavigationRegion3D *navigationregion = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node());

Expand Down Expand Up @@ -5168,6 +5179,7 @@ void NavigationLink3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo

ur->commit_action();
}
#endif // MODULE_NAVIGATION_ENABLED

//////

Expand Down
Loading