Add startup flag to override XR mode settings
This commit is contained in:
parent
eac22e3eb4
commit
1dd671014b
|
@ -343,6 +343,7 @@ void Main::print_help(const char *p_binary) {
|
|||
OS::get_singleton()->print(" --resolution <W>x<H> Request window resolution.\n");
|
||||
OS::get_singleton()->print(" --position <X>,<Y> Request window position.\n");
|
||||
OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
|
||||
OS::get_singleton()->print(" --xr-mode <mode> Select XR mode (default/off/on).\n");
|
||||
OS::get_singleton()->print("\n");
|
||||
|
||||
OS::get_singleton()->print("Debug options:\n");
|
||||
|
@ -1181,6 +1182,25 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
OS::get_singleton()->disable_crash_handler();
|
||||
} else if (I->get() == "--skip-breakpoints") {
|
||||
skip_breakpoints = true;
|
||||
} else if (I->get() == "--xr-mode") {
|
||||
if (I->next()) {
|
||||
String xr_mode = I->next()->get().to_lower();
|
||||
N = I->next()->next();
|
||||
if (xr_mode == "default") {
|
||||
XRServer::set_xr_mode(XRServer::XRMODE_DEFAULT);
|
||||
} else if (xr_mode == "off") {
|
||||
XRServer::set_xr_mode(XRServer::XRMODE_OFF);
|
||||
} else if (xr_mode == "on") {
|
||||
XRServer::set_xr_mode(XRServer::XRMODE_ON);
|
||||
} else {
|
||||
OS::get_singleton()->print("Unknown --xr-mode argument \"%s\", aborting.\n", xr_mode.ascii().get_data());
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
OS::get_singleton()->print("Missing --xr-mode argument, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
} else {
|
||||
main_args.push_back(I->get());
|
||||
}
|
||||
|
|
|
@ -58,19 +58,14 @@ bool OpenXRAPI::openxr_is_enabled(bool p_check_run_in_editor) {
|
|||
// @TODO we need an overrule switch so we can force enable openxr, i.e run "godot --openxr_enabled"
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint() && p_check_run_in_editor) {
|
||||
#ifdef TOOLS_ENABLED
|
||||
// Disabled for now, using XR inside of the editor we'll be working on during the coming months.
|
||||
return false;
|
||||
|
||||
// bool enabled = GLOBAL_GET("xr/openxr/in_editor"); // EDITOR_GET("xr/openxr/in_editor");
|
||||
// return enabled;
|
||||
#else
|
||||
// we should never get here, editor hint won't be true if the editor isn't compiled in.
|
||||
return false;
|
||||
#endif
|
||||
} else {
|
||||
bool enabled = GLOBAL_GET("xr/openxr/enabled");
|
||||
return enabled;
|
||||
if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) {
|
||||
return GLOBAL_GET("xr/openxr/enabled");
|
||||
} else {
|
||||
return XRServer::get_xr_mode() == XRServer::XRMODE_ON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "core/config/project_settings.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/print_string.h"
|
||||
#include "servers/xr_server.h"
|
||||
|
||||
RendererCompositor *(*RendererCompositor::_create_func)() = nullptr;
|
||||
bool RendererCompositor::low_end = false;
|
||||
|
@ -46,7 +47,11 @@ bool RendererCompositor::is_xr_enabled() const {
|
|||
}
|
||||
|
||||
RendererCompositor::RendererCompositor() {
|
||||
xr_enabled = GLOBAL_GET("xr/shaders/enabled");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
RendererCanvasRender *RendererCanvasRender::singleton = nullptr;
|
||||
|
|
|
@ -33,6 +33,16 @@
|
|||
#include "xr/xr_interface.h"
|
||||
#include "xr/xr_positional_tracker.h"
|
||||
|
||||
XRServer::XRMode XRServer::xr_mode = XRMODE_DEFAULT;
|
||||
|
||||
XRServer::XRMode XRServer::get_xr_mode() {
|
||||
return xr_mode;
|
||||
}
|
||||
|
||||
void XRServer::set_xr_mode(XRServer::XRMode p_mode) {
|
||||
xr_mode = p_mode;
|
||||
}
|
||||
|
||||
XRServer *XRServer::singleton = nullptr;
|
||||
|
||||
XRServer *XRServer::get_singleton() {
|
||||
|
|
|
@ -57,6 +57,12 @@ class XRServer : public Object {
|
|||
_THREAD_SAFE_CLASS_
|
||||
|
||||
public:
|
||||
enum XRMode {
|
||||
XRMODE_DEFAULT, /* Default behaviour, means we check project settings */
|
||||
XRMODE_OFF, /* Ignore project settings, disable OpenXR, disable shaders */
|
||||
XRMODE_ON, /* Ignore project settings, enable OpenXR, enable shaders, run editor in VR (if applicable) */
|
||||
};
|
||||
|
||||
enum TrackerType {
|
||||
TRACKER_HEAD = 0x01, /* tracks the position of the players head (or in case of handheld AR, location of the phone) */
|
||||
TRACKER_CONTROLLER = 0x02, /* tracks a controller */
|
||||
|
@ -75,6 +81,8 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
static XRMode xr_mode;
|
||||
|
||||
Vector<Ref<XRInterface>> interfaces;
|
||||
Dictionary trackers;
|
||||
|
||||
|
@ -90,6 +98,9 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static XRMode get_xr_mode();
|
||||
static void set_xr_mode(XRMode p_mode);
|
||||
|
||||
static XRServer *get_singleton();
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue