History

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

Leonardo Murillo committed 12 years ago

Commit 82ecc9c2 parents b8aaf4e ea63f05304 files · +6903 −94913Browse files

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

Unified · Split

interface/src/Application.cpp+114−160
@@ -5,10 +5,16 @@ · 4 unmodified lines
55 // Created by Andrzej Kapolka on 5/10/13.
66 // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
77
8+#ifdef WIN32
9+#include <Systime.h>
10+#endif
11+
812 #include <sstream>
913
1014 #include <stdlib.h>
1115 #include <cmath>
16+#include <math.h>
17+
1218
1319 #include <glm/gtx/component_wise.hpp>
1420 #include <glm/gtx/quaternion.hpp>
@@ -130,7 +136,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 115 unmodified lines
130136 _lookingAwayFromOrigin(true),
131137 _lookatTargetAvatar(NULL),
132138 _lookatIndicatorScale(1.0f),
133− _perfStatsOn(false),
134139 _chatEntryOn(false),
135140 _audio(&_audioScope, STARTUP_JITTER_SAMPLES),
136141 _enableProcessVoxelsThread(true),
@@ -168,7 +173,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 31 unmodified lines
168173 }
169174
170175 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
171−
176+
172177 // connect our processDatagrams slot to the QUDPSocket readyRead() signal
173178 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams()));
174179
@@ -179,7 +184,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
179184 connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
180185
181186 audioThread->start();
182−
187+
183188 connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
184189
185190 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
@@ -216,7 +221,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 30 unmodified lines
216221 #endif
217222
218223 // tell the NodeList instance who to tell the domain server we care about
219− const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
224+ const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
220225 NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
221226 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
222227
@@ -323,11 +328,21 @@ void Application::initializeGL() { · 100 unmodified lines
323328 glutInit(&argc, 0);
324329 #endif
325330
331+ #ifdef WIN32
332+ GLenum err = glewInit();
333+ if (GLEW_OK != err) {
334+ /* Problem: glewInit failed, something is seriously wrong. */
335+ qDebug("Error: %s\n", glewGetErrorString(err));
336+ }
337+ qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
338+ #endif
339+
340+
326341 // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
327342 // field of view and near and far clip to make it interesting.
328343 //viewFrustumOffsetCamera.setFieldOfView(90.0);
329− _viewFrustumOffsetCamera.setNearClip(0.1);
330− _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE);
344+ _viewFrustumOffsetCamera.setNearClip(0.1f);
345+ _viewFrustumOffsetCamera.setFarClip(500.0f * TREE_SCALE);
331346
332347 initDisplay();
333348 qDebug( "Initialized Display.");
@@ -461,7 +476,7 @@ void Application::paintGL() { · 127 unmodified lines
461476 bool eyeRelativeCamera = false;
462477 if (_rearMirrorTools->getZoomLevel() == BODY) {
463478 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale());
464− _mirrorCamera.setTargetPosition(_myAvatar.getChestJointPosition());
479+ _mirrorCamera.setTargetPosition(_myAvatar.getChestPosition());
465480 } else { // HEAD zoom level
466481 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale());
467482 if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) {
@@ -1288,38 +1303,6 @@ void Application::sendPingPackets() { · 820 unmodified lines
12881303 nodesToPing, sizeof(nodesToPing));
12891304 }
12901305
1291−void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) {
1292− unsigned char packet[MAX_PACKET_SIZE];
1293− unsigned char* packetPosition = packet;
1294−
1295− packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO);
1296−
1297− QByteArray rfcUUID = NodeList::getInstance()->getOwnerUUID().toRfc4122();
1298− memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size());
1299− packetPosition += rfcUUID.size();
1300−
1301− *(uint32_t*)packetPosition = frameCount;
1302− packetPosition += sizeof(uint32_t);
1303−
1304− *(uint32_t*)packetPosition = data.size();
1305− packetPosition += sizeof(uint32_t);
1306−
1307− uint32_t* offsetPosition = (uint32_t*)packetPosition;
1308− packetPosition += sizeof(uint32_t);
1309−
1310− int headerSize = packetPosition - packet;
1311−
1312− // break the data up into submessages of the maximum size (at least one, for zero-length packets)
1313− *offsetPosition = 0;
1314− do {
1315− int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize);
1316− memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize);
1317− getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1);
1318− *offsetPosition += payloadSize;
1319−
1320− } while (*offsetPosition < data.size());
1321−}
1322−
13231306 // Every second, check the frame rates and other stuff
13241307 void Application::timer() {
13251308 gettimeofday(&_timerEnd, NULL);
@@ -1362,6 +1345,7 @@ static glm::vec3 getFaceVector(BoxFace face) { · 36 unmodified lines
13621345 case MIN_Z_FACE:
13631346 return glm::vec3(0, 0, -1);
13641347
1348+ default: // quiet windows warnings
13651349 case MAX_Z_FACE:
13661350 return glm::vec3(0, 0, 1);
13671351 }
@@ -1419,13 +1403,15 @@ void Application::terminate() { · 51 unmodified lines
14191403 // let the avatar mixer know we're out
14201404 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
14211405
1422− printf("");
14231406 _voxelProcessor.terminate();
14241407 _voxelHideShowThread.terminate();
14251408 _voxelEditSender.terminate();
14261409 _particleEditSender.terminate();
1427− _persistThread->terminate();
1428− _persistThread = NULL;
1410+ if (_persistThread) {
1411+ _persistThread->terminate();
1412+ _persistThread->deleteLater();
1413+ _persistThread = NULL;
1414+ }
14291415 }
14301416
14311417 static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
@@ -1477,14 +1463,6 @@ void Application::processAvatarURLsMessage(unsigned char* packetData, size_t dat · 45 unmodified lines
14771463 avatar->getUUID());
14781464 }
14791465
1480−void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) {
1481− Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes);
1482− if (!avatar) {
1483− return;
1484− }
1485− avatar->getHead().getVideoFace().processVideoMessage(packetData, dataBytes);
1486−}
1487−
14881466 void Application::checkBandwidthMeterClick() {
14891467 // ... to be called upon button release
14901468
@@ -1504,6 +1482,11 @@ void Application::setFullscreen(bool fullscreen) { · 13 unmodified lines
15041482 (_window->windowState() & ~Qt::WindowFullScreen));
15051483 }
15061484
1485+void Application::setEnable3DTVMode(bool enable3DTVMode) {
1486+ resizeGL(_glWidget->width(),_glWidget->height());
1487+}
1488+
1489+
15071490 void Application::setRenderVoxels(bool voxelRender) {
15081491 _voxelEditSender.setShouldSend(voxelRender);
15091492 if (!voxelRender) {
@@ -1953,7 +1936,7 @@ void Application::shrinkMirrorView() { · 443 unmodified lines
19531936
19541937 const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
19551938 const float MAX_VOXEL_EDIT_DISTANCE = 50.0f;
1956−const float HEAD_SPHERE_RADIUS = 0.07;
1939+const float HEAD_SPHERE_RADIUS = 0.07f;
19571940
19581941 static QUuid DEFAULT_NODE_ID_REF;
19591942
@@ -1974,12 +1957,12 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 14 unmodified lines
19741957 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
19751958 Avatar* avatar = (Avatar*)node->getLinkedData();
19761959 float distance;
1977−
1960+
19781961 if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
19791962 // rescale to compensate for head embiggening
19801963 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
19811964 (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
1982−
1965+
19831966 _lookatIndicatorScale = avatar->getHead().getScale();
19841967 _lookatOtherPosition = avatar->getHead().getPosition();
19851968 nodeUUID = avatar->getOwningNode()->getUUID();
@@ -1987,7 +1970,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line
19871970 }
19881971 }
19891972 }
1990−
1973+
19911974 return NULL;
19921975 }
19931976
@@ -2029,7 +2012,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 35 unmodified lines
20292012 void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
20302013 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20312014 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
2032−
2015+
20332016 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
20342017 QMutexLocker(&node->getMutex());
20352018 if (node->getLinkedData()) {
@@ -2046,11 +2029,11 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 10 unmodified lines
20462029 for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) {
20472030 Avatar* avatar = *fade;
20482031 const float SHRINK_RATE = 0.9f;
2049−
2032+
20502033 avatar->setTargetScale(avatar->getScale() * SHRINK_RATE);
2051−
2052− const float MIN_FADE_SCALE = 0.001;
2053−
2034+
2035+ const float MIN_FADE_SCALE = 0.001f;
2036+
20542037 if (avatar->getTargetScale() < MIN_FADE_SCALE) {
20552038 delete avatar;
20562039 _avatarFades.erase(fade--);
@@ -2105,17 +2088,23 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 48 unmodified lines
21052088 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21062089 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
21072090
2091+ const float FAR_AWAY_STARE = TREE_SCALE;
21082092 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
21092093 lookAtSpot = _myCamera.getPosition();
21102094
2095+ } else if (_mouseHidden) {
2096+ // if the mouse cursor is hidden, just look straight ahead
2097+ glm::vec3 rayOrigin, rayDirection;
2098+ _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
2099+ lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
2100+
21112101 } else if (!_lookatTargetAvatar) {
21122102 if (_isHoverVoxel) {
21132103 // Look at the hovered voxel
21142104 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
21152105
21162106 } else {
2117− // Just look in direction of the mouse ray
2118− const float FAR_AWAY_STARE = TREE_SCALE;
2107+ // Just look in direction of the mouse ray
21192108 lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
21202109 }
21212110 }
@@ -2268,6 +2257,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 146 unmodified lines
22682257 }
22692258 }
22702259
2260+
22712261 void Application::updateHandAndTouch(float deltaTime) {
22722262 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
22732263 PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
@@ -2311,7 +2301,9 @@ void Application::updateThreads(float deltaTime) { · 37 unmodified lines
23112301 _voxelHideShowThread.threadRoutine();
23122302 _voxelEditSender.threadRoutine();
23132303 _particleEditSender.threadRoutine();
2314− _persistThread->threadRoutine();
2304+ if (_persistThread) {
2305+ _persistThread->threadRoutine();
2306+ }
23152307 }
23162308 }
23172309
@@ -2357,7 +2349,7 @@ void Application::updateTransmitter(float deltaTime) { · 39 unmodified lines
23572349
23582350 // no transmitter drive implies transmitter pick
23592351 if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
2360− _transmitterPickStart = _myAvatar.getSkeleton().joint[AVATAR_JOINT_CHEST].position;
2352+ _transmitterPickStart = _myAvatar.getChestPosition();
23612353 glm::vec3 direction = _myAvatar.getOrientation() *
23622354 glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT;
23632355
@@ -2406,12 +2398,6 @@ void Application::updateCamera(float deltaTime) { · 42 unmodified lines
24062398 glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE;
24072399 _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z));
24082400 updateProjectionMatrix();
2409−
2410− } else if (_webcam.isActive()) {
2411− const float EYE_OFFSET_SCALE = 0.5f;
2412− glm::vec3 position = _webcam.getEstimatedPosition() * EYE_OFFSET_SCALE;
2413− _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, -position.y, position.z));
2414− updateProjectionMatrix();
24152401 }
24162402 }
24172403 }
@@ -2523,8 +2509,8 @@ void Application::updateAvatar(float deltaTime) { · 105 unmodified lines
25232509 _myAvatar.getHand().setPitchUpdate(0.f);
25242510 _pitchFromTouch = 0.0f;
25252511
2526− // Update my avatar's state from gyros and/or webcam
2527− _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
2512+ // Update my avatar's state from gyros
2513+ _myAvatar.updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
25282514
25292515 // Update head mouse from faceshift if active
25302516 if (_faceshift.isActive()) {
@@ -2621,32 +2607,32 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 90 unmodified lines
26212607 int totalServers = 0;
26222608 int inViewServers = 0;
26232609 int unknownJurisdictionServers = 0;
2624−
2610+
26252611 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
26262612 // only send to the NodeTypes that are serverType
26272613 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
26282614 totalServers++;
2629−
2615+
26302616 // get the server bounds for this server
26312617 QUuid nodeUUID = node->getUUID();
2632−
2618+
26332619 // if we haven't heard from this voxel server, go ahead and send it a query, so we
26342620 // can get the jurisdiction...
26352621 if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
26362622 unknownJurisdictionServers++;
26372623 } else {
26382624 const JurisdictionMap& map = (jurisdictions)[nodeUUID];
2639−
2625+
26402626 unsigned char* rootCode = map.getRootOctalCode();
2641−
2627+
26422628 if (rootCode) {
26432629 VoxelPositionSize rootDetails;
26442630 voxelDetailsForCode(rootCode, rootDetails);
26452631 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
26462632 serverBounds.scale(TREE_SCALE);
2647−
2633+
26482634 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
2649−
2635+
26502636 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
26512637 inViewServers++;
26522638 }
@@ -2679,20 +2665,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 26 unmodified lines
26792665 if (wantExtraDebugging && unknownJurisdictionServers > 0) {
26802666 qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer);
26812667 }
2682−
2668+
26832669 NodeList* nodeList = NodeList::getInstance();
2684−
2670+
26852671 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
26862672 // only send to the NodeTypes that are serverType
26872673 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
2688−
2689−
2674+
2675+
26902676 // get the server bounds for this server
26912677 QUuid nodeUUID = node->getUUID();
2692−
2678+
26932679 bool inView = false;
26942680 bool unknownView = false;
2695−
2681+
26962682 // if we haven't heard from this voxel server, go ahead and send it a query, so we
26972683 // can get the jurisdiction...
26982684 if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
@@ -2702,15 +2688,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines
27022688 }
27032689 } else {
27042690 const JurisdictionMap& map = (jurisdictions)[nodeUUID];
2705−
2691+
27062692 unsigned char* rootCode = map.getRootOctalCode();
2707−
2693+
27082694 if (rootCode) {
27092695 VoxelPositionSize rootDetails;
27102696 voxelDetailsForCode(rootCode, rootDetails);
27112697 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
27122698 serverBounds.scale(TREE_SCALE);
2713−
2699+
27142700 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
27152701 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
27162702 inView = true;
@@ -2723,7 +2709,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 6 unmodified lines
27232709 }
27242710 }
27252711 }
2726−
2712+
27272713 if (inView) {
27282714 _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS);
27292715 } else if (unknownView) {
@@ -2731,7 +2717,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line
27312717 qDebug() << "no known jurisdiction for node " << *node << ", give it budget of "
27322718 << perUnknownServer << " to send us jurisdiction.";
27332719 }
2734−
2720+
27352721 // set the query's position/orientation to be degenerate in a manner that will get the scene quickly
27362722 // If there's only one server, then don't do this, and just let the normal voxel query pass through
27372723 // as expected... this way, we will actually get a valid scene if there is one to be seen
@@ -2739,8 +2725,8 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line
27392725 _voxelQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1));
27402726 const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0);
27412727 _voxelQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE);
2742− _voxelQuery.setCameraNearClip(0.1);
2743− _voxelQuery.setCameraFarClip(0.1);
2728+ _voxelQuery.setCameraNearClip(0.1f);
2729+ _voxelQuery.setCameraFarClip(0.1f);
27442730 if (wantExtraDebugging) {
27452731 qDebug() << "Using 'minimal' camera position for node" << *node;
27462732 }
@@ -2755,24 +2741,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 8 unmodified lines
27552741 }
27562742 // set up the packet for sending...
27572743 unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
2758−
2744+
27592745 // insert packet type/version and node UUID
27602746 endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType);
27612747 QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
27622748 memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());
27632749 endOfVoxelQueryPacket += ownerUUID.size();
2764−
2750+
27652751 // encode the query data...
27662752 endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);
2767−
2753+
27682754 int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;
2769−
2755+
27702756 // make sure we still have an active socket
27712757 if (node->getActiveSocket()) {
27722758 nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength,
27732759 node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
27742760 }
2775−
2761+
27762762 // Feed number of bytes to corresponding channel of the bandwidth meter
27772763 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);
27782764 }
@@ -2898,9 +2884,9 @@ void Application::setupWorldLight() { · 119 unmodified lines
28982884 glm::vec3 sunDirection = getSunDirection();
28992885 GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 };
29002886 glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
2901− GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
2887+ GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f };
29022888 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
2903− GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
2889+ GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f };
29042890 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
29052891
29062892 glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR);
@@ -2981,7 +2967,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 74 unmodified lines
29812967 glEnable(GL_DEPTH_TEST);
29822968
29832969 // Enable to show line from me to the voxel I am touching
2984− //renderLineToTouchedVoxel();
29852970 //renderThrustAtVoxel(_voxelThrust);
29862971
29872972 if (!selfAvatarOnly) {
@@ -3161,10 +3146,10 @@ void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { · 173 unmodified lines
31613146 translation.z + _viewMatrixTranslation.z);
31623147 }
31633148
3164−void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
3165− float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
3149+void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
3150+ float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
31663151
3167− _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
3152+ _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
31683153 }
31693154
31703155 void Application::displayOverlay() {
@@ -3252,13 +3237,13 @@ void Application::displayOverlay() { · 81 unmodified lines
32523237 char nodes[100];
32533238
32543239 int totalAvatars = 0, totalServers = 0;
3255−
3240+
32563241 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
32573242 node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
32583243 }
32593244
32603245 sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
3261− drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0);
3246+ drawtext(_glWidget->width() - 150, 20, 0.10f, 0, 1.0f, 0, nodes, 1, 0, 0);
32623247 }
32633248
32643249 // testing rendering coverage map
@@ -3280,14 +3265,10 @@ void Application::displayOverlay() { · 15 unmodified lines
32803265 char frameTimer[10];
32813266 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
32823267 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
3283− drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30, 0, 1.0, 0, frameTimer, 0, 0, 0);
3284− drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1);
3268+ drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0);
3269+ drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);
32853270 }
32863271
3287−
3288− // render the webcam input frame
3289− _webcam.renderPreview(_glWidget->width(), _glWidget->height());
3290−
32913272 _palette.render(_glWidget->width(), _glWidget->height());
32923273
32933274 QAction* paintColorAction = NULL;
@@ -3343,6 +3324,7 @@ void Application::displayOverlay() { · 49 unmodified lines
33433324 glPopMatrix();
33443325 }
33453326
3327+
33463328 void Application::displayStats() {
33473329 int statsVerticalOffset = 8;
33483330 const int PELS_PER_LINE = 15;
@@ -3366,7 +3348,7 @@ void Application::displayStats() { · 17 unmodified lines
33663348 // Now handle voxel servers, since there could be more than one, we average their ping times
33673349 unsigned long totalPingVoxel = 0;
33683350 int voxelServerCount = 0;
3369−
3351+
33703352 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
33713353 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
33723354 totalPingVoxel += node->getPingMs();
@@ -3376,7 +3358,7 @@ void Application::displayStats() { · 3 unmodified lines
33763358 }
33773359 }
33783360 }
3379−
3361+
33803362 if (voxelServerCount) {
33813363 pingVoxel = totalPingVoxel/voxelServerCount;
33823364 }
@@ -3524,20 +3506,6 @@ void Application::displayStats() { · 141 unmodified lines
35243506 }
35253507 statsVerticalOffset += PELS_PER_LINE;
35263508 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3527−
3528− if (_perfStatsOn) {
3529− // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
3530− char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1];
3531− int lines = PerfStat::DumpStats(perfStatLinesArray);
3532−
3533− for (int line=0; line < lines; line++) {
3534− statsVerticalOffset += PELS_PER_LINE;
3535− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
3536− delete perfStatLinesArray[line]; // we're responsible for cleanup
3537− perfStatLinesArray[line]=NULL;
3538− }
3539− delete []perfStatLinesArray; // we're responsible for cleanup
3540− }
35413509 }
35423510
35433511 void Application::renderThrustAtVoxel(const glm::vec3& thrust) {
@@ -3552,20 +3520,6 @@ void Application::renderThrustAtVoxel(const glm::vec3& thrust) { · 8 unmodified lines
35523520 }
35533521 }
35543522
3555−void Application::renderLineToTouchedVoxel() {
3556− // Draw a teal line to the voxel I am currently dragging on
3557− if (_mousePressed) {
3558− glColor3f(0, 1, 1);
3559− glLineWidth(2.0f);
3560− glBegin(GL_LINES);
3561− glm::vec3 voxelTouched = getMouseVoxelWorldCoordinates(_mouseVoxelDragging);
3562− glVertex3f(voxelTouched.x, voxelTouched.y, voxelTouched.z);
3563− glm::vec3 headPosition = _myAvatar.getHeadJointPosition();
3564− glVertex3fv(&headPosition.x);
3565− glEnd();
3566− }
3567−}
3568−
35693523
35703524 glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
35713525 float horizontalScale = _glWidget->width() / 2.0f;
@@ -3712,10 +3666,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 140 unmodified lines
37123666 if (!selfAvatarOnly) {
37133667 // Render avatars of other nodes
37143668 NodeList* nodeList = NodeList::getInstance();
3715−
3669+
37163670 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
37173671 QMutexLocker(&node->getMutex());
3718−
3672+
37193673 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
37203674 Avatar *avatar = (Avatar *)node->getLinkedData();
37213675 if (!avatar->isInitialized()) {
@@ -3972,7 +3926,6 @@ void Application::resetSensors() { · 250 unmodified lines
39723926 _headMouseX = _mouseX = _glWidget->width() / 2;
39733927 _headMouseY = _mouseY = _glWidget->height() / 2;
39743928
3975− _webcam.reset();
39763929 _faceshift.reset();
39773930
39783931 if (OculusManager::isConnected()) {
@@ -4063,7 +4016,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 84 unmodified lines
40634016 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
40644017 VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
40654018 fade.voxelDetails = rootDetails;
4066− const float slightly_smaller = 0.99;
4019+ const float slightly_smaller = 0.99f;
40674020 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
40684021 _voxelFades.push_back(fade);
40694022 }
@@ -4094,7 +4047,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines
40944047 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
40954048 VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
40964049 fade.voxelDetails = rootDetails;
4097− const float slightly_smaller = 0.99;
4050+ const float slightly_smaller = 0.99f;
40984051 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
40994052 _voxelFades.push_back(fade);
41004053 }
@@ -4184,7 +4137,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 83 unmodified lines
41844137 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
41854138 VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
41864139 fade.voxelDetails = rootDetails;
4187− const float slightly_smaller = 0.99;
4140+ const float slightly_smaller = 0.99f;
41884141 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
41894142 _voxelFades.push_back(fade);
41904143 }
@@ -4213,28 +4166,28 @@ void Application::processDatagrams() { · 22 unmodified lines
42134166 MAX_PACKET_SIZE,
42144167 senderSockAddr.getAddressPointer(),
42154168 senderSockAddr.getPortPointer()))) {
4216−
4169+
42174170 _packetCount++;
42184171 _bytesCount += bytesReceived;
4219−
4172+
42204173 if (packetVersionMatch(_incomingPacket)) {
42214174 // only process this packet if we have a match on the packet version
42224175 switch (_incomingPacket[0]) {
42234176 case PACKET_TYPE_TRANSMITTER_DATA_V2:
42244177 // V2 = IOS transmitter app
42254178 _myTransmitter.processIncomingData(_incomingPacket, bytesReceived);
4226−
4179+
42274180 break;
42284181 case PACKET_TYPE_MIXED_AUDIO:
42294182 QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
42304183 Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived)));
42314184 break;
4232−
4185+
42334186 case PACKET_TYPE_PARTICLE_ADD_RESPONSE:
42344187 // look up our ParticleEditHanders....
42354188 ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived);
42364189 break;
4237−
4190+
42384191 case PACKET_TYPE_PARTICLE_DATA:
42394192 case PACKET_TYPE_VOXEL_DATA:
42404193 case PACKET_TYPE_VOXEL_ERASE:
@@ -4242,7 +4195,7 @@ void Application::processDatagrams() { · 1 unmodified line
42424195 case PACKET_TYPE_ENVIRONMENT_DATA: {
42434196 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
42444197 "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
4245−
4198+
42464199 bool wantExtraDebugging = getLogger()->extraDebugging();
42474200 if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) {
42484201 int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket);
@@ -4254,10 +4207,10 @@ void Application::processDatagrams() { · 5 unmodified lines
42544207 dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
42554208 VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
42564209 int flightTime = arrivedAt - sentAt;
4257−
4210+
42584211 printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
42594212 }
4260−
4213+
42614214 // add this packet to our list of voxel packets and process them on the voxel processing
42624215 _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived);
42634216 break;
@@ -4275,9 +4228,6 @@ void Application::processDatagrams() { · 11 unmodified lines
42754228 case PACKET_TYPE_AVATAR_URLS:
42764229 processAvatarURLsMessage(_incomingPacket, bytesReceived);
42774230 break;
4278− case PACKET_TYPE_AVATAR_FACE_VIDEO:
4279− processAvatarFaceVideoMessage(_incomingPacket, bytesReceived);
4280− break;
42814231 case PACKET_TYPE_DATA_SERVER_GET:
42824232 case PACKET_TYPE_DATA_SERVER_PUT:
42834233 case PACKET_TYPE_DATA_SERVER_SEND:
@@ -4394,15 +4344,19 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 110 unmodified lines
43944344
43954345 if (_persistThread) {
43964346 _persistThread->terminate();
4347+ _persistThread->deleteLater();
43974348 _persistThread = NULL;
43984349 }
43994350
44004351 QString localVoxelCacheFileName = getLocalVoxelCacheFileName();
44014352 const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds
4402− _persistThread = new OctreePersistThread(_voxels.getTree(),
4403− localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL);
44044353
4405− qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName;
4354+ if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableLocalVoxelCache)) {
4355+ _persistThread = new OctreePersistThread(_voxels.getTree(),
4356+ localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL);
4357+
4358+ qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName;
4359+ }
44064360
44074361 if (_persistThread) {
44084362 _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates

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