Skip to content

Commit 7e3d5ea

Browse files
committed
Allow building the editor with 3D disabled.
1 parent 9182eb2 commit 7e3d5ea

File tree

85 files changed

+720
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+720
-102
lines changed

SConstruct

-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ sys.modules.pop("detect")
963963
if env.editor_build:
964964
unsupported_opts = []
965965
for disable_opt in [
966-
"disable_3d",
967966
"disable_advanced_gui",
968967
"disable_physics_2d",
969968
"disable_navigation_2d",

editor/animation_track_editor.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
#include "editor/multi_node_edit.h"
4646
#include "editor/plugins/animation_player_editor_plugin.h"
4747
#include "editor/themes/editor_scale.h"
48+
#ifndef _3D_DISABLED
4849
#include "scene/3d/mesh_instance_3d.h"
50+
#endif // _3D_DISABLED
4951
#include "scene/animation/animation_player.h"
5052
#include "scene/animation/tween.h"
5153
#include "scene/gui/check_box.h"
@@ -4247,7 +4249,7 @@ void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_bezi
42474249
_edit_menu_pressed(EDIT_GOTO_NEXT_STEP_TIMELINE_ONLY);
42484250
}
42494251
}
4250-
4252+
#ifndef _3D_DISABLED
42514253
void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value) {
42524254
ERR_FAIL_NULL(root);
42534255
ERR_FAIL_COND_MSG(
@@ -4312,6 +4314,7 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const
43124314
}
43134315
return false;
43144316
}
4317+
#endif // _3D_DISABLED
43154318

43164319
void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant &p_value) {
43174320
String path = p_path;
@@ -5589,6 +5592,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
55895592
// id.value is filled in each case handled below.
55905593

55915594
switch (animation->track_get_type(p_track)) {
5595+
#ifndef _3D_DISABLED
55925596
case Animation::TYPE_POSITION_3D: {
55935597
Node3D *base = Object::cast_to<Node3D>(node);
55945598

@@ -5629,6 +5633,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
56295633

56305634
id.value = base->get_blend_shape_value(base->find_blend_shape_by_name(id.path.get_subname(0)));
56315635
} break;
5636+
#endif // _3D_DISABLED
56325637
case Animation::TYPE_VALUE: {
56335638
NodePath bp;
56345639
_find_hint_for_track(p_track, bp, &id.value);

editor/animation_track_editor.h

+4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
#include "editor/editor_data.h"
3434
#include "editor/editor_properties.h"
3535
#include "editor/property_selector.h"
36+
#ifndef _3D_DISABLED
3637
#include "scene/3d/node_3d.h"
38+
#endif // _3D_DISABLED
3739
#include "scene/gui/control.h"
3840
#include "scene/gui/menu_button.h"
3941
#include "scene/gui/scroll_bar.h"
@@ -924,8 +926,10 @@ class AnimationTrackEditor : public VBoxContainer {
924926
void set_anim_pos(float p_pos);
925927
void insert_node_value_key(Node *p_node, const String &p_property, bool p_only_if_exists = false, bool p_advance = false);
926928
void insert_value_key(const String &p_property, bool p_advance);
929+
#ifndef _3D_DISABLED
927930
void insert_transform_key(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type, const Variant &p_value);
928931
bool has_track(Node3D *p_node, const String &p_sub, const Animation::TrackType p_type);
932+
#endif // _3D_DISABLED
929933
void make_insert_queue();
930934
void commit_insert_queue();
931935

editor/animation_track_editor_plugins.cpp

+22-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
#include "editor/themes/editor_scale.h"
3838
#include "scene/2d/animated_sprite_2d.h"
3939
#include "scene/2d/sprite_2d.h"
40+
#ifndef _3D_DISABLED
4041
#include "scene/3d/sprite_3d.h"
42+
#endif // _3D_DISABLED
4143
#include "scene/animation/animation_player.h"
4244
#include "servers/audio/audio_stream.h"
4345

@@ -377,7 +379,11 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
377379

378380
Size2 size;
379381

380-
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
382+
if (Object::cast_to<Sprite2D>(object)
383+
#ifndef _3D_DISABLED
384+
|| Object::cast_to<Sprite3D>(object)
385+
#endif // _3D_DISABLED
386+
) {
381387
Ref<Texture2D> texture = object->call("get_texture");
382388
if (texture.is_null()) {
383389
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
@@ -398,7 +404,11 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
398404
if (vframes > 1) {
399405
size.y /= vframes;
400406
}
401-
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
407+
} else if (Object::cast_to<AnimatedSprite2D>(object)
408+
#ifndef _3D_DISABLED
409+
|| Object::cast_to<AnimatedSprite3D>(object)
410+
#endif // _3D_DISABLED
411+
) {
402412
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
403413
if (sf.is_null()) {
404414
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
@@ -454,7 +464,11 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
454464
Ref<Texture2D> texture;
455465
Rect2 region;
456466

457-
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
467+
if (Object::cast_to<Sprite2D>(object)
468+
#ifndef _3D_DISABLED
469+
|| Object::cast_to<Sprite3D>(object)
470+
#endif // _3D_DISABLED
471+
) {
458472
texture = object->call("get_texture");
459473
if (texture.is_null()) {
460474
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
@@ -489,7 +503,11 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
489503
region.position.x += region.size.x * coords.x;
490504
region.position.y += region.size.y * coords.y;
491505

492-
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
506+
} else if (Object::cast_to<AnimatedSprite2D>(object)
507+
#ifndef _3D_DISABLED
508+
|| Object::cast_to<AnimatedSprite3D>(object)
509+
#endif // _3D_DISABLED
510+
) {
493511
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
494512
if (sf.is_null()) {
495513
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);

editor/debugger/script_editor_debugger.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@
5050
#include "editor/inspector_dock.h"
5151
#include "editor/plugins/canvas_item_editor_plugin.h"
5252
#include "editor/plugins/editor_debugger_plugin.h"
53-
#include "editor/plugins/node_3d_editor_plugin.h"
5453
#include "editor/themes/editor_scale.h"
5554
#include "main/performance.h"
56-
#include "scene/3d/camera_3d.h"
5755
#include "scene/debugger/scene_debugger.h"
5856
#include "scene/gui/button.h"
5957
#include "scene/gui/dialogs.h"
@@ -68,6 +66,11 @@
6866
#include "servers/debugger/servers_debugger.h"
6967
#include "servers/display_server.h"
7068

69+
#ifndef _3D_DISABLED
70+
#include "editor/plugins/node_3d_editor_plugin.h"
71+
#include "scene/3d/camera_3d.h"
72+
#endif // _3D_DISABLED
73+
7174
using CameraOverride = EditorDebuggerNode::CameraOverride;
7275

7376
void ScriptEditorDebugger::_put_msg(const String &p_message, const Array &p_data, uint64_t p_thread_id) {
@@ -1048,6 +1051,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
10481051
_put_msg("scene:transform_camera_2d", msg);
10491052
}
10501053

1054+
#ifndef _3D_DISABLED
10511055
// Node3D Editor
10521056
{
10531057
Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_last_used_viewport();
@@ -1065,6 +1069,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
10651069
msg.push_back(cam->get_far());
10661070
_put_msg("scene:transform_camera_3d", msg);
10671071
}
1072+
#endif // _3D_DISABLED
10681073
}
10691074

10701075
if (is_breaked() && can_request_idle_draw) {

editor/editor_feature_profile.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
#include "scene/gui/separator.h"
4343

4444
const char *EditorFeatureProfile::feature_names[FEATURE_MAX] = {
45+
#ifndef _3D_DISABLED
4546
TTRC("3D Editor"),
47+
#endif // _3D_DISABLED
4648
TTRC("Script Editor"),
4749
TTRC("Asset Library"),
4850
TTRC("Scene Tree Editing"),
@@ -54,7 +56,9 @@ const char *EditorFeatureProfile::feature_names[FEATURE_MAX] = {
5456
};
5557

5658
const char *EditorFeatureProfile::feature_descriptions[FEATURE_MAX] = {
59+
#ifndef _3D_DISABLED
5760
TTRC("Allows to view and edit 3D scenes."),
61+
#endif // _3D_DISABLED
5862
TTRC("Allows to edit scripts using the integrated script editor."),
5963
TTRC("Provides built-in access to the Asset Library."),
6064
TTRC("Allows editing the node hierarchy in the Scene dock."),
@@ -66,7 +70,9 @@ const char *EditorFeatureProfile::feature_descriptions[FEATURE_MAX] = {
6670
};
6771

6872
const char *EditorFeatureProfile::feature_identifiers[FEATURE_MAX] = {
73+
#ifndef _3D_DISABLED
6974
"3d",
75+
#endif // _3D_DISABLED
7076
"script",
7177
"asset_lib",
7278
"scene_tree",
@@ -303,7 +309,9 @@ void EditorFeatureProfile::_bind_methods() {
303309
ClassDB::bind_method(D_METHOD("save_to_file", "path"), &EditorFeatureProfile::save_to_file);
304310
ClassDB::bind_method(D_METHOD("load_from_file", "path"), &EditorFeatureProfile::load_from_file);
305311

312+
#ifndef _3D_DISABLED
306313
BIND_ENUM_CONSTANT(FEATURE_3D);
314+
#endif // _3D_DISABLED
307315
BIND_ENUM_CONSTANT(FEATURE_SCRIPT);
308316
BIND_ENUM_CONSTANT(FEATURE_ASSET_LIB);
309317
BIND_ENUM_CONSTANT(FEATURE_SCENE_TREE);

editor/editor_feature_profile.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class EditorFeatureProfile : public RefCounted {
4444

4545
public:
4646
enum Feature {
47+
#ifndef _3D_DISABLED
4748
FEATURE_3D,
49+
#endif // _3D_DISABLED
4850
FEATURE_SCRIPT,
4951
FEATURE_ASSET_LIB,
5052
FEATURE_SCENE_TREE,

editor/editor_help_search.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#pragma once
3232

33+
#include "core/doc_data.h"
3334
#include "editor/plugins/editor_plugin.h"
3435
#include "scene/gui/dialogs.h"
3536
#include "scene/gui/option_button.h"

editor/editor_interface.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@
4848
#include "editor/gui/editor_toaster.h"
4949
#include "editor/gui/scene_tree_editor.h"
5050
#include "editor/inspector_dock.h"
51-
#include "editor/plugins/node_3d_editor_plugin.h"
5251
#include "editor/property_selector.h"
5352
#include "editor/themes/editor_scale.h"
5453
#include "main/main.h"
5554
#include "plugins/editor_preview_plugins.h"
56-
#include "scene/3d/light_3d.h"
57-
#include "scene/3d/mesh_instance_3d.h"
5855
#include "scene/gui/box_container.h"
5956
#include "scene/gui/control.h"
6057
#include "scene/main/window.h"
6158
#include "scene/resources/theme.h"
6259

60+
#ifndef _3D_DISABLED
61+
#include "editor/plugins/node_3d_editor_plugin.h"
62+
#include "scene/3d/light_3d.h"
63+
#include "scene/3d/mesh_instance_3d.h"
64+
#endif // _3D_DISABLED
65+
6366
EditorInterface *EditorInterface::singleton = nullptr;
6467

6568
void EditorInterface::restart_editor(bool p_save) {
@@ -103,6 +106,7 @@ EditorUndoRedoManager *EditorInterface::get_editor_undo_redo() const {
103106
return EditorUndoRedoManager::get_singleton();
104107
}
105108

109+
#ifndef _3D_DISABLED
106110
AABB EditorInterface::_calculate_aabb_for_scene(Node *p_node, AABB &p_scene_aabb) {
107111
MeshInstance3D *mesh_node = Object::cast_to<MeshInstance3D>(p_node);
108112
if (mesh_node && mesh_node->get_mesh().is_valid()) {
@@ -359,6 +363,7 @@ void EditorInterface::make_scene_preview(const String &p_path, Node *p_scene, in
359363
EditorResourcePreview::get_singleton()->check_for_invalidation(p_path);
360364
EditorFileSystem::get_singleton()->emit_signal(SNAME("filesystem_changed"));
361365
}
366+
#endif // _3D_DISABLED
362367

363368
void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
364369
EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
@@ -390,10 +395,12 @@ SubViewport *EditorInterface::get_editor_viewport_2d() const {
390395
return EditorNode::get_singleton()->get_scene_root();
391396
}
392397

398+
#ifndef _3D_DISABLED
393399
SubViewport *EditorInterface::get_editor_viewport_3d(int p_idx) const {
394400
ERR_FAIL_INDEX_V(p_idx, static_cast<int>(Node3DEditor::VIEWPORTS_COUNT), nullptr);
395401
return Node3DEditor::get_singleton()->get_editor_viewport(p_idx)->get_viewport_node();
396402
}
403+
#endif // _3D_DISABLED
397404

398405
void EditorInterface::set_main_screen_editor(const String &p_name) {
399406
EditorNode::get_singleton()->get_editor_main_screen()->select_by_name(p_name);
@@ -754,10 +761,12 @@ void EditorInterface::get_argument_options(const StringName &p_function, int p_i
754761
for (String E : { "\"2D\"", "\"3D\"", "\"Script\"", "\"Game\"", "\"AssetLib\"" }) {
755762
r_options->push_back(E);
756763
}
764+
#ifndef _3D_DISABLED
757765
} else if (pf == "get_editor_viewport_3d") {
758766
for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
759767
r_options->push_back(String::num_int64(i));
760768
}
769+
#endif // _3D_DISABLED
761770
}
762771
}
763772
Object::get_argument_options(p_function, p_idx, r_options);
@@ -779,7 +788,9 @@ void EditorInterface::_bind_methods() {
779788
ClassDB::bind_method(D_METHOD("get_editor_toaster"), &EditorInterface::get_editor_toaster);
780789
ClassDB::bind_method(D_METHOD("get_editor_undo_redo"), &EditorInterface::get_editor_undo_redo);
781790

791+
#ifndef _3D_DISABLED
782792
ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
793+
#endif // _3D_DISABLED
783794

784795
ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
785796
ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
@@ -791,7 +802,9 @@ void EditorInterface::_bind_methods() {
791802
ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen);
792803
ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
793804
ClassDB::bind_method(D_METHOD("get_editor_viewport_2d"), &EditorInterface::get_editor_viewport_2d);
805+
#ifndef _3D_DISABLED
794806
ClassDB::bind_method(D_METHOD("get_editor_viewport_3d", "idx"), &EditorInterface::get_editor_viewport_3d, DEFVAL(0));
807+
#endif // _3D_DISABLED
795808

796809
ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
797810
ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);

editor/editor_interface.h

+6
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ class EditorInterface : public Object {
8080

8181
// Editor tools.
8282

83+
#ifndef _3D_DISABLED
8384
TypedArray<Texture2D> _make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size);
8485
AABB _calculate_aabb_for_scene(Node *p_node, AABB &p_scene_aabb);
86+
#endif // _3D_DISABLED
8587

8688
protected:
8789
static void _bind_methods();
@@ -109,8 +111,10 @@ class EditorInterface : public Object {
109111
EditorToaster *get_editor_toaster() const;
110112
EditorUndoRedoManager *get_editor_undo_redo() const;
111113

114+
#ifndef _3D_DISABLED
112115
Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
113116
void make_scene_preview(const String &p_path, Node *p_scene, int p_preview_size);
117+
#endif // _3D_DISABLED
114118

115119
void set_plugin_enabled(const String &p_plugin, bool p_enabled);
116120
bool is_plugin_enabled(const String &p_plugin) const;
@@ -123,7 +127,9 @@ class EditorInterface : public Object {
123127
VBoxContainer *get_editor_main_screen() const;
124128
ScriptEditor *get_script_editor() const;
125129
SubViewport *get_editor_viewport_2d() const;
130+
#ifndef _3D_DISABLED
126131
SubViewport *get_editor_viewport_3d(int p_idx = 0) const;
132+
#endif // _3D_DISABLED
127133

128134
void set_main_screen_editor(const String &p_name);
129135
void set_distraction_free_mode(bool p_enter);

editor/editor_main_screen.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@
4141
void EditorMainScreen::_notification(int p_what) {
4242
switch (p_what) {
4343
case NOTIFICATION_READY: {
44+
#ifndef _3D_DISABLED
4445
if (EDITOR_3D < buttons.size() && buttons[EDITOR_3D]->is_visible()) {
4546
// If the 3D editor is enabled, use this as the default.
4647
select(EDITOR_3D);
4748
return;
4849
}
50+
#else
51+
if (buttons[EDITOR_2D]->is_visible()) {
52+
select(EDITOR_2D);
53+
return;
54+
}
55+
#endif // _3D_DISABLED
4956

5057
// Switch to the first main screen plugin that is enabled. Usually this is
5158
// 2D, but may be subsequent ones if 2D is disabled in the feature profile.

editor/editor_main_screen.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class EditorMainScreen : public PanelContainer {
4444
public:
4545
enum EditorTable {
4646
EDITOR_2D = 0,
47+
#ifndef _3D_DISABLED
4748
EDITOR_3D,
49+
#endif // _3D_DISABLED
4850
EDITOR_SCRIPT,
4951
EDITOR_GAME,
5052
EDITOR_ASSETLIB,

0 commit comments

Comments
 (0)