more cleanup

This commit is contained in:
ZappoMan 2017-04-24 18:01:54 -07:00
parent aa955ee360
commit 382645ddd0
7 changed files with 14 additions and 21 deletions

View file

@ -537,7 +537,7 @@ void Agent::setIsAvatar(bool isAvatar) {
connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket); connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket);
// start the timers // start the timers
_avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); _avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets
// tell the avatarAudioTimer to start ticking // tell the avatarAudioTimer to start ticking
emit startAvatarAudioTimer(); emit startAvatarAudioTimer();

View file

@ -405,7 +405,7 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer<ReceivedMessage> mes
// parse the identity packet and update the change timestamp if appropriate // parse the identity packet and update the change timestamp if appropriate
AvatarData::Identity identity; AvatarData::Identity identity;
AvatarData::parseAvatarIdentityPacket(message, identity); AvatarData::parseAvatarIdentityPacket(message->getMessage(), identity);
bool identityChanged = false; bool identityChanged = false;
bool displayNameChanged = false; bool displayNameChanged = false;
avatar.processAvatarIdentity(identity, identityChanged, displayNameChanged); avatar.processAvatarIdentity(identity, identityChanged, displayNameChanged);

View file

@ -412,13 +412,9 @@ void MyAvatar::update(float deltaTime) {
Q_ARG(glm::vec3, (getPosition() - halfBoundingBoxDimensions)), Q_ARG(glm::vec3, (getPosition() - halfBoundingBoxDimensions)),
Q_ARG(glm::vec3, (halfBoundingBoxDimensions*2.0f))); Q_ARG(glm::vec3, (halfBoundingBoxDimensions*2.0f)));
uint64_t now = usecTimestampNow(); if (getIdentityDataChanged()) {
if (now > _identityPacketExpiry || _avatarEntityDataLocallyEdited) { qDebug() << __FUNCTION__ << "about to call... sendIdentityPacket();";
_identityPacketExpiry = now + AVATAR_IDENTITY_PACKET_SEND_INTERVAL_USECS; sendIdentityPacket();
if (getIdentityDataChanged()) {
qDebug() << __FUNCTION__ << "about to call... sendIdentityPacket(); --- _identityPacketExpiry:" << _identityPacketExpiry << "_avatarEntityDataLocallyEdited:" << _avatarEntityDataLocallyEdited;
sendIdentityPacket();
}
} }
simulate(deltaTime); simulate(deltaTime);
@ -1261,7 +1257,7 @@ void MyAvatar::useFullAvatarURL(const QUrl& fullAvatarURL, const QString& modelN
setSkeletonModelURL(fullAvatarURL); setSkeletonModelURL(fullAvatarURL);
UserActivityLogger::getInstance().changedModel("skeleton", urlString); UserActivityLogger::getInstance().changedModel("skeleton", urlString);
} }
_identityPacketExpiry = 0; // triggers an identity packet next update() markIdentityDataChanged();
} }
void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) { void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {

View file

@ -701,8 +701,6 @@ private:
std::mutex _holdActionsMutex; std::mutex _holdActionsMutex;
std::vector<AvatarActionHold*> _holdActions; std::vector<AvatarActionHold*> _holdActions;
uint64_t _identityPacketExpiry { 0 };
float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f }; float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
float AUDIO_ENERGY_CONSTANT { 0.000001f }; float AUDIO_ENERGY_CONSTANT { 0.000001f };
float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f }; float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };

View file

@ -14,7 +14,6 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <limits>
#include <stdint.h> #include <stdint.h>
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
@ -1455,8 +1454,7 @@ QStringList AvatarData::getJointNames() const {
return _jointNames; return _jointNames;
} }
void AvatarData::parseAvatarIdentityPacket(const QSharedPointer<ReceivedMessage>& message, Identity& identityOut) { void AvatarData::parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut) {
const QByteArray& data = message->getMessage();
QDataStream packetStream(data); QDataStream packetStream(data);
packetStream >> identityOut.uuid packetStream >> identityOut.uuid
@ -1491,9 +1489,6 @@ void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityC
return; return;
} }
_identityUpdatedAt = identity.updatedAt;
qDebug() << __FUNCTION__ << "_identityUpdatedAt:" << _identityUpdatedAt;
if (_firstSkeletonCheck || (identity.skeletonModelURL != cannonicalSkeletonModelURL(emptyURL))) { if (_firstSkeletonCheck || (identity.skeletonModelURL != cannonicalSkeletonModelURL(emptyURL))) {
setSkeletonModelURL(identity.skeletonModelURL); setSkeletonModelURL(identity.skeletonModelURL);
identityChanged = true; identityChanged = true;
@ -1526,6 +1521,11 @@ void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityC
// flag this avatar as non-stale by updating _averageBytesReceived // flag this avatar as non-stale by updating _averageBytesReceived
const int BOGUS_NUM_BYTES = 1; const int BOGUS_NUM_BYTES = 1;
_averageBytesReceived.updateAverage(BOGUS_NUM_BYTES); _averageBytesReceived.updateAverage(BOGUS_NUM_BYTES);
// use the timestamp from this identity, since we want to honor the updated times in "server clock"
// this will overwrite any changes we made locally to this AvatarData's _identityUpdatedAt
_identityUpdatedAt = identity.updatedAt;
qDebug() << __FUNCTION__ << "_identityUpdatedAt:" << _identityUpdatedAt;
} }
QByteArray AvatarData::identityByteArray() const { QByteArray AvatarData::identityByteArray() const {

View file

@ -249,7 +249,6 @@ static const float MIN_AVATAR_SCALE = .005f;
const float MAX_AUDIO_LOUDNESS = 1000.0f; // close enough for mouth animation const float MAX_AUDIO_LOUDNESS = 1000.0f; // close enough for mouth animation
const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000; const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000;
const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_USECS = AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS * USECS_PER_MSEC;
// See also static AvatarData::defaultFullAvatarModelUrl(). // See also static AvatarData::defaultFullAvatarModelUrl().
const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default"); const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default");
@ -534,7 +533,7 @@ public:
quint64 updatedAt; quint64 updatedAt;
}; };
static void parseAvatarIdentityPacket(const QSharedPointer<ReceivedMessage>& message, Identity& identityOut); static void parseAvatarIdentityPacket(const QByteArray& data, Identity& identityOut);
// identityChanged returns true if identity has changed, false otherwise. // identityChanged returns true if identity has changed, false otherwise.
// displayNameChanged returns true if displayName has changed, false otherwise. // displayNameChanged returns true if displayName has changed, false otherwise.

View file

@ -127,7 +127,7 @@ AvatarSharedPointer AvatarHashMap::parseAvatarData(QSharedPointer<ReceivedMessag
void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) { void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
AvatarData::Identity identity; AvatarData::Identity identity;
AvatarData::parseAvatarIdentityPacket(message, identity); AvatarData::parseAvatarIdentityPacket(message->getMessage(), identity);
// make sure this isn't for an ignored avatar // make sure this isn't for an ignored avatar
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();