History

Merge remote-tracking branch 'upstream/master' into particles

Jeffrey Ventrella committed 13 years ago

Commit 6e844812 parents 7f3750f 4b0899641 files · +3689 −97Browse files

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

Unified · Split

interface/src/Application.cpp+52−5
@@ -938,6 +938,36 @@ void Application::sendPingPackets() { · 937 unmodified lines
938938 nodesToPing, sizeof(nodesToPing));
939939 }
940940
941+void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) {
942+ unsigned char packet[MAX_PACKET_SIZE];
943+ unsigned char* packetPosition = packet;
944+
945+ packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO);
946+
947+ *(uint16_t*)packetPosition = NodeList::getInstance()->getOwnerID();
948+ packetPosition += sizeof(uint16_t);
949+
950+ *(uint32_t*)packetPosition = frameCount;
951+ packetPosition += sizeof(uint32_t);
952+
953+ *(uint32_t*)packetPosition = data.size();
954+ packetPosition += sizeof(uint32_t);
955+
956+ uint32_t* offsetPosition = (uint32_t*)packetPosition;
957+ packetPosition += sizeof(uint32_t);
958+
959+ int headerSize = packetPosition - packet;
960+
961+ // break the data up into submessages of the maximum size
962+ *offsetPosition = 0;
963+ while (*offsetPosition < data.size()) {
964+ int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize);
965+ memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize);
966+ getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1);
967+ *offsetPosition += payloadSize;
968+ }
969+}
970+
941971 // Every second, check the frame rates and other stuff
942972 void Application::timer() {
943973 gettimeofday(&_timerEnd, NULL);
@@ -1047,7 +1077,7 @@ void Application::sendAvatarVoxelURLMessage(const QUrl& url) { · 103 unmodified lines
10471077 controlledBroadcastToNodes((unsigned char*)message.data(), message.size(), & NODE_TYPE_AVATAR_MIXER, 1);
10481078 }
10491079
1050−void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t dataBytes) {
1080+static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
10511081 // skip the header
10521082 int numBytesPacketHeader = numBytesForPacketHeader(packetData);
10531083 packetData += numBytesPacketHeader;
@@ -1061,18 +1091,31 @@ void Application::processAvatarVoxelURLMessage(unsigned char *packetData, size_t · 7 unmodified lines
10611091 // make sure the node exists
10621092 Node* node = NodeList::getInstance()->nodeWithID(nodeID);
10631093 if (!node || !node->getLinkedData()) {
1064− return;
1094+ return NULL;
10651095 }
10661096 Avatar* avatar = static_cast<Avatar*>(node->getLinkedData());
1067− if (!avatar->isInitialized()) {
1068− return; // wait until initialized
1069− }
1097+ return avatar->isInitialized() ? avatar : NULL;
1098+}
1099+
1100+void Application::processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes) {
1101+ Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes);
1102+ if (!avatar) {
1103+ return;
1104+ }
10701105 QUrl url = QUrl::fromEncoded(QByteArray((char*)packetData, dataBytes));
10711106
10721107 // invoke the set URL function on the simulate/render thread
10731108 QMetaObject::invokeMethod(avatar->getVoxels(), "setVoxelURL", Q_ARG(QUrl, url));
10741109 }
10751110
1111+void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) {
1112+ Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes);
1113+ if (!avatar) {
1114+ return;
1115+ }
1116+ avatar->getHead().getFace().processVideoMessage(packetData, dataBytes);
1117+}
1118+
10761119 void Application::checkBandwidthMeterClick() {
10771120 // ... to be called upon button release
10781121
@@ -1682,6 +1725,7 @@ void Application::initMenu() { · 603 unmodified lines
16821725 (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
16831726 _renderAvatarBalls->setChecked(false);
16841727 renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
1728+ renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
16851729 (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
16861730 _renderFrameTimerOn->setChecked(false);
16871731 (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
@@ -3402,6 +3446,9 @@ void* Application::networkReceive(void* args) { · 1714 unmodified lines
34023446 case PACKET_TYPE_AVATAR_VOXEL_URL:
34033447 processAvatarVoxelURLMessage(app->_incomingPacket, bytesReceived);
34043448 break;
3449+ case PACKET_TYPE_AVATAR_FACE_VIDEO:
3450+ processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived);
3451+ break;
34053452 default:
34063453 NodeList::getInstance()->processNodeData(&senderAddress, app->_incomingPacket, bytesReceived);
34073454 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t