Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 23 files). Show all
Unified · Split
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | #include <QtScript/QScriptContext> | 14 | #include <QtScript/QScriptContext> |
| 15 | 15 | ||
| 16 | #include <shared/QtHelpers.h> | ||
| 16 | #include <avatar/AvatarManager.h> | 17 | #include <avatar/AvatarManager.h> |
| 17 | #include <display-plugins/DisplayPlugin.h> | 18 | #include <display-plugins/DisplayPlugin.h> |
| 18 | #include <display-plugins/CompositorHelper.h> | 19 | #include <display-plugins/CompositorHelper.h> |
| @@ -152,22 +153,31 @@ QString HMDScriptingInterface::preferredAudioOutput() const { · 133 unmodified lines | |||
| 152 | return qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice(); | 153 | return qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice(); |
| 153 | } | 154 | } |
| 154 | 155 | ||
| 155 | bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const { | 156 | bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) { |
| 157 | if (QThread::currentThread() != thread()) { | ||
| 158 | bool result; | ||
| 159 | hifi::qt::blockingInvokeMethod(this, "setHandLasers", Q_RETURN_ARG(bool, result), | ||
| 160 | Q_ARG(int, hands), Q_ARG(bool, enabled), Q_ARG(glm::vec4, color), Q_ARG(glm::vec3, direction)); | ||
| 161 | return result; | ||
| 162 | } | ||
| 163 | |||
| 156 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 164 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 157 | offscreenUi->executeOnUiThread([offscreenUi, enabled] { | 165 | offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); |
| 158 | offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | ||
| 159 | }); | ||
| 160 | return qApp->getActiveDisplayPlugin()->setHandLaser(hands, | 166 | return qApp->getActiveDisplayPlugin()->setHandLaser(hands, |
| 161 | enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, | 167 | enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, |
| 162 | color, direction); | 168 | color, direction); |
| 163 | } | 169 | } |
| 164 | 170 | ||
| 165 | bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) const { | 171 | bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) { |
| 166 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 172 | if (QThread::currentThread() != thread()) { |
| 167 | offscreenUi->executeOnUiThread([offscreenUi, enabled] { | 173 | bool result; |
| 168 | offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | 174 | hifi::qt::blockingInvokeMethod(this, "setExtraLaser", Q_RETURN_ARG(bool, result), |
| 169 | }); | 175 | Q_ARG(glm::vec3, worldStart), Q_ARG(bool, enabled), Q_ARG(glm::vec4, color), Q_ARG(glm::vec3, direction)); |
| 176 | return result; | ||
| 177 | } | ||
| 170 | 178 | ||
| 179 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | ||
| 180 | offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | ||
| 171 | 181 | ||
| 172 | auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 182 | auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 173 | auto sensorToWorld = myAvatar->getSensorToWorldMatrix(); | 183 | auto sensorToWorld = myAvatar->getSensorToWorldMatrix(); |
| @@ -179,11 +189,11 @@ bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enab · 5 unmodified lines | |||
| 179 | color, sensorStart, sensorDirection); | 189 | color, sensorStart, sensorDirection); |
| 180 | } | 190 | } |
| 181 | 191 | ||
| 182 | void HMDScriptingInterface::disableExtraLaser() const { | 192 | void HMDScriptingInterface::disableExtraLaser() { |
| 183 | setExtraLaser(vec3(0), false, vec4(0), vec3(0)); | 193 | setExtraLaser(vec3(0), false, vec4(0), vec3(0)); |
| 184 | } | 194 | } |
| 185 | 195 | ||
| 186 | void HMDScriptingInterface::disableHandLasers(int hands) const { | 196 | void HMDScriptingInterface::disableHandLasers(int hands) { |
| 187 | setHandLasers(hands, false, vec4(0), vec3(0)); | 197 | setHandLasers(hands, false, vec4(0), vec3(0)); |
| 188 | } | 198 | } |
| 189 | 199 | ||