History

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

ZappoMan committed 12 years ago

Commit ed0a2a52 parents 08b06cc c58f44f159 files · +2506 −2422Browse files

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

Unified · Split

interface/src/Application.cpp+157−171
@@ -50,7 +50,6 @@ · 49 unmodified lines
5050 #include <QMediaPlayer>
5151
5252 #include <AudioInjector.h>
53−#include <NodeTypes.h>
5453 #include <Logging.h>
5554 #include <OctalCode.h>
5655 #include <PacketHeaders.h>
@@ -122,6 +121,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 65 unmodified lines
122121 _wantToKillLocalVoxels(false),
123122 _audioScope(256, 200, true),
124123 _avatarManager(),
124+ _myAvatar(NULL),
125125 _profile(QString()),
126126 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
127127 _mouseX(0),
@@ -158,6 +158,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 30 unmodified lines
158158 _logger(new FileLogger()),
159159 _persistThread(NULL)
160160 {
161+ _myAvatar = _avatarManager.getMyAvatar();
162+
161163 _applicationStartupTime = startup_time;
162164
163165 switchToResourcesParentIfRequired();
@@ -183,7 +185,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 19 unmodified lines
183185 _nodeThread->setPriority(QThread::TimeCriticalPriority);
184186
185187 // put the NodeList and datagram processing on the node thread
186− NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
188+ NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort);
187189
188190 nodeList->moveToThread(_nodeThread);
189191 _datagramProcessor.moveToThread(_nodeThread);
@@ -230,9 +232,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 40 unmodified lines
230232 #endif
231233
232234 // tell the NodeList instance who to tell the domain server we care about
233− nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
234− << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
235− << NODE_TYPE_METAVOXEL_SERVER);
235+ nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
236+ << NodeType::VoxelServer << NodeType::ParticleServer
237+ << NodeType::MetavoxelServer);
236238
237239 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
238240 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
@@ -328,6 +330,9 @@ Application::~Application() { · 89 unmodified lines
328330 VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
329331 Menu::getInstance()->deleteLater();
330332
333+ _avatarManager.clear();
334+ _myAvatar = NULL;
335+
331336 delete _logger;
332337 delete _settings;
333338 delete _glWidget;
@@ -442,25 +447,25 @@ void Application::paintGL() { · 108 unmodified lines
442447 _myCamera.setUpShift (0.0f);
443448 _myCamera.setDistance (0.0f);
444449 _myCamera.setTightness (0.0f); // Camera is directly connected to head without smoothing
445− _myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
446− _myCamera.setTargetRotation(_myAvatar.getHead().getOrientation());
450+ _myCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition());
451+ _myCamera.setTargetRotation(_myAvatar->getHead().getOrientation());
447452
448453 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
449454 _myCamera.setTightness(0.0f); // In first person, camera follows head exactly without delay
450− _myCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
451− _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
455+ _myCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition());
456+ _myCamera.setTargetRotation(_myAvatar->getHead().getCameraOrientation());
452457
453458 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
454459 _myCamera.setTightness (0.0f); // Camera is directly connected to head without smoothing
455− _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition());
456− _myCamera.setTargetRotation(_myAvatar.getHead().getCameraOrientation());
460+ _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());
461+ _myCamera.setTargetRotation(_myAvatar->getHead().getCameraOrientation());
457462
458463 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
459464 _myCamera.setTightness(0.0f);
460− float headHeight = _myAvatar.getHead().calculateAverageEyePosition().y - _myAvatar.getPosition().y;
461− _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar.getScale());
462− _myCamera.setTargetPosition(_myAvatar.getPosition() + glm::vec3(0, headHeight, 0));
463− _myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
465+ float headHeight = _myAvatar->getHead().calculateAverageEyePosition().y - _myAvatar->getPosition().y;
466+ _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
467+ _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
468+ _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
464469 }
465470
466471 // Update camera position
@@ -517,22 +522,22 @@ void Application::paintGL() { · 50 unmodified lines
517522
518523 bool eyeRelativeCamera = false;
519524 if (_rearMirrorTools->getZoomLevel() == BODY) {
520− _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale());
521− _mirrorCamera.setTargetPosition(_myAvatar.getChestPosition());
525+ _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
526+ _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());
522527 } else { // HEAD zoom level
523− _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale());
524− if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) {
528+ _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
529+ if (_myAvatar->getSkeletonModel().isActive() && _myAvatar->getHead().getFaceModel().isActive()) {
525530 // as a hack until we have a better way of dealing with coordinate precision issues, reposition the
526531 // face/body so that the average eye position lies at the origin
527532 eyeRelativeCamera = true;
528533 _mirrorCamera.setTargetPosition(glm::vec3());
529534
530535 } else {
531− _mirrorCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition());
536+ _mirrorCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition());
532537 }
533538 }
534539
535− _mirrorCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
540+ _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
536541 _mirrorCamera.update(1.0f/_fps);
537542
538543 // set the bounds of rear mirror view
@@ -549,27 +554,27 @@ void Application::paintGL() { · 10 unmodified lines
549554 glPushMatrix();
550555 if (eyeRelativeCamera) {
551556 // save absolute translations
552− glm::vec3 absoluteSkeletonTranslation = _myAvatar.getSkeletonModel().getTranslation();
553− glm::vec3 absoluteFaceTranslation = _myAvatar.getHead().getFaceModel().getTranslation();
557+ glm::vec3 absoluteSkeletonTranslation = _myAvatar->getSkeletonModel().getTranslation();
558+ glm::vec3 absoluteFaceTranslation = _myAvatar->getHead().getFaceModel().getTranslation();
554559
555560 // get the eye positions relative to the neck and use them to set the face translation
556561 glm::vec3 leftEyePosition, rightEyePosition;
557− _myAvatar.getHead().getFaceModel().setTranslation(glm::vec3());
558− _myAvatar.getHead().getFaceModel().getEyePositions(leftEyePosition, rightEyePosition);
559− _myAvatar.getHead().getFaceModel().setTranslation((leftEyePosition + rightEyePosition) * -0.5f);
562+ _myAvatar->getHead().getFaceModel().setTranslation(glm::vec3());
563+ _myAvatar->getHead().getFaceModel().getEyePositions(leftEyePosition, rightEyePosition);
564+ _myAvatar->getHead().getFaceModel().setTranslation((leftEyePosition + rightEyePosition) * -0.5f);
560565
561566 // get the neck position relative to the body and use it to set the skeleton translation
562567 glm::vec3 neckPosition;
563− _myAvatar.getSkeletonModel().setTranslation(glm::vec3());
564− _myAvatar.getSkeletonModel().getNeckPosition(neckPosition);
565− _myAvatar.getSkeletonModel().setTranslation(_myAvatar.getHead().getFaceModel().getTranslation() -
568+ _myAvatar->getSkeletonModel().setTranslation(glm::vec3());
569+ _myAvatar->getSkeletonModel().getNeckPosition(neckPosition);
570+ _myAvatar->getSkeletonModel().setTranslation(_myAvatar->getHead().getFaceModel().getTranslation() -
566571 neckPosition);
567572
568573 displaySide(_mirrorCamera, true);
569574
570575 // restore absolute translations
571− _myAvatar.getSkeletonModel().setTranslation(absoluteSkeletonTranslation);
572− _myAvatar.getHead().getFaceModel().setTranslation(absoluteFaceTranslation);
576+ _myAvatar->getSkeletonModel().setTranslation(absoluteSkeletonTranslation);
577+ _myAvatar->getHead().getFaceModel().setTranslation(absoluteFaceTranslation);
573578 } else {
574579 displaySide(_mirrorCamera, true);
575580 }
@@ -651,32 +656,30 @@ void Application::resetProfile(const QString& username) { · 75 unmodified lines
651656 updateWindowTitle();
652657 }
653658
654−void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
655− const QSet<NODE_TYPE>& destinationNodeTypes) {
656− foreach(NODE_TYPE type, destinationNodeTypes) {
659+void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
660+ foreach(NodeType_t type, destinationNodeTypes) {
657661 // Intercept data to voxel server when voxels are disabled
658− if (type == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
662+ if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
659663 continue;
660664 }
661665
662666 // Perform the broadcast for one type
663− int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes,
664− QSet<NODE_TYPE>() << type);
667+ int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type);
665668
666669 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
667670 BandwidthMeter::ChannelIndex channel;
668671 switch (type) {
669− case NODE_TYPE_AGENT:
670− case NODE_TYPE_AVATAR_MIXER:
672+ case NodeType::Agent:
673+ case NodeType::AvatarMixer:
671674 channel = BandwidthMeter::AVATARS;
672675 break;
673− case NODE_TYPE_VOXEL_SERVER:
676+ case NodeType::VoxelServer:
674677 channel = BandwidthMeter::VOXELS;
675678 break;
676679 default:
677680 continue;
678681 }
679− _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
682+ _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * packet.size());
680683 }
681684 }
682685
@@ -692,12 +695,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 9 unmodified lines
692695 if (activeWindow() == _window) {
693696 if (_chatEntryOn) {
694697 if (_chatEntry.keyPressEvent(event)) {
695− _myAvatar.setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
698+ _myAvatar->setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
696699 DELETE_KEY_DOWN : INSERT_KEY_DOWN);
697− _myAvatar.setChatMessage(string(_chatEntry.getContents().size(), SOLID_BLOCK_CHAR));
700+ _myAvatar->setChatMessage(string(_chatEntry.getContents().size(), SOLID_BLOCK_CHAR));
698701
699702 } else {
700− _myAvatar.setChatMessage(_chatEntry.getContents());
703+ _myAvatar->setChatMessage(_chatEntry.getContents());
701704 _chatEntry.clear();
702705 _chatEntryOn = false;
703706 setMenuShortcutsEnabled(true);
@@ -741,10 +744,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 37 unmodified lines
741744 if (_nudgeStarted) {
742745 _nudgeGuidePosition.y += _mouseVoxel.s;
743746 } else {
744− if (!_myAvatar.getDriveKeys(UP)) {
745− _myAvatar.jump();
747+ if (!_myAvatar->getDriveKeys(UP)) {
748+ _myAvatar->jump();
746749 }
747− _myAvatar.setDriveKeys(UP, 1);
750+ _myAvatar->setDriveKeys(UP, 1);
748751 }
749752 break;
750753
@@ -756,7 +759,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
756759 if (_nudgeStarted) {
757760 _nudgeGuidePosition.y -= _mouseVoxel.s;
758761 } else {
759− _myAvatar.setDriveKeys(DOWN, 1);
762+ _myAvatar->setDriveKeys(DOWN, 1);
760763 }
761764 break;
762765
@@ -776,7 +779,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines
776779 }
777780 }
778781 } else {
779− _myAvatar.setDriveKeys(FWD, 1);
782+ _myAvatar->setDriveKeys(FWD, 1);
780783 }
781784 break;
782785
@@ -802,7 +805,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 19 unmodified lines
802805 }
803806 }
804807 } else {
805− _myAvatar.setDriveKeys(BACK, 1);
808+ _myAvatar->setDriveKeys(BACK, 1);
806809 }
807810 break;
808811
@@ -836,7 +839,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 27 unmodified lines
836839 }
837840 }
838841 } else {
839− _myAvatar.setDriveKeys(ROT_LEFT, 1);
842+ _myAvatar->setDriveKeys(ROT_LEFT, 1);
840843 }
841844 break;
842845
@@ -856,7 +859,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines
856859 }
857860 }
858861 } else {
859− _myAvatar.setDriveKeys(ROT_RIGHT, 1);
862+ _myAvatar->setDriveKeys(ROT_RIGHT, 1);
860863 }
861864 break;
862865
@@ -866,8 +869,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
866869 nudgeVoxels();
867870 } else {
868871 _chatEntryOn = true;
869− _myAvatar.setKeyState(NO_KEY_DOWN);
870− _myAvatar.setChatMessage(string());
872+ _myAvatar->setKeyState(NO_KEY_DOWN);
873+ _myAvatar->setChatMessage(string());
871874 setMenuShortcutsEnabled(false);
872875 }
873876 break;
@@ -890,7 +893,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 16 unmodified lines
890893 } else if (_nudgeStarted && isShifted) {
891894 _nudgeGuidePosition.y += _mouseVoxel.s;
892895 } else {
893− _myAvatar.setDriveKeys(isShifted ? UP : FWD, 1);
896+ _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1);
894897 }
895898 break;
896899
@@ -912,7 +915,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 15 unmodified lines
912915 } else if (_nudgeStarted && isShifted) {
913916 _nudgeGuidePosition.y -= _mouseVoxel.s;
914917 } else {
915− _myAvatar.setDriveKeys(isShifted ? DOWN : BACK, 1);
918+ _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1);
916919 }
917920 break;
918921
@@ -932,7 +935,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines
932935 }
933936 }
934937 } else {
935− _myAvatar.setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1);
938+ _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1);
936939 }
937940 break;
938941
@@ -952,7 +955,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines
952955 }
953956 }
954957 } else {
955− _myAvatar.setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1);
958+ _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1);
956959 }
957960 break;
958961
@@ -1070,13 +1073,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 111 unmodified lines
10701073 }
10711074 break;
10721075 case Qt::Key_Plus:
1073− _myAvatar.increaseSize();
1076+ _myAvatar->increaseSize();
10741077 break;
10751078 case Qt::Key_Minus:
1076− _myAvatar.decreaseSize();
1079+ _myAvatar->decreaseSize();
10771080 break;
10781081 case Qt::Key_Equal:
1079− _myAvatar.resetSize();
1082+ _myAvatar->resetSize();
10801083 break;
10811084
10821085 case Qt::Key_1:
@@ -1111,7 +1114,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 28 unmodified lines
11111114
11121115 if (activeWindow() == _window) {
11131116 if (_chatEntryOn) {
1114− _myAvatar.setKeyState(NO_KEY_DOWN);
1117+ _myAvatar->setKeyState(NO_KEY_DOWN);
11151118 return;
11161119 }
11171120
@@ -1120,47 +1123,47 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 2 unmodified lines
11201123 _pasteMode = false;
11211124 break;
11221125 case Qt::Key_E:
1123− _myAvatar.setDriveKeys(UP, 0);
1126+ _myAvatar->setDriveKeys(UP, 0);
11241127 break;
11251128
11261129 case Qt::Key_C:
1127− _myAvatar.setDriveKeys(DOWN, 0);
1130+ _myAvatar->setDriveKeys(DOWN, 0);
11281131 break;
11291132
11301133 case Qt::Key_W:
1131− _myAvatar.setDriveKeys(FWD, 0);
1134+ _myAvatar->setDriveKeys(FWD, 0);
11321135 break;
11331136
11341137 case Qt::Key_S:
1135− _myAvatar.setDriveKeys(BACK, 0);
1138+ _myAvatar->setDriveKeys(BACK, 0);
11361139 break;
11371140
11381141 case Qt::Key_A:
1139− _myAvatar.setDriveKeys(ROT_LEFT, 0);
1142+ _myAvatar->setDriveKeys(ROT_LEFT, 0);
11401143 break;
11411144
11421145 case Qt::Key_D:
1143− _myAvatar.setDriveKeys(ROT_RIGHT, 0);
1146+ _myAvatar->setDriveKeys(ROT_RIGHT, 0);
11441147 break;
11451148
11461149 case Qt::Key_Up:
1147− _myAvatar.setDriveKeys(FWD, 0);
1148− _myAvatar.setDriveKeys(UP, 0);
1150+ _myAvatar->setDriveKeys(FWD, 0);
1151+ _myAvatar->setDriveKeys(UP, 0);
11491152 break;
11501153
11511154 case Qt::Key_Down:
1152− _myAvatar.setDriveKeys(BACK, 0);
1153− _myAvatar.setDriveKeys(DOWN, 0);
1155+ _myAvatar->setDriveKeys(BACK, 0);
1156+ _myAvatar->setDriveKeys(DOWN, 0);
11541157 break;
11551158
11561159 case Qt::Key_Left:
1157− _myAvatar.setDriveKeys(LEFT, 0);
1158− _myAvatar.setDriveKeys(ROT_LEFT, 0);
1160+ _myAvatar->setDriveKeys(LEFT, 0);
1161+ _myAvatar->setDriveKeys(ROT_LEFT, 0);
11591162 break;
11601163
11611164 case Qt::Key_Right:
1162− _myAvatar.setDriveKeys(RIGHT, 0);
1163− _myAvatar.setDriveKeys(ROT_RIGHT, 0);
1165+ _myAvatar->setDriveKeys(RIGHT, 0);
1166+ _myAvatar->setDriveKeys(ROT_RIGHT, 0);
11641167 break;
11651168
11661169 default:
@@ -1195,11 +1198,11 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 28 unmodified lines
11951198 // orbit behavior
11961199 if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) {
11971200 if (_avatarManager.getLookAtTargetAvatar()) {
1198− _myAvatar.orbit(_avatarManager.getLookAtTargetAvatar()->getPosition(), deltaX, deltaY);
1201+ _myAvatar->orbit(_avatarManager.getLookAtTargetAvatar()->getPosition(), deltaX, deltaY);
11991202 return;
12001203 }
12011204 if (_isHoverVoxel) {
1202− _myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
1205+ _myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
12031206 return;
12041207 }
12051208 }
@@ -1282,14 +1285,14 @@ void Application::mousePressEvent(QMouseEvent* event) { · 76 unmodified lines
12821285
12831286 const float PERCENTAGE_TO_MOVE_TOWARD = 0.90f;
12841287 glm::vec3 newTarget = getMouseVoxelWorldCoordinates(_hoverVoxel);
1285− glm::vec3 myPosition = _myAvatar.getPosition();
1288+ glm::vec3 myPosition = _myAvatar->getPosition();
12861289
12871290 // If there is not an action tool set (add, delete, color), move to this voxel
12881291 if (Menu::getInstance()->isOptionChecked(MenuOption::ClickToFly) &&
12891292 !(Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) ||
12901293 Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode) ||
12911294 Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode))) {
1292− _myAvatar.setMoveTarget(myPosition + (newTarget - myPosition) * PERCENTAGE_TO_MOVE_TOWARD);
1295+ _myAvatar->setMoveTarget(myPosition + (newTarget - myPosition) * PERCENTAGE_TO_MOVE_TOWARD);
12931296 }
12941297 }
12951298
@@ -1409,13 +1412,11 @@ void Application::wheelEvent(QWheelEvent* event) { · 113 unmodified lines
14091412 }
14101413
14111414 void Application::sendPingPackets() {
1412− unsigned char pingPacket[MAX_PACKET_SIZE];
1413− int length = NodeList::getInstance()->fillPingPacket(pingPacket);
1414−
1415− getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>()
1416− << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
1417− << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
1418− << NODE_TYPE_METAVOXEL_SERVER);
1415+ QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
1416+ getInstance()->controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
1417+ << NodeType::ParticleServer
1418+ << NodeType::AudioMixer << NodeType::AvatarMixer
1419+ << NodeType::MetavoxelServer);
14191420 }
14201421
14211422 // Every second, check the frame rates and other stuff
@@ -1443,8 +1444,8 @@ void Application::timer() { · 21 unmodified lines
14431444 DataServerClient::resendUnmatchedPackets();
14441445
14451446 // give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server
1446− _profile.updatePosition(_myAvatar.getPosition());
1447− _profile.updateOrientation(_myAvatar.getOrientation());
1447+ _profile.updatePosition(_myAvatar->getPosition());
1448+ _profile.updateOrientation(_myAvatar->getOrientation());
14481449 }
14491450
14501451 static glm::vec3 getFaceVector(BoxFace face) {
@@ -1553,7 +1554,7 @@ void Application::removeVoxel(glm::vec3 position, · 102 unmodified lines
15531554 voxel.y = position.y / TREE_SCALE;
15541555 voxel.z = position.z / TREE_SCALE;
15551556 voxel.s = scale / TREE_SCALE;
1556− _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_VOXEL_ERASE, voxel);
1557+ _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel);
15571558
15581559 // delete it locally to see the effect immediately (and in case no voxel server is present)
15591560 _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
@@ -1574,7 +1575,7 @@ void Application::makeVoxel(glm::vec3 position, · 14 unmodified lines
15741575 voxel.red = red;
15751576 voxel.green = green;
15761577 voxel.blue = blue;
1577− PACKET_TYPE message = isDestructive ? PACKET_TYPE_VOXEL_SET_DESTRUCTIVE : PACKET_TYPE_VOXEL_SET;
1578+ PacketType message = isDestructive ? PacketTypeVoxelSetDestructive : PacketTypeVoxelSet;
15781579 _voxelEditSender.sendVoxelEditMessage(message, voxel);
15791580
15801581 // create the voxel locally so it appears immediately
@@ -1644,7 +1645,7 @@ bool Application::sendVoxelsOperation(OctreeElement* element, void* extraData) { · 63 unmodified lines
16441645 codeColorBuffer[bytesInCode + RED_INDEX] = voxel->getColor()[RED_INDEX];
16451646 codeColorBuffer[bytesInCode + GREEN_INDEX] = voxel->getColor()[GREEN_INDEX];
16461647 codeColorBuffer[bytesInCode + BLUE_INDEX] = voxel->getColor()[BLUE_INDEX];
1647− getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_VOXEL_SET_DESTRUCTIVE,
1648+ getInstance()->_voxelEditSender.queueVoxelEditMessage(PacketTypeVoxelSetDestructive,
16481649 codeColorBuffer, codeAndColorLength);
16491650
16501651 delete[] codeColorBuffer;
@@ -1739,7 +1740,7 @@ void Application::pasteVoxels() { · 88 unmodified lines
17391740 }
17401741
17411742 void Application::findAxisAlignment() {
1742− glm::vec3 direction = _myAvatar.getMouseRayDirection();
1743+ glm::vec3 direction = _myAvatar->getMouseRayDirection();
17431744 if (fabs(direction.z) > fabs(direction.x)) {
17441745 _lookingAlongX = false;
17451746 if (direction.z < 0) {
@@ -1825,12 +1826,10 @@ void Application::init() { · 79 unmodified lines
18251826 _headMouseY = _mouseY = _glWidget->height() / 2;
18261827 QCursor::setPos(_headMouseX, _headMouseY);
18271828
1828− _myAvatar.init();
1829− _myAvatar.setPosition(START_LOCATION);
1829+ // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
1830+ _avatarManager.init();
18301831 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
18311832 _myCamera.setModeShiftRate(1.0f);
1832− _myAvatar.setDisplayingLookatVectors(false);
1833− _avatarManager.setMyAvatar(&_myAvatar);
18341833
18351834 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
18361835 _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);
@@ -1946,9 +1945,9 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 109 unmodified lines
19461945
19471946 bool Application::isLookingAtMyAvatar(Avatar* avatar) {
19481947 glm::vec3 theirLookat = avatar->getHead().getLookAtPosition();
1949− glm::vec3 myHeadPosition = _myAvatar.getHead().getPosition();
1948+ glm::vec3 myHeadPosition = _myAvatar->getHead().getPosition();
19501949
1951− if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar.getScale())) {
1950+ if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
19521951 return true;
19531952 }
19541953 return false;
@@ -1986,10 +1985,10 @@ void Application::updateMouseRay() { · 31 unmodified lines
19861985 }
19871986
19881987 // tell my avatar if the mouse is being pressed...
1989− _myAvatar.setMousePressed(_mousePressed);
1988+ _myAvatar->setMousePressed(_mousePressed);
19901989
19911990 // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position
1992− _myAvatar.setMouseRay(_mouseRayOrigin, _mouseRayDirection);
1991+ _myAvatar->setMouseRay(_mouseRayOrigin, _mouseRayDirection);
19931992 }
19941993
19951994 void Application::updateFaceshift() {
@@ -2002,7 +2001,7 @@ void Application::updateFaceshift() { · 6 unmodified lines
20022001
20032002 // Copy angular velocity if measured by faceshift, to the head
20042003 if (_faceshift.isActive()) {
2005− _myAvatar.getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity());
2004+ _myAvatar->getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity());
20062005 }
20072006 }
20082007
@@ -2026,14 +2025,14 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { · 17 unmodified lines
20262025 }
20272026 if (_faceshift.isActive()) {
20282027 // deflect using Faceshift gaze data
2029− glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition();
2028+ glm::vec3 origin = _myAvatar->getHead().calculateAverageEyePosition();
20302029 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
20312030 float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
20322031 lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3(
20332032 _faceshift.getEstimatedEyePitch() * pitchSign * deflection, _faceshift.getEstimatedEyeYaw() * deflection, 0.0f))) *
20342033 glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
20352034 }
2036− _myAvatar.getHead().setLookAtPosition(lookAtSpot);
2035+ _myAvatar->getHead().setLookAtPosition(lookAtSpot);
20372036 }
20382037
20392038 void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) {
@@ -2091,9 +2090,9 @@ void Application::updateMouseVoxels(float deltaTime, float& distance, BoxFace& f · 51 unmodified lines
20912090 _mouseVoxel.s = 0.0f;
20922091 bool wasInitialized = _mouseVoxelScaleInitialized;
20932092 if (Menu::getInstance()->isVoxelModeActionChecked() &&
2094− (fabs(_myAvatar.getVelocity().x) +
2095− fabs(_myAvatar.getVelocity().y) +
2096− fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
2093+ (fabs(_myAvatar->getVelocity().x) +
2094+ fabs(_myAvatar->getVelocity().y) +
2095+ fabs(_myAvatar->getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
20972096
20982097 if (_voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _mouseVoxel, distance, face)) {
20992098 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
@@ -2225,16 +2224,16 @@ void Application::updateMyAvatarSimulation(float deltaTime) { · 125 unmodified lines
22252224 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarSimulation()");
22262225
22272226 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
2228− _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
2227+ _myAvatar->setGravity(_environment.getGravity(_myAvatar->getPosition()));
22292228 }
22302229 else {
2231− _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
2230+ _myAvatar->setGravity(glm::vec3(0.0f, 0.0f, 0.0f));
22322231 }
22332232
22342233 if (Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
2235− _myAvatar.simulate(deltaTime, &_myTransmitter);
2234+ _myAvatar->simulate(deltaTime, &_myTransmitter);
22362235 } else {
2237− _myAvatar.simulate(deltaTime, NULL);
2236+ _myAvatar->simulate(deltaTime, NULL);
22382237 }
22392238 }
22402239
@@ -2262,8 +2261,8 @@ void Application::updateTransmitter(float deltaTime) { · 21 unmodified lines
22622261
22632262 // no transmitter drive implies transmitter pick
22642263 if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
2265− _transmitterPickStart = _myAvatar.getChestPosition();
2266− glm::vec3 direction = _myAvatar.getOrientation() *
2264+ _transmitterPickStart = _myAvatar->getChestPosition();
2265+ glm::vec3 direction = _myAvatar->getOrientation() *
22672266 glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT;
22682267
22692268 // check against voxels, avatars
@@ -2337,8 +2336,8 @@ void Application::updateAudio(float deltaTime) { · 67 unmodified lines
23372336 PerformanceWarning warn(showWarnings, "Application::updateAudio()");
23382337
23392338 // Update audio stats for procedural sounds
2340− _audio.setLastAcceleration(_myAvatar.getThrust());
2341− _audio.setLastVelocity(_myAvatar.getVelocity());
2339+ _audio.setLastAcceleration(_myAvatar->getThrust());
2340+ _audio.setLastVelocity(_myAvatar->getVelocity());
23422341 }
23432342
23442343 void Application::updateCursor(float deltaTime) {
@@ -2348,7 +2347,7 @@ void Application::updateCursor(float deltaTime) { · 3 unmodified lines
23482347 // watch mouse position, if it hasn't moved, hide the cursor
23492348 bool underMouse = _glWidget->underMouse();
23502349 if (!_mouseHidden) {
2351− uint64_t now = usecTimestampNow();
2350+ quint64 now = usecTimestampNow();
23522351 int elapsed = now - _lastMouseMove;
23532352 const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second
23542353 if (elapsed > HIDE_CURSOR_TIMEOUT && (underMouse || !_seenMouseMove)) {
@@ -2410,16 +2409,16 @@ void Application::updateAvatar(float deltaTime) { · 55 unmodified lines
24102409 PerformanceWarning warn(showWarnings, "Application::updateAvatar()");
24112410
24122411 // rotate body yaw for yaw received from multitouch
2413− _myAvatar.setOrientation(_myAvatar.getOrientation()
2412+ _myAvatar->setOrientation(_myAvatar->getOrientation()
24142413 * glm::quat(glm::vec3(0, _yawFromTouch, 0)));
24152414 _yawFromTouch = 0.f;
24162415
24172416 // apply pitch from touch
2418− _myAvatar.getHead().setPitch(_myAvatar.getHead().getPitch() + _pitchFromTouch);
2417+ _myAvatar->getHead().setPitch(_myAvatar->getHead().getPitch() + _pitchFromTouch);
24192418 _pitchFromTouch = 0.0f;
24202419
24212420 // Update my avatar's state from gyros
2422− _myAvatar.updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
2421+ _myAvatar->updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
24232422
24242423 // Update head mouse from faceshift if active
24252424 if (_faceshift.isActive()) {
@@ -2440,27 +2439,19 @@ void Application::updateAvatar(float deltaTime) { · 14 unmodified lines
24402439 float yaw, pitch, roll;
24412440 OculusManager::getEulerAngles(yaw, pitch, roll);
24422441
2443− _myAvatar.getHead().setYaw(yaw);
2444− _myAvatar.getHead().setPitch(pitch);
2445− _myAvatar.getHead().setRoll(roll);
2442+ _myAvatar->getHead().setYaw(yaw);
2443+ _myAvatar->getHead().setPitch(pitch);
2444+ _myAvatar->getHead().setRoll(roll);
24462445 }
24472446
24482447 // Get audio loudness data from audio input device
2449− _myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness());
2448+ _myAvatar->getHead().setAudioLoudness(_audio.getLastInputLoudness());
24502449
24512450 // send head/hand data to the avatar mixer and voxel server
2452− unsigned char broadcastString[MAX_PACKET_SIZE];
2453− unsigned char* endOfBroadcastStringWrite = broadcastString;
2454−
2455− endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA);
2451+ QByteArray avatarData = byteArrayWithPopluatedHeader(PacketTypeAvatarData);
2452+ avatarData.append(_myAvatar->toByteArray());
24562453
2457− // pack the NodeList owner UUID
2458− endOfBroadcastStringWrite += NodeList::getInstance()->packOwnerUUID(endOfBroadcastStringWrite);
2459−
2460− endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
2461−
2462− controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
2463− QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
2454+ controlledBroadcastToNodes(avatarData, NodeSet() << NodeType::AvatarMixer);
24642455
24652456 // Update _viewFrustum with latest camera and view frustum data...
24662457 // NOTE: we get this from the view frustum, to make it simpler, since the
@@ -2471,11 +2462,11 @@ void Application::updateAvatar(float deltaTime) { · 4 unmodified lines
24712462 loadViewFrustum(_myCamera, _viewFrustum);
24722463
24732464 // Update my voxel servers with my current voxel query...
2474− queryOctree(NODE_TYPE_VOXEL_SERVER, PACKET_TYPE_VOXEL_QUERY, _voxelServerJurisdictions);
2475− queryOctree(NODE_TYPE_PARTICLE_SERVER, PACKET_TYPE_PARTICLE_QUERY, _particleServerJurisdictions);
2465+ queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions);
2466+ queryOctree(NodeType::ParticleServer, PacketTypeParticleQuery, _particleServerJurisdictions);
24762467 }
24772468
2478−void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, NodeToJurisdictionMap& jurisdictions) {
2469+void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
24792470
24802471 // if voxels are disabled, then don't send this at all...
24812472 if (!Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
@@ -2643,10 +2634,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 161 unmodified lines
26432634 unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
26442635
26452636 // insert packet type/version and node UUID
2646− endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType);
2647− QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
2648− memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());
2649− endOfVoxelQueryPacket += ownerUUID.size();
2637+ endOfVoxelQueryPacket += populatePacketHeader(reinterpret_cast<char*>(endOfVoxelQueryPacket), packetType);
26502638
26512639 // encode the query data...
26522640 endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);
@@ -3157,7 +3145,7 @@ void Application::displayOverlay() { · 504 unmodified lines
31573145 // Show on-screen msec timer
31583146 if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) {
31593147 char frameTimer[10];
3160− uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
3148+ quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
31613149 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
31623150 int timerBottom =
31633151 (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
@@ -3248,10 +3236,8 @@ void Application::displayStats() { · 84 unmodified lines
32483236
32493237 glPointSize(1.0f);
32503238
3251− int totalAvatars = 0, totalServers = 0;
3252− foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
3253− node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
3254− }
3239+ int totalAvatars = _avatarManager.size();
3240+ int totalServers = NodeList::getInstance()->size();
32553241
32563242 if (mirrorEnabled) {
32573243 horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
@@ -3294,8 +3280,8 @@ void Application::displayStats() { · 36 unmodified lines
32943280 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
32953281
32963282 NodeList* nodeList = NodeList::getInstance();
3297− SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3298− SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3283+ SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NodeType::AudioMixer);
3284+ SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NodeType::AvatarMixer);
32993285
33003286 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
33013287 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
@@ -3305,7 +3291,7 @@ void Application::displayStats() { · 3 unmodified lines
33053291 int voxelServerCount = 0;
33063292
33073293 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
3308− if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
3294+ if (node->getType() == NodeType::VoxelServer) {
33093295 totalPingVoxel += node->getPingMs();
33103296 voxelServerCount++;
33113297 if (pingVoxelMax < node->getPingMs()) {
@@ -3348,7 +3334,7 @@ void Application::displayStats() { · 36 unmodified lines
33483334 horizontalOffset += 171;
33493335 }
33503336
3351− glm::vec3 avatarPos = _myAvatar.getPosition();
3337+ glm::vec3 avatarPos = _myAvatar->getPosition();
33523338
33533339 lines = _statsExpanded ? 4 : 3;
33543340 displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - (mirrorEnabled ? 301 : 411) - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
@@ -3363,9 +3349,9 @@ void Application::displayStats() { · 8 unmodified lines
33633349 sprintf(avatarPosition, "Position: %.3f, %.3f, %.3f", avatarPos.x, avatarPos.y, avatarPos.z);
33643350 }
33653351 char avatarVelocity[30];
3366− sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar.getVelocity()));
3352+ sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity()));
33673353 char avatarBodyYaw[30];
3368− sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar.getBodyYaw());
3354+ sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar->getBodyYaw());
33693355 char avatarMixerStats[200];
33703356
33713357 verticalOffset += STATS_PELS_PER_LINE;
@@ -3376,7 +3362,7 @@ void Application::displayStats() { · 4 unmodified lines
33763362 drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarBodyYaw, .93f, .93f, .93f);
33773363
33783364 if (_statsExpanded) {
3379− SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3365+ SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer);
33803366 if (avatarMixer) {
33813367 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
33823368 roundf(avatarMixer->getAverageKilobitsPerSecond()),
@@ -3950,7 +3936,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 567 unmodified lines
39503936 void Application::deleteVoxelUnderCursor() {
39513937 if (_mouseVoxel.s != 0) {
39523938 // sending delete to the server is sufficient, server will send new version so we see updates soon enough
3953− _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_VOXEL_ERASE, _mouseVoxel);
3939+ _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, _mouseVoxel);
39543940
39553941 // delete it locally to see the effect immediately (and in case no voxel server is present)
39563942 _voxels.deleteVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
@@ -3986,10 +3972,10 @@ void Application::resetSensors() { · 29 unmodified lines
39863972 }
39873973
39883974 QCursor::setPos(_headMouseX, _headMouseY);
3989− _myAvatar.reset();
3975+ _myAvatar->reset();
39903976 _myTransmitter.resetLevels();
3991− _myAvatar.setVelocity(glm::vec3(0,0,0));
3992− _myAvatar.setThrust(glm::vec3(0,0,0));
3977+ _myAvatar->setVelocity(glm::vec3(0,0,0));
3978+ _myAvatar->setThrust(glm::vec3(0,0,0));
39933979
39943980 QMetaObject::invokeMethod(&_audio, "reset", Qt::QueuedConnection);
39953981 }
@@ -4054,7 +4040,7 @@ void Application::domainChanged(const QString& domainHostname) { · 58 unmodified lines
40544040 }
40554041
40564042 void Application::nodeKilled(SharedNodePointer node) {
4057− if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
4043+ if (node->getType() == NodeType::VoxelServer) {
40584044 QUuid nodeUUID = node->getUUID();
40594045 // see if this is the first we've heard of this node...
40604046 if (_voxelServerJurisdictions.find(nodeUUID) != _voxelServerJurisdictions.end()) {
@@ -4085,7 +4071,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines
40854071 }
40864072 _voxelSceneStatsLock.unlock();
40874073
4088− } else if (node->getType() == NODE_TYPE_PARTICLE_SERVER) {
4074+ } else if (node->getType() == NodeType::ParticleServer) {
40894075 QUuid nodeUUID = node->getUUID();
40904076 // see if this is the first we've heard of this node...
40914077 if (_particleServerJurisdictions.find(nodeUUID) != _particleServerJurisdictions.end()) {
@@ -4116,14 +4102,13 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines
41164102 }
41174103 _voxelSceneStatsLock.unlock();
41184104
4119− } else if (node->getType() == NODE_TYPE_AVATAR_MIXER) {
4105+ } else if (node->getType() == NodeType::AvatarMixer) {
41204106 // our avatar mixer has gone away - clear the hash of avatars
4121− _avatarManager.clearHash();
4107+ _avatarManager.clearMixedAvatars();
41224108 }
41234109 }
41244110
4125−void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t messageLength,
4126− const HifiSockAddr& senderSockAddr, bool wasStatsPacket) {
4111+void Application::trackIncomingVoxelPacket(const QByteArray& packet, const HifiSockAddr& senderSockAddr, bool wasStatsPacket) {
41274112
41284113 // Attempt to identify the sender from it's address.
41294114 SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
@@ -4134,13 +4119,13 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 4 unmodified lines
41344119 _voxelSceneStatsLock.lockForWrite();
41354120 if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
41364121 VoxelSceneStats& stats = _octreeServerSceneStats[nodeUUID];
4137− stats.trackIncomingOctreePacket(messageData, messageLength, wasStatsPacket, serverNode->getClockSkewUsec());
4122+ stats.trackIncomingOctreePacket(packet, wasStatsPacket, serverNode->getClockSkewUsec());
41384123 }
41394124 _voxelSceneStatsLock.unlock();
41404125 }
41414126 }
41424127
4143−int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) {
4128+int Application::parseOctreeStats(const QByteArray& packet, const HifiSockAddr& senderSockAddr) {
41444129
41454130 // But, also identify the sender, and keep track of the contained jurisdiction root for this server
41464131 SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
@@ -4148,7 +4133,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 1 unmodified line
41484133 // parse the incoming stats datas stick it in a temporary object for now, while we
41494134 // determine which server it belongs to
41504135 VoxelSceneStats temp;
4151− int statsMessageLength = temp.unpackFromMessage(messageData, messageLength);
4136+ int statsMessageLength = temp.unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()), packet.size());
41524137
41534138 // quick fix for crash... why would voxelServer be NULL?
41544139 if (server) {
@@ -4157,7 +4142,8 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 2 unmodified lines
41574142 // now that we know the node ID, let's add these stats to the stats for that node...
41584143 _voxelSceneStatsLock.lockForWrite();
41594144 if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
4160− _octreeServerSceneStats[nodeUUID].unpackFromMessage(messageData, messageLength);
4145+ _octreeServerSceneStats[nodeUUID].unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()),
4146+ packet.size());
41614147 } else {
41624148 _octreeServerSceneStats[nodeUUID] = temp;
41634149 }
@@ -4168,7 +4154,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 4 unmodified lines
41684154
41694155 // see if this is the first we've heard of this node...
41704156 NodeToJurisdictionMap* jurisdiction = NULL;
4171− if (server->getType() == NODE_TYPE_VOXEL_SERVER) {
4157+ if (server->getType() == NodeType::VoxelServer) {
41724158 jurisdiction = &_voxelServerJurisdictions;
41734159 } else {
41744160 jurisdiction = &_particleServerJurisdictions;
@@ -4233,7 +4219,7 @@ void Application::removeScriptName(const QString& fileNameString) · 58 unmodified lines
42334219 _activeScripts.removeOne(fileNameString);
42344220 }
42354221
4236−void Application::loadScript(const QString& fileNameString){
4222+void Application::loadScript(const QString& fileNameString) {
42374223 _activeScripts.append(fileNameString);
42384224 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
42394225 const char* fileName = fileNameAscii.data();
@@ -4271,7 +4257,7 @@ void Application::loadScript(const QString& fileNameString){ · 31 unmodified lines
42714257 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
42724258
42734259 // hook our avatar object into this script engine
4274− scriptEngine->setAvatarData(&_myAvatar, "MyAvatar");
4260+ scriptEngine->setAvatarData( static_cast<Avatar*>(_myAvatar), "MyAvatar");
42754261
42764262 QThread* workerThread = new QThread(this);
42774263
@@ -4438,6 +4424,6 @@ void Application::takeSnapshot() { · 160 unmodified lines
44384424 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
44394425 player->play();
44404426
4441− Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar.getPosition());
4427+ Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition());
44424428 }
44434429

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