Showing the changes to interface/src/Application.cpp (1 of 238 files). Show all
Unified · Split
| @@ -89,6 +89,8 @@ · 88 unmodified lines | |||
| 89 | #include "ui/Stats.h" | 89 | #include "ui/Stats.h" |
| 90 | #include "ui/TextRenderer.h" | 90 | #include "ui/TextRenderer.h" |
| 91 | 91 | ||
| 92 | #include "devices/Leapmotion.h" | ||
| 93 | |||
| 92 | using namespace std; | 94 | using namespace std; |
| 93 | 95 | ||
| 94 | // Starfield information | 96 | // Starfield information |
| @@ -155,7 +157,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 60 unmodified lines | |||
| 155 | _mouseX(0), | 157 | _mouseX(0), |
| 156 | _mouseY(0), | 158 | _mouseY(0), |
| 157 | _lastMouseMove(usecTimestampNow()), | 159 | _lastMouseMove(usecTimestampNow()), |
| 158 | _lastMouseMoveType(QEvent::MouseMove), | 160 | _lastMouseMoveWasSimulated(false), |
| 159 | _mouseHidden(false), | 161 | _mouseHidden(false), |
| 160 | _seenMouseMove(false), | 162 | _seenMouseMove(false), |
| 161 | _touchAvgX(0.0f), | 163 | _touchAvgX(0.0f), |
| @@ -174,7 +176,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines | |||
| 174 | _runningScriptsWidget(NULL), | 176 | _runningScriptsWidget(NULL), |
| 175 | _runningScriptsWidgetWasVisible(false), | 177 | _runningScriptsWidgetWasVisible(false), |
| 176 | _trayIcon(new QSystemTrayIcon(_window)), | 178 | _trayIcon(new QSystemTrayIcon(_window)), |
| 177 | _lastNackTime(usecTimestampNow()) | 179 | _lastNackTime(usecTimestampNow()), |
| 180 | _lastSendDownstreamAudioStats(usecTimestampNow()) | ||
| 178 | { | 181 | { |
| 179 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 182 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 180 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | 183 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| @@ -356,6 +359,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 175 unmodified lines | |||
| 356 | 359 | ||
| 357 | // Set the sixense filtering | 360 | // Set the sixense filtering |
| 358 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); | 361 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 362 | |||
| 363 | // Set hand controller velocity filtering | ||
| 364 | _sixenseManager.setLowVelocityFilter(Menu::getInstance()->isOptionChecked(MenuOption::LowVelocityFilter)); | ||
| 359 | 365 | ||
| 360 | checkVersion(); | 366 | checkVersion(); |
| 361 | 367 | ||
| @@ -588,7 +594,7 @@ void Application::paintGL() { · 226 unmodified lines | |||
| 588 | 594 | ||
| 589 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | 595 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 590 | _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay | 596 | _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay |
| 591 | _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); | 597 | _myCamera.setTargetPosition(_myAvatar->getHead()->getFilteredEyePosition()); |
| 592 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); | 598 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); |
| 593 | 599 | ||
| 594 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | 600 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| @@ -603,9 +609,19 @@ void Application::paintGL() { · 8 unmodified lines | |||
| 603 | 609 | ||
| 604 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 610 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 605 | _myCamera.setTightness(0.0f); | 611 | _myCamera.setTightness(0.0f); |
| 606 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | 612 | //Only behave like a true mirror when in the OR |
| 607 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | 613 | if (OculusManager::isConnected()) { |
| 608 | _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)); | 614 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 615 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | ||
| 616 | _myCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)); | ||
| 617 | } else { | ||
| 618 | _myCamera.setTightness(0.0f); | ||
| 619 | glm::vec3 eyePosition = _myAvatar->getHead()->getFilteredEyePosition(); | ||
| 620 | float headHeight = eyePosition.y - _myAvatar->getPosition().y; | ||
| 621 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | ||
| 622 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); | ||
| 623 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | ||
| 624 | } | ||
| 609 | } | 625 | } |
| 610 | 626 | ||
| 611 | // Update camera position | 627 | // Update camera position |
| @@ -684,7 +700,7 @@ void Application::paintGL() { · 72 unmodified lines | |||
| 684 | } | 700 | } |
| 685 | 701 | ||
| 686 | { | 702 | { |
| 687 | PerformanceTimer perfTimer("paintGL/renderOverlay"); | 703 | PerformanceTimer perfTimer("renderOverlay"); |
| 688 | // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay() | 704 | // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay() |
| 689 | _applicationOverlay.renderOverlay(true); | 705 | _applicationOverlay.renderOverlay(true); |
| 690 | if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) { | 706 | if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) { |
| @@ -712,7 +728,6 @@ void Application::resizeGL(int width, int height) { · 21 unmodified lines | |||
| 712 | resetCamerasOnResizeGL(_myCamera, width, height); | 728 | resetCamerasOnResizeGL(_myCamera, width, height); |
| 713 | 729 | ||
| 714 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? | 730 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? |
| 715 | _applicationOverlay.resize(); | ||
| 716 | 731 | ||
| 717 | updateProjectionMatrix(); | 732 | updateProjectionMatrix(); |
| 718 | glLoadIdentity(); | 733 | glLoadIdentity(); |
| @@ -1128,18 +1143,19 @@ void Application::focusOutEvent(QFocusEvent* event) { · 409 unmodified lines | |||
| 1128 | _keysPressed.clear(); | 1143 | _keysPressed.clear(); |
| 1129 | } | 1144 | } |
| 1130 | 1145 | ||
| 1131 | void Application::mouseMoveEvent(QMouseEvent* event) { | 1146 | void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { |
| 1132 | 1147 | ||
| 1133 | bool showMouse = true; | 1148 | bool showMouse = true; |
| 1149 | |||
| 1150 | // Used by application overlay to determine how to draw cursor(s) | ||
| 1151 | _lastMouseMoveWasSimulated = deviceID > 0; | ||
| 1152 | |||
| 1134 | // If this mouse move event is emitted by a controller, dont show the mouse cursor | 1153 | // If this mouse move event is emitted by a controller, dont show the mouse cursor |
| 1135 | if (event->type() == CONTROLLER_MOVE_EVENT) { | 1154 | if (_lastMouseMoveWasSimulated) { |
| 1136 | showMouse = false; | 1155 | showMouse = false; |
| 1137 | } | 1156 | } |
| 1138 | 1157 | ||
| 1139 | // Used by application overlay to determine how to draw cursor(s) | 1158 | _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts |
| 1140 | _lastMouseMoveType = event->type(); | ||
| 1141 | |||
| 1142 | _controllerScriptingInterface.emitMouseMoveEvent(event); // send events to any registered scripts | ||
| 1143 | 1159 | ||
| 1144 | // if one of our scripts have asked to capture this event, then stop processing it | 1160 | // if one of our scripts have asked to capture this event, then stop processing it |
| 1145 | if (_controllerScriptingInterface.isMouseCaptured()) { | 1161 | if (_controllerScriptingInterface.isMouseCaptured()) { |
| @@ -1158,7 +1174,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 12 unmodified lines | |||
| 1158 | _mouseY = event->y(); | 1174 | _mouseY = event->y(); |
| 1159 | } | 1175 | } |
| 1160 | 1176 | ||
| 1161 | void Application::mousePressEvent(QMouseEvent* event) { | 1177 | void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { |
| 1162 | _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts | 1178 | _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts |
| 1163 | 1179 | ||
| 1164 | // if one of our scripts have asked to capture this event, then stop processing it | 1180 | // if one of our scripts have asked to capture this event, then stop processing it |
| @@ -1191,7 +1207,7 @@ void Application::mousePressEvent(QMouseEvent* event) { · 26 unmodified lines | |||
| 1191 | } | 1207 | } |
| 1192 | } | 1208 | } |
| 1193 | 1209 | ||
| 1194 | void Application::mouseReleaseEvent(QMouseEvent* event) { | 1210 | void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { |
| 1195 | _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts | 1211 | _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts |
| 1196 | 1212 | ||
| 1197 | // if one of our scripts have asked to capture this event, then stop processing it | 1213 | // if one of our scripts have asked to capture this event, then stop processing it |
| @@ -1358,18 +1374,18 @@ void Application::idle() { · 160 unmodified lines | |||
| 1358 | if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) { | 1374 | if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) { |
| 1359 | _lastTimeUpdated.start(); | 1375 | _lastTimeUpdated.start(); |
| 1360 | { | 1376 | { |
| 1361 | PerformanceTimer perfTimer("idle/update"); | 1377 | PerformanceTimer perfTimer("update"); |
| 1362 | PerformanceWarning warn(showWarnings, "Application::idle()... update()"); | 1378 | PerformanceWarning warn(showWarnings, "Application::idle()... update()"); |
| 1363 | const float BIGGEST_DELTA_TIME_SECS = 0.25f; | 1379 | const float BIGGEST_DELTA_TIME_SECS = 0.25f; |
| 1364 | update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS)); | 1380 | update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS)); |
| 1365 | } | 1381 | } |
| 1366 | { | 1382 | { |
| 1367 | PerformanceTimer perfTimer("idle/updateGL"); | 1383 | PerformanceTimer perfTimer("updateGL"); |
| 1368 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); | 1384 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1369 | _glWidget->updateGL(); | 1385 | _glWidget->updateGL(); |
| 1370 | } | 1386 | } |
| 1371 | { | 1387 | { |
| 1372 | PerformanceTimer perfTimer("idle/rest"); | 1388 | PerformanceTimer perfTimer("rest"); |
| 1373 | PerformanceWarning warn(showWarnings, "Application::idle()... rest of it"); | 1389 | PerformanceWarning warn(showWarnings, "Application::idle()... rest of it"); |
| 1374 | _idleLoopStdev.addValue(timeSinceLastUpdate); | 1390 | _idleLoopStdev.addValue(timeSinceLastUpdate); |
| 1375 | 1391 | ||
| @@ -1381,7 +1397,7 @@ void Application::idle() { · 5 unmodified lines | |||
| 1381 | } | 1397 | } |
| 1382 | 1398 | ||
| 1383 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { | 1399 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 1384 | PerformanceTimer perfTimer("idle/rest/_buckyBalls"); | 1400 | PerformanceTimer perfTimer("buckyBalls"); |
| 1385 | _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); | 1401 | _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); |
| 1386 | } | 1402 | } |
| 1387 | 1403 | ||
| @@ -1429,6 +1445,10 @@ void Application::setRenderVoxels(bool voxelRender) { · 41 unmodified lines | |||
| 1429 | } | 1445 | } |
| 1430 | } | 1446 | } |
| 1431 | 1447 | ||
| 1448 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { | ||
| 1449 | getSixenseManager()->setLowVelocityFilter(lowVelocityFilter); | ||
| 1450 | } | ||
| 1451 | |||
| 1432 | void Application::doKillLocalVoxels() { | 1452 | void Application::doKillLocalVoxels() { |
| 1433 | _wantToKillLocalVoxels = true; | 1453 | _wantToKillLocalVoxels = true; |
| 1434 | } | 1454 | } |
| @@ -1734,6 +1754,8 @@ void Application::init() { · 299 unmodified lines | |||
| 1734 | _faceplus.init(); | 1754 | _faceplus.init(); |
| 1735 | _visage.init(); | 1755 | _visage.init(); |
| 1736 | 1756 | ||
| 1757 | Leapmotion::init(); | ||
| 1758 | |||
| 1737 | // fire off an immediate domain-server check in now that settings are loaded | 1759 | // fire off an immediate domain-server check in now that settings are loaded |
| 1738 | NodeList::getInstance()->sendDomainServerCheckIn(); | 1760 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1739 | 1761 | ||
| @@ -1828,7 +1850,7 @@ bool Application::isLookingAtMyAvatar(Avatar* avatar) { · 88 unmodified lines | |||
| 1828 | } | 1850 | } |
| 1829 | 1851 | ||
| 1830 | void Application::updateLOD() { | 1852 | void Application::updateLOD() { |
| 1831 | PerformanceTimer perfTimer("idle/update/updateLOD"); | 1853 | PerformanceTimer perfTimer("LOD"); |
| 1832 | // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode | 1854 | // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode |
| 1833 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { | 1855 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { |
| 1834 | Menu::getInstance()->autoAdjustLOD(_fps); | 1856 | Menu::getInstance()->autoAdjustLOD(_fps); |
| @@ -1838,7 +1860,7 @@ void Application::updateLOD() { · 3 unmodified lines | |||
| 1838 | } | 1860 | } |
| 1839 | 1861 | ||
| 1840 | void Application::updateMouseRay() { | 1862 | void Application::updateMouseRay() { |
| 1841 | PerformanceTimer perfTimer("idle/update/updateMouseRay"); | 1863 | PerformanceTimer perfTimer("mouseRay"); |
| 1842 | 1864 | ||
| 1843 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1865 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1844 | PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); | 1866 | PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); |
| @@ -1871,8 +1893,6 @@ void Application::updateMouseRay() { · 26 unmodified lines | |||
| 1871 | } | 1893 | } |
| 1872 | 1894 | ||
| 1873 | void Application::updateFaceshift() { | 1895 | void Application::updateFaceshift() { |
| 1874 | PerformanceTimer perfTimer("idle/update/updateFaceshift"); | ||
| 1875 | |||
| 1876 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1896 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1877 | PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); | 1897 | PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); |
| 1878 | 1898 | ||
| @@ -1886,8 +1906,6 @@ void Application::updateFaceshift() { · 7 unmodified lines | |||
| 1886 | } | 1906 | } |
| 1887 | 1907 | ||
| 1888 | void Application::updateVisage() { | 1908 | void Application::updateVisage() { |
| 1889 | PerformanceTimer perfTimer("idle/update/updateVisage"); | ||
| 1890 | |||
| 1891 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1909 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1892 | PerformanceWarning warn(showWarnings, "Application::updateVisage()"); | 1910 | PerformanceWarning warn(showWarnings, "Application::updateVisage()"); |
| 1893 | 1911 | ||
| @@ -1896,11 +1914,11 @@ void Application::updateVisage() { · 2 unmodified lines | |||
| 1896 | } | 1914 | } |
| 1897 | 1915 | ||
| 1898 | void Application::updateMyAvatarLookAtPosition() { | 1916 | void Application::updateMyAvatarLookAtPosition() { |
| 1899 | PerformanceTimer perfTimer("idle/update/updateMyAvatarLookAtPosition"); | 1917 | PerformanceTimer perfTimer("lookAt"); |
| 1900 | |||
| 1901 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1918 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1902 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); | 1919 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); |
| 1903 | 1920 | ||
| 1921 | _myAvatar->updateLookAtTargetAvatar(); | ||
| 1904 | FaceTracker* tracker = getActiveFaceTracker(); | 1922 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1905 | 1923 | ||
| 1906 | bool isLookingAtSomeone = false; | 1924 | bool isLookingAtSomeone = false; |
| @@ -1928,17 +1946,9 @@ void Application::updateMyAvatarLookAtPosition() { · 21 unmodified lines | |||
| 1928 | } | 1946 | } |
| 1929 | } else { | 1947 | } else { |
| 1930 | // I am not looking at anyone else, so just look forward | 1948 | // I am not looking at anyone else, so just look forward |
| 1931 | lookAtSpot = _myAvatar->getHead()->calculateAverageEyePosition() + | 1949 | lookAtSpot = _myAvatar->getHead()->getEyePosition() + |
| 1932 | (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.f, 0.f, -TREE_SCALE)); | 1950 | (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.f, 0.f, -TREE_SCALE)); |
| 1933 | } | 1951 | } |
| 1934 | // TODO: Add saccade to mouse pointer when stable, IF not looking at someone (since we know we are looking at it) | ||
| 1935 | /* | ||
| 1936 | const float FIXED_MIN_EYE_DISTANCE = 0.3f; | ||
| 1937 | float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : | ||
| 1938 | glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition())); | ||
| 1939 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance); | ||
| 1940 | */ | ||
| 1941 | |||
| 1942 | } | 1952 | } |
| 1943 | // | 1953 | // |
| 1944 | // Deflect the eyes a bit to match the detected Gaze from 3D camera if active | 1954 | // Deflect the eyes a bit to match the detected Gaze from 3D camera if active |
| @@ -1948,7 +1958,7 @@ void Application::updateMyAvatarLookAtPosition() { · 3 unmodified lines | |||
| 1948 | float eyeYaw = tracker->getEstimatedEyeYaw(); | 1958 | float eyeYaw = tracker->getEstimatedEyeYaw(); |
| 1949 | const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f; | 1959 | const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f; |
| 1950 | // deflect using Faceshift gaze data | 1960 | // deflect using Faceshift gaze data |
| 1951 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); | 1961 | glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); |
| 1952 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; | 1962 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 1953 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); | 1963 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); |
| 1954 | if (isLookingAtSomeone) { | 1964 | if (isLookingAtSomeone) { |
| @@ -1963,7 +1973,7 @@ void Application::updateMyAvatarLookAtPosition() { · 8 unmodified lines | |||
| 1963 | } | 1973 | } |
| 1964 | 1974 | ||
| 1965 | void Application::updateThreads(float deltaTime) { | 1975 | void Application::updateThreads(float deltaTime) { |
| 1966 | PerformanceTimer perfTimer("idle/update/updateThreads"); | 1976 | PerformanceTimer perfTimer("updateThreads"); |
| 1967 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1977 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1968 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); | 1978 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| 1969 | 1979 | ||
| @@ -1978,7 +1988,7 @@ void Application::updateThreads(float deltaTime) { · 8 unmodified lines | |||
| 1978 | } | 1988 | } |
| 1979 | 1989 | ||
| 1980 | void Application::updateMetavoxels(float deltaTime) { | 1990 | void Application::updateMetavoxels(float deltaTime) { |
| 1981 | PerformanceTimer perfTimer("idle/update/updateMetavoxels"); | 1991 | PerformanceTimer perfTimer("updateMetavoxels"); |
| 1982 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1992 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1983 | PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()"); | 1993 | PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()"); |
| 1984 | 1994 | ||
| @@ -2008,7 +2018,7 @@ void Application::cameraMenuChanged() { · 23 unmodified lines | |||
| 2008 | } | 2018 | } |
| 2009 | 2019 | ||
| 2010 | void Application::updateCamera(float deltaTime) { | 2020 | void Application::updateCamera(float deltaTime) { |
| 2011 | PerformanceTimer perfTimer("idle/update/updateCamera"); | 2021 | PerformanceTimer perfTimer("updateCamera"); |
| 2012 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2022 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2013 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); | 2023 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); |
| 2014 | 2024 | ||
| @@ -2026,7 +2036,7 @@ void Application::updateCamera(float deltaTime) { · 11 unmodified lines | |||
| 2026 | } | 2036 | } |
| 2027 | 2037 | ||
| 2028 | void Application::updateDialogs(float deltaTime) { | 2038 | void Application::updateDialogs(float deltaTime) { |
| 2029 | PerformanceTimer perfTimer("idle/update/updateDialogs"); | 2039 | PerformanceTimer perfTimer("updateDialogs"); |
| 2030 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2040 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2031 | PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); | 2041 | PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); |
| 2032 | 2042 | ||
| @@ -2043,7 +2053,7 @@ void Application::updateDialogs(float deltaTime) { · 10 unmodified lines | |||
| 2043 | } | 2053 | } |
| 2044 | 2054 | ||
| 2045 | void Application::updateCursor(float deltaTime) { | 2055 | void Application::updateCursor(float deltaTime) { |
| 2046 | PerformanceTimer perfTimer("idle/update/updateCursor"); | 2056 | PerformanceTimer perfTimer("updateCursor"); |
| 2047 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2057 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2048 | PerformanceWarning warn(showWarnings, "Application::updateCursor()"); | 2058 | PerformanceWarning warn(showWarnings, "Application::updateCursor()"); |
| 2049 | 2059 | ||
| @@ -2068,84 +2078,76 @@ void Application::updateCursor(float deltaTime) { · 18 unmodified lines | |||
| 2068 | } | 2078 | } |
| 2069 | 2079 | ||
| 2070 | void Application::update(float deltaTime) { | 2080 | void Application::update(float deltaTime) { |
| 2071 | //PerformanceTimer perfTimer("idle/update"); // NOTE: we track this above in Application::idle() | ||
| 2072 | |||
| 2073 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2081 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2074 | PerformanceWarning warn(showWarnings, "Application::update()"); | 2082 | PerformanceWarning warn(showWarnings, "Application::update()"); |
| 2075 | 2083 | ||
| 2076 | updateLOD(); | 2084 | updateLOD(); |
| 2077 | updateMouseRay(); // check what's under the mouse and update the mouse voxel | 2085 | updateMouseRay(); // check what's under the mouse and update the mouse voxel |
| 2078 | updateFaceshift(); | ||
| 2079 | updateVisage(); | ||
| 2080 | |||
| 2081 | { | 2086 | { |
| 2082 | PerformanceTimer perfTimer("idle/update/updateLookAtTargetAvatar"); | 2087 | PerformanceTimer perfTimer("devices"); |
| 2083 | _myAvatar->updateLookAtTargetAvatar(); | 2088 | DeviceTracker::updateAll(); |
| 2084 | } | 2089 | updateFaceshift(); |
| 2085 | updateMyAvatarLookAtPosition(); | 2090 | updateVisage(); |
| 2086 | { | ||
| 2087 | PerformanceTimer perfTimer("idle/update/sixense,joystick,prioVR"); | ||
| 2088 | _sixenseManager.update(deltaTime); | 2091 | _sixenseManager.update(deltaTime); |
| 2089 | _joystickManager.update(); | 2092 | _joystickManager.update(); |
| 2090 | _prioVR.update(deltaTime); | 2093 | _prioVR.update(deltaTime); |
| 2094 | |||
| 2091 | } | 2095 | } |
| 2092 | |||
| 2093 | { | 2096 | { |
| 2094 | PerformanceTimer perfTimer("idle/update/updateMyAvatar"); | 2097 | PerformanceTimer perfTimer("myAvatar"); |
| 2098 | updateMyAvatarLookAtPosition(); | ||
| 2095 | updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes | 2099 | updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2096 | } | 2100 | } |
| 2097 | 2101 | ||
| 2102 | |||
| 2103 | // Dispatch input events | ||
| 2104 | _controllerScriptingInterface.updateInputControllers(); | ||
| 2105 | |||
| 2098 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 2106 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2099 | 2107 | ||
| 2100 | { | 2108 | _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| 2101 | PerformanceTimer perfTimer("idle/update/_avatarManager"); | 2109 | |
| 2102 | _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... | ||
| 2103 | } | ||
| 2104 | updateMetavoxels(deltaTime); // update metavoxels | 2110 | updateMetavoxels(deltaTime); // update metavoxels |
| 2105 | updateCamera(deltaTime); // handle various camera tweaks like off axis projection | 2111 | updateCamera(deltaTime); // handle various camera tweaks like off axis projection |
| 2106 | updateDialogs(deltaTime); // update various stats dialogs if present | 2112 | updateDialogs(deltaTime); // update various stats dialogs if present |
| 2107 | updateCursor(deltaTime); // Handle cursor updates | 2113 | updateCursor(deltaTime); // Handle cursor updates |
| 2108 | 2114 | ||
| 2109 | { | 2115 | { |
| 2110 | PerformanceTimer perfTimer("idle/update/_particles"); | 2116 | PerformanceTimer perfTimer("particles"); |
| 2111 | _particles.update(); // update the particles... | 2117 | _particles.update(); // update the particles... |
| 2112 | } | 2118 | { |
| 2113 | { | 2119 | PerformanceTimer perfTimer("collisions"); |
| 2114 | PerformanceTimer perfTimer("idle/update/_particleCollisionSystem"); | 2120 | _particleCollisionSystem.update(); // collide the particles... |
| 2115 | _particleCollisionSystem.update(); // collide the particles... | 2121 | } |
| 2116 | } | 2122 | } |
| 2117 | 2123 | ||
| 2118 | { | 2124 | { |
| 2119 | PerformanceTimer perfTimer("idle/update/_models"); | 2125 | PerformanceTimer perfTimer("models"); |
| 2120 | _models.update(); // update the models... | 2126 | _models.update(); // update the models... |
| 2121 | _modelClipboardRenderer.update(); | 2127 | _modelClipboardRenderer.update(); |
| 2122 | } | 2128 | } |
| 2123 | 2129 | ||
| 2124 | { | 2130 | { |
| 2125 | PerformanceTimer perfTimer("idle/update/_overlays"); | 2131 | PerformanceTimer perfTimer("overlays"); |
| 2126 | _overlays.update(deltaTime); | 2132 | _overlays.update(deltaTime); |
| 2127 | } | 2133 | } |
| 2128 | 2134 | ||
| 2129 | { | 2135 | { |
| 2130 | PerformanceTimer perfTimer("idle/update/emit simulating"); | 2136 | PerformanceTimer perfTimer("emitSimulating"); |
| 2131 | // let external parties know we're updating | 2137 | // let external parties know we're updating |
| 2132 | emit simulating(deltaTime); | 2138 | emit simulating(deltaTime); |
| 2133 | } | 2139 | } |
| 2134 | } | 2140 | } |
| 2135 | 2141 | ||
| 2136 | void Application::updateMyAvatar(float deltaTime) { | 2142 | void Application::updateMyAvatar(float deltaTime) { |
| 2137 | PerformanceTimer perfTimer("updateMyAvatar"); | ||
| 2138 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2143 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2139 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()"); | 2144 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()"); |
| 2140 | 2145 | ||
| 2141 | { | 2146 | _myAvatar->update(deltaTime); |
| 2142 | PerformanceTimer perfTimer("updateMyAvatar/_myAvatar->update()"); | ||
| 2143 | _myAvatar->update(deltaTime); | ||
| 2144 | } | ||
| 2145 | 2147 | ||
| 2146 | { | 2148 | { |
| 2147 | // send head/hand data to the avatar mixer and voxel server | 2149 | // send head/hand data to the avatar mixer and voxel server |
| 2148 | PerformanceTimer perfTimer("updateMyAvatar/sendToAvatarMixer"); | 2150 | PerformanceTimer perfTimer("send"); |
| 2149 | QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData); | 2151 | QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData); |
| 2150 | packet.append(_myAvatar->toByteArray()); | 2152 | packet.append(_myAvatar->toByteArray()); |
| 2151 | controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer); | 2153 | controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer); |
| @@ -2158,14 +2160,15 @@ void Application::updateMyAvatar(float deltaTime) { · 6 unmodified lines | |||
| 2158 | // actually need to calculate the view frustum planes to send these details | 2160 | // actually need to calculate the view frustum planes to send these details |
| 2159 | // to the server. | 2161 | // to the server. |
| 2160 | { | 2162 | { |
| 2161 | PerformanceTimer perfTimer("updateMyAvatar/loadViewFrustum"); | 2163 | PerformanceTimer perfTimer("loadViewFrustum"); |
| 2162 | loadViewFrustum(_myCamera, _viewFrustum); | 2164 | loadViewFrustum(_myCamera, _viewFrustum); |
| 2163 | } | 2165 | } |
| 2164 | 2166 | ||
| 2167 | quint64 now = usecTimestampNow(); | ||
| 2168 | |||
| 2165 | // Update my voxel servers with my current voxel query... | 2169 | // Update my voxel servers with my current voxel query... |
| 2166 | { | 2170 | { |
| 2167 | PerformanceTimer perfTimer("updateMyAvatar/queryOctree"); | 2171 | PerformanceTimer perfTimer("queryOctree"); |
| 2168 | quint64 now = usecTimestampNow(); | ||
| 2169 | quint64 sinceLastQuery = now - _lastQueriedTime; | 2172 | quint64 sinceLastQuery = now - _lastQueriedTime; |
| 2170 | const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; | 2173 | const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; |
| 2171 | bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; | 2174 | bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY; |
| @@ -2183,7 +2186,6 @@ void Application::updateMyAvatar(float deltaTime) { · 11 unmodified lines | |||
| 2183 | 2186 | ||
| 2184 | // sent nack packets containing missing sequence numbers of received packets from nodes | 2187 | // sent nack packets containing missing sequence numbers of received packets from nodes |
| 2185 | { | 2188 | { |
| 2186 | quint64 now = usecTimestampNow(); | ||
| 2187 | quint64 sinceLastNack = now - _lastNackTime; | 2189 | quint64 sinceLastNack = now - _lastNackTime; |
| 2188 | const quint64 TOO_LONG_SINCE_LAST_NACK = 1 * USECS_PER_SECOND; | 2190 | const quint64 TOO_LONG_SINCE_LAST_NACK = 1 * USECS_PER_SECOND; |
| 2189 | if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) { | 2191 | if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) { |
| @@ -2191,6 +2193,15 @@ void Application::updateMyAvatar(float deltaTime) { · 1 unmodified line | |||
| 2191 | sendNackPackets(); | 2193 | sendNackPackets(); |
| 2192 | } | 2194 | } |
| 2193 | } | 2195 | } |
| 2196 | |||
| 2197 | { | ||
| 2198 | quint64 sinceLastNack = now - _lastSendDownstreamAudioStats; | ||
| 2199 | if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) { | ||
| 2200 | _lastSendDownstreamAudioStats = now; | ||
| 2201 | |||
| 2202 | QMetaObject::invokeMethod(&_audio, "sendDownstreamAudioStatsPacket", Qt::QueuedConnection); | ||
| 2203 | } | ||
| 2204 | } | ||
| 2194 | } | 2205 | } |
| 2195 | 2206 | ||
| 2196 | int Application::sendNackPackets() { | 2207 | int Application::sendNackPackets() { |
| @@ -2497,7 +2508,7 @@ glm::vec3 Application::getSunDirection() { · 300 unmodified lines | |||
| 2497 | } | 2508 | } |
| 2498 | 2509 | ||
| 2499 | void Application::updateShadowMap() { | 2510 | void Application::updateShadowMap() { |
| 2500 | PerformanceTimer perfTimer("paintGL/updateShadowMap"); | 2511 | PerformanceTimer perfTimer("shadowMap"); |
| 2501 | QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject(); | 2512 | QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject(); |
| 2502 | fbo->bind(); | 2513 | fbo->bind(); |
| 2503 | glEnable(GL_DEPTH_TEST); | 2514 | glEnable(GL_DEPTH_TEST); |
| @@ -2619,7 +2630,9 @@ void Application::updateShadowMap() { · 115 unmodified lines | |||
| 2619 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); | 2630 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 2620 | } | 2631 | } |
| 2621 | 2632 | ||
| 2622 | const GLfloat WHITE_SPECULAR_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | 2633 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; |
| 2634 | const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f }; | ||
| 2635 | const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f }; | ||
| 2623 | const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f }; | 2636 | const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f }; |
| 2624 | 2637 | ||
| 2625 | void Application::setupWorldLight() { | 2638 | void Application::setupWorldLight() { |
| @@ -2631,13 +2644,10 @@ void Application::setupWorldLight() { · 5 unmodified lines | |||
| 2631 | glm::vec3 sunDirection = getSunDirection(); | 2644 | glm::vec3 sunDirection = getSunDirection(); |
| 2632 | GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 }; | 2645 | GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 }; |
| 2633 | glLightfv(GL_LIGHT0, GL_POSITION, light_position0); | 2646 | glLightfv(GL_LIGHT0, GL_POSITION, light_position0); |
| 2634 | GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f }; | 2647 | glLightfv(GL_LIGHT0, GL_AMBIENT, WORLD_AMBIENT_COLOR); |
| 2635 | glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); | 2648 | glLightfv(GL_LIGHT0, GL_DIFFUSE, WORLD_DIFFUSE_COLOR); |
| 2636 | GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f }; | 2649 | glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR); |
| 2637 | glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); | 2650 | glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR); |
| 2638 | |||
| 2639 | glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR); | ||
| 2640 | glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); | ||
| 2641 | glMateriali(GL_FRONT, GL_SHININESS, 96); | 2651 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 2642 | } | 2652 | } |
| 2643 | 2653 | ||
| @@ -2660,7 +2670,7 @@ QImage Application::renderAvatarBillboard() { · 16 unmodified lines | |||
| 2660 | } | 2670 | } |
| 2661 | 2671 | ||
| 2662 | void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { | 2672 | void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { |
| 2663 | PerformanceTimer perfTimer("paintGL/displaySide"); | 2673 | PerformanceTimer perfTimer("display"); |
| 2664 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); | 2674 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); |
| 2665 | // transform by eye offset | 2675 | // transform by eye offset |
| 2666 | 2676 | ||
| @@ -2694,7 +2704,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 27 unmodified lines | |||
| 2694 | 2704 | ||
| 2695 | // Setup 3D lights (after the camera transform, so that they are positioned in world space) | 2705 | // Setup 3D lights (after the camera transform, so that they are positioned in world space) |
| 2696 | { | 2706 | { |
| 2697 | PerformanceTimer perfTimer("paintGL/displaySide/setupWorldLight"); | 2707 | PerformanceTimer perfTimer("lights"); |
| 2698 | setupWorldLight(); | 2708 | setupWorldLight(); |
| 2699 | } | 2709 | } |
| 2700 | 2710 | ||
| @@ -2713,7 +2723,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 12 unmodified lines | |||
| 2713 | } | 2723 | } |
| 2714 | 2724 | ||
| 2715 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { | 2725 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { |
| 2716 | PerformanceTimer perfTimer("paintGL/displaySide/stars"); | 2726 | PerformanceTimer perfTimer("stars"); |
| 2717 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2727 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2718 | "Application::displaySide() ... stars..."); | 2728 | "Application::displaySide() ... stars..."); |
| 2719 | if (!_stars.isStarsLoaded()) { | 2729 | if (!_stars.isStarsLoaded()) { |
| @@ -2742,7 +2752,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 22 unmodified lines | |||
| 2742 | 2752 | ||
| 2743 | // draw the sky dome | 2753 | // draw the sky dome |
| 2744 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | 2754 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { |
| 2745 | PerformanceTimer perfTimer("paintGL/displaySide/atmosphere"); | 2755 | PerformanceTimer perfTimer("atmosphere"); |
| 2746 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2756 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2747 | "Application::displaySide() ... atmosphere..."); | 2757 | "Application::displaySide() ... atmosphere..."); |
| 2748 | _environment.renderAtmospheres(whichCamera); | 2758 | _environment.renderAtmospheres(whichCamera); |
| @@ -2763,13 +2773,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 14 unmodified lines | |||
| 2763 | 2773 | ||
| 2764 | // draw the audio reflector overlay | 2774 | // draw the audio reflector overlay |
| 2765 | { | 2775 | { |
| 2766 | PerformanceTimer perfTimer("paintGL/displaySide/audioReflector"); | 2776 | PerformanceTimer perfTimer("audio"); |
| 2767 | _audioReflector.render(); | 2777 | _audioReflector.render(); |
| 2768 | } | 2778 | } |
| 2769 | 2779 | ||
| 2770 | // Draw voxels | 2780 | // Draw voxels |
| 2771 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | 2781 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 2772 | PerformanceTimer perfTimer("paintGL/displaySide/voxels"); | 2782 | PerformanceTimer perfTimer("voxels"); |
| 2773 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2783 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2774 | "Application::displaySide() ... voxels..."); | 2784 | "Application::displaySide() ... voxels..."); |
| 2775 | _voxels.render(); | 2785 | _voxels.render(); |
| @@ -2777,14 +2787,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line | |||
| 2777 | 2787 | ||
| 2778 | // also, metavoxels | 2788 | // also, metavoxels |
| 2779 | if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) { | 2789 | if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) { |
| 2780 | PerformanceTimer perfTimer("paintGL/displaySide/metavoxels"); | 2790 | PerformanceTimer perfTimer("metavoxels"); |
| 2781 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2791 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2782 | "Application::displaySide() ... metavoxels..."); | 2792 | "Application::displaySide() ... metavoxels..."); |
| 2783 | _metavoxels.render(); | 2793 | _metavoxels.render(); |
| 2784 | } | 2794 | } |
| 2785 | 2795 | ||
| 2786 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { | 2796 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 2787 | PerformanceTimer perfTimer("paintGL/displaySide/buckyBalls"); | 2797 | PerformanceTimer perfTimer("buckyBalls"); |
| 2788 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2798 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2789 | "Application::displaySide() ... bucky balls..."); | 2799 | "Application::displaySide() ... bucky balls..."); |
| 2790 | _buckyBalls.render(); | 2800 | _buckyBalls.render(); |
| @@ -2792,7 +2802,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line | |||
| 2792 | 2802 | ||
| 2793 | // render particles... | 2803 | // render particles... |
| 2794 | if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) { | 2804 | if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) { |
| 2795 | PerformanceTimer perfTimer("paintGL/displaySide/particles"); | 2805 | PerformanceTimer perfTimer("particles"); |
| 2796 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2806 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2797 | "Application::displaySide() ... particles..."); | 2807 | "Application::displaySide() ... particles..."); |
| 2798 | _particles.render(); | 2808 | _particles.render(); |
| @@ -2800,7 +2810,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line | |||
| 2800 | 2810 | ||
| 2801 | // render models... | 2811 | // render models... |
| 2802 | if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) { | 2812 | if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) { |
| 2803 | PerformanceTimer perfTimer("paintGL/displaySide/models"); | 2813 | PerformanceTimer perfTimer("models"); |
| 2804 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2814 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2805 | "Application::displaySide() ... models..."); | 2815 | "Application::displaySide() ... models..."); |
| 2806 | _models.render(); | 2816 | _models.render(); |
| @@ -2809,14 +2819,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 2 unmodified lines | |||
| 2809 | 2819 | ||
| 2810 | // render the ambient occlusion effect if enabled | 2820 | // render the ambient occlusion effect if enabled |
| 2811 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { | 2821 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { |
| 2812 | PerformanceTimer perfTimer("paintGL/displaySide/AmbientOcclusion"); | 2822 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 2813 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2823 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2814 | "Application::displaySide() ... AmbientOcclusion..."); | 2824 | "Application::displaySide() ... AmbientOcclusion..."); |
| 2815 | _ambientOcclusionEffect.render(); | 2825 | _ambientOcclusionEffect.render(); |
| 2816 | } | 2826 | } |
| 2817 | 2827 | ||
| 2818 | // restore default, white specular | 2828 | // restore default, white specular |
| 2819 | glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR); | 2829 | glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR); |
| 2820 | 2830 | ||
| 2821 | _nodeBoundsDisplay.draw(); | 2831 | _nodeBoundsDisplay.draw(); |
| 2822 | 2832 | ||
| @@ -2824,20 +2834,27 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line | |||
| 2824 | 2834 | ||
| 2825 | bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); | 2835 | bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); |
| 2826 | { | 2836 | { |
| 2827 | PerformanceTimer perfTimer("paintGL/displaySide/renderAvatars"); | 2837 | PerformanceTimer perfTimer("avatars"); |
| 2838 | |||
| 2828 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly); | 2839 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly); |
| 2840 | |||
| 2841 | //Render the sixense lasers | ||
| 2842 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) { | ||
| 2843 | _myAvatar->renderLaserPointers(); | ||
| 2844 | } | ||
| 2829 | } | 2845 | } |
| 2830 | 2846 | ||
| 2831 | if (!selfAvatarOnly) { | 2847 | if (!selfAvatarOnly) { |
| 2832 | // Render the world box | 2848 | // Render the world box |
| 2833 | if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) && Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) { | 2849 | if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) && |
| 2834 | PerformanceTimer perfTimer("paintGL/displaySide/renderWorldBox"); | 2850 | Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) { |
| 2851 | PerformanceTimer perfTimer("worldBox"); | ||
| 2835 | renderWorldBox(); | 2852 | renderWorldBox(); |
| 2836 | } | 2853 | } |
| 2837 | 2854 | ||
| 2838 | // view frustum for debugging | 2855 | // view frustum for debugging |
| 2839 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) { | 2856 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) { |
| 2840 | PerformanceTimer perfTimer("paintGL/displaySide/ViewFrustum"); | 2857 | PerformanceTimer perfTimer("viewFrustum"); |
| 2841 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2858 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2842 | "Application::displaySide() ... renderViewFrustum..."); | 2859 | "Application::displaySide() ... renderViewFrustum..."); |
| 2843 | renderViewFrustum(_viewFrustum); | 2860 | renderViewFrustum(_viewFrustum); |
| @@ -2845,7 +2862,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line | |||
| 2845 | 2862 | ||
| 2846 | // render voxel fades if they exist | 2863 | // render voxel fades if they exist |
| 2847 | if (_voxelFades.size() > 0) { | 2864 | if (_voxelFades.size() > 0) { |
| 2848 | PerformanceTimer perfTimer("paintGL/displaySide/voxel fades"); | 2865 | PerformanceTimer perfTimer("voxelFades"); |
| 2849 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2866 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2850 | "Application::displaySide() ... voxel fades..."); | 2867 | "Application::displaySide() ... voxel fades..."); |
| 2851 | _voxelFadesLock.lockForWrite(); | 2868 | _voxelFadesLock.lockForWrite(); |
| @@ -2862,13 +2879,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 10 unmodified lines | |||
| 2862 | 2879 | ||
| 2863 | // give external parties a change to hook in | 2880 | // give external parties a change to hook in |
| 2864 | { | 2881 | { |
| 2865 | PerformanceTimer perfTimer("paintGL/displaySide/inWorldInterface"); | 2882 | PerformanceTimer perfTimer("inWorldInterface"); |
| 2866 | emit renderingInWorldInterface(); | 2883 | emit renderingInWorldInterface(); |
| 2867 | } | 2884 | } |
| 2868 | 2885 | ||
| 2869 | // render JS/scriptable overlays | 2886 | // render JS/scriptable overlays |
| 2870 | { | 2887 | { |
| 2871 | PerformanceTimer perfTimer("paintGL/displaySide/3dOverlays"); | 2888 | PerformanceTimer perfTimer("3dOverlays"); |
| 2872 | _overlays.render3D(); | 2889 | _overlays.render3D(); |
| 2873 | } | 2890 | } |
| 2874 | } | 2891 | } |
| @@ -2948,7 +2965,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 73 unmodified lines | |||
| 2948 | _mirrorCamera.setTargetPosition(glm::vec3()); | 2965 | _mirrorCamera.setTargetPosition(glm::vec3()); |
| 2949 | 2966 | ||
| 2950 | } else { | 2967 | } else { |
| 2951 | _mirrorCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); | 2968 | _mirrorCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition()); |
| 2952 | } | 2969 | } |
| 2953 | } | 2970 | } |
| 2954 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); | 2971 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); |
| @@ -2977,7 +2994,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 22 unmodified lines | |||
| 2977 | _myAvatar->getSkeletonModel().getNeckPosition(neckPosition); | 2994 | _myAvatar->getSkeletonModel().getNeckPosition(neckPosition); |
| 2978 | 2995 | ||
| 2979 | // get the eye position relative to the body | 2996 | // get the eye position relative to the body |
| 2980 | glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); | 2997 | glm::vec3 eyePosition = _myAvatar->getHead()->getEyePosition(); |
| 2981 | float eyeHeight = eyePosition.y - _myAvatar->getPosition().y; | 2998 | float eyeHeight = eyePosition.y - _myAvatar->getPosition().y; |
| 2982 | 2999 | ||
| 2983 | // set the translation of the face relative to the neck position | 3000 | // set the translation of the face relative to the neck position |
| @@ -2995,6 +3012,13 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 11 unmodified lines | |||
| 2995 | attachment->setTranslation(attachment->getTranslation() + delta); | 3012 | attachment->setTranslation(attachment->getTranslation() + delta); |
| 2996 | } | 3013 | } |
| 2997 | 3014 | ||
| 3015 | // and lo, even the shadow matrices | ||
| 3016 | glm::mat4 savedShadowMatrices[CASCADED_SHADOW_MATRIX_COUNT]; | ||
| 3017 | for (int i = 0; i < CASCADED_SHADOW_MATRIX_COUNT; i++) { | ||
| 3018 | savedShadowMatrices[i] = _shadowMatrices[i]; | ||
| 3019 | _shadowMatrices[i] = glm::transpose(glm::transpose(_shadowMatrices[i]) * glm::translate(-delta)); | ||
| 3020 | } | ||
| 3021 | |||
| 2998 | displaySide(_mirrorCamera, true); | 3022 | displaySide(_mirrorCamera, true); |
| 2999 | 3023 | ||
| 3000 | // restore absolute translations | 3024 | // restore absolute translations |
| @@ -3003,6 +3027,11 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 2 unmodified lines | |||
| 3003 | for (int i = 0; i < absoluteAttachmentTranslations.size(); i++) { | 3027 | for (int i = 0; i < absoluteAttachmentTranslations.size(); i++) { |
| 3004 | _myAvatar->getAttachmentModels().at(i)->setTranslation(absoluteAttachmentTranslations.at(i)); | 3028 | _myAvatar->getAttachmentModels().at(i)->setTranslation(absoluteAttachmentTranslations.at(i)); |
| 3005 | } | 3029 | } |
| 3030 | |||
| 3031 | // restore the shadow matrices | ||
| 3032 | for (int i = 0; i < CASCADED_SHADOW_MATRIX_COUNT; i++) { | ||
| 3033 | _shadowMatrices[i] = savedShadowMatrices[i]; | ||
| 3034 | } | ||
| 3006 | } else { | 3035 | } else { |
| 3007 | displaySide(_mirrorCamera, true); | 3036 | displaySide(_mirrorCamera, true); |
| 3008 | } | 3037 | } |
| @@ -3205,6 +3234,7 @@ void Application::resetSensors() { · 196 unmodified lines | |||
| 3205 | OculusManager::reset(); | 3234 | OculusManager::reset(); |
| 3206 | 3235 | ||
| 3207 | _prioVR.reset(); | 3236 | _prioVR.reset(); |
| 3237 | //_leapmotion.reset(); | ||
| 3208 | 3238 | ||
| 3209 | QCursor::setPos(_mouseX, _mouseY); | 3239 | QCursor::setPos(_mouseX, _mouseY); |
| 3210 | _myAvatar->reset(); | 3240 | _myAvatar->reset(); |
| @@ -3355,7 +3385,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 144 unmodified lines | |||
| 3355 | _modelEditSender.nodeKilled(node); | 3385 | _modelEditSender.nodeKilled(node); |
| 3356 | 3386 | ||
| 3357 | if (node->getType() == NodeType::AudioMixer) { | 3387 | if (node->getType() == NodeType::AudioMixer) { |
| 3358 | QMetaObject::invokeMethod(&_audio, "resetIncomingMixedAudioSequenceNumberStats"); | 3388 | QMetaObject::invokeMethod(&_audio, "audioMixerKilled"); |
| 3359 | } | 3389 | } |
| 3360 | 3390 | ||
| 3361 | if (node->getType() == NodeType::VoxelServer) { | 3391 | if (node->getType() == NodeType::VoxelServer) { |
| @@ -3640,6 +3670,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 278 unmodified lines | |||
| 3640 | scriptEngine->getModelsScriptingInterface()->setPacketSender(&_modelEditSender); | 3670 | scriptEngine->getModelsScriptingInterface()->setPacketSender(&_modelEditSender); |
| 3641 | scriptEngine->getModelsScriptingInterface()->setModelTree(_models.getTree()); | 3671 | scriptEngine->getModelsScriptingInterface()->setModelTree(_models.getTree()); |
| 3642 | 3672 | ||
| 3673 | // model has some custom types | ||
| 3674 | Model::registerMetaTypes(scriptEngine); | ||
| 3675 | |||
| 3643 | // hook our avatar object into this script engine | 3676 | // hook our avatar object into this script engine |
| 3644 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features | 3677 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features |
| 3645 | 3678 | ||
| @@ -3669,6 +3702,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 23 unmodified lines | |||
| 3669 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | 3702 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); |
| 3670 | scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector); | 3703 | scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector); |
| 3671 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); | 3704 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 3705 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); | ||
| 3706 | |||
| 3707 | scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager); | ||
| 3672 | 3708 | ||
| 3673 | #ifdef HAVE_RTMIDI | 3709 | #ifdef HAVE_RTMIDI |
| 3674 | scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance()); | 3710 | scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance()); |