mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:57:58 +02:00
Resolve the comments of @ZappoMan.
This commit is contained in:
parent
a2851b5bcb
commit
0920dbc1a8
7 changed files with 92 additions and 94 deletions
|
@ -244,6 +244,8 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
|
||||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||||
|
|
||||||
static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com";
|
static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com";
|
||||||
|
static const int INTERVAL_TO_CHECK_HMD_MOUNTED_STATUS = 500; // milliseconds
|
||||||
|
static const QString OCULUS_RIFT_DISPLAY_PLUGIN_NAME = "Oculus Rift";
|
||||||
|
|
||||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
||||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||||
|
@ -1338,18 +1340,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||||
properties["using_hmd"] = isHMDMode();
|
properties["using_hmd"] = isHMDMode();
|
||||||
|
|
||||||
if (isOculusRiftPluginAvailable()) {
|
if (isHMDPluginAvailable()) {
|
||||||
// If Oculus Rift Plugin is available and current display plugin is not Oculus Rift
|
// Currently, autoswitch display mode support is only for Oculus Rift.
|
||||||
// then startOculusRiftStandBySession to listen Oculus HMD Mounted status.
|
// If HMD Plugin is available and current display plugin is not HMD plugin
|
||||||
if (getActiveDisplayPlugin()->getName() != "Oculus Rift" &&
|
// then startHMDStandBySession to listen HMD Mounted status.
|
||||||
!oculusRiftPlugin->isStandBySessionActive()) {
|
if (getActiveDisplayPlugin()->getName() != _hmdPluginName &&
|
||||||
startOculusRiftStandBySession();
|
!_hmdPlugin->isStandBySessionActive()) {
|
||||||
|
startHMDStandBySession();
|
||||||
}
|
}
|
||||||
// Poll periodically to check whether the user has worn Oculus HMD or not. And switch Display mode accordingly.
|
// Poll periodically to check whether the user has worn HMD or not. And switch Display mode accordingly.
|
||||||
// If the user wear Oculus HMD then switch to VR mode. If the user removes Oculus HMD then switch to Desktop mode.
|
// If the user wear HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.
|
||||||
QTimer *switchDisplayModeTimer = new QTimer(this);
|
QTimer *switchDisplayModeTimer = new QTimer(this);
|
||||||
connect(switchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayModeForOculus()));
|
connect(switchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayMode()));
|
||||||
switchDisplayModeTimer->start(500);
|
switchDisplayModeTimer->start(INTERVAL_TO_CHECK_HMD_MOUNTED_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glInfo = getGLContextData();
|
auto glInfo = getGLContextData();
|
||||||
|
@ -1581,8 +1584,8 @@ void Application::aboutToQuit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveDisplayPlugin()->deactivate();
|
getActiveDisplayPlugin()->deactivate();
|
||||||
if (oculusRiftPlugin && oculusRiftPlugin->isStandBySessionActive()) {
|
if (_hmdPlugin && _hmdPlugin->isStandBySessionActive()) {
|
||||||
oculusRiftPlugin->endStandBySession();
|
_hmdPlugin->endStandBySession();
|
||||||
}
|
}
|
||||||
// Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
|
// Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
|
||||||
DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
|
DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
|
||||||
|
@ -6846,54 +6849,48 @@ void Application::updateDisplayMode() {
|
||||||
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isOculusRiftPluginAvailable() {
|
bool Application::isHMDPluginAvailable() {
|
||||||
bool isOculusRiftPluginAvailable = false;
|
bool isHMDEnabledPluginAvailable = false;
|
||||||
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||||
// Default to the first item on the list, in case none of the menu items match
|
// Currently, autoswitch display mode support is only for Oculus Rift.
|
||||||
DisplayPluginPointer defaultplugin = displayPlugins.at(0);
|
|
||||||
if (defaultplugin->isHmd() && defaultplugin->getName() == "Oculus Rift") {
|
|
||||||
oculusRiftPlugin = defaultplugin;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Iterate to check If Oculus Rift Plugin is available
|
|
||||||
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
||||||
QString pluginname = displayPlugin->getName();
|
if (displayPlugin->isHmd() && displayPlugin->getName() == OCULUS_RIFT_DISPLAY_PLUGIN_NAME) {
|
||||||
if (displayPlugin->isHmd() && pluginname == "Oculus Rift") {
|
_hmdPlugin = displayPlugin;
|
||||||
oculusRiftPlugin = displayPlugin;
|
_hmdPluginName = displayPlugin->getName();
|
||||||
_oculusHMDMountedStatus = displayPlugin->isDisplayVisible();
|
_hmdMountedStatus = displayPlugin->isDisplayVisible();
|
||||||
isOculusRiftPluginAvailable = true;
|
isHMDEnabledPluginAvailable = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isOculusRiftPluginAvailable;
|
return isHMDEnabledPluginAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::switchDisplayModeForOculus() {
|
void Application::switchDisplayMode() {
|
||||||
bool currenthmdMountedStatus = oculusRiftPlugin->isDisplayVisible();
|
bool currentHMDMountedStatus = _hmdPlugin->isDisplayVisible();
|
||||||
if (currenthmdMountedStatus != _oculusHMDMountedStatus) {
|
if (currentHMDMountedStatus != _hmdMountedStatus) {
|
||||||
// Switch to respective mode as soon as currenthmdMountedStatus changes
|
// Switch to respective mode as soon as currenthmdMountedStatus changes
|
||||||
if (currenthmdMountedStatus == false && _oculusHMDMountedStatus == true) {
|
if (currentHMDMountedStatus == false && _hmdMountedStatus == true) {
|
||||||
qCDebug(interfaceapp) << "Switching from HMD to desktop mode";
|
qCDebug(interfaceapp) << "Switching from HMD to desktop mode";
|
||||||
setActiveDisplayPlugin("Desktop");
|
setActiveDisplayPlugin("Desktop");
|
||||||
startOculusRiftStandBySession();
|
startHMDStandBySession();
|
||||||
}
|
}
|
||||||
if (currenthmdMountedStatus == true && _oculusHMDMountedStatus == false) {
|
if (currentHMDMountedStatus == true && _hmdMountedStatus == false) {
|
||||||
qCDebug(interfaceapp) << "Switching from Desktop to HMD mode";
|
qCDebug(interfaceapp) << "Switching from Desktop to HMD mode";
|
||||||
endOculusRiftStandBySession();
|
endHMDStandBySession();
|
||||||
setActiveDisplayPlugin("Oculus Rift");
|
setActiveDisplayPlugin(_hmdPluginName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_oculusHMDMountedStatus = currenthmdMountedStatus;
|
_hmdMountedStatus = currentHMDMountedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::startOculusRiftStandBySession() {
|
bool Application::startHMDStandBySession() {
|
||||||
bool isStandBySessionStarted = oculusRiftPlugin->startStandBySession();
|
bool isStandBySessionStarted = _hmdPlugin->startStandBySession();
|
||||||
qCDebug(interfaceapp) << "startOculusRiftStandBySession: " << isStandBySessionStarted;
|
qCDebug(interfaceapp) << "startHMDStandBySession: " << isStandBySessionStarted;
|
||||||
return isStandBySessionStarted;
|
return isStandBySessionStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::endOculusRiftStandBySession() {
|
void Application::endHMDStandBySession() {
|
||||||
oculusRiftPlugin->endStandBySession();
|
_hmdPlugin->endStandBySession();
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4 Application::getEyeProjection(int eye) const {
|
mat4 Application::getEyeProjection(int eye) const {
|
||||||
|
|
|
@ -442,7 +442,7 @@ private slots:
|
||||||
void addAssetToWorldErrorTimeout();
|
void addAssetToWorldErrorTimeout();
|
||||||
|
|
||||||
void handleSandboxStatus(QNetworkReply* reply);
|
void handleSandboxStatus(QNetworkReply* reply);
|
||||||
void switchDisplayModeForOculus();
|
void switchDisplayMode();
|
||||||
private:
|
private:
|
||||||
static void initDisplay();
|
static void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
@ -684,11 +684,12 @@ private:
|
||||||
SharedSoundPointer _snapshotSound;
|
SharedSoundPointer _snapshotSound;
|
||||||
|
|
||||||
|
|
||||||
DisplayPluginPointer oculusRiftPlugin;
|
DisplayPluginPointer _hmdPlugin; // HMD Enabled Plugin
|
||||||
bool isOculusRiftPluginAvailable();
|
QString _hmdPluginName;
|
||||||
bool _oculusHMDMountedStatus; // Keep track of Oculus Rift HMDMounted Flag
|
bool isHMDPluginAvailable();
|
||||||
bool startOculusRiftStandBySession();
|
bool _hmdMountedStatus; // Check HMD Mounted status
|
||||||
void endOculusRiftStandBySession();
|
bool startHMDStandBySession();
|
||||||
|
void endHMDStandBySession();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue