Skip to content

Commit aea559b

Browse files
committed
Allow to compile the engine without XR support
1 parent cc7a951 commit aea559b

33 files changed

+77
-57
lines changed

SConstruct

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ opts.Add(BoolVariable("vulkan", "Enable the vulkan rendering driver", True))
186186
opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", True))
187187
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False))
188188
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver on supported platforms (Apple arm64 only)", False))
189-
opts.Add(BoolVariable("openxr", "Enable the OpenXR driver", True))
190189
opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loader dynamically", True))
191190
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True))
192191
opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
@@ -220,6 +219,7 @@ opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot")
220219
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "")
221220
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False))
222221
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
222+
opts.Add(BoolVariable("disable_xr", "Disable XR nodes and server", False))
223223
opts.Add("build_profile", "Path to a file containing a feature build profile", "")
224224
opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True))
225225
opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True))
@@ -995,6 +995,7 @@ if env["disable_3d"]:
995995
Exit(255)
996996
else:
997997
env.Append(CPPDEFINES=["_3D_DISABLED"])
998+
env["disable_xr"] = True
998999
if env["disable_advanced_gui"]:
9991000
if env.editor_build:
10001001
print_error(
@@ -1003,6 +1004,8 @@ if env["disable_advanced_gui"]:
10031004
Exit(255)
10041005
else:
10051006
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
1007+
if env["disable_xr"]:
1008+
env.Append(CPPDEFINES=["XR_DISABLED"])
10061009
if env["minizip"]:
10071010
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
10081011
if env["brotli"]:

editor/editor_build_profile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = {
4646
"disable_2d_physics",
4747
"disable_3d_physics",
4848
"disable_navigation",
49-
"openxr",
49+
"disable_xr",
5050
"rendering_device", // FIXME: there's no scons option to disable rendering device
5151
"opengl3",
5252
"vulkan",
@@ -82,7 +82,7 @@ const bool EditorBuildProfile::build_option_disable_values[BUILD_OPTION_MAX] = {
8282
true, // PHYSICS_2D
8383
true, // PHYSICS_3D
8484
true, // NAVIGATION
85-
false, // XR
85+
true, // XR
8686
false, // RENDERING_DEVICE
8787
false, // OPENGL
8888
false, // VULKAN

editor/gui/editor_run_bar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ EditorRunBar::EditorRunBar() {
587587
run_native->connect("native_run", callable_mp(this, &EditorRunBar::_run_native));
588588

589589
bool add_play_xr_mode_options = false;
590-
#ifndef _3D_DISABLED
590+
#ifndef XR_DISABLED
591591
if (OS::get_singleton()->has_feature("xr_editor") &&
592592
(XRServer::get_xr_mode() == XRServer::XRMODE_ON ||
593593
(XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT && GLOBAL_GET("xr/openxr/enabled")))) {
@@ -596,7 +596,7 @@ EditorRunBar::EditorRunBar() {
596596
// either regular mode or XR mode.
597597
add_play_xr_mode_options = true;
598598
}
599-
#endif // _3D_DISABLED
599+
#endif // XR_DISABLED
600600

601601
if (add_play_xr_mode_options) {
602602
MenuButton *menu_button = memnew(MenuButton);

main/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,9 @@ Error Main::test_setup() {
713713

714714
/** INITIALIZE SERVERS **/
715715
register_server_types();
716-
#ifndef _3D_DISABLED
716+
#ifndef XR_DISABLED
717717
XRServer::set_xr_mode(XRServer::XRMODE_OFF); // Skip in tests.
718-
#endif // _3D_DISABLED
718+
#endif // XR_DISABLED
719719
initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
720720
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);
721721

@@ -1734,7 +1734,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
17341734
OS::get_singleton()->disable_crash_handler();
17351735
} else if (arg == "--skip-breakpoints") {
17361736
skip_breakpoints = true;
1737-
#ifndef _3D_DISABLED
1737+
#ifndef XR_DISABLED
17381738
} else if (arg == "--xr-mode") {
17391739
if (N) {
17401740
String xr_mode = N->get().to_lower();
@@ -1753,7 +1753,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
17531753
OS::get_singleton()->print("Missing --xr-mode argument, aborting.\n");
17541754
goto error;
17551755
}
1756-
#endif // _3D_DISABLED
1756+
#endif // XR_DISABLED
17571757
} else if (arg == "--benchmark") {
17581758
OS::get_singleton()->set_use_benchmark(true);
17591759
} else if (arg == "--benchmark-file") {
@@ -3196,7 +3196,7 @@ Error Main::setup2(bool p_show_boot_logo) {
31963196
OS::get_singleton()->benchmark_end_measure("Servers", "Audio");
31973197
}
31983198

3199-
#ifndef _3D_DISABLED
3199+
#ifndef XR_DISABLED
32003200
/* Initialize XR Server */
32013201

32023202
{
@@ -3206,7 +3206,7 @@ Error Main::setup2(bool p_show_boot_logo) {
32063206

32073207
OS::get_singleton()->benchmark_end_measure("Servers", "XR");
32083208
}
3209-
#endif // _3D_DISABLED
3209+
#endif // XR_DISABLED
32103210

32113211
OS::get_singleton()->benchmark_end_measure("Startup", "Servers");
32123212

@@ -4427,9 +4427,9 @@ bool Main::iteration() {
44274427
bool exit = false;
44284428

44294429
// process all our active interfaces
4430-
#ifndef _3D_DISABLED
4430+
#ifndef XR_DISABLED
44314431
XRServer::get_singleton()->_process();
4432-
#endif // _3D_DISABLED
4432+
#endif // XR_DISABLED
44334433

44344434
NavigationServer2D::get_singleton()->sync();
44354435
NavigationServer3D::get_singleton()->sync();
@@ -4683,13 +4683,13 @@ void Main::cleanup(bool p_force) {
46834683
//clear global shader variables before scene and other graphics stuff are deinitialized.
46844684
rendering_server->global_shader_parameters_clear();
46854685

4686-
#ifndef _3D_DISABLED
4686+
#ifndef XR_DISABLED
46874687
if (xr_server) {
46884688
// Now that we're unregistering properly in plugins we need to keep access to xr_server for a little longer
46894689
// We do however unset our primary interface
46904690
xr_server->set_primary_interface(Ref<XRInterface>());
46914691
}
4692-
#endif // _3D_DISABLED
4692+
#endif // XR_DISABLED
46934693

46944694
#ifdef TOOLS_ENABLED
46954695
GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_EDITOR);

modules/mobile_vr/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def can_build(env, platform):
2-
return not env["disable_3d"]
2+
return not env["disable_xr"]
33

44

55
def configure(env):

modules/openxr/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def can_build(env, platform):
22
if platform in ("linuxbsd", "windows", "android", "macos"):
3-
return env["openxr"] and not env["disable_3d"]
3+
return not env["disable_xr"]
44
else:
5-
# not supported on these platforms
5+
# Not supported on these platforms.
66
return False
77

88

modules/openxr/scene/openxr_composition_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "../openxr_interface.h"
3636

3737
#include "scene/3d/mesh_instance_3d.h"
38-
#include "scene/3d/xr_nodes.h"
38+
#include "scene/3d/xr/xr_nodes.h"
3939
#include "scene/main/viewport.h"
4040

4141
#include "platform/android/api/java_class_wrapper.h"

modules/openxr/scene/openxr_visibility_mask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#include "../extensions/openxr_visibility_mask_extension.h"
3434
#include "../openxr_interface.h"
35-
#include "scene/3d/xr_nodes.h"
35+
#include "scene/3d/xr/xr_nodes.h"
3636

3737
void OpenXRVisibilityMask::_bind_methods() {
3838
}

modules/webxr/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def can_build(env, platform):
2-
return env["opengl3"] and not env["disable_3d"]
2+
return env["opengl3"] and not env["disable_xr"]
33

44

55
def configure(env):

platform/android/java_godot_lib_jni.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,15 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env,
272272

273273
if (step.get() == STEP_SHOW_LOGO) {
274274
bool xr_enabled = false;
275-
#ifndef _3D_DISABLED
275+
#ifndef XR_DISABLED
276276
// Unlike PCVR, there's no additional 2D screen onto which to render the boot logo,
277277
// so we skip this step if xr is enabled.
278278
if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) {
279279
xr_enabled = GLOBAL_GET("xr/shaders/enabled");
280280
} else {
281281
xr_enabled = XRServer::get_xr_mode() == XRServer::XRMODE_ON;
282282
}
283-
#endif // _3D_DISABLED
283+
#endif // XR_DISABLED
284284
if (!xr_enabled) {
285285
Main::setup_boot_logo();
286286
}

0 commit comments

Comments
 (0)