History

Merge branch 'master' of git://github.com/highfidelity/hifi into 19783

Ryan Huffman committed 12 years ago

Commit d777e4b2 parents ade1903 f5dbc54238 files · +12133 −3304Browse files

Showing the changes to interface/src/Application.cpp (1 of 238 files). Show all

Unified · Split

interface/src/Application.cpp+145−109
@@ -89,6 +89,8 @@ · 88 unmodified lines
8989 #include "ui/Stats.h"
9090 #include "ui/TextRenderer.h"
9191
92+#include "devices/Leapmotion.h"
93+
9294 using namespace std;
9395
9496 // Starfield information
@@ -155,7 +157,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 60 unmodified lines
155157 _mouseX(0),
156158 _mouseY(0),
157159 _lastMouseMove(usecTimestampNow()),
158− _lastMouseMoveType(QEvent::MouseMove),
160+ _lastMouseMoveWasSimulated(false),
159161 _mouseHidden(false),
160162 _seenMouseMove(false),
161163 _touchAvgX(0.0f),
@@ -174,7 +176,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines
174176 _runningScriptsWidget(NULL),
175177 _runningScriptsWidgetWasVisible(false),
176178 _trayIcon(new QSystemTrayIcon(_window)),
177− _lastNackTime(usecTimestampNow())
179+ _lastNackTime(usecTimestampNow()),
180+ _lastSendDownstreamAudioStats(usecTimestampNow())
178181 {
179182 // read the ApplicationInfo.ini file for Name/Version/Domain information
180183 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
356359
357360 // Set the sixense filtering
358361 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
362+
363+ // Set hand controller velocity filtering
364+ _sixenseManager.setLowVelocityFilter(Menu::getInstance()->isOptionChecked(MenuOption::LowVelocityFilter));
359365
360366 checkVersion();
361367
@@ -588,7 +594,7 @@ void Application::paintGL() { · 226 unmodified lines
588594
589595 if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
590596 _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());
592598 _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
593599
594600 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
@@ -603,9 +609,19 @@ void Application::paintGL() { · 8 unmodified lines
603609
604610 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
605611 _myCamera.setTightness(0.0f);
606− _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
607− _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
608− _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0));
612+ //Only behave like a true mirror when in the OR
613+ if (OculusManager::isConnected()) {
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+ }
609625 }
610626
611627 // Update camera position
@@ -684,7 +700,7 @@ void Application::paintGL() { · 72 unmodified lines
684700 }
685701
686702 {
687− PerformanceTimer perfTimer("paintGL/renderOverlay");
703+ PerformanceTimer perfTimer("renderOverlay");
688704 // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
689705 _applicationOverlay.renderOverlay(true);
690706 if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
@@ -712,7 +728,6 @@ void Application::resizeGL(int width, int height) { · 21 unmodified lines
712728 resetCamerasOnResizeGL(_myCamera, width, height);
713729
714730 glViewport(0, 0, width, height); // shouldn't this account for the menu???
715− _applicationOverlay.resize();
716731
717732 updateProjectionMatrix();
718733 glLoadIdentity();
@@ -1128,18 +1143,19 @@ void Application::focusOutEvent(QFocusEvent* event) { · 409 unmodified lines
11281143 _keysPressed.clear();
11291144 }
11301145
1131−void Application::mouseMoveEvent(QMouseEvent* event) {
1146+void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
11321147
11331148 bool showMouse = true;
1149+
1150+ // Used by application overlay to determine how to draw cursor(s)
1151+ _lastMouseMoveWasSimulated = deviceID > 0;
1152+
11341153 // 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) {
11361155 showMouse = false;
11371156 }
11381157
1139− // Used by application overlay to determine how to draw cursor(s)
1140− _lastMouseMoveType = event->type();
1141−
1142− _controllerScriptingInterface.emitMouseMoveEvent(event); // send events to any registered scripts
1158+ _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts
11431159
11441160 // if one of our scripts have asked to capture this event, then stop processing it
11451161 if (_controllerScriptingInterface.isMouseCaptured()) {
@@ -1158,7 +1174,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 12 unmodified lines
11581174 _mouseY = event->y();
11591175 }
11601176
1161−void Application::mousePressEvent(QMouseEvent* event) {
1177+void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
11621178 _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
11631179
11641180 // 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
11911207 }
11921208 }
11931209
1194−void Application::mouseReleaseEvent(QMouseEvent* event) {
1210+void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
11951211 _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts
11961212
11971213 // 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
13581374 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
13591375 _lastTimeUpdated.start();
13601376 {
1361− PerformanceTimer perfTimer("idle/update");
1377+ PerformanceTimer perfTimer("update");
13621378 PerformanceWarning warn(showWarnings, "Application::idle()... update()");
13631379 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
13641380 update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
13651381 }
13661382 {
1367− PerformanceTimer perfTimer("idle/updateGL");
1383+ PerformanceTimer perfTimer("updateGL");
13681384 PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
13691385 _glWidget->updateGL();
13701386 }
13711387 {
1372− PerformanceTimer perfTimer("idle/rest");
1388+ PerformanceTimer perfTimer("rest");
13731389 PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
13741390 _idleLoopStdev.addValue(timeSinceLastUpdate);
13751391
@@ -1381,7 +1397,7 @@ void Application::idle() { · 5 unmodified lines
13811397 }
13821398
13831399 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
1384− PerformanceTimer perfTimer("idle/rest/_buckyBalls");
1400+ PerformanceTimer perfTimer("buckyBalls");
13851401 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
13861402 }
13871403
@@ -1429,6 +1445,10 @@ void Application::setRenderVoxels(bool voxelRender) { · 41 unmodified lines
14291445 }
14301446 }
14311447
1448+void Application::setLowVelocityFilter(bool lowVelocityFilter) {
1449+ getSixenseManager()->setLowVelocityFilter(lowVelocityFilter);
1450+}
1451+
14321452 void Application::doKillLocalVoxels() {
14331453 _wantToKillLocalVoxels = true;
14341454 }
@@ -1734,6 +1754,8 @@ void Application::init() { · 299 unmodified lines
17341754 _faceplus.init();
17351755 _visage.init();
17361756
1757+ Leapmotion::init();
1758+
17371759 // fire off an immediate domain-server check in now that settings are loaded
17381760 NodeList::getInstance()->sendDomainServerCheckIn();
17391761
@@ -1828,7 +1850,7 @@ bool Application::isLookingAtMyAvatar(Avatar* avatar) { · 88 unmodified lines
18281850 }
18291851
18301852 void Application::updateLOD() {
1831− PerformanceTimer perfTimer("idle/update/updateLOD");
1853+ PerformanceTimer perfTimer("LOD");
18321854 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
18331855 if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) {
18341856 Menu::getInstance()->autoAdjustLOD(_fps);
@@ -1838,7 +1860,7 @@ void Application::updateLOD() { · 3 unmodified lines
18381860 }
18391861
18401862 void Application::updateMouseRay() {
1841− PerformanceTimer perfTimer("idle/update/updateMouseRay");
1863+ PerformanceTimer perfTimer("mouseRay");
18421864
18431865 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
18441866 PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");
@@ -1871,8 +1893,6 @@ void Application::updateMouseRay() { · 26 unmodified lines
18711893 }
18721894
18731895 void Application::updateFaceshift() {
1874− PerformanceTimer perfTimer("idle/update/updateFaceshift");
1875−
18761896 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
18771897 PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
18781898
@@ -1886,8 +1906,6 @@ void Application::updateFaceshift() { · 7 unmodified lines
18861906 }
18871907
18881908 void Application::updateVisage() {
1889− PerformanceTimer perfTimer("idle/update/updateVisage");
1890−
18911909 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
18921910 PerformanceWarning warn(showWarnings, "Application::updateVisage()");
18931911
@@ -1896,11 +1914,11 @@ void Application::updateVisage() { · 2 unmodified lines
18961914 }
18971915
18981916 void Application::updateMyAvatarLookAtPosition() {
1899− PerformanceTimer perfTimer("idle/update/updateMyAvatarLookAtPosition");
1900−
1917+ PerformanceTimer perfTimer("lookAt");
19011918 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19021919 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
19031920
1921+ _myAvatar->updateLookAtTargetAvatar();
19041922 FaceTracker* tracker = getActiveFaceTracker();
19051923
19061924 bool isLookingAtSomeone = false;
@@ -1928,17 +1946,9 @@ void Application::updateMyAvatarLookAtPosition() { · 21 unmodified lines
19281946 }
19291947 } else {
19301948 // I am not looking at anyone else, so just look forward
1931− lookAtSpot = _myAvatar->getHead()->calculateAverageEyePosition() +
1949+ lookAtSpot = _myAvatar->getHead()->getEyePosition() +
19321950 (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.f, 0.f, -TREE_SCALE));
19331951 }
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−
19421952 }
19431953 //
19441954 // 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
19481958 float eyeYaw = tracker->getEstimatedEyeYaw();
19491959 const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f;
19501960 // deflect using Faceshift gaze data
1951− glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition();
1961+ glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
19521962 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
19531963 float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
19541964 if (isLookingAtSomeone) {
@@ -1963,7 +1973,7 @@ void Application::updateMyAvatarLookAtPosition() { · 8 unmodified lines
19631973 }
19641974
19651975 void Application::updateThreads(float deltaTime) {
1966− PerformanceTimer perfTimer("idle/update/updateThreads");
1976+ PerformanceTimer perfTimer("updateThreads");
19671977 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19681978 PerformanceWarning warn(showWarnings, "Application::updateThreads()");
19691979
@@ -1978,7 +1988,7 @@ void Application::updateThreads(float deltaTime) { · 8 unmodified lines
19781988 }
19791989
19801990 void Application::updateMetavoxels(float deltaTime) {
1981− PerformanceTimer perfTimer("idle/update/updateMetavoxels");
1991+ PerformanceTimer perfTimer("updateMetavoxels");
19821992 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19831993 PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()");
19841994
@@ -2008,7 +2018,7 @@ void Application::cameraMenuChanged() { · 23 unmodified lines
20082018 }
20092019
20102020 void Application::updateCamera(float deltaTime) {
2011− PerformanceTimer perfTimer("idle/update/updateCamera");
2021+ PerformanceTimer perfTimer("updateCamera");
20122022 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20132023 PerformanceWarning warn(showWarnings, "Application::updateCamera()");
20142024
@@ -2026,7 +2036,7 @@ void Application::updateCamera(float deltaTime) { · 11 unmodified lines
20262036 }
20272037
20282038 void Application::updateDialogs(float deltaTime) {
2029− PerformanceTimer perfTimer("idle/update/updateDialogs");
2039+ PerformanceTimer perfTimer("updateDialogs");
20302040 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20312041 PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
20322042
@@ -2043,7 +2053,7 @@ void Application::updateDialogs(float deltaTime) { · 10 unmodified lines
20432053 }
20442054
20452055 void Application::updateCursor(float deltaTime) {
2046− PerformanceTimer perfTimer("idle/update/updateCursor");
2056+ PerformanceTimer perfTimer("updateCursor");
20472057 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20482058 PerformanceWarning warn(showWarnings, "Application::updateCursor()");
20492059
@@ -2068,84 +2078,76 @@ void Application::updateCursor(float deltaTime) { · 18 unmodified lines
20682078 }
20692079
20702080 void Application::update(float deltaTime) {
2071− //PerformanceTimer perfTimer("idle/update"); // NOTE: we track this above in Application::idle()
2072−
20732081 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20742082 PerformanceWarning warn(showWarnings, "Application::update()");
20752083
20762084 updateLOD();
20772085 updateMouseRay(); // check what's under the mouse and update the mouse voxel
2078− updateFaceshift();
2079− updateVisage();
2080−
20812086 {
2082− PerformanceTimer perfTimer("idle/update/updateLookAtTargetAvatar");
2083− _myAvatar->updateLookAtTargetAvatar();
2084− }
2085− updateMyAvatarLookAtPosition();
2086− {
2087− PerformanceTimer perfTimer("idle/update/sixense,joystick,prioVR");
2087+ PerformanceTimer perfTimer("devices");
2088+ DeviceTracker::updateAll();
2089+ updateFaceshift();
2090+ updateVisage();
20882091 _sixenseManager.update(deltaTime);
20892092 _joystickManager.update();
20902093 _prioVR.update(deltaTime);
2094+
20912095 }
2092−
20932096 {
2094− PerformanceTimer perfTimer("idle/update/updateMyAvatar");
2097+ PerformanceTimer perfTimer("myAvatar");
2098+ updateMyAvatarLookAtPosition();
20952099 updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
20962100 }
20972101
2102+
2103+ // Dispatch input events
2104+ _controllerScriptingInterface.updateInputControllers();
2105+
20982106 updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
20992107
2100− {
2101− PerformanceTimer perfTimer("idle/update/_avatarManager");
2102− _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
2103− }
2108+ _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
2109+
21042110 updateMetavoxels(deltaTime); // update metavoxels
21052111 updateCamera(deltaTime); // handle various camera tweaks like off axis projection
21062112 updateDialogs(deltaTime); // update various stats dialogs if present
21072113 updateCursor(deltaTime); // Handle cursor updates
21082114
21092115 {
2110− PerformanceTimer perfTimer("idle/update/_particles");
2116+ PerformanceTimer perfTimer("particles");
21112117 _particles.update(); // update the particles...
2112− }
2113− {
2114− PerformanceTimer perfTimer("idle/update/_particleCollisionSystem");
2115− _particleCollisionSystem.update(); // collide the particles...
2118+ {
2119+ PerformanceTimer perfTimer("collisions");
2120+ _particleCollisionSystem.update(); // collide the particles...
2121+ }
21162122 }
21172123
21182124 {
2119− PerformanceTimer perfTimer("idle/update/_models");
2125+ PerformanceTimer perfTimer("models");
21202126 _models.update(); // update the models...
21212127 _modelClipboardRenderer.update();
21222128 }
21232129
21242130 {
2125− PerformanceTimer perfTimer("idle/update/_overlays");
2131+ PerformanceTimer perfTimer("overlays");
21262132 _overlays.update(deltaTime);
21272133 }
21282134
21292135 {
2130− PerformanceTimer perfTimer("idle/update/emit simulating");
2136+ PerformanceTimer perfTimer("emitSimulating");
21312137 // let external parties know we're updating
21322138 emit simulating(deltaTime);
21332139 }
21342140 }
21352141
21362142 void Application::updateMyAvatar(float deltaTime) {
2137− PerformanceTimer perfTimer("updateMyAvatar");
21382143 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21392144 PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()");
21402145
2141− {
2142− PerformanceTimer perfTimer("updateMyAvatar/_myAvatar->update()");
2143− _myAvatar->update(deltaTime);
2144− }
2146+ _myAvatar->update(deltaTime);
21452147
21462148 {
21472149 // send head/hand data to the avatar mixer and voxel server
2148− PerformanceTimer perfTimer("updateMyAvatar/sendToAvatarMixer");
2150+ PerformanceTimer perfTimer("send");
21492151 QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
21502152 packet.append(_myAvatar->toByteArray());
21512153 controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer);
@@ -2158,14 +2160,15 @@ void Application::updateMyAvatar(float deltaTime) { · 6 unmodified lines
21582160 // actually need to calculate the view frustum planes to send these details
21592161 // to the server.
21602162 {
2161− PerformanceTimer perfTimer("updateMyAvatar/loadViewFrustum");
2163+ PerformanceTimer perfTimer("loadViewFrustum");
21622164 loadViewFrustum(_myCamera, _viewFrustum);
21632165 }
21642166
2167+ quint64 now = usecTimestampNow();
2168+
21652169 // Update my voxel servers with my current voxel query...
21662170 {
2167− PerformanceTimer perfTimer("updateMyAvatar/queryOctree");
2168− quint64 now = usecTimestampNow();
2171+ PerformanceTimer perfTimer("queryOctree");
21692172 quint64 sinceLastQuery = now - _lastQueriedTime;
21702173 const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
21712174 bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY;
@@ -2183,7 +2186,6 @@ void Application::updateMyAvatar(float deltaTime) { · 11 unmodified lines
21832186
21842187 // sent nack packets containing missing sequence numbers of received packets from nodes
21852188 {
2186− quint64 now = usecTimestampNow();
21872189 quint64 sinceLastNack = now - _lastNackTime;
21882190 const quint64 TOO_LONG_SINCE_LAST_NACK = 1 * USECS_PER_SECOND;
21892191 if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) {
@@ -2191,6 +2193,15 @@ void Application::updateMyAvatar(float deltaTime) { · 1 unmodified line
21912193 sendNackPackets();
21922194 }
21932195 }
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+ }
21942205 }
21952206
21962207 int Application::sendNackPackets() {
@@ -2497,7 +2508,7 @@ glm::vec3 Application::getSunDirection() { · 300 unmodified lines
24972508 }
24982509
24992510 void Application::updateShadowMap() {
2500− PerformanceTimer perfTimer("paintGL/updateShadowMap");
2511+ PerformanceTimer perfTimer("shadowMap");
25012512 QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject();
25022513 fbo->bind();
25032514 glEnable(GL_DEPTH_TEST);
@@ -2619,7 +2630,9 @@ void Application::updateShadowMap() { · 115 unmodified lines
26192630 glViewport(0, 0, _glWidget->width(), _glWidget->height());
26202631 }
26212632
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 };
26232636 const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
26242637
26252638 void Application::setupWorldLight() {
@@ -2631,13 +2644,10 @@ void Application::setupWorldLight() { · 5 unmodified lines
26312644 glm::vec3 sunDirection = getSunDirection();
26322645 GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 };
26332646 glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
2634− GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f };
2635− glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
2636− GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f };
2637− glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
2638−
2639− glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2640− glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2647+ glLightfv(GL_LIGHT0, GL_AMBIENT, WORLD_AMBIENT_COLOR);
2648+ glLightfv(GL_LIGHT0, GL_DIFFUSE, WORLD_DIFFUSE_COLOR);
2649+ glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);
2650+ glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
26412651 glMateriali(GL_FRONT, GL_SHININESS, 96);
26422652 }
26432653
@@ -2660,7 +2670,7 @@ QImage Application::renderAvatarBillboard() { · 16 unmodified lines
26602670 }
26612671
26622672 void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
2663− PerformanceTimer perfTimer("paintGL/displaySide");
2673+ PerformanceTimer perfTimer("display");
26642674 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
26652675 // transform by eye offset
26662676
@@ -2694,7 +2704,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 27 unmodified lines
26942704
26952705 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
26962706 {
2697− PerformanceTimer perfTimer("paintGL/displaySide/setupWorldLight");
2707+ PerformanceTimer perfTimer("lights");
26982708 setupWorldLight();
26992709 }
27002710
@@ -2713,7 +2723,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 12 unmodified lines
27132723 }
27142724
27152725 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
2716− PerformanceTimer perfTimer("paintGL/displaySide/stars");
2726+ PerformanceTimer perfTimer("stars");
27172727 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27182728 "Application::displaySide() ... stars...");
27192729 if (!_stars.isStarsLoaded()) {
@@ -2742,7 +2752,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 22 unmodified lines
27422752
27432753 // draw the sky dome
27442754 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
2745− PerformanceTimer perfTimer("paintGL/displaySide/atmosphere");
2755+ PerformanceTimer perfTimer("atmosphere");
27462756 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27472757 "Application::displaySide() ... atmosphere...");
27482758 _environment.renderAtmospheres(whichCamera);
@@ -2763,13 +2773,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 14 unmodified lines
27632773
27642774 // draw the audio reflector overlay
27652775 {
2766− PerformanceTimer perfTimer("paintGL/displaySide/audioReflector");
2776+ PerformanceTimer perfTimer("audio");
27672777 _audioReflector.render();
27682778 }
27692779
27702780 // Draw voxels
27712781 if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2772− PerformanceTimer perfTimer("paintGL/displaySide/voxels");
2782+ PerformanceTimer perfTimer("voxels");
27732783 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27742784 "Application::displaySide() ... voxels...");
27752785 _voxels.render();
@@ -2777,14 +2787,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line
27772787
27782788 // also, metavoxels
27792789 if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
2780− PerformanceTimer perfTimer("paintGL/displaySide/metavoxels");
2790+ PerformanceTimer perfTimer("metavoxels");
27812791 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27822792 "Application::displaySide() ... metavoxels...");
27832793 _metavoxels.render();
27842794 }
27852795
27862796 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
2787− PerformanceTimer perfTimer("paintGL/displaySide/buckyBalls");
2797+ PerformanceTimer perfTimer("buckyBalls");
27882798 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27892799 "Application::displaySide() ... bucky balls...");
27902800 _buckyBalls.render();
@@ -2792,7 +2802,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line
27922802
27932803 // render particles...
27942804 if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) {
2795− PerformanceTimer perfTimer("paintGL/displaySide/particles");
2805+ PerformanceTimer perfTimer("particles");
27962806 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
27972807 "Application::displaySide() ... particles...");
27982808 _particles.render();
@@ -2800,7 +2810,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line
28002810
28012811 // render models...
28022812 if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) {
2803− PerformanceTimer perfTimer("paintGL/displaySide/models");
2813+ PerformanceTimer perfTimer("models");
28042814 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
28052815 "Application::displaySide() ... models...");
28062816 _models.render();
@@ -2809,14 +2819,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 2 unmodified lines
28092819
28102820 // render the ambient occlusion effect if enabled
28112821 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
2812− PerformanceTimer perfTimer("paintGL/displaySide/AmbientOcclusion");
2822+ PerformanceTimer perfTimer("ambientOcclusion");
28132823 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
28142824 "Application::displaySide() ... AmbientOcclusion...");
28152825 _ambientOcclusionEffect.render();
28162826 }
28172827
28182828 // restore default, white specular
2819− glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2829+ glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
28202830
28212831 _nodeBoundsDisplay.draw();
28222832
@@ -2824,20 +2834,27 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line
28242834
28252835 bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR);
28262836 {
2827− PerformanceTimer perfTimer("paintGL/displaySide/renderAvatars");
2837+ PerformanceTimer perfTimer("avatars");
2838+
28282839 _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+ }
28292845 }
28302846
28312847 if (!selfAvatarOnly) {
28322848 // Render the world box
2833− if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) && Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
2834− PerformanceTimer perfTimer("paintGL/displaySide/renderWorldBox");
2849+ if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
2850+ Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
2851+ PerformanceTimer perfTimer("worldBox");
28352852 renderWorldBox();
28362853 }
28372854
28382855 // view frustum for debugging
28392856 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2840− PerformanceTimer perfTimer("paintGL/displaySide/ViewFrustum");
2857+ PerformanceTimer perfTimer("viewFrustum");
28412858 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
28422859 "Application::displaySide() ... renderViewFrustum...");
28432860 renderViewFrustum(_viewFrustum);
@@ -2845,7 +2862,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1 unmodified line
28452862
28462863 // render voxel fades if they exist
28472864 if (_voxelFades.size() > 0) {
2848− PerformanceTimer perfTimer("paintGL/displaySide/voxel fades");
2865+ PerformanceTimer perfTimer("voxelFades");
28492866 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
28502867 "Application::displaySide() ... voxel fades...");
28512868 _voxelFadesLock.lockForWrite();
@@ -2862,13 +2879,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 10 unmodified lines
28622879
28632880 // give external parties a change to hook in
28642881 {
2865− PerformanceTimer perfTimer("paintGL/displaySide/inWorldInterface");
2882+ PerformanceTimer perfTimer("inWorldInterface");
28662883 emit renderingInWorldInterface();
28672884 }
28682885
28692886 // render JS/scriptable overlays
28702887 {
2871− PerformanceTimer perfTimer("paintGL/displaySide/3dOverlays");
2888+ PerformanceTimer perfTimer("3dOverlays");
28722889 _overlays.render3D();
28732890 }
28742891 }
@@ -2948,7 +2965,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 73 unmodified lines
29482965 _mirrorCamera.setTargetPosition(glm::vec3());
29492966
29502967 } else {
2951− _mirrorCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
2968+ _mirrorCamera.setTargetPosition(_myAvatar->getHead()->getEyePosition());
29522969 }
29532970 }
29542971 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
@@ -2977,7 +2994,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 22 unmodified lines
29772994 _myAvatar->getSkeletonModel().getNeckPosition(neckPosition);
29782995
29792996 // get the eye position relative to the body
2980− glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition();
2997+ glm::vec3 eyePosition = _myAvatar->getHead()->getEyePosition();
29812998 float eyeHeight = eyePosition.y - _myAvatar->getPosition().y;
29822999
29833000 // 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
29953012 attachment->setTranslation(attachment->getTranslation() + delta);
29963013 }
29973014
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+
29983022 displaySide(_mirrorCamera, true);
29993023
30003024 // restore absolute translations
@@ -3003,6 +3027,11 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 2 unmodified lines
30033027 for (int i = 0; i < absoluteAttachmentTranslations.size(); i++) {
30043028 _myAvatar->getAttachmentModels().at(i)->setTranslation(absoluteAttachmentTranslations.at(i));
30053029 }
3030+
3031+ // restore the shadow matrices
3032+ for (int i = 0; i < CASCADED_SHADOW_MATRIX_COUNT; i++) {
3033+ _shadowMatrices[i] = savedShadowMatrices[i];
3034+ }
30063035 } else {
30073036 displaySide(_mirrorCamera, true);
30083037 }
@@ -3205,6 +3234,7 @@ void Application::resetSensors() { · 196 unmodified lines
32053234 OculusManager::reset();
32063235
32073236 _prioVR.reset();
3237+ //_leapmotion.reset();
32083238
32093239 QCursor::setPos(_mouseX, _mouseY);
32103240 _myAvatar->reset();
@@ -3355,7 +3385,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 144 unmodified lines
33553385 _modelEditSender.nodeKilled(node);
33563386
33573387 if (node->getType() == NodeType::AudioMixer) {
3358− QMetaObject::invokeMethod(&_audio, "resetIncomingMixedAudioSequenceNumberStats");
3388+ QMetaObject::invokeMethod(&_audio, "audioMixerKilled");
33593389 }
33603390
33613391 if (node->getType() == NodeType::VoxelServer) {
@@ -3640,6 +3670,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 278 unmodified lines
36403670 scriptEngine->getModelsScriptingInterface()->setPacketSender(&_modelEditSender);
36413671 scriptEngine->getModelsScriptingInterface()->setModelTree(_models.getTree());
36423672
3673+ // model has some custom types
3674+ Model::registerMetaTypes(scriptEngine);
3675+
36433676 // hook our avatar object into this script engine
36443677 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
36453678
@@ -3669,6 +3702,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 23 unmodified lines
36693702 scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
36703703 scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector);
36713704 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
3705+ scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
3706+
3707+ scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
36723708
36733709 #ifdef HAVE_RTMIDI
36743710 scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t