add parsing of PacketTypeAvatarIdentity to AvatarMixer

This commit is contained in:
Stephen Birarda 2014-02-04 13:27:05 -08:00
parent e879a7f18d
commit 31bd5f7ce8
3 changed files with 71 additions and 2 deletions

View file

@ -19,7 +19,7 @@
#include <SharedUtil.h>
#include <UUID.h>
#include "AvatarData.h"
#include "AvatarMixerClientData.h"
#include "AvatarMixer.h"
@ -36,7 +36,7 @@ AvatarMixer::AvatarMixer(const QByteArray& packet) :
void attachAvatarDataToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) {
newNode->setLinkedData(new AvatarData());
newNode->setLinkedData(new AvatarMixerClientData());
}
}
@ -130,6 +130,18 @@ void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSoc
}
break;
}
case PacketTypeAvatarIdentity: {
QUuid nodeUUID;
deconstructPacketHeader(dataByteArray, nodeUUID);
// check if we have a matching node in our list
SharedNodePointer avatarNode = nodeList->nodeWithUUID(nodeUUID);
if (avatarNode) {
// process the avatar identity packet sent from the avatar
reinterpret_cast<AvatarMixerClientData*>(avatarNode->getLinkedData())->parseIdentityPacket(dataByteArray);
}
}
case PacketTypeKillAvatar: {
nodeList->processKillNode(dataByteArray);
break;
@ -155,6 +167,8 @@ void AvatarMixer::run() {
gettimeofday(&startTime, NULL);
while (!_isFinished) {
QCoreApplication::processEvents();

View file

@ -0,0 +1,25 @@
//
// AvatarMixerClientData.cpp
// hifi
//
// Created by Stephen Birarda on 2/4/2014.
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
//
#include "AvatarMixerClientData.h"
void AvatarMixerClientData::parseIdentityPacket(const QByteArray &packet) {
QDataStream packetStream(packet);
packetStream.skipRawData(numBytesForPacketHeader(packet));
QUrl faceModelURL, skeletonURL;
packetStream >> faceModelURL >> skeletonURL;
if (faceModelURL != _faceModelURL) {
_faceModelURL = faceModelURL;
}
if (skeletonURL != _skeletonURL) {
_skeletonURL = skeletonURL;
}
}

View file

@ -0,0 +1,30 @@
//
// AvatarMixerClientData.h
// hifi
//
// Created by Stephen Birarda on 2/4/2014.
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
//
#ifndef __hifi__AvatarMixerClientData__
#define __hifi__AvatarMixerClientData__
#include <QtCore/QUrl>
#include <AvatarData.h>
class AvatarMixerClientData : public AvatarData {
public:
const QUrl& getFaceModelURL() const { return _faceModelURL; }
void setFaceModelURL(const QUrl& faceModelURL) { _faceModelURL = faceModelURL; }
const QUrl& getSkeletonURL() const { return _skeletonURL; }
void setSkeletonURL(const QUrl& skeletonURL) { _skeletonURL = skeletonURL; }
void parseIdentityPacket(const QByteArray& packet);
private:
QUrl _faceModelURL;
QUrl _skeletonURL;
};
#endif /* defined(__hifi__AvatarMixerClientData__) */