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
82 return _showHandControllersCount > 0;82 return _showHandControllersCount > 0;
83}83}
84 84
85void HMDScriptingInterface::activateHMDHandMouse() {
86 QWriteLocker lock(&_hmdHandMouseLock);
87 auto offscreenUi = DependencyManager::get<OffscreenUi>();
88 offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", true);
89 _hmdHandMouseCount++;
90}
91
92void 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
85void HMDScriptingInterface::closeTablet() {101void HMDScriptingInterface::closeTablet() {
86 _showTablet = false;102 _showTablet = false;
87}103}
@@ -153,50 +169,6 @@ QString HMDScriptingInterface::preferredAudioOutput() const { · 65 unmodified lines
153 return qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice();169 return qApp->getActiveDisplayPlugin()->getPreferredAudioOutDevice();
154}170}
155 171
156bool 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
171bool 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
192void HMDScriptingInterface::disableExtraLaser() {
193 setExtraLaser(vec3(0), false, vec4(0), vec3(0));
194}
195
196void HMDScriptingInterface::disableHandLasers(int hands) {
197 setHandLasers(hands, false, vec4(0), vec3(0));
198}
199
200bool HMDScriptingInterface::suppressKeyboard() {172bool HMDScriptingInterface::suppressKeyboard() {
201 return qApp->getActiveDisplayPlugin()->suppressKeyboard();173 return qApp->getActiveDisplayPlugin()->suppressKeyboard();
202}174}