mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +02:00
Fix HMD.mountedChanged() API signal
This commit is contained in:
parent
b29044fd7e
commit
5e624246a8
8 changed files with 31 additions and 11 deletions
|
@ -143,6 +143,7 @@
|
||||||
#include <QmlFragmentClass.h>
|
#include <QmlFragmentClass.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <display-plugins/CompositorHelper.h>
|
#include <display-plugins/CompositorHelper.h>
|
||||||
|
#include <display-plugins/hmd/HmdDisplayPlugin.h>
|
||||||
#include <trackers/EyeTracker.h>
|
#include <trackers/EyeTracker.h>
|
||||||
#include <avatars-renderer/ScriptAvatar.h>
|
#include <avatars-renderer/ScriptAvatar.h>
|
||||||
#include <RenderableEntityItem.h>
|
#include <RenderableEntityItem.h>
|
||||||
|
@ -2717,6 +2718,10 @@ void Application::initializeDisplayPlugins() {
|
||||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
|
||||||
[this](const QSize& size) { resizeGL(); });
|
[this](const QSize& size) { resizeGL(); });
|
||||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
||||||
|
if (displayPlugin->isHmd()) {
|
||||||
|
QObject::connect(dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get()), &HmdDisplayPlugin::isHmdMountedChanged,
|
||||||
|
DependencyManager::get<HMDScriptingInterface>().data(), &HMDScriptingInterface::mountedChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default display plugin needs to be activated first, otherwise the display plugin thread
|
// The default display plugin needs to be activated first, otherwise the display plugin thread
|
||||||
|
|
|
@ -345,17 +345,6 @@ signals:
|
||||||
*/
|
*/
|
||||||
bool shouldShowHandControllersChanged();
|
bool shouldShowHandControllersChanged();
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Triggered when the <code>HMD.mounted</code> property value changes.
|
|
||||||
* @function HMD.mountedChanged
|
|
||||||
* @returns {Signal}
|
|
||||||
* @example <caption>Report when there's a change in the HMD being worn.</caption>
|
|
||||||
* HMD.mountedChanged.connect(function () {
|
|
||||||
* print("Mounted changed. HMD is mounted: " + HMD.mounted);
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
void mountedChanged();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HMDScriptingInterface();
|
HMDScriptingInterface();
|
||||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||||
|
|
|
@ -54,6 +54,17 @@ signals:
|
||||||
*/
|
*/
|
||||||
void displayModeChanged(bool isHMDMode);
|
void displayModeChanged(bool isHMDMode);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the <code>HMD.mounted</code> property value changes.
|
||||||
|
* @function HMD.mountedChanged
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report when there's a change in the HMD being worn.</caption>
|
||||||
|
* HMD.mountedChanged.connect(function () {
|
||||||
|
* print("Mounted changed. HMD is mounted: " + HMD.mounted);
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
void mountedChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _IPDScale{ 1.0 };
|
float _IPDScale{ 1.0 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "../OpenGLDisplayPlugin.h"
|
#include "../OpenGLDisplayPlugin.h"
|
||||||
|
|
||||||
class HmdDisplayPlugin : public OpenGLDisplayPlugin {
|
class HmdDisplayPlugin : public OpenGLDisplayPlugin {
|
||||||
|
Q_OBJECT
|
||||||
using Parent = OpenGLDisplayPlugin;
|
using Parent = OpenGLDisplayPlugin;
|
||||||
public:
|
public:
|
||||||
~HmdDisplayPlugin();
|
~HmdDisplayPlugin();
|
||||||
|
@ -45,6 +46,9 @@ public:
|
||||||
|
|
||||||
virtual bool onDisplayTextureReset() override { _clearPreviewFlag = true; return true; };
|
virtual bool onDisplayTextureReset() override { _clearPreviewFlag = true; return true; };
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void isHmdMountedChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void hmdPresent() = 0;
|
virtual void hmdPresent() = 0;
|
||||||
virtual bool isHmdMounted() const = 0;
|
virtual bool isHmdMounted() const = 0;
|
||||||
|
|
|
@ -36,6 +36,10 @@ bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||||
if (ovr::reorientRequested(status)) {
|
if (ovr::reorientRequested(status)) {
|
||||||
emit resetSensorsRequested();
|
emit resetSensorsRequested();
|
||||||
}
|
}
|
||||||
|
if (ovr::hmdMounted(status) != _isHmdMounted) {
|
||||||
|
_isHmdMounted = !_isHmdMounted;
|
||||||
|
emit isHmdMountedChanged();
|
||||||
|
}
|
||||||
|
|
||||||
_currentRenderFrameInfo = FrameInfo();
|
_currentRenderFrameInfo = FrameInfo();
|
||||||
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||||
|
|
|
@ -44,4 +44,5 @@ protected:
|
||||||
ovrLayerEyeFov _sceneLayer;
|
ovrLayerEyeFov _sceneLayer;
|
||||||
ovrViewScaleDesc _viewScaleDesc;
|
ovrViewScaleDesc _viewScaleDesc;
|
||||||
// ovrLayerEyeFovDepth _depthLayer;
|
// ovrLayerEyeFovDepth _depthLayer;
|
||||||
|
bool _isHmdMounted { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -699,7 +699,11 @@ void OpenVrDisplayPlugin::postPreview() {
|
||||||
_nextSimPoseData = nextSim;
|
_nextSimPoseData = nextSim;
|
||||||
});
|
});
|
||||||
_nextRenderPoseData = nextRender;
|
_nextRenderPoseData = nextRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHmdMounted() != _isHmdMounted) {
|
||||||
|
_isHmdMounted = !_isHmdMounted;
|
||||||
|
emit isHmdMountedChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,4 +90,6 @@ private:
|
||||||
friend class OpenVrSubmitThread;
|
friend class OpenVrSubmitThread;
|
||||||
|
|
||||||
bool _asyncReprojectionActive { false };
|
bool _asyncReprojectionActive { false };
|
||||||
|
|
||||||
|
bool _isHmdMounted { false };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue