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