some fixes for when an avatar is a child of something else

This commit is contained in:
Seth Alves 2017-02-12 08:27:39 -08:00
parent e6142d9719
commit 1164a1b3bf
3 changed files with 23 additions and 20 deletions

View file

@ -405,7 +405,7 @@ void AvatarMixer::broadcastAvatarData() {
otherNodeData->getLastReceivedSequenceNumber());
// determine if avatar is in view, to determine how much data to include...
glm::vec3 otherNodeBoxScale = (otherNodeData->getPosition() - otherNodeData->getGlobalBoundingBoxCorner()) * 2.0f;
glm::vec3 otherNodeBoxScale = (otherPosition - otherNodeData->getGlobalBoundingBoxCorner()) * 2.0f;
AABox otherNodeBox(otherNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
bool isInView = nodeData->otherAvatarInView(otherNodeBox);
@ -431,7 +431,7 @@ void AvatarMixer::broadcastAvatarData() {
auto lastEncodeForOther = nodeData->getLastOtherAvatarEncodeTime(otherNode->getUUID());
QVector<JointData>& lastSentJointsForOther = nodeData->getLastOtherAvatarSentJoints(otherNode->getUUID());
bool distanceAdjust = true;
glm::vec3 viewerPosition = nodeData->getPosition();
glm::vec3 viewerPosition = myPosition;
auto bytes = otherAvatar.toByteArray(detail, lastEncodeForOther, lastSentJointsForOther, distanceAdjust, viewerPosition, &lastSentJointsForOther);
numAvatarDataBytes += avatarPacketList->write(bytes);

View file

@ -1324,6 +1324,7 @@ void Avatar::setParentID(const QUuid& parentID) {
if (!isMyAvatar()) {
return;
}
QUuid initialParentID = getParentID();
bool success;
Transform beforeChangeTransform = getTransform(success);
SpatiallyNestable::setParentID(parentID);
@ -1332,6 +1333,9 @@ void Avatar::setParentID(const QUuid& parentID) {
if (!success) {
qCDebug(interfaceapp) << "Avatar::setParentID failed to reset avatar's location.";
}
if (initialParentID != parentID) {
_parentChanged = usecTimestampNow();
}
}
}

View file

@ -405,6 +405,18 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
_additionalFlagsRateOutbound.increment(numBytes);
}
if (hasParentInfo) {
auto startSection = destinationBuffer;
auto parentInfo = reinterpret_cast<AvatarDataPacket::ParentInfo*>(destinationBuffer);
QByteArray referentialAsBytes = parentID.toRfc4122();
memcpy(parentInfo->parentUUID, referentialAsBytes.data(), referentialAsBytes.size());
parentInfo->parentJointIndex = _parentJointIndex;
destinationBuffer += sizeof(AvatarDataPacket::ParentInfo);
int numBytes = destinationBuffer - startSection;
_parentInfoRateOutbound.increment(numBytes);
}
if (hasAvatarLocalPosition) {
auto startSection = destinationBuffer;
auto data = reinterpret_cast<AvatarDataPacket::AvatarLocalPosition*>(destinationBuffer);
@ -418,18 +430,6 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
_localPositionRateOutbound.increment(numBytes);
}
if (hasParentInfo) {
auto startSection = destinationBuffer;
auto parentInfo = reinterpret_cast<AvatarDataPacket::ParentInfo*>(destinationBuffer);
QByteArray referentialAsBytes = parentID.toRfc4122();
memcpy(parentInfo->parentUUID, referentialAsBytes.data(), referentialAsBytes.size());
parentInfo->parentJointIndex = _parentJointIndex;
destinationBuffer += sizeof(AvatarDataPacket::ParentInfo);
int numBytes = destinationBuffer - startSection;
_parentInfoRateOutbound.increment(numBytes);
}
// If it is connected, pack up the data
if (hasFaceTrackerInfo) {
auto startSection = destinationBuffer;
@ -904,19 +904,18 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
auto newParentID = QUuid::fromRfc4122(byteArray);
if ((_parentID != newParentID) || (_parentJointIndex = parentInfo->parentJointIndex)) {
_parentID = newParentID;
_parentJointIndex = parentInfo->parentJointIndex;
if ((_parentID != newParentID) || (_parentJointIndex != parentInfo->parentJointIndex)) {
setParentID(newParentID);
setParentJointIndex(parentInfo->parentJointIndex);
_parentChanged = usecTimestampNow();
}
int numBytesRead = sourceBuffer - startSection;
_parentInfoRate.increment(numBytesRead);
_parentInfoUpdateRate.increment();
}
else {
} else {
// FIXME - this aint totally right, for switching to parent/no-parent
_parentID = QUuid();
setParentID(QUuid());
}
if (hasAvatarLocalPosition) {