mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
kill avatars in hash map after a timeout threshold
This commit is contained in:
parent
69d3360675
commit
3e4369f2ff
3 changed files with 16 additions and 3 deletions
|
@ -52,7 +52,8 @@ AvatarData::AvatarData() :
|
|||
_displayNameAlpha(0.0f),
|
||||
_billboard(),
|
||||
_errorLogExpiry(0),
|
||||
_owningAvatarMixer()
|
||||
_owningAvatarMixer(),
|
||||
_lastUpdateTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -194,6 +195,10 @@ bool AvatarData::shouldLogError(const quint64& now) {
|
|||
|
||||
// read data in packet starting at byte offset and return number of bytes parsed
|
||||
int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||
|
||||
// reset the last heard timer since we have new data for this AvatarData
|
||||
_lastUpdateTimer.restart();
|
||||
|
||||
// lazily allocate memory for HeadData in case we're not an Avatar instance
|
||||
if (!_headData) {
|
||||
_headData = new HeadData(this);
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef unsigned long long quint64;
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QObject>
|
||||
|
@ -224,6 +225,8 @@ public:
|
|||
Node* getOwningAvatarMixer() { return _owningAvatarMixer.data(); }
|
||||
void setOwningAvatarMixer(const QWeakPointer<Node>& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; }
|
||||
|
||||
QElapsedTimer& getLastUpdateTimer() { return _lastUpdateTimer; }
|
||||
|
||||
virtual float getBoundingRadius() const { return 1.f; }
|
||||
|
||||
static void setNetworkAccessManager(QNetworkAccessManager* sharedAccessManager) { networkAccessManager = sharedAccessManager; }
|
||||
|
@ -284,7 +287,8 @@ protected:
|
|||
quint64 _errorLogExpiry; ///< time in future when to log an error
|
||||
|
||||
QWeakPointer<Node> _owningAvatarMixer;
|
||||
|
||||
QElapsedTimer _lastUpdateTimer;
|
||||
|
||||
/// Loads the joint indices, names from the FST file (if any)
|
||||
virtual void updateJointMappings();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
AvatarHashMap::AvatarHashMap() :
|
||||
_avatarHash()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AvatarHashMap::insert(const QUuid& id, AvatarSharedPointer avatar) {
|
||||
|
@ -27,8 +28,11 @@ AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator)
|
|||
return _avatarHash.erase(iterator);
|
||||
}
|
||||
|
||||
const qint64 AVATAR_SILENCE_THRESHOLD_MSECS = 5 * 1000;
|
||||
|
||||
bool AvatarHashMap::shouldKillAvatar(const AvatarSharedPointer& sharedAvatar) {
|
||||
return (sharedAvatar->getOwningAvatarMixer() == NULL);
|
||||
return (sharedAvatar->getOwningAvatarMixer() == NULL
|
||||
&& sharedAvatar->getLastUpdateTimer().elapsed() > AVATAR_SILENCE_THRESHOLD_MSECS);
|
||||
}
|
||||
|
||||
AvatarSharedPointer AvatarHashMap::newSharedAvatar() {
|
||||
|
|
Loading…
Reference in a new issue