diff --git a/SConstruct b/SConstruct index 5566770148b..9622396eb63 100644 --- a/SConstruct +++ b/SConstruct @@ -257,6 +257,7 @@ opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False)) opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot") opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "") opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False)) +opts.Add(BoolVariable("disable_xr", "Disable XR nodes for a smaller executable", False)) opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False)) opts.Add("build_profile", "Path to a file containing a feature build profile", "") opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True)) @@ -999,6 +1000,13 @@ if env["disable_3d"]: Exit(255) else: env.Append(CPPDEFINES=["_3D_DISABLED"]) + env["disable_xr"] = True +if env["disable_xr"]: + if env.editor_build: + print_error("Build option `disable_xr=yes` cannot be used for editor builds, only for export template builds.") + Exit(255) + else: + env.Append(CPPDEFINES=["_XR_DISABLED"]) if env["disable_advanced_gui"]: if env.editor_build: print_error( diff --git a/main/main.cpp b/main/main.cpp index 9014bfad294..8aa3816da53 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -612,7 +612,7 @@ void Main::print_help(const char *p_binary) { print_help_option("--position ,", "Request window position.\n"); print_help_option("--screen ", "Request window screen.\n"); print_help_option("--single-window", "Use a single window (no separate subwindows).\n"); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED print_help_option("--xr-mode ", "Select XR (Extended Reality) mode [\"default\", \"off\", \"on\"].\n"); #endif @@ -1722,7 +1722,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->disable_crash_handler(); } else if (arg == "--skip-breakpoints") { skip_breakpoints = true; -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED } else if (arg == "--xr-mode") { if (N) { String xr_mode = N->get().to_lower(); diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py index f6b64fb690b..bbacf562313 100644 --- a/modules/mobile_vr/config.py +++ b/modules/mobile_vr/config.py @@ -1,5 +1,5 @@ def can_build(env, platform): - return not env["disable_3d"] + return not env["disable_xr"] def configure(env): diff --git a/modules/openxr/config.py b/modules/openxr/config.py index 559aa2acf69..af094b4ce4b 100644 --- a/modules/openxr/config.py +++ b/modules/openxr/config.py @@ -1,6 +1,6 @@ def can_build(env, platform): if platform in ("linuxbsd", "windows", "android", "macos"): - return env["openxr"] and not env["disable_3d"] + return env["openxr"] and not env["disable_xr"] else: # not supported on these platforms return False diff --git a/modules/webxr/config.py b/modules/webxr/config.py index 8d75e7f531b..357dcde0b6c 100644 --- a/modules/webxr/config.py +++ b/modules/webxr/config.py @@ -1,5 +1,5 @@ def can_build(env, platform): - return env["opengl3"] and not env["disable_3d"] + return env["opengl3"] and not env["disable_xr"] def configure(env): diff --git a/scene/3d/SCsub b/scene/3d/SCsub index e7ba8be9b52..e587a66123e 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -7,4 +7,5 @@ env.add_source_files(env.scene_sources, "*.cpp") # Chain load SCsubs SConscript("physics/SCsub") -SConscript("xr/SCsub") +if not env["disable_xr"]: + SConscript("xr/SCsub") diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index ef46d16efe6..a3275e2c7e1 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -284,10 +284,6 @@ #include "scene/3d/visible_on_screen_notifier_3d.h" #include "scene/3d/voxel_gi.h" #include "scene/3d/world_environment.h" -#include "scene/3d/xr/xr_body_modifier_3d.h" -#include "scene/3d/xr/xr_face_modifier_3d.h" -#include "scene/3d/xr/xr_hand_modifier_3d.h" -#include "scene/3d/xr/xr_nodes.h" #include "scene/animation/root_motion_view.h" #include "scene/resources/3d/box_shape_3d.h" #include "scene/resources/3d/capsule_shape_3d.h" @@ -307,6 +303,13 @@ #include "scene/resources/3d/world_boundary_shape_3d.h" #endif // _3D_DISABLED +#ifndef _XR_DISABLED +#include "scene/3d/xr/xr_body_modifier_3d.h" +#include "scene/3d/xr/xr_face_modifier_3d.h" +#include "scene/3d/xr/xr_hand_modifier_3d.h" +#include "scene/3d/xr/xr_nodes.h" +#endif // _XR_DISABLED + static Ref resource_saver_text; static Ref resource_loader_text; @@ -544,6 +547,8 @@ void register_scene_types() { GDREGISTER_VIRTUAL_CLASS(GeometryInstance3D); GDREGISTER_CLASS(Camera3D); GDREGISTER_CLASS(AudioListener3D); + +#ifndef _XR_DISABLED GDREGISTER_CLASS(XRCamera3D); GDREGISTER_CLASS(XRNode3D); GDREGISTER_CLASS(XRController3D); @@ -552,6 +557,8 @@ void register_scene_types() { GDREGISTER_CLASS(XRBodyModifier3D); GDREGISTER_CLASS(XRHandModifier3D); GDREGISTER_CLASS(XRFaceModifier3D); +#endif // _XR_DISABLED + GDREGISTER_CLASS(MeshInstance3D); GDREGISTER_CLASS(OccluderInstance3D); GDREGISTER_ABSTRACT_CLASS(Occluder3D);