mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +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);
|
||||
|
||||
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 {
|
||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||
|
@ -1338,19 +1340,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||
properties["using_hmd"] = isHMDMode();
|
||||
|
||||
if (isOculusRiftPluginAvailable()) {
|
||||
// If Oculus Rift Plugin is available and current display plugin is not Oculus Rift
|
||||
// then startOculusRiftStandBySession to listen Oculus HMD Mounted status.
|
||||
if (getActiveDisplayPlugin()->getName() != "Oculus Rift" &&
|
||||
!oculusRiftPlugin->isStandBySessionActive()) {
|
||||
startOculusRiftStandBySession();
|
||||
}
|
||||
// Poll periodically to check whether the user has worn Oculus 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.
|
||||
QTimer *switchDisplayModeTimer = new QTimer(this);
|
||||
connect(switchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayModeForOculus()));
|
||||
switchDisplayModeTimer->start(500);
|
||||
}
|
||||
if (isHMDPluginAvailable()) {
|
||||
// Currently, autoswitch display mode support is only for Oculus Rift.
|
||||
// If HMD Plugin is available and current display plugin is not HMD plugin
|
||||
// then startHMDStandBySession to listen HMD Mounted status.
|
||||
if (getActiveDisplayPlugin()->getName() != _hmdPluginName &&
|
||||
!_hmdPlugin->isStandBySessionActive()) {
|
||||
startHMDStandBySession();
|
||||
}
|
||||
// Poll periodically to check whether the user has worn HMD or not. And switch Display mode accordingly.
|
||||
// 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);
|
||||
connect(switchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayMode()));
|
||||
switchDisplayModeTimer->start(INTERVAL_TO_CHECK_HMD_MOUNTED_STATUS);
|
||||
}
|
||||
|
||||
auto glInfo = getGLContextData();
|
||||
properties["gl_info"] = glInfo;
|
||||
|
@ -1581,8 +1584,8 @@ void Application::aboutToQuit() {
|
|||
}
|
||||
|
||||
getActiveDisplayPlugin()->deactivate();
|
||||
if (oculusRiftPlugin && oculusRiftPlugin->isStandBySessionActive()) {
|
||||
oculusRiftPlugin->endStandBySession();
|
||||
if (_hmdPlugin && _hmdPlugin->isStandBySessionActive()) {
|
||||
_hmdPlugin->endStandBySession();
|
||||
}
|
||||
// Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
|
||||
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");
|
||||
}
|
||||
|
||||
bool Application::isOculusRiftPluginAvailable() {
|
||||
bool isOculusRiftPluginAvailable = false;
|
||||
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||
// Default to the first item on the list, in case none of the menu items match
|
||||
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()) {
|
||||
QString pluginname = displayPlugin->getName();
|
||||
if (displayPlugin->isHmd() && pluginname == "Oculus Rift") {
|
||||
oculusRiftPlugin = displayPlugin;
|
||||
_oculusHMDMountedStatus = displayPlugin->isDisplayVisible();
|
||||
isOculusRiftPluginAvailable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isOculusRiftPluginAvailable;
|
||||
bool Application::isHMDPluginAvailable() {
|
||||
bool isHMDEnabledPluginAvailable = false;
|
||||
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||
// Currently, autoswitch display mode support is only for Oculus Rift.
|
||||
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
||||
if (displayPlugin->isHmd() && displayPlugin->getName() == OCULUS_RIFT_DISPLAY_PLUGIN_NAME) {
|
||||
_hmdPlugin = displayPlugin;
|
||||
_hmdPluginName = displayPlugin->getName();
|
||||
_hmdMountedStatus = displayPlugin->isDisplayVisible();
|
||||
isHMDEnabledPluginAvailable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isHMDEnabledPluginAvailable;
|
||||
}
|
||||
|
||||
void Application::switchDisplayModeForOculus() {
|
||||
bool currenthmdMountedStatus = oculusRiftPlugin->isDisplayVisible();
|
||||
if (currenthmdMountedStatus != _oculusHMDMountedStatus) {
|
||||
// Switch to respective mode as soon as currenthmdMountedStatus changes
|
||||
if (currenthmdMountedStatus == false && _oculusHMDMountedStatus == true) {
|
||||
qCDebug(interfaceapp) << "Switching from HMD to desktop mode";
|
||||
setActiveDisplayPlugin("Desktop");
|
||||
startOculusRiftStandBySession();
|
||||
}
|
||||
if (currenthmdMountedStatus == true && _oculusHMDMountedStatus == false) {
|
||||
qCDebug(interfaceapp) << "Switching from Desktop to HMD mode";
|
||||
endOculusRiftStandBySession();
|
||||
setActiveDisplayPlugin("Oculus Rift");
|
||||
}
|
||||
}
|
||||
_oculusHMDMountedStatus = currenthmdMountedStatus;
|
||||
void Application::switchDisplayMode() {
|
||||
bool currentHMDMountedStatus = _hmdPlugin->isDisplayVisible();
|
||||
if (currentHMDMountedStatus != _hmdMountedStatus) {
|
||||
// Switch to respective mode as soon as currenthmdMountedStatus changes
|
||||
if (currentHMDMountedStatus == false && _hmdMountedStatus == true) {
|
||||
qCDebug(interfaceapp) << "Switching from HMD to desktop mode";
|
||||
setActiveDisplayPlugin("Desktop");
|
||||
startHMDStandBySession();
|
||||
}
|
||||
if (currentHMDMountedStatus == true && _hmdMountedStatus == false) {
|
||||
qCDebug(interfaceapp) << "Switching from Desktop to HMD mode";
|
||||
endHMDStandBySession();
|
||||
setActiveDisplayPlugin(_hmdPluginName);
|
||||
}
|
||||
}
|
||||
_hmdMountedStatus = currentHMDMountedStatus;
|
||||
}
|
||||
|
||||
bool Application::startOculusRiftStandBySession() {
|
||||
bool isStandBySessionStarted = oculusRiftPlugin->startStandBySession();
|
||||
qCDebug(interfaceapp) << "startOculusRiftStandBySession: " << isStandBySessionStarted;
|
||||
return isStandBySessionStarted;
|
||||
bool Application::startHMDStandBySession() {
|
||||
bool isStandBySessionStarted = _hmdPlugin->startStandBySession();
|
||||
qCDebug(interfaceapp) << "startHMDStandBySession: " << isStandBySessionStarted;
|
||||
return isStandBySessionStarted;
|
||||
}
|
||||
|
||||
void Application::endOculusRiftStandBySession() {
|
||||
oculusRiftPlugin->endStandBySession();
|
||||
void Application::endHMDStandBySession() {
|
||||
_hmdPlugin->endStandBySession();
|
||||
}
|
||||
|
||||
mat4 Application::getEyeProjection(int eye) const {
|
||||
|
|
|
@ -442,7 +442,7 @@ private slots:
|
|||
void addAssetToWorldErrorTimeout();
|
||||
|
||||
void handleSandboxStatus(QNetworkReply* reply);
|
||||
void switchDisplayModeForOculus();
|
||||
void switchDisplayMode();
|
||||
private:
|
||||
static void initDisplay();
|
||||
void init();
|
||||
|
@ -684,11 +684,12 @@ private:
|
|||
SharedSoundPointer _snapshotSound;
|
||||
|
||||
|
||||
DisplayPluginPointer oculusRiftPlugin;
|
||||
bool isOculusRiftPluginAvailable();
|
||||
bool _oculusHMDMountedStatus; // Keep track of Oculus Rift HMDMounted Flag
|
||||
bool startOculusRiftStandBySession();
|
||||
void endOculusRiftStandBySession();
|
||||
DisplayPluginPointer _hmdPlugin; // HMD Enabled Plugin
|
||||
QString _hmdPluginName;
|
||||
bool isHMDPluginAvailable();
|
||||
bool _hmdMountedStatus; // Check HMD Mounted status
|
||||
bool startHMDStandBySession();
|
||||
void endHMDStandBySession();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -339,15 +339,15 @@ void OpenGLDisplayPlugin::deactivate() {
|
|||
}
|
||||
|
||||
bool OpenGLDisplayPlugin::startStandBySession() {
|
||||
if (!activateStandBySession()) {
|
||||
return false;
|
||||
}
|
||||
return Parent::startStandBySession();
|
||||
if (!activateStandBySession()) {
|
||||
return false;
|
||||
}
|
||||
return Parent::startStandBySession();
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::endStandBySession() {
|
||||
deactivateStandBySession();
|
||||
return Parent::endStandBySession();
|
||||
deactivateStandBySession();
|
||||
return Parent::endStandBySession();
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::customizeContext() {
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
// between the main thread and the presentation thread
|
||||
bool activate() override final;
|
||||
void deactivate() override final;
|
||||
bool startStandBySession() override final;
|
||||
void endStandBySession() override final;
|
||||
bool startStandBySession() override final;
|
||||
void endStandBySession() override final;
|
||||
bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
bool isDisplayVisible() const override { return true; }
|
||||
|
||||
|
@ -102,9 +102,9 @@ protected:
|
|||
virtual bool internalActivate() { return true; }
|
||||
virtual void internalDeactivate() {}
|
||||
|
||||
// Returns true on successful activation of standby session
|
||||
virtual bool activateStandBySession() { return true; }
|
||||
virtual void deactivateStandBySession() {}
|
||||
// Returns true on successful activation of standby session
|
||||
virtual bool activateStandBySession() { return true; }
|
||||
virtual void deactivateStandBySession() {}
|
||||
|
||||
// Plugin specific functionality to send the composed scene to the output window or device
|
||||
virtual void internalPresent();
|
||||
|
|
|
@ -53,18 +53,18 @@ public:
|
|||
virtual bool isActive() {
|
||||
return _active;
|
||||
}
|
||||
virtual bool startStandBySession() {
|
||||
_standbysessionstatus = true;
|
||||
return _standbysessionstatus;
|
||||
}
|
||||
virtual bool startStandBySession() {
|
||||
_standbysessionstatus = true;
|
||||
return _standbysessionstatus;
|
||||
}
|
||||
|
||||
virtual void endStandBySession() {
|
||||
_standbysessionstatus = false;
|
||||
}
|
||||
virtual void endStandBySession() {
|
||||
_standbysessionstatus = false;
|
||||
}
|
||||
|
||||
virtual bool isStandBySessionActive() {
|
||||
return _standbysessionstatus;
|
||||
}
|
||||
virtual bool isStandBySessionActive() {
|
||||
return _standbysessionstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the application during it's idle phase. If the plugin needs to do
|
||||
|
@ -85,7 +85,7 @@ signals:
|
|||
|
||||
protected:
|
||||
bool _active { false };
|
||||
bool _standbysessionstatus { false };
|
||||
bool _standbysessionstatus { false };
|
||||
PluginContainer* _container { nullptr };
|
||||
static const char* UNKNOWN_PLUGIN_ID;
|
||||
|
||||
|
|
|
@ -128,15 +128,15 @@ void OculusBaseDisplayPlugin::internalDeactivate() {
|
|||
}
|
||||
|
||||
bool OculusBaseDisplayPlugin::activateStandBySession() {
|
||||
_session = acquireOculusSession();
|
||||
if (!_session) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
_session = acquireOculusSession();
|
||||
if (!_session) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void OculusBaseDisplayPlugin::deactivateStandBySession() {
|
||||
releaseOculusSession();
|
||||
_session = nullptr;
|
||||
releaseOculusSession();
|
||||
_session = nullptr;
|
||||
}
|
||||
void OculusBaseDisplayPlugin::updatePresentPose() {
|
||||
//mat4 sensorResetMat;
|
||||
|
|
|
@ -33,8 +33,8 @@ protected:
|
|||
void uncustomizeContext() override;
|
||||
bool internalActivate() override;
|
||||
void internalDeactivate() override;
|
||||
bool activateStandBySession() override;
|
||||
void deactivateStandBySession() override;
|
||||
bool activateStandBySession() override;
|
||||
void deactivateStandBySession() override;
|
||||
void updatePresentPose() override;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue