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 | 14 | #include <QtScript/QScriptContext> |
| 15 | 15 | |
| 16 | +#include <shared/QtHelpers.h> | |
| 16 | 17 | #include <avatar/AvatarManager.h> |
| 17 | 18 | #include <display-plugins/DisplayPlugin.h> |
| 18 | 19 | #include <display-plugins/CompositorHelper.h> |
| @@ -152,22 +153,31 @@ QString HMDScriptingInterface::preferredAudioOutput() const { · 133 unmodified lines | ||
| 152 | 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 | 164 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 157 | − offscreenUi->executeOnUiThread([offscreenUi, enabled] { | |
| 158 | − offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | |
| 159 | − }); | |
| 165 | + offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | |
| 160 | 166 | return qApp->getActiveDisplayPlugin()->setHandLaser(hands, |
| 161 | 167 | enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None, |
| 162 | 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 { | |
| 166 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 167 | − offscreenUi->executeOnUiThread([offscreenUi, enabled] { | |
| 168 | − offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled); | |
| 169 | − }); | |
| 171 | +bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) { | |
| 172 | + if (QThread::currentThread() != thread()) { | |
| 173 | + bool result; | |
| 174 | + hifi::qt::blockingInvokeMethod(this, "setExtraLaser", Q_RETURN_ARG(bool, result), | |
| 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 | 182 | auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 173 | 183 | auto sensorToWorld = myAvatar->getSensorToWorldMatrix(); |
| @@ -179,11 +189,11 @@ bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enab · 5 unmodified lines | ||
| 179 | 189 | color, sensorStart, sensorDirection); |
| 180 | 190 | } |
| 181 | 191 | |
| 182 | −void HMDScriptingInterface::disableExtraLaser() const { | |
| 192 | +void HMDScriptingInterface::disableExtraLaser() { | |
| 183 | 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 | 197 | setHandLasers(hands, false, vec4(0), vec3(0)); |
| 188 | 198 | } |
| 189 | 199 | |