mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 04:52:17 +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 <Preferences.h>
|
||||
#include <display-plugins/CompositorHelper.h>
|
||||
#include <display-plugins/hmd/HmdDisplayPlugin.h>
|
||||
#include <trackers/EyeTracker.h>
|
||||
#include <avatars-renderer/ScriptAvatar.h>
|
||||
#include <RenderableEntityItem.h>
|
||||
|
@ -2717,6 +2718,10 @@ void Application::initializeDisplayPlugins() {
|
|||
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
|
||||
[this](const QSize& size) { resizeGL(); });
|
||||
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
|
||||
|
|
|
@ -345,17 +345,6 @@ signals:
|
|||
*/
|
||||
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:
|
||||
HMDScriptingInterface();
|
||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||
|
|
|
@ -54,6 +54,17 @@ signals:
|
|||
*/
|
||||
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:
|
||||
float _IPDScale{ 1.0 };
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "../OpenGLDisplayPlugin.h"
|
||||
|
||||
class HmdDisplayPlugin : public OpenGLDisplayPlugin {
|
||||
Q_OBJECT
|
||||
using Parent = OpenGLDisplayPlugin;
|
||||
public:
|
||||
~HmdDisplayPlugin();
|
||||
|
@ -45,6 +46,9 @@ public:
|
|||
|
||||
virtual bool onDisplayTextureReset() override { _clearPreviewFlag = true; return true; };
|
||||
|
||||
signals:
|
||||
void isHmdMountedChanged();
|
||||
|
||||
protected:
|
||||
virtual void hmdPresent() = 0;
|
||||
virtual bool isHmdMounted() const = 0;
|
||||
|
|
|
@ -36,6 +36,10 @@ bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
|||
if (ovr::reorientRequested(status)) {
|
||||
emit resetSensorsRequested();
|
||||
}
|
||||
if (ovr::hmdMounted(status) != _isHmdMounted) {
|
||||
_isHmdMounted = !_isHmdMounted;
|
||||
emit isHmdMountedChanged();
|
||||
}
|
||||
|
||||
_currentRenderFrameInfo = FrameInfo();
|
||||
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||
|
|
|
@ -44,4 +44,5 @@ protected:
|
|||
ovrLayerEyeFov _sceneLayer;
|
||||
ovrViewScaleDesc _viewScaleDesc;
|
||||
// ovrLayerEyeFovDepth _depthLayer;
|
||||
bool _isHmdMounted { false };
|
||||
};
|
||||
|
|
|
@ -699,7 +699,11 @@ void OpenVrDisplayPlugin::postPreview() {
|
|||
_nextSimPoseData = nextSim;
|
||||
});
|
||||
_nextRenderPoseData = nextRender;
|
||||
}
|
||||
|
||||
if (isHmdMounted() != _isHmdMounted) {
|
||||
_isHmdMounted = !_isHmdMounted;
|
||||
emit isHmdMountedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,4 +90,6 @@ private:
|
|||
friend class OpenVrSubmitThread;
|
||||
|
||||
bool _asyncReprojectionActive { false };
|
||||
|
||||
bool _isHmdMounted { false };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue