mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 12:42:58 +02:00
Merge pull request #9652 from sethalves/avatar-as-child-fixes
some fixes for when an avatar is a child of something else
This commit is contained in:
commit
f433347362
8 changed files with 42 additions and 38 deletions
|
@ -405,7 +405,7 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
otherNodeData->getLastReceivedSequenceNumber());
|
otherNodeData->getLastReceivedSequenceNumber());
|
||||||
|
|
||||||
// determine if avatar is in view, to determine how much data to include...
|
// 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);
|
AABox otherNodeBox(otherNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale);
|
||||||
bool isInView = nodeData->otherAvatarInView(otherNodeBox);
|
bool isInView = nodeData->otherAvatarInView(otherNodeBox);
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
auto lastEncodeForOther = nodeData->getLastOtherAvatarEncodeTime(otherNode->getUUID());
|
auto lastEncodeForOther = nodeData->getLastOtherAvatarEncodeTime(otherNode->getUUID());
|
||||||
QVector<JointData>& lastSentJointsForOther = nodeData->getLastOtherAvatarSentJoints(otherNode->getUUID());
|
QVector<JointData>& lastSentJointsForOther = nodeData->getLastOtherAvatarSentJoints(otherNode->getUUID());
|
||||||
bool distanceAdjust = true;
|
bool distanceAdjust = true;
|
||||||
glm::vec3 viewerPosition = nodeData->getPosition();
|
glm::vec3 viewerPosition = myPosition;
|
||||||
auto bytes = otherAvatar.toByteArray(detail, lastEncodeForOther, lastSentJointsForOther, distanceAdjust, viewerPosition, &lastSentJointsForOther);
|
auto bytes = otherAvatar.toByteArray(detail, lastEncodeForOther, lastSentJointsForOther, distanceAdjust, viewerPosition, &lastSentJointsForOther);
|
||||||
numAvatarDataBytes += avatarPacketList->write(bytes);
|
numAvatarDataBytes += avatarPacketList->write(bytes);
|
||||||
|
|
||||||
|
|
|
@ -1361,6 +1361,7 @@ void Avatar::setParentID(const QUuid& parentID) {
|
||||||
if (!isMyAvatar()) {
|
if (!isMyAvatar()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QUuid initialParentID = getParentID();
|
||||||
bool success;
|
bool success;
|
||||||
Transform beforeChangeTransform = getTransform(success);
|
Transform beforeChangeTransform = getTransform(success);
|
||||||
SpatiallyNestable::setParentID(parentID);
|
SpatiallyNestable::setParentID(parentID);
|
||||||
|
@ -1369,6 +1370,9 @@ void Avatar::setParentID(const QUuid& parentID) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qCDebug(interfaceapp) << "Avatar::setParentID failed to reset avatar's location.";
|
qCDebug(interfaceapp) << "Avatar::setParentID failed to reset avatar's location.";
|
||||||
}
|
}
|
||||||
|
if (initialParentID != parentID) {
|
||||||
|
_parentChanged = usecTimestampNow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ Line3DOverlay::~Line3DOverlay() {
|
||||||
|
|
||||||
glm::vec3 Line3DOverlay::getStart() const {
|
glm::vec3 Line3DOverlay::getStart() const {
|
||||||
bool success;
|
bool success;
|
||||||
glm::vec3 worldStart = localToWorld(_start, _parentID, _parentJointIndex, success);
|
glm::vec3 worldStart = localToWorld(_start, getParentID(), getParentJointIndex(), success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug() << "Line3DOverlay::getStart failed";
|
qDebug() << "Line3DOverlay::getStart failed";
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ glm::vec3 Line3DOverlay::getStart() const {
|
||||||
|
|
||||||
glm::vec3 Line3DOverlay::getEnd() const {
|
glm::vec3 Line3DOverlay::getEnd() const {
|
||||||
bool success;
|
bool success;
|
||||||
glm::vec3 worldEnd = localToWorld(_end, _parentID, _parentJointIndex, success);
|
glm::vec3 worldEnd = localToWorld(_end, getParentID(), getParentJointIndex(), success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug() << "Line3DOverlay::getEnd failed";
|
qDebug() << "Line3DOverlay::getEnd failed";
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ glm::vec3 Line3DOverlay::getEnd() const {
|
||||||
|
|
||||||
void Line3DOverlay::setStart(const glm::vec3& start) {
|
void Line3DOverlay::setStart(const glm::vec3& start) {
|
||||||
bool success;
|
bool success;
|
||||||
_start = worldToLocal(start, _parentID, _parentJointIndex, success);
|
_start = worldToLocal(start, getParentID(), getParentJointIndex(), success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug() << "Line3DOverlay::setStart failed";
|
qDebug() << "Line3DOverlay::setStart failed";
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void Line3DOverlay::setStart(const glm::vec3& start) {
|
||||||
|
|
||||||
void Line3DOverlay::setEnd(const glm::vec3& end) {
|
void Line3DOverlay::setEnd(const glm::vec3& end) {
|
||||||
bool success;
|
bool success;
|
||||||
_end = worldToLocal(end, _parentID, _parentJointIndex, success);
|
_end = worldToLocal(end, getParentID(), getParentJointIndex(), success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug() << "Line3DOverlay::setEnd failed";
|
qDebug() << "Line3DOverlay::setEnd failed";
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,8 +257,10 @@ 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 = hasParent() && (sendAll ||
|
||||||
|
tranlationChangedSince(lastSentTime) ||
|
||||||
|
parentInfoChangedSince(lastSentTime));
|
||||||
|
|
||||||
bool hasFaceTrackerInfo = hasFaceTracker() && (sendAll || faceTrackerInfoChangedSince(lastSentTime));
|
bool hasFaceTrackerInfo = hasFaceTracker() && (sendAll || faceTrackerInfoChangedSince(lastSentTime));
|
||||||
bool hasJointData = sendAll || !sendMinimum;
|
bool hasJointData = sendAll || !sendMinimum;
|
||||||
|
@ -404,6 +406,18 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
_additionalFlagsRateOutbound.increment(numBytes);
|
_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 = getParentJointIndex();
|
||||||
|
destinationBuffer += sizeof(AvatarDataPacket::ParentInfo);
|
||||||
|
|
||||||
|
int numBytes = destinationBuffer - startSection;
|
||||||
|
_parentInfoRateOutbound.increment(numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
if (hasAvatarLocalPosition) {
|
if (hasAvatarLocalPosition) {
|
||||||
auto startSection = destinationBuffer;
|
auto startSection = destinationBuffer;
|
||||||
auto data = reinterpret_cast<AvatarDataPacket::AvatarLocalPosition*>(destinationBuffer);
|
auto data = reinterpret_cast<AvatarDataPacket::AvatarLocalPosition*>(destinationBuffer);
|
||||||
|
@ -417,18 +431,6 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
_localPositionRateOutbound.increment(numBytes);
|
_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 it is connected, pack up the data
|
||||||
if (hasFaceTrackerInfo) {
|
if (hasFaceTrackerInfo) {
|
||||||
auto startSection = destinationBuffer;
|
auto startSection = destinationBuffer;
|
||||||
|
@ -882,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;
|
||||||
|
@ -890,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));
|
||||||
|
@ -902,9 +902,9 @@ 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)) {
|
||||||
_parentID = newParentID;
|
SpatiallyNestable::setParentID(newParentID);
|
||||||
_parentJointIndex = parentInfo->parentJointIndex;
|
SpatiallyNestable::setParentJointIndex(parentInfo->parentJointIndex);
|
||||||
_parentChanged = usecTimestampNow();
|
_parentChanged = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,13 +912,8 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
_parentInfoRate.increment(numBytesRead);
|
_parentInfoRate.increment(numBytesRead);
|
||||||
_parentInfoUpdateRate.increment();
|
_parentInfoUpdateRate.increment();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// FIXME - this aint totally right, for switching to parent/no-parent
|
|
||||||
_parentID = QUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasAvatarLocalPosition) {
|
if (hasAvatarLocalPosition) {
|
||||||
assert(hasParent()); // we shouldn't have local position unless we have a parent
|
|
||||||
auto startSection = sourceBuffer;
|
auto startSection = sourceBuffer;
|
||||||
|
|
||||||
PACKET_READ_CHECK(AvatarLocalPosition, sizeof(AvatarDataPacket::AvatarLocalPosition));
|
PACKET_READ_CHECK(AvatarLocalPosition, sizeof(AvatarDataPacket::AvatarLocalPosition));
|
||||||
|
@ -930,7 +925,11 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
}
|
}
|
||||||
return buffer.size();
|
return buffer.size();
|
||||||
}
|
}
|
||||||
setLocalPosition(position);
|
if (hasParent()) {
|
||||||
|
setLocalPosition(position);
|
||||||
|
} else {
|
||||||
|
qCWarning(avatars) << "received localPosition for avatar with no parent";
|
||||||
|
}
|
||||||
sourceBuffer += sizeof(AvatarDataPacket::AvatarLocalPosition);
|
sourceBuffer += sizeof(AvatarDataPacket::AvatarLocalPosition);
|
||||||
int numBytesRead = sourceBuffer - startSection;
|
int numBytesRead = sourceBuffer - startSection;
|
||||||
_localPositionRate.increment(numBytesRead);
|
_localPositionRate.increment(numBytesRead);
|
||||||
|
|
|
@ -1595,7 +1595,7 @@ void EntityItem::updatePosition(const glm::vec3& value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::updateParentID(const QUuid& value) {
|
void EntityItem::updateParentID(const QUuid& value) {
|
||||||
if (_parentID != value) {
|
if (getParentID() != value) {
|
||||||
setParentID(value);
|
setParentID(value);
|
||||||
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; // children are forced to be kinematic
|
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE; // children are forced to be kinematic
|
||||||
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
_dirtyFlags |= Simulation::DIRTY_COLLISION_GROUP; // may need to not collide with own avatar
|
||||||
|
|
|
@ -56,7 +56,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
case PacketType::KillAvatar:
|
case PacketType::KillAvatar:
|
||||||
return static_cast<PacketVersion>(AvatarMixerPacketVersion::VariableAvatarData);
|
return static_cast<PacketVersion>(AvatarMixerPacketVersion::AvatarAsChildFixes);
|
||||||
case PacketType::MessagesData:
|
case PacketType::MessagesData:
|
||||||
return static_cast<PacketVersion>(MessageDataVersion::TextOrBinaryData);
|
return static_cast<PacketVersion>(MessageDataVersion::TextOrBinaryData);
|
||||||
case PacketType::ICEServerHeartbeat:
|
case PacketType::ICEServerHeartbeat:
|
||||||
|
|
|
@ -224,7 +224,8 @@ enum class AvatarMixerPacketVersion : PacketVersion {
|
||||||
SessionDisplayName,
|
SessionDisplayName,
|
||||||
Unignore,
|
Unignore,
|
||||||
ImmediateSessionDisplayNameUpdates,
|
ImmediateSessionDisplayNameUpdates,
|
||||||
VariableAvatarData
|
VariableAvatarData,
|
||||||
|
AvatarAsChildFixes
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DomainConnectRequestVersion : PacketVersion {
|
enum class DomainConnectRequestVersion : PacketVersion {
|
||||||
|
|
|
@ -186,9 +186,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
const NestableType _nestableType; // EntityItem or an AvatarData
|
const NestableType _nestableType; // EntityItem or an AvatarData
|
||||||
QUuid _id;
|
QUuid _id;
|
||||||
QUuid _parentID; // what is this thing's transform relative to?
|
|
||||||
quint16 _parentJointIndex { INVALID_JOINT_INDEX }; // which joint of the parent is this relative to?
|
|
||||||
|
|
||||||
mutable SpatiallyNestableWeakPointer _parent;
|
mutable SpatiallyNestableWeakPointer _parent;
|
||||||
|
|
||||||
virtual void beParentOfChild(SpatiallyNestablePointer newChild) const;
|
virtual void beParentOfChild(SpatiallyNestablePointer newChild) const;
|
||||||
|
@ -211,6 +208,9 @@ protected:
|
||||||
quint64 _rotationChanged { 0 };
|
quint64 _rotationChanged { 0 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QUuid _parentID; // what is this thing's transform relative to?
|
||||||
|
quint16 _parentJointIndex { INVALID_JOINT_INDEX }; // which joint of the parent is this relative to?
|
||||||
|
|
||||||
mutable ReadWriteLockable _transformLock;
|
mutable ReadWriteLockable _transformLock;
|
||||||
mutable ReadWriteLockable _idLock;
|
mutable ReadWriteLockable _idLock;
|
||||||
mutable ReadWriteLockable _velocityLock;
|
mutable ReadWriteLockable _velocityLock;
|
||||||
|
|
Loading…
Reference in a new issue