diff --git a/main/main.cpp b/main/main.cpp index 8aa3816da53..566574c6ab6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -85,9 +85,12 @@ #ifndef _3D_DISABLED #include "servers/physics_server_3d.h" #include "servers/physics_server_3d_dummy.h" -#include "servers/xr_server.h" #endif // _3D_DISABLED +#ifndef _XR_DISABLED +#include "servers/xr_server.h" +#endif // _XR_DISABLED + #ifdef TESTS_ENABLED #include "tests/test_main.h" #endif @@ -168,8 +171,10 @@ static NavigationServer3D *navigation_server_3d = nullptr; #ifndef _3D_DISABLED static PhysicsServer3DManager *physics_server_3d_manager = nullptr; static PhysicsServer3D *physics_server_3d = nullptr; -static XRServer *xr_server = nullptr; #endif // _3D_DISABLED +#ifndef _XR_DISABLED +static XRServer *xr_server = nullptr; +#endif // _XR_DISABLED // We error out if setup2() doesn't turn this true static bool _start_success = false; @@ -734,9 +739,9 @@ Error Main::test_setup() { /** INITIALIZE SERVERS **/ register_server_types(); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED XRServer::set_xr_mode(XRServer::XRMODE_OFF); // Skip in tests. -#endif // _3D_DISABLED +#endif // _XR_DISABLED initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS); GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS); @@ -1741,7 +1746,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->print("Missing --xr-mode argument, aborting.\n"); goto error; } -#endif // _3D_DISABLED +#endif // _XR_DISABLED } else if (arg == "--benchmark") { OS::get_singleton()->set_use_benchmark(true); } else if (arg == "--benchmark-file") { @@ -2573,7 +2578,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF("display/window/ios/hide_status_bar", true); GLOBAL_DEF("display/window/ios/suppress_ui_gesture", true); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED // XR project settings. GLOBAL_DEF_RST_BASIC("xr/openxr/enabled", false); GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "xr/openxr/default_action_map", PROPERTY_HINT_FILE, "*.tres"), "res://openxr_action_map.tres"); @@ -2603,7 +2608,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // EDITOR_DEF_RST("xr/openxr/in_editor", false); // GLOBAL_DEF("xr/openxr/in_editor", false); #endif // TOOLS_ENABLED -#endif // _3D_DISABLED +#endif // _XR_DISABLED Engine::get_singleton()->set_frame_delay(frame_delay); @@ -3121,7 +3126,7 @@ Error Main::setup2(bool p_show_boot_logo) { OS::get_singleton()->benchmark_end_measure("Servers", "Audio"); } -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED /* Initialize XR Server */ { @@ -3131,7 +3136,7 @@ Error Main::setup2(bool p_show_boot_logo) { OS::get_singleton()->benchmark_end_measure("Servers", "XR"); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED OS::get_singleton()->benchmark_end_measure("Startup", "Servers"); @@ -4306,9 +4311,9 @@ bool Main::iteration() { bool exit = false; // process all our active interfaces -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED XRServer::get_singleton()->_process(); -#endif // _3D_DISABLED +#endif // _XR_DISABLED NavigationServer2D::get_singleton()->sync(); NavigationServer3D::get_singleton()->sync(); @@ -4557,13 +4562,13 @@ void Main::cleanup(bool p_force) { //clear global shader variables before scene and other graphics stuff are deinitialized. rendering_server->global_shader_parameters_clear(); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (xr_server) { // Now that we're unregistering properly in plugins we need to keep access to xr_server for a little longer // We do however unset our primary interface xr_server->set_primary_interface(Ref()); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED #ifdef TOOLS_ENABLED GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_EDITOR); @@ -4593,11 +4598,11 @@ void Main::cleanup(bool p_force) { EngineDebugger::deinitialize(); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (xr_server) { memdelete(xr_server); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED if (audio_server) { audio_server->finish(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index ba69f8cc45d..b422e010cda 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -687,7 +687,7 @@ void Viewport::_process_picking() { physics_picking_events.clear(); return; } -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (use_xr) { if (XRServer::get_singleton() != nullptr) { Ref xr_interface = XRServer::get_singleton()->get_primary_interface(); @@ -698,7 +698,7 @@ void Viewport::_process_picking() { } } } -#endif +#endif // _XR_DISABLED _drop_physics_mouseover(true); @@ -1004,7 +1004,7 @@ bool Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, size_2d_override = p_size_2d_override; stretch_transform = stretch_transform_new; -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (!use_xr) { #endif @@ -1014,7 +1014,7 @@ bool Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, RS::get_singleton()->viewport_set_size(viewport, 0, 0); } -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED } // if (!use_xr) #endif @@ -1043,7 +1043,7 @@ bool Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, } Size2i Viewport::_get_size() const { -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (use_xr) { if (XRServer::get_singleton() != nullptr) { Ref xr_interface = XRServer::get_singleton()->get_primary_interface(); @@ -1054,7 +1054,7 @@ Size2i Viewport::_get_size() const { } return Size2i(); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED return size; } @@ -3645,9 +3645,11 @@ void Viewport::set_vrs_mode(Viewport::VRSMode p_vrs_mode) { case VRS_TEXTURE: { RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_TEXTURE); } break; +#ifndef _XR_DISABLED case VRS_XR: { RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_XR); } break; +#endif // _XR_DISABLED default: { RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_DISABLED); } break; @@ -4430,6 +4432,7 @@ void Viewport::_propagate_exit_world_3d(Node *p_node) { } } +#ifndef _XR_DISABLED void Viewport::set_use_xr(bool p_use_xr) { ERR_MAIN_THREAD_GUARD; if (use_xr != p_use_xr) { @@ -4456,6 +4459,7 @@ bool Viewport::is_using_xr() { ERR_READ_THREAD_GUARD_V(false); return use_xr; } +#endif // _XR_DISABLED void Viewport::set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode) { ERR_MAIN_THREAD_GUARD; @@ -4690,8 +4694,10 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_disable_3d", "disable"), &Viewport::set_disable_3d); ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled); +#ifndef _XR_DISABLED ClassDB::bind_method(D_METHOD("set_use_xr", "use"), &Viewport::set_use_xr); ClassDB::bind_method(D_METHOD("is_using_xr"), &Viewport::is_using_xr); +#endif // _XR_DISABLED ClassDB::bind_method(D_METHOD("set_scaling_3d_mode", "scaling_3d_mode"), &Viewport::set_scaling_3d_mode); ClassDB::bind_method(D_METHOD("get_scaling_3d_mode"), &Viewport::get_scaling_3d_mode); @@ -4715,7 +4721,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("get_vrs_texture"), &Viewport::get_vrs_texture); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); +#ifndef _XR_DISABLED ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr"); +#endif // _XR_DISABLED ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); #endif // _3D_DISABLED @@ -4865,7 +4873,9 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(VRS_DISABLED); BIND_ENUM_CONSTANT(VRS_TEXTURE); +#ifndef _XR_DISABLED BIND_ENUM_CONSTANT(VRS_XR); +#endif // _XR_DISABLED BIND_ENUM_CONSTANT(VRS_MAX); BIND_ENUM_CONSTANT(VRS_UPDATE_DISABLED); diff --git a/servers/SCsub b/servers/SCsub index 7abe53b9e17..47e8ddb202c 100644 --- a/servers/SCsub +++ b/servers/SCsub @@ -29,6 +29,8 @@ SConscript("text/SCsub") if not env["disable_3d"]: env.add_source_files(env.servers_sources, "physics_server_3d.cpp") env.add_source_files(env.servers_sources, "physics_server_3d_wrap_mt.cpp") + +if not env["disable_xr"]: SConscript("xr/SCsub") env.add_source_files(env.servers_sources, "xr_server.cpp") diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 18ee8630838..d2e2faee564 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -93,6 +93,9 @@ #include "physics_server_3d_dummy.h" #include "physics_server_3d_wrap_mt.h" #include "servers/extensions/physics_server_3d_extension.h" +#endif // _3D_DISABLED + +#ifndef _XR_DISABLED #include "xr/xr_body_tracker.h" #include "xr/xr_controller_tracker.h" #include "xr/xr_face_tracker.h" @@ -101,7 +104,7 @@ #include "xr/xr_interface_extension.h" #include "xr/xr_positional_tracker.h" #include "xr_server.h" -#endif // _3D_DISABLED +#endif // _XR_DISABLED ShaderTypes *shader_types = nullptr; @@ -307,7 +310,9 @@ void register_server_types() { GLOBAL_DEF(PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"), "DEFAULT"); PhysicsServer3DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_3d)); +#endif // _3D_DISABLED +#ifndef _XR_DISABLED GDREGISTER_ABSTRACT_CLASS(XRInterface); GDREGISTER_CLASS(XRVRS); GDREGISTER_CLASS(XRBodyTracker); @@ -319,7 +324,7 @@ void register_server_types() { GDREGISTER_CLASS(XRPositionalTracker); GDREGISTER_CLASS(XRServer); GDREGISTER_ABSTRACT_CLASS(XRTracker); -#endif // _3D_DISABLED +#endif // _XR_DISABLED GDREGISTER_ABSTRACT_CLASS(NavigationServer3D); GDREGISTER_CLASS(NavigationPathQueryParameters3D); @@ -359,8 +364,10 @@ void register_server_singletons() { Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton(), "PhysicsServer2D")); #ifndef _3D_DISABLED Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton(), "PhysicsServer3D")); - Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer")); #endif // _3D_DISABLED +#ifndef _XR_DISABLED + Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer")); +#endif // _XR_DISABLED OS::get_singleton()->benchmark_end_measure("Servers", "Register Singletons"); } diff --git a/servers/rendering/renderer_compositor.cpp b/servers/rendering/renderer_compositor.cpp index 428cecead1a..63d7e0148dd 100644 --- a/servers/rendering/renderer_compositor.cpp +++ b/servers/rendering/renderer_compositor.cpp @@ -31,7 +31,10 @@ #include "renderer_compositor.h" #include "core/config/project_settings.h" + +#ifndef _XR_DISABLED #include "servers/xr_server.h" +#endif // _XR_DISABLED RendererCompositor *RendererCompositor::singleton = nullptr; @@ -42,21 +45,23 @@ RendererCompositor *RendererCompositor::create() { return _create_func(); } +#ifndef _XR_DISABLED bool RendererCompositor::is_xr_enabled() const { return xr_enabled; } +#endif // _XR_DISABLED RendererCompositor::RendererCompositor() { ERR_FAIL_COND_MSG(singleton != nullptr, "A RendererCompositor singleton already exists."); singleton = this; -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) { xr_enabled = GLOBAL_GET("xr/shaders/enabled"); } else { xr_enabled = XRServer::get_xr_mode() == XRServer::XRMODE_ON; } -#endif // _3D_DISABLED +#endif // _XR_DISABLED } RendererCompositor::~RendererCompositor() { diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index 933b9e457f5..f53cff757c1 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -69,7 +69,10 @@ struct BlitToScreen { class RendererCompositor { private: +#ifndef _XR_DISABLED bool xr_enabled = false; +#endif // _XR_DISABLED + static RendererCompositor *singleton; protected: @@ -106,7 +109,9 @@ public: virtual double get_total_time() const = 0; static bool is_low_end() { return low_end; }; +#ifndef _XR_DISABLED virtual bool is_xr_enabled() const; +#endif // _XR_DISABLED static RendererCompositor *get_singleton() { return singleton; } RendererCompositor(); diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 43abb22e3d8..970c07948eb 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2758,7 +2758,9 @@ void RendererSceneCull::render_camera(const Ref &p_render_bu } camera_data.set_camera(transform, projection, is_orthogonal, vaspect, jitter, taa_frame_count, camera->visible_layers); - } else { + } +#ifndef _XR_DISABLED + else { // Setup our camera for our XR interface. // We can support multiple views here each with their own camera Transform3D transforms[RendererSceneRender::MAX_RENDER_VIEWS]; @@ -2786,6 +2788,7 @@ void RendererSceneCull::render_camera(const Ref &p_render_bu // this won't be called (see fail check above) but keeping this comment to indicate we may support more then 2 views in the future... } } +#endif // _XR_DISABLED RID environment = _render_get_environment(p_camera, p_scenario); RID compositor = _render_get_compositor(p_camera, p_scenario); diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index 972f66d325f..3e52ad39e65 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -46,9 +46,9 @@ #include "servers/rendering/rendering_server_globals.h" #include "servers/rendering/storage/utilities.h" -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED #include "servers/xr/xr_interface.h" -#endif // _3D_DISABLED +#endif // _XR_DISABLED class RenderingLightCuller; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 4d6435f48a5..a77bf3514a5 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -242,9 +242,11 @@ void RendererViewport::_draw_3d(Viewport *p_viewport) { RENDER_TIMESTAMP("> Render 3D Scene"); Ref xr_interface; +#ifndef _XR_DISABLED if (p_viewport->use_xr && XRServer::get_singleton() != nullptr) { xr_interface = XRServer::get_singleton()->get_primary_interface(); } +#endif // _XR_DISABLED if (p_viewport->use_occlusion_culling) { if (p_viewport->occlusion_buffer_dirty) { @@ -681,7 +683,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { void RendererViewport::draw_viewports(bool p_swap_buffers) { timestamp_vp_map.clear(); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED // get our xr interface in case we need it Ref xr_interface; XRServer *xr_server = XRServer::get_singleton(); @@ -692,7 +694,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { // retrieve the interface responsible for rendering xr_interface = xr_server->get_primary_interface(); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED if (Engine::get_singleton()->is_editor_hint()) { RSG::texture_storage->set_default_clear_color(GLOBAL_GET("rendering/environment/defaults/default_clear_color")); @@ -725,7 +727,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { bool visible = vp->viewport_to_screen_rect != Rect2(); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (vp->use_xr) { if (xr_interface.is_valid()) { // Ignore update mode we have to commit frames to our XR interface @@ -740,7 +742,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { vp->size = Size2(); } } else -#endif // _3D_DISABLED +#endif // _XR_DISABLED { if (vp->update_mode == RS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) { visible = true; @@ -779,7 +781,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { RENDER_TIMESTAMP("> Render Viewport " + itos(i)); RSG::texture_storage->render_target_set_as_unused(vp->render_target); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED if (vp->use_xr && xr_interface.is_valid()) { // Inform XR interface we're about to render its viewport, // if this returns false we don't render. @@ -817,7 +819,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { } } } else -#endif // _3D_DISABLED +#endif // _XR_DISABLED { RSG::scene->set_debug_draw_mode(vp->debug_draw); @@ -896,6 +898,7 @@ void RendererViewport::viewport_initialize(RID p_rid) { viewport->fsr_enabled = !RSG::rasterizer->is_low_end() && !viewport->disable_3d; } +#ifndef _XR_DISABLED void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_NULL(viewport); @@ -913,6 +916,7 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) { _configure_3d_render_buffers(viewport); } } +#endif // _XR_DISABLED void RendererViewport::viewport_set_scaling_3d_mode(RID p_viewport, RS::ViewportScaling3DMode p_mode) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); @@ -971,8 +975,9 @@ void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_heig Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_NULL(viewport); +#ifndef _XR_DISABLED ERR_FAIL_COND_MSG(viewport->use_xr, "Cannot set viewport size when using XR"); - +#endif // _XR_DISABLED _viewport_set_size(viewport, p_width, p_height, 1); } diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index bf97905f869..6b8efa207ea 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -39,9 +39,9 @@ #include "servers/rendering_server.h" #include "storage/render_scene_buffers.h" -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED #include "servers/xr/xr_interface.h" -#endif // _3D_DISABLED +#endif // _XR_DISABLED class RendererViewport { public: @@ -52,8 +52,10 @@ public: RID self; RID parent; +#ifndef _XR_DISABLED // use xr interface to override camera positioning and projection matrices and control output bool use_xr = false; +#endif // _XR_DISABLED Size2i internal_size; Size2i size; @@ -177,7 +179,9 @@ public: snap_2d_transforms_to_pixel = false; snap_2d_vertices_to_pixel = false; +#ifndef _XR_DISABLED use_xr = false; +#endif // _XR_DISABLED sdf_active = false; time_cpu_begin = 0; @@ -220,7 +224,9 @@ public: RID viewport_allocate(); void viewport_initialize(RID p_rid); +#ifndef _XR_DISABLED void viewport_set_use_xr(RID p_viewport, bool p_use_xr); +#endif // _XR_DISABLED void viewport_set_size(RID p_viewport, int p_width, int p_height); diff --git a/servers/rendering/rendering_method.h b/servers/rendering/rendering_method.h index f6212faf085..7213dc4ef16 100644 --- a/servers/rendering/rendering_method.h +++ b/servers/rendering/rendering_method.h @@ -34,13 +34,13 @@ #include "servers/rendering/storage/render_scene_buffers.h" #include "servers/rendering_server.h" -#ifdef _3D_DISABLED +#ifdef _XR_DISABLED // RendererSceneCull::render_camera is empty when 3D is disabled, but // it and RenderingMethod::render_camera have a parameter for XRInterface. #define XRInterface RefCounted #else // 3D enabled #include "servers/xr/xr_interface.h" -#endif // _3D_DISABLED +#endif // _XR_DISABLED class RenderingMethod { public: diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index b994ebf3374..b0c00ec7670 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -89,13 +89,13 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) { RSG::rasterizer->end_frame(p_swap_buffers); -#ifndef _3D_DISABLED +#ifndef _XR_DISABLED XRServer *xr_server = XRServer::get_singleton(); if (xr_server != nullptr) { // let our XR server know we're done so we can get our frame timing xr_server->end_frame(); } -#endif // _3D_DISABLED +#endif // _XR_DISABLED RSG::canvas->update_visibility_notifiers(); RSG::scene->update_visibility_notifiers(); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 2dcdc3f2543..0777812c094 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -626,7 +626,9 @@ public: FUNCRIDSPLIT(viewport) +#ifndef _XR_DISABLED FUNC2(viewport_set_use_xr, RID, bool) +#endif // _XR_DISABLED FUNC3(viewport_set_size, RID, int, int) FUNC2(viewport_set_active, RID, bool) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 879a83f5198..0e585a5fb2a 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -6052,7 +6052,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons //being sampler, this either comes from a uniform ShaderNode::Uniform *u = &shader->uniforms[varname]; ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously - +#ifndef _XR_DISABLED if (RendererCompositor::get_singleton()->is_xr_enabled() && is_custom_func) { ShaderNode::Uniform::Hint hint = u->hint; @@ -6061,6 +6061,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } } +#endif // _XR_DISABLED //propagate if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat, u->hint)) { diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 0ad56961c0c..59e04a2125e 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2781,7 +2781,9 @@ void RenderingServer::_bind_methods() { /* VIEWPORT */ ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create); +#ifndef _XR_DISABLED ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr); +#endif // _XR_DISABLED ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size); ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active); ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport); @@ -2928,7 +2930,9 @@ void RenderingServer::_bind_methods() { BIND_ENUM_CONSTANT(VIEWPORT_VRS_DISABLED); BIND_ENUM_CONSTANT(VIEWPORT_VRS_TEXTURE); +#ifndef _XR_DISABLED BIND_ENUM_CONSTANT(VIEWPORT_VRS_XR); +#endif // _XR_DISABLED BIND_ENUM_CONSTANT(VIEWPORT_VRS_MAX); BIND_ENUM_CONSTANT(VIEWPORT_VRS_UPDATE_DISABLED); @@ -3656,7 +3660,9 @@ void RenderingServer::init() { GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_renderable_lights", PROPERTY_HINT_RANGE, "2,256,1"), 32); GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/limits/opengl/max_lights_per_object", PROPERTY_HINT_RANGE, "2,1024,1"), 8); +#ifndef _XR_DISABLED GLOBAL_DEF_RST_BASIC("xr/shaders/enabled", false); +#endif // _XR_DISABLED GLOBAL_DEF("debug/shader_language/warnings/enable", true); GLOBAL_DEF("debug/shader_language/warnings/treat_warnings_as_errors", false); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 878b02eaf13..d8ca5041b34 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -893,7 +893,9 @@ public: VIEWPORT_SCALING_3D_MODE_OFF = 255, // for internal use only }; +#ifndef _XR_DISABLED virtual void viewport_set_use_xr(RID p_viewport, bool p_use_xr) = 0; +#endif // _XR_DISABLED virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0; virtual void viewport_set_active(RID p_viewport, bool p_active) = 0; virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0; @@ -1070,7 +1072,9 @@ public: enum ViewportVRSMode { VIEWPORT_VRS_DISABLED, VIEWPORT_VRS_TEXTURE, +#ifndef _XR_DISABLED VIEWPORT_VRS_XR, +#endif // _XR_DISABLED VIEWPORT_VRS_MAX, }; diff --git a/servers/xr/xr_interface.cpp b/servers/xr/xr_interface.cpp index 26f315a4542..67390d85fea 100644 --- a/servers/xr/xr_interface.cpp +++ b/servers/xr/xr_interface.cpp @@ -31,6 +31,8 @@ #include "xr_interface.h" #include "servers/rendering/renderer_compositor.h" +//#ifndef _XR_DISABLED // WORKAROUND + void XRInterface::_bind_methods() { ADD_SIGNAL(MethodInfo("play_area_changed", PropertyInfo(Variant::INT, "mode"))); @@ -211,3 +213,5 @@ Array XRInterface::get_supported_environment_blend_modes() { default_blend_modes.push_back(XR_ENV_BLEND_MODE_OPAQUE); return default_blend_modes; } + +//#endif // _XR_DISABLED diff --git a/servers/xr/xr_interface.h b/servers/xr/xr_interface.h index 55495731c55..9a96480cad7 100644 --- a/servers/xr/xr_interface.h +++ b/servers/xr/xr_interface.h @@ -31,6 +31,8 @@ #ifndef XR_INTERFACE_H #define XR_INTERFACE_H +#ifndef _XR_DISABLED // WORKAROUND + #include "core/math/projection.h" #include "core/os/thread_safe.h" #include "servers/xr_server.h" @@ -166,4 +168,6 @@ VARIANT_ENUM_CAST(XRInterface::TrackingStatus); VARIANT_ENUM_CAST(XRInterface::PlayAreaMode); VARIANT_ENUM_CAST(XRInterface::EnvironmentBlendMode); +#endif // _XR_DISABLED + #endif // XR_INTERFACE_H