fix handling of an avatar's parent changing

This commit is contained in:
Seth Alves 2017-02-12 10:01:30 -08:00
parent 1164a1b3bf
commit 0c2abc9883

View file

@ -258,8 +258,8 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
// local position, and parent info only apply to avatars that are parented. The local position // local position, and parent info only apply to avatars that are parented. The local position
// and the parent info can change independently though, so we track their "changed since" // and the parent info can change independently though, so we track their "changed since"
// separately // separately
bool hasParentInfo = hasParent() && (sendAll || parentInfoChangedSince(lastSentTime)); bool hasParentInfo = sendAll || parentInfoChangedSince(lastSentTime);
bool hasAvatarLocalPosition = hasParent() && (sendAll || tranlationChangedSince(lastSentTime)); bool hasAvatarLocalPosition = sendAll || tranlationChangedSince(lastSentTime);
bool hasFaceTrackerInfo = hasFaceTracker() && (sendAll || faceTrackerInfoChangedSince(lastSentTime)); bool hasFaceTrackerInfo = hasFaceTracker() && (sendAll || faceTrackerInfoChangedSince(lastSentTime));
bool hasJointData = sendAll || !sendMinimum; bool hasJointData = sendAll || !sendMinimum;
@ -884,7 +884,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
sourceBuffer += sizeof(AvatarDataPacket::AdditionalFlags); sourceBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
if (somethingChanged) { if (somethingChanged) {
_additionalFlagsChanged = usecTimestampNow(); _additionalFlagsChanged = usecTimestampNow();
} }
int numBytesRead = sourceBuffer - startSection; int numBytesRead = sourceBuffer - startSection;
@ -892,8 +892,6 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
_additionalFlagsUpdateRate.increment(); _additionalFlagsUpdateRate.increment();
} }
// FIXME -- make sure to handle the existance of a parent vs a change in the parent...
//bool hasReferential = oneAtBit(bitItems, HAS_REFERENTIAL);
if (hasParentInfo) { if (hasParentInfo) {
auto startSection = sourceBuffer; auto startSection = sourceBuffer;
PACKET_READ_CHECK(ParentInfo, sizeof(AvatarDataPacket::ParentInfo)); PACKET_READ_CHECK(ParentInfo, sizeof(AvatarDataPacket::ParentInfo));
@ -904,18 +902,15 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
auto newParentID = QUuid::fromRfc4122(byteArray); auto newParentID = QUuid::fromRfc4122(byteArray);
if ((_parentID != newParentID) || (_parentJointIndex != parentInfo->parentJointIndex)) { if ((getParentID() != newParentID) || (getParentJointIndex() != parentInfo->parentJointIndex)) {
setParentID(newParentID); SpatiallyNestable::setParentID(newParentID);
setParentJointIndex(parentInfo->parentJointIndex); SpatiallyNestable::setParentJointIndex(parentInfo->parentJointIndex);
_parentChanged = usecTimestampNow(); _parentChanged = usecTimestampNow();
} }
int numBytesRead = sourceBuffer - startSection; int numBytesRead = sourceBuffer - startSection;
_parentInfoRate.increment(numBytesRead); _parentInfoRate.increment(numBytesRead);
_parentInfoUpdateRate.increment(); _parentInfoUpdateRate.increment();
} else {
// FIXME - this aint totally right, for switching to parent/no-parent
setParentID(QUuid());
} }
if (hasAvatarLocalPosition) { if (hasAvatarLocalPosition) {