mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 14:04:23 +02:00
WIP commit, socket errors when AvatarIdentity is larger then MTU
This commit is contained in:
parent
b48134e30c
commit
c48fce4f5a
4 changed files with 60 additions and 58 deletions
|
@ -417,7 +417,9 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer<ReceivedMessage> mes
|
||||||
AvatarData& avatar = nodeData->getAvatar();
|
AvatarData& avatar = nodeData->getAvatar();
|
||||||
|
|
||||||
// parse the identity packet and update the change timestamp if appropriate
|
// parse the identity packet and update the change timestamp if appropriate
|
||||||
if (avatar.hasIdentityChangedAfterParsing(message->getMessage())) {
|
AvatarData::Identity identity;
|
||||||
|
AvatarData::parseAvatarIdentityPacket(message->getMessage(), identity);
|
||||||
|
if (avatar.processAvatarIdentity(identity)) {
|
||||||
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
QMutexLocker nodeDataLocker(&nodeData->getMutex());
|
||||||
nodeData->flagIdentityChange();
|
nodeData->flagIdentityChange();
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,7 +612,8 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
// the wrong bones, resulting in a twisted avatar, An un-animated avatar is preferable to this.
|
// the wrong bones, resulting in a twisted avatar, An un-animated avatar is preferable to this.
|
||||||
bool skipJoints = false;
|
bool skipJoints = false;
|
||||||
if (_networkJointIndexMap.empty()) {
|
if (_networkJointIndexMap.empty()) {
|
||||||
skipJoints = true;
|
qCDebug(avatars) << "AJT: parseAvatarDataPacket _networkJointIndexMap.size = " << _networkJointIndexMap.size();
|
||||||
|
skipJoints = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bytesOfValidity = (int)ceil((float)numJoints / (float)BITS_IN_BYTE);
|
int bytesOfValidity = (int)ceil((float)numJoints / (float)BITS_IN_BYTE);
|
||||||
|
@ -726,7 +727,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // numJoints * 12 bytes
|
} // numJoints * 6 bytes
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (numValidJointRotations > 15) {
|
if (numValidJointRotations > 15) {
|
||||||
|
@ -981,42 +982,45 @@ void AvatarData::clearJointsData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarData::hasIdentityChangedAfterParsing(const QByteArray& data) {
|
void AvatarData::parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut) {
|
||||||
QDataStream packetStream(data);
|
QDataStream packetStream(data);
|
||||||
|
packetStream >> identityOut.uuid >> identityOut.skeletonModelURL >> identityOut.attachmentData >> identityOut.displayName >> identityOut.jointIndices;
|
||||||
QUuid avatarUUID;
|
|
||||||
QUrl skeletonModelURL;
|
|
||||||
QVector<AttachmentData> attachmentData;
|
|
||||||
QString displayName;
|
|
||||||
QHash <QString, int> networkJointIndices;
|
|
||||||
packetStream >> avatarUUID >> skeletonModelURL >> attachmentData >> displayName >> networkJointIndices;
|
|
||||||
bool hasIdentityChanged = false;
|
|
||||||
|
|
||||||
if (!_jointIndices.empty() && _networkJointIndexMap.empty() && !networkJointIndices.empty()) {
|
|
||||||
// build networkJointIndexMap from _jointIndices and networkJointIndices.
|
|
||||||
_networkJointIndexMap.fill(networkJointIndices.size(), -1);
|
|
||||||
for (auto iter = networkJointIndices.cbegin(); iter != networkJointIndices.end(); ++iter) {
|
|
||||||
int jointIndex = getJointIndex(iter.key());
|
|
||||||
_networkJointIndexMap[iter.value()] = jointIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AJT: just got a new networkJointIndicesMap.
|
// AJT: just got a new networkJointIndicesMap.
|
||||||
qCDebug(avatars) << "AJT: receiving networkJointIndices.size = " << networkJointIndices.size();
|
qCDebug(avatars) << "AJT: receiving identity.jointIndices.size = " << identityOut.jointIndices.size();
|
||||||
|
}
|
||||||
|
|
||||||
if (_firstSkeletonCheck || (skeletonModelURL != _skeletonModelURL)) {
|
bool AvatarData::processAvatarIdentity(const Identity& identity) {
|
||||||
setSkeletonModelURL(skeletonModelURL);
|
|
||||||
|
bool hasIdentityChanged = false;
|
||||||
|
|
||||||
|
qCDebug(avatars) << "AJT: processAvatarIdentity got here!";
|
||||||
|
|
||||||
|
if (!_jointIndices.empty() && _networkJointIndexMap.empty() && !identity.jointIndices.empty()) {
|
||||||
|
// build networkJointIndexMap from _jointIndices and networkJointIndices.
|
||||||
|
_networkJointIndexMap.fill(identity.jointIndices.size(), -1);
|
||||||
|
for (auto iter = identity.jointIndices.cbegin(); iter != identity.jointIndices.end(); ++iter) {
|
||||||
|
int jointIndex = getJointIndex(iter.key());
|
||||||
|
_networkJointIndexMap[iter.value()] = jointIndex;
|
||||||
|
qCDebug(avatars) << "AJT: mapping " << iter.value() << " -> " << jointIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qCDebug(avatars) << "AJT: processAvatarIdentity got here!";
|
||||||
|
|
||||||
|
if (_firstSkeletonCheck || (identity.skeletonModelURL != _skeletonModelURL)) {
|
||||||
|
setSkeletonModelURL(identity.skeletonModelURL);
|
||||||
hasIdentityChanged = true;
|
hasIdentityChanged = true;
|
||||||
_firstSkeletonCheck = false;
|
_firstSkeletonCheck = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayName != _displayName) {
|
if (identity.displayName != _displayName) {
|
||||||
setDisplayName(displayName);
|
setDisplayName(identity.displayName);
|
||||||
hasIdentityChanged = true;
|
hasIdentityChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachmentData != _attachmentData) {
|
if (identity.attachmentData != _attachmentData) {
|
||||||
setAttachmentData(attachmentData);
|
setAttachmentData(identity.attachmentData);
|
||||||
hasIdentityChanged = true;
|
hasIdentityChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,6 +1208,8 @@ void AvatarData::sendIdentityPacket() {
|
||||||
|
|
||||||
QByteArray identityData = identityByteArray();
|
QByteArray identityData = identityByteArray();
|
||||||
|
|
||||||
|
qCDebug(avatars) << "AJT: sendIdentityPacket() size = " << identityData.size();
|
||||||
|
|
||||||
auto packetList = NLPacketList::create(PacketType::AvatarIdentity, QByteArray(), true, true);
|
auto packetList = NLPacketList::create(PacketType::AvatarIdentity, QByteArray(), true, true);
|
||||||
packetList->write(identityData);
|
packetList->write(identityData);
|
||||||
nodeList->eachMatchingNode(
|
nodeList->eachMatchingNode(
|
||||||
|
@ -1213,6 +1219,8 @@ void AvatarData::sendIdentityPacket() {
|
||||||
[&](const SharedNodePointer& node) {
|
[&](const SharedNodePointer& node) {
|
||||||
nodeList->sendPacketList(std::move(packetList), *node);
|
nodeList->sendPacketList(std::move(packetList), *node);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
qCDebug(avatars) << "AJT: sendIdentityPacket() done!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::updateJointMappings() {
|
void AvatarData::updateJointMappings() {
|
||||||
|
|
|
@ -280,7 +280,19 @@ public:
|
||||||
|
|
||||||
const HeadData* getHeadData() const { return _headData; }
|
const HeadData* getHeadData() const { return _headData; }
|
||||||
|
|
||||||
bool hasIdentityChangedAfterParsing(const QByteArray& data);
|
struct Identity {
|
||||||
|
QUuid uuid;
|
||||||
|
QUrl skeletonModelURL;
|
||||||
|
QVector<AttachmentData> attachmentData;
|
||||||
|
QString displayName;
|
||||||
|
QHash<QString, int> jointIndices;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut);
|
||||||
|
|
||||||
|
// returns true if identity has changed, false otherwise.
|
||||||
|
bool processAvatarIdentity(const Identity& identity);
|
||||||
|
|
||||||
QByteArray identityByteArray();
|
QByteArray identityByteArray();
|
||||||
|
|
||||||
const QUrl& getSkeletonModelURL() const { return _skeletonModelURL; }
|
const QUrl& getSkeletonModelURL() const { return _skeletonModelURL; }
|
||||||
|
|
|
@ -107,33 +107,13 @@ void AvatarHashMap::processAvatarDataPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
// setup a data stream to parse the packet
|
AvatarData::Identity identity;
|
||||||
QDataStream identityStream(message->getMessage());
|
AvatarData::parseAvatarIdentityPacket(message->getMessage(), identity);
|
||||||
|
|
||||||
QUuid sessionUUID;
|
|
||||||
|
|
||||||
while (!identityStream.atEnd()) {
|
|
||||||
|
|
||||||
QUrl faceMeshURL, skeletonURL;
|
|
||||||
QVector<AttachmentData> attachmentData;
|
|
||||||
QString displayName;
|
|
||||||
identityStream >> sessionUUID >> faceMeshURL >> skeletonURL >> attachmentData >> displayName;
|
|
||||||
|
|
||||||
// mesh URL for a UUID, find avatar in our list
|
// mesh URL for a UUID, find avatar in our list
|
||||||
auto avatar = newOrExistingAvatar(sessionUUID, sendingNode);
|
auto avatar = newOrExistingAvatar(identity.uuid, sendingNode);
|
||||||
|
|
||||||
if (avatar->getSkeletonModelURL().isEmpty() || (avatar->getSkeletonModelURL() != skeletonURL)) {
|
avatar->processAvatarIdentity(identity);
|
||||||
avatar->setSkeletonModelURL(skeletonURL); // Will expand "" to default and so will not continuously fire
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avatar->getAttachmentData() != attachmentData) {
|
|
||||||
avatar->setAttachmentData(attachmentData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avatar->getDisplayName() != displayName) {
|
|
||||||
avatar->setDisplayName(displayName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::processKillAvatar(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AvatarHashMap::processKillAvatar(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
|
|
Loading…
Reference in a new issue