Showing the changes to interface/src/Application.cpp (1 of 66 files). Show all
Unified · Split
| @@ -253,7 +253,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 252 unmodified lines | ||
| 253 | 253 | _window->setCentralWidget(_glWidget); |
| 254 | 254 | |
| 255 | 255 | restoreSizeAndPosition(); |
| 256 | − loadScripts(); | |
| 257 | 256 | |
| 258 | 257 | QFontDatabase fontDatabase; |
| 259 | 258 | fontDatabase.addApplicationFont("resources/styles/Inconsolata.otf"); |
| @@ -283,6 +282,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 23 unmodified lines | ||
| 283 | 282 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 284 | 283 | |
| 285 | 284 | checkVersion(); |
| 285 | + | |
| 286 | + // do this as late as possible so that all required subsystems are inialized | |
| 287 | + loadScripts(); | |
| 286 | 288 | } |
| 287 | 289 | |
| 288 | 290 | Application::~Application() { |
| @@ -676,6 +678,14 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 387 unmodified lines | ||
| 676 | 678 | } |
| 677 | 679 | |
| 678 | 680 | void Application::keyPressEvent(QKeyEvent* event) { |
| 681 | + | |
| 682 | + _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts | |
| 683 | + | |
| 684 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 685 | + if (_controllerScriptingInterface.isKeyCaptured(event)) { | |
| 686 | + return; | |
| 687 | + } | |
| 688 | + | |
| 679 | 689 | if (activeWindow() == _window) { |
| 680 | 690 | if (_chatEntryOn) { |
| 681 | 691 | if (_chatEntry.keyPressEvent(event)) { |
| @@ -1087,6 +1097,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 405 unmodified lines | ||
| 1087 | 1097 | } |
| 1088 | 1098 | |
| 1089 | 1099 | void Application::keyReleaseEvent(QKeyEvent* event) { |
| 1100 | + | |
| 1101 | + _controllerScriptingInterface.emitKeyReleaseEvent(event); // send events to any registered scripts | |
| 1102 | + | |
| 1103 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1104 | + if (_controllerScriptingInterface.isKeyCaptured(event)) { | |
| 1105 | + return; | |
| 1106 | + } | |
| 1107 | + | |
| 1108 | + | |
| 1090 | 1109 | if (activeWindow() == _window) { |
| 1091 | 1110 | if (_chatEntryOn) { |
| 1092 | 1111 | _myAvatar.setKeyState(NO_KEY_DOWN); |
| @@ -1149,6 +1168,14 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 56 unmodified lines | ||
| 1149 | 1168 | } |
| 1150 | 1169 | |
| 1151 | 1170 | void Application::mouseMoveEvent(QMouseEvent* event) { |
| 1171 | + _controllerScriptingInterface.emitMouseMoveEvent(event); // send events to any registered scripts | |
| 1172 | + | |
| 1173 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1174 | + if (_controllerScriptingInterface.isMouseCaptured()) { | |
| 1175 | + return; | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + | |
| 1152 | 1179 | _lastMouseMove = usecTimestampNow(); |
| 1153 | 1180 | if (_mouseHidden) { |
| 1154 | 1181 | getGLWidget()->setCursor(Qt::ArrowCursor); |
| @@ -1195,6 +1222,14 @@ const float HOVER_VOXEL_FREQUENCY = 7040.f; · 40 unmodified lines | ||
| 1195 | 1222 | const float HOVER_VOXEL_DECAY = 0.999f; |
| 1196 | 1223 | |
| 1197 | 1224 | void Application::mousePressEvent(QMouseEvent* event) { |
| 1225 | + _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts | |
| 1226 | + | |
| 1227 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1228 | + if (_controllerScriptingInterface.isMouseCaptured()) { | |
| 1229 | + return; | |
| 1230 | + } | |
| 1231 | + | |
| 1232 | + | |
| 1198 | 1233 | if (activeWindow() == _window) { |
| 1199 | 1234 | if (event->button() == Qt::LeftButton) { |
| 1200 | 1235 | _mouseX = event->x(); |
| @@ -1262,6 +1297,13 @@ void Application::mousePressEvent(QMouseEvent* event) { · 61 unmodified lines | ||
| 1262 | 1297 | } |
| 1263 | 1298 | |
| 1264 | 1299 | void Application::mouseReleaseEvent(QMouseEvent* event) { |
| 1300 | + _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts | |
| 1301 | + | |
| 1302 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1303 | + if (_controllerScriptingInterface.isMouseCaptured()) { | |
| 1304 | + return; | |
| 1305 | + } | |
| 1306 | + | |
| 1265 | 1307 | if (activeWindow() == _window) { |
| 1266 | 1308 | if (event->button() == Qt::LeftButton) { |
| 1267 | 1309 | _mouseX = event->x(); |
| @@ -1278,6 +1320,13 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 10 unmodified lines | ||
| 1278 | 1320 | } |
| 1279 | 1321 | |
| 1280 | 1322 | void Application::touchUpdateEvent(QTouchEvent* event) { |
| 1323 | + _controllerScriptingInterface.emitTouchUpdateEvent(event); // send events to any registered scripts | |
| 1324 | + | |
| 1325 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1326 | + if (_controllerScriptingInterface.isTouchCaptured()) { | |
| 1327 | + return; | |
| 1328 | + } | |
| 1329 | + | |
| 1281 | 1330 | bool validTouch = false; |
| 1282 | 1331 | if (activeWindow() == _window) { |
| 1283 | 1332 | const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); |
| @@ -1302,19 +1351,46 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 18 unmodified lines | ||
| 1302 | 1351 | } |
| 1303 | 1352 | |
| 1304 | 1353 | void Application::touchBeginEvent(QTouchEvent* event) { |
| 1354 | + _controllerScriptingInterface.emitTouchBeginEvent(event); // send events to any registered scripts | |
| 1355 | + | |
| 1305 | 1356 | touchUpdateEvent(event); |
| 1357 | + | |
| 1358 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1359 | + if (_controllerScriptingInterface.isTouchCaptured()) { | |
| 1360 | + return; | |
| 1361 | + } | |
| 1362 | + | |
| 1363 | + // put any application specific touch behavior below here.. | |
| 1306 | 1364 | _lastTouchAvgX = _touchAvgX; |
| 1307 | 1365 | _lastTouchAvgY = _touchAvgY; |
| 1366 | + | |
| 1308 | 1367 | } |
| 1309 | 1368 | |
| 1310 | 1369 | void Application::touchEndEvent(QTouchEvent* event) { |
| 1370 | + _controllerScriptingInterface.emitTouchEndEvent(event); // send events to any registered scripts | |
| 1371 | + | |
| 1372 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1373 | + if (_controllerScriptingInterface.isTouchCaptured()) { | |
| 1374 | + return; | |
| 1375 | + } | |
| 1376 | + | |
| 1377 | + // put any application specific touch behavior below here.. | |
| 1311 | 1378 | _touchDragStartedAvgX = _touchAvgX; |
| 1312 | 1379 | _touchDragStartedAvgY = _touchAvgY; |
| 1313 | 1380 | _isTouchPressed = false; |
| 1381 | + | |
| 1314 | 1382 | } |
| 1315 | 1383 | |
| 1316 | 1384 | const bool USE_MOUSEWHEEL = false; |
| 1317 | 1385 | void Application::wheelEvent(QWheelEvent* event) { |
| 1386 | + | |
| 1387 | + _controllerScriptingInterface.emitWheelEvent(event); // send events to any registered scripts | |
| 1388 | + | |
| 1389 | + // if one of our scripts have asked to capture this event, then stop processing it | |
| 1390 | + if (_controllerScriptingInterface.isWheelCaptured()) { | |
| 1391 | + return; | |
| 1392 | + } | |
| 1393 | + | |
| 1318 | 1394 | // Wheel Events disabled for now because they are also activated by touch look pitch up/down. |
| 1319 | 1395 | if (USE_MOUSEWHEEL && (activeWindow() == _window)) { |
| 1320 | 1396 | if (!Menu::getInstance()->isVoxelModeActionChecked()) { |
| @@ -1749,6 +1825,7 @@ void Application::init() { · 428 unmodified lines | ||
| 1749 | 1825 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1750 | 1826 | _myCamera.setModeShiftRate(1.0f); |
| 1751 | 1827 | _myAvatar.setDisplayingLookatVectors(false); |
| 1828 | + _avatarManager.setMyAvatar(&_myAvatar); | |
| 1752 | 1829 | |
| 1753 | 1830 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1754 | 1831 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); |
| @@ -1795,7 +1872,7 @@ void Application::init() { · 40 unmodified lines | ||
| 1795 | 1872 | |
| 1796 | 1873 | _metavoxels.init(); |
| 1797 | 1874 | |
| 1798 | − _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_myAvatar); | |
| 1875 | + _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager); | |
| 1799 | 1876 | |
| 1800 | 1877 | _palette.init(_glWidget->width(), _glWidget->height()); |
| 1801 | 1878 | _palette.addAction(Menu::getInstance()->getActionForOption(MenuOption::VoxelAddMode), 0, 0); |
| @@ -2309,7 +2386,7 @@ void Application::update(float deltaTime) { · 507 unmodified lines | ||
| 2309 | 2386 | updateCursor(deltaTime); // Handle cursor updates |
| 2310 | 2387 | |
| 2311 | 2388 | _particles.update(); // update the particles... |
| 2312 | − _particleCollisionSystem.update(); // handle collisions for the particles... | |
| 2389 | + _particleCollisionSystem.update(); // collide the particles... | |
| 2313 | 2390 | } |
| 2314 | 2391 | |
| 2315 | 2392 | void Application::updateAvatar(float deltaTime) { |
| @@ -2322,10 +2399,7 @@ void Application::updateAvatar(float deltaTime) { · 6 unmodified lines | ||
| 2322 | 2399 | _yawFromTouch = 0.f; |
| 2323 | 2400 | |
| 2324 | 2401 | // apply pitch from touch |
| 2325 | − _myAvatar.getHead().setMousePitch(_myAvatar.getHead().getMousePitch() + | |
| 2326 | − _myAvatar.getHand().getPitchUpdate() + | |
| 2327 | − _pitchFromTouch); | |
| 2328 | − _myAvatar.getHand().setPitchUpdate(0.f); | |
| 2402 | + _myAvatar.getHead().setPitch(_myAvatar.getHead().getPitch() + _pitchFromTouch); | |
| 2329 | 2403 | _pitchFromTouch = 0.0f; |
| 2330 | 2404 | |
| 2331 | 2405 | // Update my avatar's state from gyros |