mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:30:42 +02:00
Merge pull request #7317 from jherico/hmd_worn
Expose a property in display plugins to determine if the device is visible to the user
This commit is contained in:
commit
ae596d79f1
10 changed files with 41 additions and 10 deletions
|
@ -92,3 +92,8 @@ glm::quat HMDScriptingInterface::getOrientation() const {
|
||||||
}
|
}
|
||||||
return glm::quat();
|
return glm::quat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HMDScriptingInterface::isMounted() const{
|
||||||
|
auto displayPlugin = qApp->getActiveDisplayPlugin();
|
||||||
|
return (displayPlugin->isHmd() && displayPlugin->isDisplayVisible());
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(glm::vec3 position READ getPosition)
|
Q_PROPERTY(glm::vec3 position READ getPosition)
|
||||||
Q_PROPERTY(glm::quat orientation READ getOrientation)
|
Q_PROPERTY(glm::quat orientation READ getOrientation)
|
||||||
|
Q_PROPERTY(bool mounted READ isMounted)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE glm::vec3 calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const;
|
Q_INVOKABLE glm::vec3 calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const;
|
||||||
|
@ -39,6 +40,7 @@ public:
|
||||||
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine);
|
||||||
static QScriptValue getHUDLookAtPosition3D(QScriptContext* context, QScriptEngine* engine);
|
static QScriptValue getHUDLookAtPosition3D(QScriptContext* context, QScriptEngine* engine);
|
||||||
|
|
||||||
|
bool isMounted() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Get the position of the HMD
|
// Get the position of the HMD
|
||||||
|
|
|
@ -29,24 +29,26 @@ protected:
|
||||||
using TextureEscrow = GLEscrow<gpu::TexturePointer>;
|
using TextureEscrow = GLEscrow<gpu::TexturePointer>;
|
||||||
public:
|
public:
|
||||||
OpenGLDisplayPlugin();
|
OpenGLDisplayPlugin();
|
||||||
virtual void activate() override;
|
void activate() override;
|
||||||
virtual void deactivate() override;
|
void deactivate() override;
|
||||||
virtual void stop() override;
|
void stop() override;
|
||||||
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||||
|
bool isDisplayVisible() const override { return true; }
|
||||||
|
|
||||||
virtual void submitSceneTexture(uint32_t frameIndex, const gpu::TexturePointer& sceneTexture) override;
|
|
||||||
virtual void submitOverlayTexture(const gpu::TexturePointer& overlayTexture) override;
|
|
||||||
virtual float presentRate() override;
|
|
||||||
|
|
||||||
virtual glm::uvec2 getRecommendedRenderSize() const override {
|
void submitSceneTexture(uint32_t frameIndex, const gpu::TexturePointer& sceneTexture) override;
|
||||||
|
void submitOverlayTexture(const gpu::TexturePointer& overlayTexture) override;
|
||||||
|
float presentRate() override;
|
||||||
|
|
||||||
|
glm::uvec2 getRecommendedRenderSize() const override {
|
||||||
return getSurfacePixels();
|
return getSurfacePixels();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual glm::uvec2 getRecommendedUiSize() const override {
|
glm::uvec2 getRecommendedUiSize() const override {
|
||||||
return getSurfaceSize();
|
return getSurfaceSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual QImage getScreenshot() const override;
|
QImage getScreenshot() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if THREADED_PRESENT
|
#if THREADED_PRESENT
|
||||||
|
|
|
@ -22,12 +22,16 @@ public:
|
||||||
glm::uvec2 getRecommendedUiSize() const override final;
|
glm::uvec2 getRecommendedUiSize() const override final;
|
||||||
glm::uvec2 getRecommendedRenderSize() const override final { return _renderTargetSize; }
|
glm::uvec2 getRecommendedRenderSize() const override final { return _renderTargetSize; }
|
||||||
void setEyeRenderPose(uint32_t frameIndex, Eye eye, const glm::mat4& pose) override final;
|
void setEyeRenderPose(uint32_t frameIndex, Eye eye, const glm::mat4& pose) override final;
|
||||||
|
bool isDisplayVisible() const override { return isHmdMounted(); }
|
||||||
|
|
||||||
|
|
||||||
void activate() override;
|
void activate() override;
|
||||||
void deactivate() override;
|
void deactivate() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void hmdPresent() = 0;
|
virtual void hmdPresent() = 0;
|
||||||
|
virtual bool isHmdMounted() const = 0;
|
||||||
|
|
||||||
void compositeOverlay() override;
|
void compositeOverlay() override;
|
||||||
void compositePointer() override;
|
void compositePointer() override;
|
||||||
void internalPresent() override;
|
void internalPresent() override;
|
||||||
|
|
|
@ -65,6 +65,12 @@ public:
|
||||||
virtual bool isThrottled() const { return false; }
|
virtual bool isThrottled() const { return false; }
|
||||||
virtual float getTargetFrameRate() { return 0.0f; }
|
virtual float getTargetFrameRate() { return 0.0f; }
|
||||||
|
|
||||||
|
/// Returns a boolean value indicating whether the display is currently visible
|
||||||
|
/// to the user. For monitor displays, false might indicate that a screensaver,
|
||||||
|
/// or power-save mode is active. For HMDs it may reflect a sensor indicating
|
||||||
|
/// whether the HMD is being worn
|
||||||
|
virtual bool isDisplayVisible() const { return false; }
|
||||||
|
|
||||||
// Rendering support
|
// Rendering support
|
||||||
|
|
||||||
// Stop requesting renders, but don't do full deactivation
|
// Stop requesting renders, but don't do full deactivation
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hmdPresent() override {}
|
void hmdPresent() override {}
|
||||||
|
bool isHmdMounted() const override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hmdPresent() override;
|
void hmdPresent() override;
|
||||||
|
// FIXME update with Oculus API call once it's available in the SDK
|
||||||
|
bool isHmdMounted() const override { return true; }
|
||||||
void customizeContext() override;
|
void customizeContext() override;
|
||||||
void uncustomizeContext() override;
|
void uncustomizeContext() override;
|
||||||
void updateFrameData() override;
|
void updateFrameData() override;
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void customizeContext() override;
|
virtual void customizeContext() override;
|
||||||
void hmdPresent() override {}
|
void hmdPresent() override {}
|
||||||
|
bool isHmdMounted() const override { return true; }
|
||||||
#if 0
|
#if 0
|
||||||
virtual void uncustomizeContext() override;
|
virtual void uncustomizeContext() override;
|
||||||
virtual void internalPresent() override;
|
virtual void internalPresent() override;
|
||||||
|
|
|
@ -154,4 +154,10 @@ void OpenVrDisplayPlugin::hmdPresent() {
|
||||||
|
|
||||||
vr::TrackedDevicePose_t currentTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
vr::TrackedDevicePose_t currentTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
|
||||||
_compositor->WaitGetPoses(currentTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, nullptr, 0);
|
_compositor->WaitGetPoses(currentTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, nullptr, 0);
|
||||||
|
_hmdActivityLevel = _system->GetTrackedDeviceActivityLevel(vr::k_unTrackedDeviceIndex_Hmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OpenVrDisplayPlugin::isHmdMounted() const {
|
||||||
|
return _hmdActivityLevel == vr::k_EDeviceActivityLevel_UserInteraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void hmdPresent() override;
|
void hmdPresent() override;
|
||||||
|
bool isHmdMounted() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vr::IVRSystem* _system { nullptr };
|
vr::IVRSystem* _system { nullptr };
|
||||||
|
std::atomic<vr::EDeviceActivityLevel> _hmdActivityLevel { vr::k_EDeviceActivityLevel_Unknown };
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
mutable Mutex _poseMutex;
|
mutable Mutex _poseMutex;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue