Showing the changes to interface/src/Application.cpp (1 of 159 files). Show all
Unified · Split
| @@ -50,7 +50,6 @@ · 49 unmodified lines | ||
| 50 | 50 | #include <QMediaPlayer> |
| 51 | 51 | |
| 52 | 52 | #include <AudioInjector.h> |
| 53 | −#include <NodeTypes.h> | |
| 54 | 53 | #include <Logging.h> |
| 55 | 54 | #include <OctalCode.h> |
| 56 | 55 | #include <PacketHeaders.h> |
| @@ -122,6 +121,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 65 unmodified lines | ||
| 122 | 121 | _wantToKillLocalVoxels(false), |
| 123 | 122 | _audioScope(256, 200, true), |
| 124 | 123 | _avatarManager(), |
| 124 | + _myAvatar(NULL), | |
| 125 | 125 | _profile(QString()), |
| 126 | 126 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 127 | 127 | _mouseX(0), |
| @@ -158,6 +158,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 30 unmodified lines | ||
| 158 | 158 | _logger(new FileLogger()), |
| 159 | 159 | _persistThread(NULL) |
| 160 | 160 | { |
| 161 | + _myAvatar = _avatarManager.getMyAvatar(); | |
| 162 | + | |
| 161 | 163 | _applicationStartupTime = startup_time; |
| 162 | 164 | |
| 163 | 165 | switchToResourcesParentIfRequired(); |
| @@ -183,7 +185,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 19 unmodified lines | ||
| 183 | 185 | _nodeThread->setPriority(QThread::TimeCriticalPriority); |
| 184 | 186 | |
| 185 | 187 | // 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); | |
| 187 | 189 | |
| 188 | 190 | nodeList->moveToThread(_nodeThread); |
| 189 | 191 | _datagramProcessor.moveToThread(_nodeThread); |
| @@ -230,9 +232,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 40 unmodified lines | ||
| 230 | 232 | #endif |
| 231 | 233 | |
| 232 | 234 | // 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); | |
| 236 | 238 | |
| 237 | 239 | // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender |
| 238 | 240 | connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent); |
| @@ -328,6 +330,9 @@ Application::~Application() { · 89 unmodified lines | ||
| 328 | 330 | VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown |
| 329 | 331 | Menu::getInstance()->deleteLater(); |
| 330 | 332 | |
| 333 | + _avatarManager.clear(); | |
| 334 | + _myAvatar = NULL; | |
| 335 | + | |
| 331 | 336 | delete _logger; |
| 332 | 337 | delete _settings; |
| 333 | 338 | delete _glWidget; |
| @@ -442,25 +447,25 @@ void Application::paintGL() { · 108 unmodified lines | ||
| 442 | 447 | _myCamera.setUpShift (0.0f); |
| 443 | 448 | _myCamera.setDistance (0.0f); |
| 444 | 449 | _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()); | |
| 447 | 452 | |
| 448 | 453 | } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 449 | 454 | _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()); | |
| 452 | 457 | |
| 453 | 458 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 454 | 459 | _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()); | |
| 457 | 462 | |
| 458 | 463 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 459 | 464 | _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))); | |
| 464 | 469 | } |
| 465 | 470 | |
| 466 | 471 | // Update camera position |
| @@ -517,22 +522,22 @@ void Application::paintGL() { · 50 unmodified lines | ||
| 517 | 522 | |
| 518 | 523 | bool eyeRelativeCamera = false; |
| 519 | 524 | 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()); | |
| 522 | 527 | } 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()) { | |
| 525 | 530 | // as a hack until we have a better way of dealing with coordinate precision issues, reposition the |
| 526 | 531 | // face/body so that the average eye position lies at the origin |
| 527 | 532 | eyeRelativeCamera = true; |
| 528 | 533 | _mirrorCamera.setTargetPosition(glm::vec3()); |
| 529 | 534 | |
| 530 | 535 | } else { |
| 531 | − _mirrorCamera.setTargetPosition(_myAvatar.getHead().calculateAverageEyePosition()); | |
| 536 | + _mirrorCamera.setTargetPosition(_myAvatar->getHead().calculateAverageEyePosition()); | |
| 532 | 537 | } |
| 533 | 538 | } |
| 534 | 539 | |
| 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))); | |
| 536 | 541 | _mirrorCamera.update(1.0f/_fps); |
| 537 | 542 | |
| 538 | 543 | // set the bounds of rear mirror view |
| @@ -549,27 +554,27 @@ void Application::paintGL() { · 10 unmodified lines | ||
| 549 | 554 | glPushMatrix(); |
| 550 | 555 | if (eyeRelativeCamera) { |
| 551 | 556 | // 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(); | |
| 554 | 559 | |
| 555 | 560 | // get the eye positions relative to the neck and use them to set the face translation |
| 556 | 561 | 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); | |
| 560 | 565 | |
| 561 | 566 | // get the neck position relative to the body and use it to set the skeleton translation |
| 562 | 567 | 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() - | |
| 566 | 571 | neckPosition); |
| 567 | 572 | |
| 568 | 573 | displaySide(_mirrorCamera, true); |
| 569 | 574 | |
| 570 | 575 | // 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); | |
| 573 | 578 | } else { |
| 574 | 579 | displaySide(_mirrorCamera, true); |
| 575 | 580 | } |
| @@ -651,32 +656,30 @@ void Application::resetProfile(const QString& username) { · 75 unmodified lines | ||
| 651 | 656 | updateWindowTitle(); |
| 652 | 657 | } |
| 653 | 658 | |
| 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) { | |
| 657 | 661 | // 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)) { | |
| 659 | 663 | continue; |
| 660 | 664 | } |
| 661 | 665 | |
| 662 | 666 | // 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); | |
| 665 | 668 | |
| 666 | 669 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 667 | 670 | BandwidthMeter::ChannelIndex channel; |
| 668 | 671 | switch (type) { |
| 669 | − case NODE_TYPE_AGENT: | |
| 670 | − case NODE_TYPE_AVATAR_MIXER: | |
| 672 | + case NodeType::Agent: | |
| 673 | + case NodeType::AvatarMixer: | |
| 671 | 674 | channel = BandwidthMeter::AVATARS; |
| 672 | 675 | break; |
| 673 | − case NODE_TYPE_VOXEL_SERVER: | |
| 676 | + case NodeType::VoxelServer: | |
| 674 | 677 | channel = BandwidthMeter::VOXELS; |
| 675 | 678 | break; |
| 676 | 679 | default: |
| 677 | 680 | continue; |
| 678 | 681 | } |
| 679 | − _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | |
| 682 | + _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * packet.size()); | |
| 680 | 683 | } |
| 681 | 684 | } |
| 682 | 685 | |
| @@ -692,12 +695,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 9 unmodified lines | ||
| 692 | 695 | if (activeWindow() == _window) { |
| 693 | 696 | if (_chatEntryOn) { |
| 694 | 697 | 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 ? | |
| 696 | 699 | 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)); | |
| 698 | 701 | |
| 699 | 702 | } else { |
| 700 | − _myAvatar.setChatMessage(_chatEntry.getContents()); | |
| 703 | + _myAvatar->setChatMessage(_chatEntry.getContents()); | |
| 701 | 704 | _chatEntry.clear(); |
| 702 | 705 | _chatEntryOn = false; |
| 703 | 706 | setMenuShortcutsEnabled(true); |
| @@ -741,10 +744,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 37 unmodified lines | ||
| 741 | 744 | if (_nudgeStarted) { |
| 742 | 745 | _nudgeGuidePosition.y += _mouseVoxel.s; |
| 743 | 746 | } else { |
| 744 | − if (!_myAvatar.getDriveKeys(UP)) { | |
| 745 | − _myAvatar.jump(); | |
| 747 | + if (!_myAvatar->getDriveKeys(UP)) { | |
| 748 | + _myAvatar->jump(); | |
| 746 | 749 | } |
| 747 | − _myAvatar.setDriveKeys(UP, 1); | |
| 750 | + _myAvatar->setDriveKeys(UP, 1); | |
| 748 | 751 | } |
| 749 | 752 | break; |
| 750 | 753 | |
| @@ -756,7 +759,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 756 | 759 | if (_nudgeStarted) { |
| 757 | 760 | _nudgeGuidePosition.y -= _mouseVoxel.s; |
| 758 | 761 | } else { |
| 759 | − _myAvatar.setDriveKeys(DOWN, 1); | |
| 762 | + _myAvatar->setDriveKeys(DOWN, 1); | |
| 760 | 763 | } |
| 761 | 764 | break; |
| 762 | 765 | |
| @@ -776,7 +779,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | ||
| 776 | 779 | } |
| 777 | 780 | } |
| 778 | 781 | } else { |
| 779 | − _myAvatar.setDriveKeys(FWD, 1); | |
| 782 | + _myAvatar->setDriveKeys(FWD, 1); | |
| 780 | 783 | } |
| 781 | 784 | break; |
| 782 | 785 | |
| @@ -802,7 +805,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 19 unmodified lines | ||
| 802 | 805 | } |
| 803 | 806 | } |
| 804 | 807 | } else { |
| 805 | − _myAvatar.setDriveKeys(BACK, 1); | |
| 808 | + _myAvatar->setDriveKeys(BACK, 1); | |
| 806 | 809 | } |
| 807 | 810 | break; |
| 808 | 811 | |
| @@ -836,7 +839,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 27 unmodified lines | ||
| 836 | 839 | } |
| 837 | 840 | } |
| 838 | 841 | } else { |
| 839 | − _myAvatar.setDriveKeys(ROT_LEFT, 1); | |
| 842 | + _myAvatar->setDriveKeys(ROT_LEFT, 1); | |
| 840 | 843 | } |
| 841 | 844 | break; |
| 842 | 845 | |
| @@ -856,7 +859,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | ||
| 856 | 859 | } |
| 857 | 860 | } |
| 858 | 861 | } else { |
| 859 | − _myAvatar.setDriveKeys(ROT_RIGHT, 1); | |
| 862 | + _myAvatar->setDriveKeys(ROT_RIGHT, 1); | |
| 860 | 863 | } |
| 861 | 864 | break; |
| 862 | 865 | |
| @@ -866,8 +869,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines | ||
| 866 | 869 | nudgeVoxels(); |
| 867 | 870 | } else { |
| 868 | 871 | _chatEntryOn = true; |
| 869 | − _myAvatar.setKeyState(NO_KEY_DOWN); | |
| 870 | − _myAvatar.setChatMessage(string()); | |
| 872 | + _myAvatar->setKeyState(NO_KEY_DOWN); | |
| 873 | + _myAvatar->setChatMessage(string()); | |
| 871 | 874 | setMenuShortcutsEnabled(false); |
| 872 | 875 | } |
| 873 | 876 | break; |
| @@ -890,7 +893,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 16 unmodified lines | ||
| 890 | 893 | } else if (_nudgeStarted && isShifted) { |
| 891 | 894 | _nudgeGuidePosition.y += _mouseVoxel.s; |
| 892 | 895 | } else { |
| 893 | − _myAvatar.setDriveKeys(isShifted ? UP : FWD, 1); | |
| 896 | + _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1); | |
| 894 | 897 | } |
| 895 | 898 | break; |
| 896 | 899 | |
| @@ -912,7 +915,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 15 unmodified lines | ||
| 912 | 915 | } else if (_nudgeStarted && isShifted) { |
| 913 | 916 | _nudgeGuidePosition.y -= _mouseVoxel.s; |
| 914 | 917 | } else { |
| 915 | − _myAvatar.setDriveKeys(isShifted ? DOWN : BACK, 1); | |
| 918 | + _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1); | |
| 916 | 919 | } |
| 917 | 920 | break; |
| 918 | 921 | |
| @@ -932,7 +935,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | ||
| 932 | 935 | } |
| 933 | 936 | } |
| 934 | 937 | } else { |
| 935 | − _myAvatar.setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1); | |
| 938 | + _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1); | |
| 936 | 939 | } |
| 937 | 940 | break; |
| 938 | 941 | |
| @@ -952,7 +955,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 13 unmodified lines | ||
| 952 | 955 | } |
| 953 | 956 | } |
| 954 | 957 | } else { |
| 955 | − _myAvatar.setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1); | |
| 958 | + _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1); | |
| 956 | 959 | } |
| 957 | 960 | break; |
| 958 | 961 | |
| @@ -1070,13 +1073,13 @@ void Application::keyPressEvent(QKeyEvent* event) { · 111 unmodified lines | ||
| 1070 | 1073 | } |
| 1071 | 1074 | break; |
| 1072 | 1075 | case Qt::Key_Plus: |
| 1073 | − _myAvatar.increaseSize(); | |
| 1076 | + _myAvatar->increaseSize(); | |
| 1074 | 1077 | break; |
| 1075 | 1078 | case Qt::Key_Minus: |
| 1076 | − _myAvatar.decreaseSize(); | |
| 1079 | + _myAvatar->decreaseSize(); | |
| 1077 | 1080 | break; |
| 1078 | 1081 | case Qt::Key_Equal: |
| 1079 | − _myAvatar.resetSize(); | |
| 1082 | + _myAvatar->resetSize(); | |
| 1080 | 1083 | break; |
| 1081 | 1084 | |
| 1082 | 1085 | case Qt::Key_1: |
| @@ -1111,7 +1114,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 28 unmodified lines | ||
| 1111 | 1114 | |
| 1112 | 1115 | if (activeWindow() == _window) { |
| 1113 | 1116 | if (_chatEntryOn) { |
| 1114 | − _myAvatar.setKeyState(NO_KEY_DOWN); | |
| 1117 | + _myAvatar->setKeyState(NO_KEY_DOWN); | |
| 1115 | 1118 | return; |
| 1116 | 1119 | } |
| 1117 | 1120 | |
| @@ -1120,47 +1123,47 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 2 unmodified lines | ||
| 1120 | 1123 | _pasteMode = false; |
| 1121 | 1124 | break; |
| 1122 | 1125 | case Qt::Key_E: |
| 1123 | − _myAvatar.setDriveKeys(UP, 0); | |
| 1126 | + _myAvatar->setDriveKeys(UP, 0); | |
| 1124 | 1127 | break; |
| 1125 | 1128 | |
| 1126 | 1129 | case Qt::Key_C: |
| 1127 | − _myAvatar.setDriveKeys(DOWN, 0); | |
| 1130 | + _myAvatar->setDriveKeys(DOWN, 0); | |
| 1128 | 1131 | break; |
| 1129 | 1132 | |
| 1130 | 1133 | case Qt::Key_W: |
| 1131 | − _myAvatar.setDriveKeys(FWD, 0); | |
| 1134 | + _myAvatar->setDriveKeys(FWD, 0); | |
| 1132 | 1135 | break; |
| 1133 | 1136 | |
| 1134 | 1137 | case Qt::Key_S: |
| 1135 | − _myAvatar.setDriveKeys(BACK, 0); | |
| 1138 | + _myAvatar->setDriveKeys(BACK, 0); | |
| 1136 | 1139 | break; |
| 1137 | 1140 | |
| 1138 | 1141 | case Qt::Key_A: |
| 1139 | − _myAvatar.setDriveKeys(ROT_LEFT, 0); | |
| 1142 | + _myAvatar->setDriveKeys(ROT_LEFT, 0); | |
| 1140 | 1143 | break; |
| 1141 | 1144 | |
| 1142 | 1145 | case Qt::Key_D: |
| 1143 | − _myAvatar.setDriveKeys(ROT_RIGHT, 0); | |
| 1146 | + _myAvatar->setDriveKeys(ROT_RIGHT, 0); | |
| 1144 | 1147 | break; |
| 1145 | 1148 | |
| 1146 | 1149 | case Qt::Key_Up: |
| 1147 | − _myAvatar.setDriveKeys(FWD, 0); | |
| 1148 | − _myAvatar.setDriveKeys(UP, 0); | |
| 1150 | + _myAvatar->setDriveKeys(FWD, 0); | |
| 1151 | + _myAvatar->setDriveKeys(UP, 0); | |
| 1149 | 1152 | break; |
| 1150 | 1153 | |
| 1151 | 1154 | case Qt::Key_Down: |
| 1152 | − _myAvatar.setDriveKeys(BACK, 0); | |
| 1153 | − _myAvatar.setDriveKeys(DOWN, 0); | |
| 1155 | + _myAvatar->setDriveKeys(BACK, 0); | |
| 1156 | + _myAvatar->setDriveKeys(DOWN, 0); | |
| 1154 | 1157 | break; |
| 1155 | 1158 | |
| 1156 | 1159 | 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); | |
| 1159 | 1162 | break; |
| 1160 | 1163 | |
| 1161 | 1164 | 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); | |
| 1164 | 1167 | break; |
| 1165 | 1168 | |
| 1166 | 1169 | default: |
| @@ -1195,11 +1198,11 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 28 unmodified lines | ||
| 1195 | 1198 | // orbit behavior |
| 1196 | 1199 | if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) { |
| 1197 | 1200 | if (_avatarManager.getLookAtTargetAvatar()) { |
| 1198 | − _myAvatar.orbit(_avatarManager.getLookAtTargetAvatar()->getPosition(), deltaX, deltaY); | |
| 1201 | + _myAvatar->orbit(_avatarManager.getLookAtTargetAvatar()->getPosition(), deltaX, deltaY); | |
| 1199 | 1202 | return; |
| 1200 | 1203 | } |
| 1201 | 1204 | if (_isHoverVoxel) { |
| 1202 | − _myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY); | |
| 1205 | + _myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY); | |
| 1203 | 1206 | return; |
| 1204 | 1207 | } |
| 1205 | 1208 | } |
| @@ -1282,14 +1285,14 @@ void Application::mousePressEvent(QMouseEvent* event) { · 76 unmodified lines | ||
| 1282 | 1285 | |
| 1283 | 1286 | const float PERCENTAGE_TO_MOVE_TOWARD = 0.90f; |
| 1284 | 1287 | glm::vec3 newTarget = getMouseVoxelWorldCoordinates(_hoverVoxel); |
| 1285 | − glm::vec3 myPosition = _myAvatar.getPosition(); | |
| 1288 | + glm::vec3 myPosition = _myAvatar->getPosition(); | |
| 1286 | 1289 | |
| 1287 | 1290 | // If there is not an action tool set (add, delete, color), move to this voxel |
| 1288 | 1291 | if (Menu::getInstance()->isOptionChecked(MenuOption::ClickToFly) && |
| 1289 | 1292 | !(Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) || |
| 1290 | 1293 | Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode) || |
| 1291 | 1294 | 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); | |
| 1293 | 1296 | } |
| 1294 | 1297 | } |
| 1295 | 1298 | |
| @@ -1409,13 +1412,11 @@ void Application::wheelEvent(QWheelEvent* event) { · 113 unmodified lines | ||
| 1409 | 1412 | } |
| 1410 | 1413 | |
| 1411 | 1414 | 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); | |
| 1419 | 1420 | } |
| 1420 | 1421 | |
| 1421 | 1422 | // Every second, check the frame rates and other stuff |
| @@ -1443,8 +1444,8 @@ void Application::timer() { · 21 unmodified lines | ||
| 1443 | 1444 | DataServerClient::resendUnmatchedPackets(); |
| 1444 | 1445 | |
| 1445 | 1446 | // 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()); | |
| 1448 | 1449 | } |
| 1449 | 1450 | |
| 1450 | 1451 | static glm::vec3 getFaceVector(BoxFace face) { |
| @@ -1553,7 +1554,7 @@ void Application::removeVoxel(glm::vec3 position, · 102 unmodified lines | ||
| 1553 | 1554 | voxel.y = position.y / TREE_SCALE; |
| 1554 | 1555 | voxel.z = position.z / TREE_SCALE; |
| 1555 | 1556 | voxel.s = scale / TREE_SCALE; |
| 1556 | − _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_VOXEL_ERASE, voxel); | |
| 1557 | + _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel); | |
| 1557 | 1558 | |
| 1558 | 1559 | // delete it locally to see the effect immediately (and in case no voxel server is present) |
| 1559 | 1560 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); |
| @@ -1574,7 +1575,7 @@ void Application::makeVoxel(glm::vec3 position, · 14 unmodified lines | ||
| 1574 | 1575 | voxel.red = red; |
| 1575 | 1576 | voxel.green = green; |
| 1576 | 1577 | voxel.blue = blue; |
| 1577 | − PACKET_TYPE message = isDestructive ? PACKET_TYPE_VOXEL_SET_DESTRUCTIVE : PACKET_TYPE_VOXEL_SET; | |
| 1578 | + PacketType message = isDestructive ? PacketTypeVoxelSetDestructive : PacketTypeVoxelSet; | |
| 1578 | 1579 | _voxelEditSender.sendVoxelEditMessage(message, voxel); |
| 1579 | 1580 | |
| 1580 | 1581 | // create the voxel locally so it appears immediately |
| @@ -1644,7 +1645,7 @@ bool Application::sendVoxelsOperation(OctreeElement* element, void* extraData) { · 63 unmodified lines | ||
| 1644 | 1645 | codeColorBuffer[bytesInCode + RED_INDEX] = voxel->getColor()[RED_INDEX]; |
| 1645 | 1646 | codeColorBuffer[bytesInCode + GREEN_INDEX] = voxel->getColor()[GREEN_INDEX]; |
| 1646 | 1647 | codeColorBuffer[bytesInCode + BLUE_INDEX] = voxel->getColor()[BLUE_INDEX]; |
| 1647 | − getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_VOXEL_SET_DESTRUCTIVE, | |
| 1648 | + getInstance()->_voxelEditSender.queueVoxelEditMessage(PacketTypeVoxelSetDestructive, | |
| 1648 | 1649 | codeColorBuffer, codeAndColorLength); |
| 1649 | 1650 | |
| 1650 | 1651 | delete[] codeColorBuffer; |
| @@ -1739,7 +1740,7 @@ void Application::pasteVoxels() { · 88 unmodified lines | ||
| 1739 | 1740 | } |
| 1740 | 1741 | |
| 1741 | 1742 | void Application::findAxisAlignment() { |
| 1742 | − glm::vec3 direction = _myAvatar.getMouseRayDirection(); | |
| 1743 | + glm::vec3 direction = _myAvatar->getMouseRayDirection(); | |
| 1743 | 1744 | if (fabs(direction.z) > fabs(direction.x)) { |
| 1744 | 1745 | _lookingAlongX = false; |
| 1745 | 1746 | if (direction.z < 0) { |
| @@ -1825,12 +1826,10 @@ void Application::init() { · 79 unmodified lines | ||
| 1825 | 1826 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 1826 | 1827 | QCursor::setPos(_headMouseX, _headMouseY); |
| 1827 | 1828 | |
| 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(); | |
| 1830 | 1831 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1831 | 1832 | _myCamera.setModeShiftRate(1.0f); |
| 1832 | − _myAvatar.setDisplayingLookatVectors(false); | |
| 1833 | − _avatarManager.setMyAvatar(&_myAvatar); | |
| 1834 | 1833 | |
| 1835 | 1834 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| 1836 | 1835 | _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT); |
| @@ -1946,9 +1945,9 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 109 unmodified lines | ||
| 1946 | 1945 | |
| 1947 | 1946 | bool Application::isLookingAtMyAvatar(Avatar* avatar) { |
| 1948 | 1947 | glm::vec3 theirLookat = avatar->getHead().getLookAtPosition(); |
| 1949 | − glm::vec3 myHeadPosition = _myAvatar.getHead().getPosition(); | |
| 1948 | + glm::vec3 myHeadPosition = _myAvatar->getHead().getPosition(); | |
| 1950 | 1949 | |
| 1951 | − if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar.getScale())) { | |
| 1950 | + if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) { | |
| 1952 | 1951 | return true; |
| 1953 | 1952 | } |
| 1954 | 1953 | return false; |
| @@ -1986,10 +1985,10 @@ void Application::updateMouseRay() { · 31 unmodified lines | ||
| 1986 | 1985 | } |
| 1987 | 1986 | |
| 1988 | 1987 | // tell my avatar if the mouse is being pressed... |
| 1989 | − _myAvatar.setMousePressed(_mousePressed); | |
| 1988 | + _myAvatar->setMousePressed(_mousePressed); | |
| 1990 | 1989 | |
| 1991 | 1990 | // 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); | |
| 1993 | 1992 | } |
| 1994 | 1993 | |
| 1995 | 1994 | void Application::updateFaceshift() { |
| @@ -2002,7 +2001,7 @@ void Application::updateFaceshift() { · 6 unmodified lines | ||
| 2002 | 2001 | |
| 2003 | 2002 | // Copy angular velocity if measured by faceshift, to the head |
| 2004 | 2003 | if (_faceshift.isActive()) { |
| 2005 | − _myAvatar.getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity()); | |
| 2004 | + _myAvatar->getHead().setAngularVelocity(_faceshift.getHeadAngularVelocity()); | |
| 2006 | 2005 | } |
| 2007 | 2006 | } |
| 2008 | 2007 | |
| @@ -2026,14 +2025,14 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { · 17 unmodified lines | ||
| 2026 | 2025 | } |
| 2027 | 2026 | if (_faceshift.isActive()) { |
| 2028 | 2027 | // deflect using Faceshift gaze data |
| 2029 | − glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition(); | |
| 2028 | + glm::vec3 origin = _myAvatar->getHead().calculateAverageEyePosition(); | |
| 2030 | 2029 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 2031 | 2030 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); |
| 2032 | 2031 | lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( |
| 2033 | 2032 | _faceshift.getEstimatedEyePitch() * pitchSign * deflection, _faceshift.getEstimatedEyeYaw() * deflection, 0.0f))) * |
| 2034 | 2033 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); |
| 2035 | 2034 | } |
| 2036 | − _myAvatar.getHead().setLookAtPosition(lookAtSpot); | |
| 2035 | + _myAvatar->getHead().setLookAtPosition(lookAtSpot); | |
| 2037 | 2036 | } |
| 2038 | 2037 | |
| 2039 | 2038 | 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 | ||
| 2091 | 2090 | _mouseVoxel.s = 0.0f; |
| 2092 | 2091 | bool wasInitialized = _mouseVoxelScaleInitialized; |
| 2093 | 2092 | 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) { | |
| 2097 | 2096 | |
| 2098 | 2097 | if (_voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _mouseVoxel, distance, face)) { |
| 2099 | 2098 | if (distance < MAX_VOXEL_EDIT_DISTANCE) { |
| @@ -2225,16 +2224,16 @@ void Application::updateMyAvatarSimulation(float deltaTime) { · 125 unmodified lines | ||
| 2225 | 2224 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarSimulation()"); |
| 2226 | 2225 | |
| 2227 | 2226 | if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) { |
| 2228 | − _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition())); | |
| 2227 | + _myAvatar->setGravity(_environment.getGravity(_myAvatar->getPosition())); | |
| 2229 | 2228 | } |
| 2230 | 2229 | else { |
| 2231 | − _myAvatar.setGravity(glm::vec3(0.0f, 0.0f, 0.0f)); | |
| 2230 | + _myAvatar->setGravity(glm::vec3(0.0f, 0.0f, 0.0f)); | |
| 2232 | 2231 | } |
| 2233 | 2232 | |
| 2234 | 2233 | if (Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) { |
| 2235 | − _myAvatar.simulate(deltaTime, &_myTransmitter); | |
| 2234 | + _myAvatar->simulate(deltaTime, &_myTransmitter); | |
| 2236 | 2235 | } else { |
| 2237 | − _myAvatar.simulate(deltaTime, NULL); | |
| 2236 | + _myAvatar->simulate(deltaTime, NULL); | |
| 2238 | 2237 | } |
| 2239 | 2238 | } |
| 2240 | 2239 | |
| @@ -2262,8 +2261,8 @@ void Application::updateTransmitter(float deltaTime) { · 21 unmodified lines | ||
| 2262 | 2261 | |
| 2263 | 2262 | // no transmitter drive implies transmitter pick |
| 2264 | 2263 | 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() * | |
| 2267 | 2266 | glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT; |
| 2268 | 2267 | |
| 2269 | 2268 | // check against voxels, avatars |
| @@ -2337,8 +2336,8 @@ void Application::updateAudio(float deltaTime) { · 67 unmodified lines | ||
| 2337 | 2336 | PerformanceWarning warn(showWarnings, "Application::updateAudio()"); |
| 2338 | 2337 | |
| 2339 | 2338 | // 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()); | |
| 2342 | 2341 | } |
| 2343 | 2342 | |
| 2344 | 2343 | void Application::updateCursor(float deltaTime) { |
| @@ -2348,7 +2347,7 @@ void Application::updateCursor(float deltaTime) { · 3 unmodified lines | ||
| 2348 | 2347 | // watch mouse position, if it hasn't moved, hide the cursor |
| 2349 | 2348 | bool underMouse = _glWidget->underMouse(); |
| 2350 | 2349 | if (!_mouseHidden) { |
| 2351 | − uint64_t now = usecTimestampNow(); | |
| 2350 | + quint64 now = usecTimestampNow(); | |
| 2352 | 2351 | int elapsed = now - _lastMouseMove; |
| 2353 | 2352 | const int HIDE_CURSOR_TIMEOUT = 1 * 1000 * 1000; // 1 second |
| 2354 | 2353 | if (elapsed > HIDE_CURSOR_TIMEOUT && (underMouse || !_seenMouseMove)) { |
| @@ -2410,16 +2409,16 @@ void Application::updateAvatar(float deltaTime) { · 55 unmodified lines | ||
| 2410 | 2409 | PerformanceWarning warn(showWarnings, "Application::updateAvatar()"); |
| 2411 | 2410 | |
| 2412 | 2411 | // rotate body yaw for yaw received from multitouch |
| 2413 | − _myAvatar.setOrientation(_myAvatar.getOrientation() | |
| 2412 | + _myAvatar->setOrientation(_myAvatar->getOrientation() | |
| 2414 | 2413 | * glm::quat(glm::vec3(0, _yawFromTouch, 0))); |
| 2415 | 2414 | _yawFromTouch = 0.f; |
| 2416 | 2415 | |
| 2417 | 2416 | // apply pitch from touch |
| 2418 | − _myAvatar.getHead().setPitch(_myAvatar.getHead().getPitch() + _pitchFromTouch); | |
| 2417 | + _myAvatar->getHead().setPitch(_myAvatar->getHead().getPitch() + _pitchFromTouch); | |
| 2419 | 2418 | _pitchFromTouch = 0.0f; |
| 2420 | 2419 | |
| 2421 | 2420 | // Update my avatar's state from gyros |
| 2422 | − _myAvatar.updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)); | |
| 2421 | + _myAvatar->updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)); | |
| 2423 | 2422 | |
| 2424 | 2423 | // Update head mouse from faceshift if active |
| 2425 | 2424 | if (_faceshift.isActive()) { |
| @@ -2440,27 +2439,19 @@ void Application::updateAvatar(float deltaTime) { · 14 unmodified lines | ||
| 2440 | 2439 | float yaw, pitch, roll; |
| 2441 | 2440 | OculusManager::getEulerAngles(yaw, pitch, roll); |
| 2442 | 2441 | |
| 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); | |
| 2446 | 2445 | } |
| 2447 | 2446 | |
| 2448 | 2447 | // Get audio loudness data from audio input device |
| 2449 | − _myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness()); | |
| 2448 | + _myAvatar->getHead().setAudioLoudness(_audio.getLastInputLoudness()); | |
| 2450 | 2449 | |
| 2451 | 2450 | // 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()); | |
| 2456 | 2453 | |
| 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); | |
| 2464 | 2455 | |
| 2465 | 2456 | // Update _viewFrustum with latest camera and view frustum data... |
| 2466 | 2457 | // 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 | ||
| 2471 | 2462 | loadViewFrustum(_myCamera, _viewFrustum); |
| 2472 | 2463 | |
| 2473 | 2464 | // 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); | |
| 2476 | 2467 | } |
| 2477 | 2468 | |
| 2478 | −void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, NodeToJurisdictionMap& jurisdictions) { | |
| 2469 | +void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) { | |
| 2479 | 2470 | |
| 2480 | 2471 | // if voxels are disabled, then don't send this at all... |
| 2481 | 2472 | if (!Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| @@ -2643,10 +2634,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 161 unmodified lines | ||
| 2643 | 2634 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2644 | 2635 | |
| 2645 | 2636 | // 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); | |
| 2650 | 2638 | |
| 2651 | 2639 | // encode the query data... |
| 2652 | 2640 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| @@ -3157,7 +3145,7 @@ void Application::displayOverlay() { · 504 unmodified lines | ||
| 3157 | 3145 | // Show on-screen msec timer |
| 3158 | 3146 | if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { |
| 3159 | 3147 | char frameTimer[10]; |
| 3160 | − uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); | |
| 3148 | + quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); | |
| 3161 | 3149 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| 3162 | 3150 | int timerBottom = |
| 3163 | 3151 | (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && |
| @@ -3248,10 +3236,8 @@ void Application::displayStats() { · 84 unmodified lines | ||
| 3248 | 3236 | |
| 3249 | 3237 | glPointSize(1.0f); |
| 3250 | 3238 | |
| 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(); | |
| 3255 | 3241 | |
| 3256 | 3242 | if (mirrorEnabled) { |
| 3257 | 3243 | horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; |
| @@ -3294,8 +3280,8 @@ void Application::displayStats() { · 36 unmodified lines | ||
| 3294 | 3280 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3295 | 3281 | |
| 3296 | 3282 | 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); | |
| 3299 | 3285 | |
| 3300 | 3286 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; |
| 3301 | 3287 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; |
| @@ -3305,7 +3291,7 @@ void Application::displayStats() { · 3 unmodified lines | ||
| 3305 | 3291 | int voxelServerCount = 0; |
| 3306 | 3292 | |
| 3307 | 3293 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3308 | − if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 3294 | + if (node->getType() == NodeType::VoxelServer) { | |
| 3309 | 3295 | totalPingVoxel += node->getPingMs(); |
| 3310 | 3296 | voxelServerCount++; |
| 3311 | 3297 | if (pingVoxelMax < node->getPingMs()) { |
| @@ -3348,7 +3334,7 @@ void Application::displayStats() { · 36 unmodified lines | ||
| 3348 | 3334 | horizontalOffset += 171; |
| 3349 | 3335 | } |
| 3350 | 3336 | |
| 3351 | − glm::vec3 avatarPos = _myAvatar.getPosition(); | |
| 3337 | + glm::vec3 avatarPos = _myAvatar->getPosition(); | |
| 3352 | 3338 | |
| 3353 | 3339 | lines = _statsExpanded ? 4 : 3; |
| 3354 | 3340 | 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 | ||
| 3363 | 3349 | sprintf(avatarPosition, "Position: %.3f, %.3f, %.3f", avatarPos.x, avatarPos.y, avatarPos.z); |
| 3364 | 3350 | } |
| 3365 | 3351 | char avatarVelocity[30]; |
| 3366 | − sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar.getVelocity())); | |
| 3352 | + sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity())); | |
| 3367 | 3353 | char avatarBodyYaw[30]; |
| 3368 | − sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar.getBodyYaw()); | |
| 3354 | + sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar->getBodyYaw()); | |
| 3369 | 3355 | char avatarMixerStats[200]; |
| 3370 | 3356 | |
| 3371 | 3357 | verticalOffset += STATS_PELS_PER_LINE; |
| @@ -3376,7 +3362,7 @@ void Application::displayStats() { · 4 unmodified lines | ||
| 3376 | 3362 | drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarBodyYaw, .93f, .93f, .93f); |
| 3377 | 3363 | |
| 3378 | 3364 | if (_statsExpanded) { |
| 3379 | − SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 3365 | + SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer); | |
| 3380 | 3366 | if (avatarMixer) { |
| 3381 | 3367 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| 3382 | 3368 | roundf(avatarMixer->getAverageKilobitsPerSecond()), |
| @@ -3950,7 +3936,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 567 unmodified lines | ||
| 3950 | 3936 | void Application::deleteVoxelUnderCursor() { |
| 3951 | 3937 | if (_mouseVoxel.s != 0) { |
| 3952 | 3938 | // 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); | |
| 3954 | 3940 | |
| 3955 | 3941 | // delete it locally to see the effect immediately (and in case no voxel server is present) |
| 3956 | 3942 | _voxels.deleteVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| @@ -3986,10 +3972,10 @@ void Application::resetSensors() { · 29 unmodified lines | ||
| 3986 | 3972 | } |
| 3987 | 3973 | |
| 3988 | 3974 | QCursor::setPos(_headMouseX, _headMouseY); |
| 3989 | − _myAvatar.reset(); | |
| 3975 | + _myAvatar->reset(); | |
| 3990 | 3976 | _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)); | |
| 3993 | 3979 | |
| 3994 | 3980 | QMetaObject::invokeMethod(&_audio, "reset", Qt::QueuedConnection); |
| 3995 | 3981 | } |
| @@ -4054,7 +4040,7 @@ void Application::domainChanged(const QString& domainHostname) { · 58 unmodified lines | ||
| 4054 | 4040 | } |
| 4055 | 4041 | |
| 4056 | 4042 | void Application::nodeKilled(SharedNodePointer node) { |
| 4057 | − if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 4043 | + if (node->getType() == NodeType::VoxelServer) { | |
| 4058 | 4044 | QUuid nodeUUID = node->getUUID(); |
| 4059 | 4045 | // see if this is the first we've heard of this node... |
| 4060 | 4046 | if (_voxelServerJurisdictions.find(nodeUUID) != _voxelServerJurisdictions.end()) { |
| @@ -4085,7 +4071,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines | ||
| 4085 | 4071 | } |
| 4086 | 4072 | _voxelSceneStatsLock.unlock(); |
| 4087 | 4073 | |
| 4088 | − } else if (node->getType() == NODE_TYPE_PARTICLE_SERVER) { | |
| 4074 | + } else if (node->getType() == NodeType::ParticleServer) { | |
| 4089 | 4075 | QUuid nodeUUID = node->getUUID(); |
| 4090 | 4076 | // see if this is the first we've heard of this node... |
| 4091 | 4077 | if (_particleServerJurisdictions.find(nodeUUID) != _particleServerJurisdictions.end()) { |
| @@ -4116,14 +4102,13 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines | ||
| 4116 | 4102 | } |
| 4117 | 4103 | _voxelSceneStatsLock.unlock(); |
| 4118 | 4104 | |
| 4119 | − } else if (node->getType() == NODE_TYPE_AVATAR_MIXER) { | |
| 4105 | + } else if (node->getType() == NodeType::AvatarMixer) { | |
| 4120 | 4106 | // our avatar mixer has gone away - clear the hash of avatars |
| 4121 | − _avatarManager.clearHash(); | |
| 4107 | + _avatarManager.clearMixedAvatars(); | |
| 4122 | 4108 | } |
| 4123 | 4109 | } |
| 4124 | 4110 | |
| 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) { | |
| 4127 | 4112 | |
| 4128 | 4113 | // Attempt to identify the sender from it's address. |
| 4129 | 4114 | SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| @@ -4134,13 +4119,13 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 4 unmodified lines | ||
| 4134 | 4119 | _voxelSceneStatsLock.lockForWrite(); |
| 4135 | 4120 | if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) { |
| 4136 | 4121 | VoxelSceneStats& stats = _octreeServerSceneStats[nodeUUID]; |
| 4137 | − stats.trackIncomingOctreePacket(messageData, messageLength, wasStatsPacket, serverNode->getClockSkewUsec()); | |
| 4122 | + stats.trackIncomingOctreePacket(packet, wasStatsPacket, serverNode->getClockSkewUsec()); | |
| 4138 | 4123 | } |
| 4139 | 4124 | _voxelSceneStatsLock.unlock(); |
| 4140 | 4125 | } |
| 4141 | 4126 | } |
| 4142 | 4127 | |
| 4143 | −int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { | |
| 4128 | +int Application::parseOctreeStats(const QByteArray& packet, const HifiSockAddr& senderSockAddr) { | |
| 4144 | 4129 | |
| 4145 | 4130 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server |
| 4146 | 4131 | SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| @@ -4148,7 +4133,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 1 unmodified line | ||
| 4148 | 4133 | // parse the incoming stats datas stick it in a temporary object for now, while we |
| 4149 | 4134 | // determine which server it belongs to |
| 4150 | 4135 | VoxelSceneStats temp; |
| 4151 | − int statsMessageLength = temp.unpackFromMessage(messageData, messageLength); | |
| 4136 | + int statsMessageLength = temp.unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()), packet.size()); | |
| 4152 | 4137 | |
| 4153 | 4138 | // quick fix for crash... why would voxelServer be NULL? |
| 4154 | 4139 | if (server) { |
| @@ -4157,7 +4142,8 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 2 unmodified lines | ||
| 4157 | 4142 | // now that we know the node ID, let's add these stats to the stats for that node... |
| 4158 | 4143 | _voxelSceneStatsLock.lockForWrite(); |
| 4159 | 4144 | 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()); | |
| 4161 | 4147 | } else { |
| 4162 | 4148 | _octreeServerSceneStats[nodeUUID] = temp; |
| 4163 | 4149 | } |
| @@ -4168,7 +4154,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 4 unmodified lines | ||
| 4168 | 4154 | |
| 4169 | 4155 | // see if this is the first we've heard of this node... |
| 4170 | 4156 | NodeToJurisdictionMap* jurisdiction = NULL; |
| 4171 | − if (server->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 4157 | + if (server->getType() == NodeType::VoxelServer) { | |
| 4172 | 4158 | jurisdiction = &_voxelServerJurisdictions; |
| 4173 | 4159 | } else { |
| 4174 | 4160 | jurisdiction = &_particleServerJurisdictions; |
| @@ -4233,7 +4219,7 @@ void Application::removeScriptName(const QString& fileNameString) · 58 unmodified lines | ||
| 4233 | 4219 | _activeScripts.removeOne(fileNameString); |
| 4234 | 4220 | } |
| 4235 | 4221 | |
| 4236 | −void Application::loadScript(const QString& fileNameString){ | |
| 4222 | +void Application::loadScript(const QString& fileNameString) { | |
| 4237 | 4223 | _activeScripts.append(fileNameString); |
| 4238 | 4224 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 4239 | 4225 | const char* fileName = fileNameAscii.data(); |
| @@ -4271,7 +4257,7 @@ void Application::loadScript(const QString& fileNameString){ · 31 unmodified lines | ||
| 4271 | 4257 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); |
| 4272 | 4258 | |
| 4273 | 4259 | // hook our avatar object into this script engine |
| 4274 | − scriptEngine->setAvatarData(&_myAvatar, "MyAvatar"); | |
| 4260 | + scriptEngine->setAvatarData( static_cast<Avatar*>(_myAvatar), "MyAvatar"); | |
| 4275 | 4261 | |
| 4276 | 4262 | QThread* workerThread = new QThread(this); |
| 4277 | 4263 | |
| @@ -4438,6 +4424,6 @@ void Application::takeSnapshot() { · 160 unmodified lines | ||
| 4438 | 4424 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4439 | 4425 | player->play(); |
| 4440 | 4426 | |
| 4441 | − Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar.getPosition()); | |
| 4427 | + Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition()); | |
| 4442 | 4428 | } |
| 4443 | 4429 | |