History

replace setHandLasers with drawHUDLayer overlay property

SamGondelman committed 9 years ago

Commit 3c8b9641 parent ee02a0b26 files · +275 −495Browse files

Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 26 files). Show all

Unified · Split

interface/src/scripting/HMDScriptingInterface.cpp+16−44
@@ -82,6 +82,22 @@ bool HMDScriptingInterface::shouldShowHandControllers() const { · 81 unmodified lines
8282 return _showHandControllersCount > 0;
8383 }
8484
85+void HMDScriptingInterface::activateHMDHandMouse() {
86+ QWriteLocker lock(&_hmdHandMouseLock);
87+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
88+ offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", true);
89+ _hmdHandMouseCount++;
90+}
91+
92+void HMDScriptingInterface::deactivateHMDHandMouse() {
93+ QWriteLocker lock(&_hmdHandMouseLock);
94+ _hmdHandMouseCount = std::max(--_hmdHandMouseCount, 0);
95+ if (_hmdHandMouseCount == 0) {
96+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
97+ offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", false);
98+ }
99+}
100+
85101 void HMDScriptingInterface::closeTablet() {
86102 _showTablet = false;
87103 }
@@ -153,50 +169,6 @@ QString HMDScriptingInterface::preferredAudioOutput() const { · 65 unmodified lines
153169 return qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice();
154170 }
155171
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− BLOCKING_INVOKE_METHOD(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−
164− auto offscreenUi = DependencyManager::get<OffscreenUi>();
165− offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled);
166− return qApp->getActiveDisplayPlugin()->setHandLaser(hands,
167− enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
168− color, direction);
169−}
170−
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− BLOCKING_INVOKE_METHOD(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− }
178−
179− auto offscreenUi = DependencyManager::get<OffscreenUi>();
180− offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled);
181−
182− auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
183− auto sensorToWorld = myAvatar->getSensorToWorldMatrix();
184− auto worldToSensor = glm::inverse(sensorToWorld);
185− auto sensorStart = ::transformPoint(worldToSensor, worldStart);
186− auto sensorDirection = ::transformVectorFast(worldToSensor, direction);
187−
188− return qApp->getActiveDisplayPlugin()->setExtraLaser(enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
189− color, sensorStart, sensorDirection);
190−}
191−
192−void HMDScriptingInterface::disableExtraLaser() {
193− setExtraLaser(vec3(0), false, vec4(0), vec3(0));
194−}
195−
196−void HMDScriptingInterface::disableHandLasers(int hands) {
197− setHandLasers(hands, false, vec4(0), vec3(0));
198−}
199−
200172 bool HMDScriptingInterface::suppressKeyboard() {
201173 return qApp->getActiveDisplayPlugin()->suppressKeyboard();
202174 }