mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
show avatar data receive rate by default with display name
This commit is contained in:
parent
cd159b7ae2
commit
f2dcacffd0
6 changed files with 44 additions and 19 deletions
|
@ -581,7 +581,8 @@ void Avatar::renderBillboard() {
|
||||||
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
glm::vec2 texCoordTopLeft(0.0f, 0.0f);
|
||||||
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
glm::vec2 texCoordBottomRight(1.0f, 1.0f);
|
||||||
|
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||||
|
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -709,11 +710,22 @@ void Avatar::renderDisplayName() {
|
||||||
glm::vec4(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA));
|
glm::vec4(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA));
|
||||||
|
|
||||||
glm::vec4 color(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
glm::vec4 color(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
||||||
|
|
||||||
|
// optionally render timing stats for this avatar with the display name
|
||||||
|
QString renderedDisplayName = _displayName;
|
||||||
|
|
||||||
|
const float BYTES_PER_KILOBYTE = 1000.0f;
|
||||||
|
float kilobytesPerSecond = getAverageBytesReceivedPerSecond() / BYTES_PER_KILOBYTE;
|
||||||
|
|
||||||
|
renderedDisplayName += QString(" - (%1 KBps, %2 Hz)")
|
||||||
|
.arg(QString::number(kilobytesPerSecond, 'f', 2))
|
||||||
|
.arg(getReceiveRate());
|
||||||
|
|
||||||
QByteArray ba = _displayName.toLocal8Bit();
|
QByteArray ba = _displayName.toLocal8Bit();
|
||||||
const char* text = ba.data();
|
const char* text = ba.data();
|
||||||
|
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text, color);
|
textRenderer(DISPLAYNAME)->draw(text_x, text_y, renderedDisplayName, color);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,11 @@ AvatarData::AvatarData() :
|
||||||
_billboard(),
|
_billboard(),
|
||||||
_errorLogExpiry(0),
|
_errorLogExpiry(0),
|
||||||
_owningAvatarMixer(),
|
_owningAvatarMixer(),
|
||||||
_lastUpdateTimer(),
|
|
||||||
_velocity(0.0f),
|
_velocity(0.0f),
|
||||||
_targetVelocity(0.0f),
|
_targetVelocity(0.0f),
|
||||||
_localAABox(DEFAULT_LOCAL_AABOX_CORNER, DEFAULT_LOCAL_AABOX_SCALE)
|
_localAABox(DEFAULT_LOCAL_AABOX_CORNER, DEFAULT_LOCAL_AABOX_SCALE)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarData::~AvatarData() {
|
AvatarData::~AvatarData() {
|
||||||
|
@ -268,9 +268,6 @@ bool AvatarData::shouldLogError(const quint64& now) {
|
||||||
// read data in packet starting at byte offset and return number of bytes parsed
|
// read data in packet starting at byte offset and return number of bytes parsed
|
||||||
int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
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
|
// lazily allocate memory for HeadData in case we're not an Avatar instance
|
||||||
if (!_headData) {
|
if (!_headData) {
|
||||||
_headData = new HeadData(this);
|
_headData = new HeadData(this);
|
||||||
|
@ -555,7 +552,17 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
}
|
}
|
||||||
} // numJoints * 8 bytes
|
} // numJoints * 8 bytes
|
||||||
|
|
||||||
return sourceBuffer - startPosition;
|
int numBytesRead = sourceBuffer - startPosition;
|
||||||
|
_averageBytesReceived.updateAverage(numBytesRead);
|
||||||
|
return numBytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AvatarData::getAverageBytesReceivedPerSecond() const {
|
||||||
|
return lrint(_averageBytesReceived.getAverageSampleValuePerSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
int AvatarData::getReceiveRate() const {
|
||||||
|
return lrint(1.0f / _averageBytesReceived.getEventDeltaAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarData::hasReferential() {
|
bool AvatarData::hasReferential() {
|
||||||
|
|
|
@ -46,9 +46,9 @@ typedef unsigned long long quint64;
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
#include <CollisionInfo.h>
|
#include <CollisionInfo.h>
|
||||||
#include <RegisteredMetaTypes.h>
|
|
||||||
|
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
|
#include <SimpleMovingAverage.h>
|
||||||
|
|
||||||
#include "AABox.h"
|
#include "AABox.h"
|
||||||
#include "HandData.h"
|
#include "HandData.h"
|
||||||
|
@ -293,11 +293,13 @@ public:
|
||||||
Node* getOwningAvatarMixer() { return _owningAvatarMixer.data(); }
|
Node* getOwningAvatarMixer() { return _owningAvatarMixer.data(); }
|
||||||
void setOwningAvatarMixer(const QWeakPointer<Node>& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; }
|
void setOwningAvatarMixer(const QWeakPointer<Node>& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; }
|
||||||
|
|
||||||
QElapsedTimer& getLastUpdateTimer() { return _lastUpdateTimer; }
|
|
||||||
|
|
||||||
const AABox& getLocalAABox() const { return _localAABox; }
|
const AABox& getLocalAABox() const { return _localAABox; }
|
||||||
const Referential* getReferential() const { return _referential; }
|
const Referential* getReferential() const { return _referential; }
|
||||||
|
|
||||||
|
int getUsecsSinceLastUpdate() const { return _averageBytesReceived.getUsecsSinceLastEvent(); }
|
||||||
|
int getAverageBytesReceivedPerSecond() const;
|
||||||
|
int getReceiveRate() const;
|
||||||
|
|
||||||
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
void setVelocity(const glm::vec3 velocity) { _velocity = velocity; }
|
||||||
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; }
|
||||||
glm::vec3 getTargetVelocity() const { return _targetVelocity; }
|
glm::vec3 getTargetVelocity() const { return _targetVelocity; }
|
||||||
|
@ -382,7 +384,6 @@ protected:
|
||||||
quint64 _errorLogExpiry; ///< time in future when to log an error
|
quint64 _errorLogExpiry; ///< time in future when to log an error
|
||||||
|
|
||||||
QWeakPointer<Node> _owningAvatarMixer;
|
QWeakPointer<Node> _owningAvatarMixer;
|
||||||
QElapsedTimer _lastUpdateTimer;
|
|
||||||
|
|
||||||
PlayerPointer _player;
|
PlayerPointer _player;
|
||||||
|
|
||||||
|
@ -395,6 +396,8 @@ protected:
|
||||||
|
|
||||||
AABox _localAABox;
|
AABox _localAABox;
|
||||||
|
|
||||||
|
SimpleMovingAverage _averageBytesReceived {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// privatize the copy constructor and assignment operator so they cannot be called
|
// privatize the copy constructor and assignment operator so they cannot be called
|
||||||
AvatarData(const AvatarData&);
|
AvatarData(const AvatarData&);
|
||||||
|
|
|
@ -25,11 +25,11 @@ AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator)
|
||||||
return _avatarHash.erase(iterator);
|
return _avatarHash.erase(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
const qint64 AVATAR_SILENCE_THRESHOLD_MSECS = 5 * 1000;
|
const qint64 AVATAR_SILENCE_THRESHOLD_USECS = 5 * 1000 * 1000;
|
||||||
|
|
||||||
bool AvatarHashMap::shouldKillAvatar(const AvatarSharedPointer& sharedAvatar) {
|
bool AvatarHashMap::shouldKillAvatar(const AvatarSharedPointer& sharedAvatar) {
|
||||||
return (sharedAvatar->getOwningAvatarMixer() == NULL
|
return (sharedAvatar->getOwningAvatarMixer() == NULL
|
||||||
|| sharedAvatar->getLastUpdateTimer().elapsed() > AVATAR_SILENCE_THRESHOLD_MSECS);
|
|| sharedAvatar->getUsecsSinceLastUpdate() > AVATAR_SILENCE_THRESHOLD_USECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer) {
|
void AvatarHashMap::processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer) {
|
||||||
|
|
|
@ -52,9 +52,9 @@ void SimpleMovingAverage::reset() {
|
||||||
|
|
||||||
float SimpleMovingAverage::getEventDeltaAverage() const {
|
float SimpleMovingAverage::getEventDeltaAverage() const {
|
||||||
return (ONE_MINUS_WEIGHTING * _eventDeltaAverage) +
|
return (ONE_MINUS_WEIGHTING * _eventDeltaAverage) +
|
||||||
(WEIGHTING * ((usecTimestampNow() - _lastEventTimestamp) / 1000000.0f));
|
(WEIGHTING * ((usecTimestampNow() - _lastEventTimestamp) / 1000000.0f ));
|
||||||
}
|
}
|
||||||
|
|
||||||
float SimpleMovingAverage::getAverageSampleValuePerSecond() const {
|
uint64_t SimpleMovingAverage::getUsecsSinceLastEvent() const {
|
||||||
return _average * (1.0f / getEventDeltaAverage());
|
return usecTimestampNow() - _lastEventTimestamp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,11 @@ public:
|
||||||
|
|
||||||
int getSampleCount() const { return _numSamples; };
|
int getSampleCount() const { return _numSamples; };
|
||||||
float getAverage() const { return _average; };
|
float getAverage() const { return _average; };
|
||||||
float getEventDeltaAverage() const;
|
float getEventDeltaAverage() const; // returned in microseconds
|
||||||
float getAverageSampleValuePerSecond() const;
|
float getAverageSampleValuePerSecond() const { return _average * (1.0f / getEventDeltaAverage()); }
|
||||||
|
|
||||||
|
uint64_t getUsecsSinceLastEvent() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _numSamples;
|
int _numSamples;
|
||||||
uint64_t _lastEventTimestamp;
|
uint64_t _lastEventTimestamp;
|
||||||
|
|
Loading…
Reference in a new issue