Moved jointIndices transmission behind #ifdef

This commit is contained in:
Anthony J. Thibault 2016-05-18 15:41:21 -07:00
parent c48fce4f5a
commit 135fa8c2aa
2 changed files with 21 additions and 23 deletions

View file

@ -611,10 +611,11 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
// an earlier AvatarIdentity packet. Because if we do, we risk applying the joint data // an earlier AvatarIdentity packet. Because if we do, we risk applying the joint data
// 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;
#ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
if (_networkJointIndexMap.empty()) { if (_networkJointIndexMap.empty()) {
qCDebug(avatars) << "AJT: parseAvatarDataPacket _networkJointIndexMap.size = " << _networkJointIndexMap.size(); skipJoints = true;
skipJoints = false;
} }
#endif
int bytesOfValidity = (int)ceil((float)numJoints / (float)BITS_IN_BYTE); int bytesOfValidity = (int)ceil((float)numJoints / (float)BITS_IN_BYTE);
minPossibleSize += bytesOfValidity; minPossibleSize += bytesOfValidity;
@ -984,29 +985,28 @@ void AvatarData::clearJointsData() {
void AvatarData::parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut) { 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;
// AJT: just got a new networkJointIndicesMap. #ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
qCDebug(avatars) << "AJT: receiving identity.jointIndices.size = " << identityOut.jointIndices.size(); packetStream >> identityOut.uuid >> identityOut.skeletonModelURL >> identityOut.attachmentData >> identityOut.displayName >> identityOut.jointIndices;
#else
packetStream >> identityOut.uuid >> identityOut.skeletonModelURL >> identityOut.attachmentData >> identityOut.displayName;
#endif
} }
bool AvatarData::processAvatarIdentity(const Identity& identity) { bool AvatarData::processAvatarIdentity(const Identity& identity) {
bool hasIdentityChanged = false; bool hasIdentityChanged = false;
qCDebug(avatars) << "AJT: processAvatarIdentity got here!"; #ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
if (!_jointIndices.empty() && _networkJointIndexMap.empty() && !identity.jointIndices.empty()) { if (!_jointIndices.empty() && _networkJointIndexMap.empty() && !identity.jointIndices.empty()) {
// build networkJointIndexMap from _jointIndices and networkJointIndices. // build networkJointIndexMap from _jointIndices and networkJointIndices.
_networkJointIndexMap.fill(identity.jointIndices.size(), -1); _networkJointIndexMap.fill(identity.jointIndices.size(), -1);
for (auto iter = identity.jointIndices.cbegin(); iter != identity.jointIndices.end(); ++iter) { for (auto iter = identity.jointIndices.cbegin(); iter != identity.jointIndices.end(); ++iter) {
int jointIndex = getJointIndex(iter.key()); int jointIndex = getJointIndex(iter.key());
_networkJointIndexMap[iter.value()] = jointIndex; _networkJointIndexMap[iter.value()] = jointIndex;
qCDebug(avatars) << "AJT: mapping " << iter.value() << " -> " << jointIndex;
} }
} }
#endif
qCDebug(avatars) << "AJT: processAvatarIdentity got here!";
if (_firstSkeletonCheck || (identity.skeletonModelURL != _skeletonModelURL)) { if (_firstSkeletonCheck || (identity.skeletonModelURL != _skeletonModelURL)) {
setSkeletonModelURL(identity.skeletonModelURL); setSkeletonModelURL(identity.skeletonModelURL);
@ -1033,10 +1033,11 @@ QByteArray AvatarData::identityByteArray() {
QUrl emptyURL(""); QUrl emptyURL("");
const QUrl& urlToSend = _skeletonModelURL.scheme() == "file" ? emptyURL : _skeletonModelURL; const QUrl& urlToSend = _skeletonModelURL.scheme() == "file" ? emptyURL : _skeletonModelURL;
// AJT: just got a sending networkJointIndices #ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
qCDebug(avatars) << "AJT: sending _jointIndices.size = " << _jointIndices.size();
identityStream << QUuid() << urlToSend << _attachmentData << _displayName << _jointIndices; identityStream << QUuid() << urlToSend << _attachmentData << _displayName << _jointIndices;
#else
identityStream << QUuid() << urlToSend << _attachmentData << _displayName;
#endif
return identityData; return identityData;
} }
@ -1141,8 +1142,6 @@ void AvatarData::detachAll(const QString& modelURL, const QString& jointName) {
void AvatarData::setJointMappingsFromNetworkReply() { void AvatarData::setJointMappingsFromNetworkReply() {
QNetworkReply* networkReply = static_cast<QNetworkReply*>(sender()); QNetworkReply* networkReply = static_cast<QNetworkReply*>(sender());
qCDebug(avatars) << "AJT: GOT HERE! finished fst network request";
QByteArray line; QByteArray line;
while (!(line = networkReply->readLine()).isEmpty()) { while (!(line = networkReply->readLine()).isEmpty()) {
line = line.trimmed(); line = line.trimmed();
@ -1180,8 +1179,6 @@ void AvatarData::setJointMappingsFromNetworkReply() {
// now that we have the jointIndices send them to the AvatarMixer. // now that we have the jointIndices send them to the AvatarMixer.
sendIdentityPacket(); sendIdentityPacket();
qCDebug(avatars) << "AJT: _jointIndices.size = " << _jointIndices.size();
networkReply->deleteLater(); networkReply->deleteLater();
} }
@ -1208,8 +1205,6 @@ 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(
@ -1219,16 +1214,15 @@ 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() {
_jointIndices.clear(); _jointIndices.clear();
_jointNames.clear(); _jointNames.clear();
_networkJointIndexMap.clear();
qCDebug(avatars) << "AJT: GOT HERE! kicking off fst network request"; #ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
_networkJointIndexMap.clear();
#endif
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) { if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();

View file

@ -285,7 +285,9 @@ public:
QUrl skeletonModelURL; QUrl skeletonModelURL;
QVector<AttachmentData> attachmentData; QVector<AttachmentData> attachmentData;
QString displayName; QString displayName;
#ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
QHash<QString, int> jointIndices; QHash<QString, int> jointIndices;
#endif
}; };
static void parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut); static void parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut);
@ -378,7 +380,9 @@ protected:
float _displayNameAlpha; float _displayNameAlpha;
QHash<QString, int> _jointIndices; ///< 1-based, since zero is returned for missing keys QHash<QString, int> _jointIndices; ///< 1-based, since zero is returned for missing keys
#ifdef TRANSMIT_JOINT_INDICES_IN_IDENTITY_PACKET
QVector<int> _networkJointIndexMap; // maps network joint indices to local model joint indices. QVector<int> _networkJointIndexMap; // maps network joint indices to local model joint indices.
#endif
QStringList _jointNames; ///< in order of depth-first traversal QStringList _jointNames; ///< in order of depth-first traversal
quint64 _errorLogExpiry; ///< time in future when to log an error quint64 _errorLogExpiry; ///< time in future when to log an error