History

Merge branch 'master' of https://github.com/worklist/hifi into new_voxel_scene_stats

ZappoMan committed 13 years ago

Commit 581e0ad2 parents 09dab89 27ed53319 files · +449 −200Browse files

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

Unified · Split

interface/src/Application.cpp+248−96
@@ -144,6 +144,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 143 unmodified lines
144144 _packetsPerSecond(0),
145145 _bytesPerSecond(0),
146146 _bytesCount(0),
147+ _recentMaxPackets(0),
148+ _resetRecentMaxPacketsSoon(true),
147149 _swatch(NULL),
148150 _pasteMode(false)
149151 {
@@ -1304,7 +1306,10 @@ static glm::vec3 getFaceVector(BoxFace face) { · 1154 unmodified lines
13041306 }
13051307
13061308 void Application::idle() {
1307− bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1309+ // Normally we check PipelineWarnings, but since idle will often take more than 10ms we only show these idle timing
1310+ // details if we're in ExtraDebugging mode. However, the ::update() and it's subcomponents will show their timing
1311+ // details normally.
1312+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging);
13081313 PerformanceWarning warn(showWarnings, "Application::idle()");
13091314
13101315 timeval check;
@@ -1314,22 +1319,30 @@ void Application::idle() { · 3 unmodified lines
13141319
13151320 double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
13161321 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
1317−
1318− const float BIGGEST_DELTA_TIME_SECS = 0.25f;
1319− update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
1320− _glWidget->updateGL();
1321− _lastTimeUpdated = check;
1322− _idleLoopStdev.addValue(timeSinceLastUpdate);
1323−
1324− // Record standard deviation and reset counter if needed
1325− const int STDEV_SAMPLES = 500;
1326− if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {
1327− _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
1328− _idleLoopStdev.reset();
1322+ {
1323+ PerformanceWarning warn(showWarnings, "Application::idle()... update()");
1324+ const float BIGGEST_DELTA_TIME_SECS = 0.25f;
1325+ update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
1326+ }
1327+ {
1328+ PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
1329+ _glWidget->updateGL();
13291330 }
1331+ {
1332+ PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
1333+ _lastTimeUpdated = check;
1334+ _idleLoopStdev.addValue(timeSinceLastUpdate);
1335+
1336+ // Record standard deviation and reset counter if needed
1337+ const int STDEV_SAMPLES = 500;
1338+ if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {
1339+ _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
1340+ _idleLoopStdev.reset();
1341+ }
13301342
1331− // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
1332− idleTimer->start(2);
1343+ // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
1344+ idleTimer->start(2);
1345+ }
13331346 }
13341347 }
13351348 void Application::terminate() {
@@ -1776,6 +1789,8 @@ static QUuid DEFAULT_NODE_ID_REF; · 440 unmodified lines
17761789
17771790 void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
17781791 glm::vec3& eyePosition) {
1792+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1793+ PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()");
17791794
17801795 _lookatTargetAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, DEFAULT_NODE_ID_REF);
17811796 }
@@ -1791,7 +1806,10 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 9 unmodified lines
17911806 float distance;
17921807 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition,
17931808 HEAD_SPHERE_RADIUS * avatar->getHead().getScale(), distance)) {
1794− eyePosition = avatar->getHead().calculateAverageEyePosition();
1809+ // rescale to compensate for head embiggening
1810+ eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
1811+ (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
1812+
17951813 _lookatIndicatorScale = avatar->getHead().getScale();
17961814 _lookatOtherPosition = headPosition;
17971815 nodeUUID = avatar->getOwningNode()->getUUID();
@@ -1907,17 +1925,13 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 109 unmodified lines
19071925 }
19081926 }
19091927
1910−void Application::update(float deltaTime) {
1928+void Application::updateMouseRay(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection) {
1929+
19111930 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1912− PerformanceWarning warn(showWarnings, "Application::update()");
1913−
1914− // tell my avatar if the mouse is being pressed...
1915− _myAvatar.setMousePressed(_mousePressed);
1916−
1917− // check what's under the mouse and update the mouse voxel
1918− glm::vec3 mouseRayOrigin, mouseRayDirection;
1919− _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(),
1920− _mouseY / (float)_glWidget->height(), mouseRayOrigin, mouseRayDirection);
1931+ PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");
1932+
1933+ _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(),
1934+ mouseRayOrigin, mouseRayDirection);
19211935
19221936 // adjust for mirroring
19231937 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
@@ -1928,12 +1942,18 @@ void Application::update(float deltaTime) { · 4 unmodified lines
19281942 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayDirection));
19291943 }
19301944
1945+ // tell my avatar if the mouse is being pressed...
1946+ _myAvatar.setMousePressed(_mousePressed);
1947+
19311948 // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position
19321949 _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection);
1933−
1934− // Set where I am looking based on my mouse ray (so that other people can see)
1935− glm::vec3 lookAtSpot;
1950+}
1951+
1952+void Application::updateFaceshift() {
19361953
1954+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1955+ PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
1956+
19371957 // Update faceshift
19381958 _faceshift.update();
19391959
@@ -1941,39 +1961,47 @@ void Application::update(float deltaTime) { · 1 unmodified line
19411961 if (_faceshift.isActive()) {
19421962 _myAvatar.getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity());
19431963 }
1964+}
19441965
1945− // if we have faceshift, use that to compute the lookat direction
1946− glm::vec3 lookAtRayOrigin = mouseRayOrigin, lookAtRayDirection = mouseRayDirection;
1947− if (_faceshift.isActive()) {
1948− lookAtRayOrigin = _myAvatar.getHead().calculateAverageEyePosition();
1949− lookAtRayDirection = _myAvatar.getHead().getOrientation() * glm::quat(glm::radians(glm::vec3(
1950− _faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
1951− }
1966+void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& lookAtRayOrigin,
1967+ glm::vec3& lookAtRayDirection) {
19521968
1953− updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);
1954− if (_lookatTargetAvatar && !_faceshift.isActive()) {
1955− // If the mouse is over another avatar's head...
1956− _myAvatar.getHead().setLookAtPosition(lookAtSpot);
1957−
1958− } else if (_isHoverVoxel && !_faceshift.isActive()) {
1959− // Look at the hovered voxel
1960− lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
1961− _myAvatar.getHead().setLookAtPosition(lookAtSpot);
1962−
1963− } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR && !_faceshift.isActive()) {
1964− _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition());
1969+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1970+ PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
19651971
1966− } else {
1967− // Just look in direction of the mouse ray
1968− const float FAR_AWAY_STARE = TREE_SCALE;
1969− lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
1970− _myAvatar.getHead().setLookAtPosition(lookAtSpot);
1972+ if (!_lookatTargetAvatar) {
1973+ if (_isHoverVoxel) {
1974+ // Look at the hovered voxel
1975+ lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
1976+
1977+ } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1978+ lookAtSpot = _myCamera.getPosition();
1979+
1980+ } else {
1981+ // Just look in direction of the mouse ray
1982+ const float FAR_AWAY_STARE = TREE_SCALE;
1983+ lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
1984+ }
19711985 }
1986+ if (_faceshift.isActive()) {
1987+ // deflect using Faceshift gaze data
1988+ glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition();
1989+ float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
1990+ const float PITCH_SCALE = 0.5f;
1991+ const float YAW_SCALE = 0.5f;
1992+ lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
1993+ _faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) *
1994+ glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
1995+ }
1996+ _myAvatar.getHead().setLookAtPosition(lookAtSpot);
1997+}
1998+
1999+void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2000+ float& distance, BoxFace& face) {
2001+
2002+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2003+ PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");
19722004
1973− // Find the voxel we are hovering over, and respond if clicked
1974− float distance;
1975− BoxFace face;
1976−
19772005 // If we have clicked on a voxel, update it's color
19782006 if (_isHoverVoxelSounding) {
19792007 VoxelNode* hoveredNode = _voxels.getVoxelAt(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
@@ -1995,23 +2023,38 @@ void Application::update(float deltaTime) { · 15 unmodified lines
19952023 } else {
19962024 // Check for a new hover voxel
19972025 glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
1998− _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face);
1999− if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel && glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {
2000− _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
2001− _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
2002− _hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
2003− _hoverVoxelOriginalColor[3] = 1;
2004− _audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY);
2005− _isHoverVoxelSounding = true;
2026+ // only do this work if MAKE_SOUND_ON_VOXEL_HOVER or MAKE_SOUND_ON_VOXEL_CLICK is enabled,
2027+ // and make sure the tree is not already busy... because otherwise you'll have to wait.
2028+ if (!_voxels.treeIsBusy()) {
2029+ {
2030+ PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
2031+ _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face);
2032+ }
2033+ if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&
2034+ glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {
2035+
2036+ _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
2037+ _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
2038+ _hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
2039+ _hoverVoxelOriginalColor[3] = 1;
2040+ _audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY);
2041+ _isHoverVoxelSounding = true;
2042+ }
20062043 }
20072044 }
2008−
2045+}
2046+
2047+void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2048+ float& distance, BoxFace& face) {
2049+
2050+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2051+ PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()");
2052+
20092053 _mouseVoxel.s = 0.0f;
20102054 if (Menu::getInstance()->isVoxelModeActionChecked() &&
20112055 (fabs(_myAvatar.getVelocity().x) +
20122056 fabs(_myAvatar.getVelocity().y) +
20132057 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
2014− PerformanceWarning warn(showWarnings, "Application::update()... findRayIntersection()");
20152058
20162059 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
20172060 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
@@ -2080,12 +2123,17 @@ void Application::update(float deltaTime) { · 62 unmodified lines
20802123 _justEditedVoxel = false;
20812124 }
20822125 }
2083−
2126+}
2127+
2128+void Application::updateHandAndTouch(float deltaTime) {
2129+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2130+ PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
2131+
20842132 // walking triggers the handControl to stop
20852133 if (_myAvatar.getMode() == AVATAR_MODE_WALKING) {
20862134 _handControl.stop();
20872135 }
2088−
2136+
20892137 // Update from Touch
20902138 if (_isTouchPressed) {
20912139 float TOUCH_YAW_SCALE = -0.25f;
@@ -2096,19 +2144,29 @@ void Application::update(float deltaTime) { · 4 unmodified lines
20962144 _lastTouchAvgX = _touchAvgX;
20972145 _lastTouchAvgY = _touchAvgY;
20982146 }
2099−
2100− // Leap finger-sensing device
2147+}
2148+
2149+void Application::updateLeap(float deltaTime) {
2150+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2151+ PerformanceWarning warn(showWarnings, "Application::updateLeap()");
2152+
21012153 LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand));
21022154 _myAvatar.getHand().setRaveGloveActive(Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove));
21032155 LeapManager::nextFrame(_myAvatar);
2104−
2105− // Read serial port interface devices
2156+}
2157+
2158+void Application::updateSerialDevices(float deltaTime) {
2159+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2160+ PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()");
2161+
21062162 if (_serialHeadSensor.isActive()) {
21072163 _serialHeadSensor.readData(deltaTime);
21082164 }
2109−
2110− // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
2111− updateAvatar(deltaTime);
2165+}
2166+
2167+void Application::updateThreads(float deltaTime) {
2168+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2169+ PerformanceWarning warn(showWarnings, "Application::updateThreads()");
21122170
21132171 // read incoming packets from network
21142172 if (!_enableNetworkThread) {
@@ -2120,12 +2178,12 @@ void Application::update(float deltaTime) { · 5 unmodified lines
21202178 _voxelProcessor.threadRoutine();
21212179 _voxelEditSender.threadRoutine();
21222180 }
2181+}
2182+
2183+void Application::updateMyAvatarSimulation(float deltaTime) {
2184+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2185+ PerformanceWarning warn(showWarnings, "Application::updateMyAvatarSimulation()");
21232186
2124−
2125− //loop through all the other avatars and simulate them...
2126− updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection);
2127−
2128− // Simulate myself
21292187 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
21302188 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
21312189 }
@@ -2138,12 +2196,21 @@ void Application::update(float deltaTime) { · 6 unmodified lines
21382196 } else {
21392197 _myAvatar.simulate(deltaTime, NULL);
21402198 }
2141−
2142− // Simulate particle cloud movements
2199+}
2200+
2201+void Application::updateParticles(float deltaTime) {
2202+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2203+ PerformanceWarning warn(showWarnings, "Application::updateParticles()");
2204+
21432205 if (Menu::getInstance()->isOptionChecked(MenuOption::ParticleCloud)) {
21442206 _cloud.simulate(deltaTime);
21452207 }
2146−
2208+}
2209+
2210+void Application::updateTransmitter(float deltaTime) {
2211+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2212+ PerformanceWarning warn(showWarnings, "Application::updateTransmitter()");
2213+
21472214 // no transmitter drive implies transmitter pick
21482215 if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
21492216 _transmitterPickStart = _myAvatar.getSkeleton().joint[AVATAR_JOINT_CHEST].position;
@@ -2178,7 +2245,12 @@ void Application::update(float deltaTime) { · 28 unmodified lines
21782245 } else {
21792246 _transmitterPickStart = _transmitterPickEnd = glm::vec3();
21802247 }
2181−
2248+}
2249+
2250+void Application::updateCamera(float deltaTime) {
2251+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2252+ PerformanceWarning warn(showWarnings, "Application::updateCamera()");
2253+
21822254 if (!OculusManager::isConnected()) {
21832255 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
21842256 if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
@@ -2213,7 +2285,12 @@ void Application::update(float deltaTime) { · 28 unmodified lines
22132285 }
22142286 }
22152287 }
2216−
2288+}
2289+
2290+void Application::updateDialogs(float deltaTime) {
2291+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2292+ PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
2293+
22172294 // Update bandwidth dialog, if any
22182295 BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog();
22192296 if (bandwidthDialog) {
@@ -2224,6 +2301,11 @@ void Application::update(float deltaTime) { · 4 unmodified lines
22242301 if (voxelStatsDialog) {
22252302 voxelStatsDialog->update();
22262303 }
2304+}
2305+
2306+void Application::updateAudio(float deltaTime) {
2307+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2308+ PerformanceWarning warn(showWarnings, "Application::updateAudio()");
22272309
22282310 // Update audio stats for procedural sounds
22292311 #ifndef _WIN32
@@ -2231,7 +2313,12 @@ void Application::update(float deltaTime) { · 1 unmodified line
22312313 _audio.setLastVelocity(_myAvatar.getVelocity());
22322314 _audio.eventuallyAnalyzePing();
22332315 #endif
2234−
2316+}
2317+
2318+void Application::updateCursor(float deltaTime) {
2319+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2320+ PerformanceWarning warn(showWarnings, "Application::updateCursor()");
2321+
22352322 // watch mouse position, if it hasn't moved, hide the cursor
22362323 bool underMouse = _glWidget->underMouse();
22372324 if (!_mouseHidden) {
@@ -2252,6 +2339,42 @@ void Application::update(float deltaTime) { · 14 unmodified lines
22522339 }
22532340 }
22542341
2342+void Application::update(float deltaTime) {
2343+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2344+ PerformanceWarning warn(showWarnings, "Application::update()");
2345+
2346+ // check what's under the mouse and update the mouse voxel
2347+ glm::vec3 mouseRayOrigin, mouseRayDirection;
2348+ updateMouseRay(deltaTime, mouseRayOrigin, mouseRayDirection);
2349+
2350+ // Set where I am looking based on my mouse ray (so that other people can see)
2351+ glm::vec3 lookAtSpot;
2352+
2353+ updateFaceshift();
2354+ updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);
2355+ updateMyAvatarLookAtPosition(lookAtSpot, mouseRayOrigin, mouseRayDirection);
2356+
2357+ // Find the voxel we are hovering over, and respond if clicked
2358+ float distance;
2359+ BoxFace face;
2360+
2361+ updateHoverVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // clicking on voxels and making sounds
2362+ updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels
2363+ updateHandAndTouch(deltaTime); // Update state for touch sensors
2364+ updateLeap(deltaTime); // Leap finger-sensing device
2365+ updateSerialDevices(deltaTime); // Read serial port interface devices
2366+ updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
2367+ updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
2368+ updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection); //loop through all the other avatars and simulate them...
2369+ updateMyAvatarSimulation(deltaTime); // Simulate myself
2370+ updateParticles(deltaTime); // Simulate particle cloud movements
2371+ updateTransmitter(deltaTime); // transmitter drive or pick
2372+ updateCamera(deltaTime); // handle various camera tweaks like off axis projection
2373+ updateDialogs(deltaTime); // update various stats dialogs if present
2374+ updateAudio(deltaTime); // Update audio stats for procedural sounds
2375+ updateCursor(deltaTime); // Handle cursor updates
2376+}
2377+
22552378 void Application::updateAvatar(float deltaTime) {
22562379 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
22572380 PerformanceWarning warn(showWarnings, "Application::updateAvatar()");
@@ -2743,6 +2866,12 @@ void Application::setupWorldLight(Camera& whichCamera) { · 485 unmodified lines
27432866 glMateriali(GL_FRONT, GL_SHININESS, 96);
27442867 }
27452868
2869+void Application::loadTranslatedViewMatrix(const glm::vec3& translation) {
2870+ glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix);
2871+ glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y,
2872+ translation.z + _viewMatrixTranslation.z);
2873+}
2874+
27462875 void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
27472876 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
27482877
@@ -2776,7 +2905,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 27 unmodified lines
27762905 glm::vec3 axis = glm::axis(rotation);
27772906 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);
27782907
2779− glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
2908+ // store view matrix without translation, which we'll use for precision-sensitive objects
2909+ glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix);
2910+ _viewMatrixTranslation = -whichCamera.getPosition();
2911+
2912+ glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);
27802913
27812914 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
27822915 setupWorldLight(whichCamera);
@@ -2934,10 +3067,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 151 unmodified lines
29343067 if (!avatar->isInitialized()) {
29353068 avatar->init();
29363069 }
2937− // Set lookAt to myCamera on client side if other avatars are looking at client
2938− if (isLookingAtMyAvatar(avatar)) {
2939− avatar->getHead().setLookAtPosition(whichCamera.getPosition());
2940− }
29413070 avatar->render(false, Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
29423071 avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
29433072 }
@@ -3258,6 +3387,8 @@ void Application::displayStats() { · 314 unmodified lines
32583387 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats);
32593388
32603389
3390+ QLocale locale(QLocale::English);
3391+
32613392 std::stringstream voxelStats;
32623393 voxelStats.precision(4);
32633394 voxelStats << "Voxels " <<
@@ -3289,9 +3420,9 @@ void Application::displayStats() { · 25 unmodified lines
32893420
32903421 voxelStats.str("");
32913422 voxelStats <<
3292− "Local Voxels Total: " << VoxelNode::getNodeCount() << ", " <<
3293− "Internal: " << VoxelNode::getInternalNodeCount() << " , " <<
3294− "Leaves: " << VoxelNode::getLeafNodeCount() << "";
3423+ "Local Voxels Total: " << localTotalString.toLocal8Bit().constData() << " / " <<
3424+ "Internal: " << localInternalString.toLocal8Bit().constData() << " / " <<
3425+ "Leaves: " << localLeavesString.toLocal8Bit().constData() << "";
32953426 statsVerticalOffset += PELS_PER_LINE;
32963427 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
32973428
@@ -3360,7 +3491,28 @@ void Application::displayStats() { · 62 unmodified lines
33603491 statsVerticalOffset += PELS_PER_LINE;
33613492 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
33623493
3363−
3494+ voxelStats.str("");
3495+ int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();
3496+ QString packetsString = locale.toString((int)voxelPacketsToProcess);
3497+ QString maxString = locale.toString((int)_recentMaxPackets);
3498+
3499+ voxelStats << "Voxel Packets to Process: " << packetsString.toLocal8Bit().constData()
3500+ << " [Recent Max: " << maxString.toLocal8Bit().constData() << "]";
3501+
3502+ if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
3503+ _recentMaxPackets = 0;
3504+ _resetRecentMaxPacketsSoon = false;
3505+ }
3506+ if (voxelPacketsToProcess == 0) {
3507+ _resetRecentMaxPacketsSoon = true;
3508+ } else {
3509+ if (voxelPacketsToProcess > _recentMaxPackets) {
3510+ _recentMaxPackets = voxelPacketsToProcess;
3511+ }
3512+ }
3513+ statsVerticalOffset += PELS_PER_LINE;
3514+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3515+
33643516 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
33653517 char avatarMixerStats[200];
33663518

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