mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:23:39 +02:00
fixes for other avatar receive stats rendering
This commit is contained in:
parent
8102e534dd
commit
57fa3d8c53
1 changed files with 117 additions and 100 deletions
|
@ -655,7 +655,9 @@ float Avatar::calculateDisplayNameScaleFactor(const glm::vec3& textPosition, boo
|
||||||
|
|
||||||
void Avatar::renderDisplayName() {
|
void Avatar::renderDisplayName() {
|
||||||
|
|
||||||
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
|
bool shouldShowReceiveStats = DependencyManager::get<AvatarManager>()->shouldShowReceiveStats();
|
||||||
|
|
||||||
|
if ((_displayName.isEmpty() && !shouldShowReceiveStats) || _displayNameAlpha == 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,14 +690,40 @@ void Avatar::renderDisplayName() {
|
||||||
float scaleFactor = calculateDisplayNameScaleFactor(textPosition, inHMD);
|
float scaleFactor = calculateDisplayNameScaleFactor(textPosition, inHMD);
|
||||||
glScalef(scaleFactor, -scaleFactor, scaleFactor); // TextRenderer::draw paints the text upside down in y axis
|
glScalef(scaleFactor, -scaleFactor, scaleFactor); // TextRenderer::draw paints the text upside down in y axis
|
||||||
|
|
||||||
int text_x = -_displayNameBoundingRect.width() / 2;
|
// optionally render timing stats for this avatar with the display name
|
||||||
int text_y = -_displayNameBoundingRect.height() / 2;
|
QString renderedDisplayName = _displayName;
|
||||||
|
QRect nameDynamicRect = _displayNameBoundingRect;
|
||||||
|
|
||||||
|
if (shouldShowReceiveStats) {
|
||||||
|
float kilobitsPerSecond = getAverageBytesReceivedPerSecond() / (float) BYTES_PER_KILOBIT;
|
||||||
|
|
||||||
|
QString statsFormat = QString("(%1 Kbps, %2 Hz)");
|
||||||
|
|
||||||
|
if (!renderedDisplayName.isEmpty()) {
|
||||||
|
statsFormat.prepend(" - ");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString statsText = statsFormat.arg(QString::number(kilobitsPerSecond, 'f', 2)).arg(getReceiveRate());
|
||||||
|
glm::vec2 extent = textRenderer(DISPLAYNAME)->computeExtent(statsText);
|
||||||
|
|
||||||
|
// add the extent required for the stats to whatever was calculated for the display name
|
||||||
|
nameDynamicRect.setWidth(nameDynamicRect.width() + extent.x);
|
||||||
|
|
||||||
|
if (extent.y > nameDynamicRect.height()) {
|
||||||
|
nameDynamicRect.setHeight(extent.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderedDisplayName += statsText;
|
||||||
|
}
|
||||||
|
|
||||||
|
int text_x = -nameDynamicRect.width() / 2;
|
||||||
|
int text_y = -nameDynamicRect.height() / 2;
|
||||||
|
|
||||||
// draw a gray background
|
// draw a gray background
|
||||||
int left = text_x + _displayNameBoundingRect.x();
|
int left = text_x + nameDynamicRect.x();
|
||||||
int right = left + _displayNameBoundingRect.width();
|
int right = left + nameDynamicRect.width();
|
||||||
int bottom = text_y + _displayNameBoundingRect.y();
|
int bottom = text_y + nameDynamicRect.y();
|
||||||
int top = bottom + _displayNameBoundingRect.height();
|
int top = bottom + nameDynamicRect.height();
|
||||||
const int border = 8;
|
const int border = 8;
|
||||||
bottom -= border;
|
bottom -= border;
|
||||||
left -= border;
|
left -= border;
|
||||||
|
@ -711,17 +739,6 @@ void Avatar::renderDisplayName() {
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (DependencyManager::get<AvatarManager>()->shouldShowReceiveStats()) {
|
|
||||||
float kilobitsPerSecond = getAverageBytesReceivedPerSecond() / (float) BYTES_PER_KILOBIT;
|
|
||||||
|
|
||||||
renderedDisplayName += QString(" - (%1 Kbps, %2 Hz)")
|
|
||||||
.arg(QString::number(kilobitsPerSecond, 'f', 2))
|
|
||||||
.arg(getReceiveRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray nameUTF8 = renderedDisplayName.toLocal8Bit();
|
QByteArray nameUTF8 = renderedDisplayName.toLocal8Bit();
|
||||||
|
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
@ -932,7 +949,7 @@ void Avatar::setDisplayName(const QString& displayName) {
|
||||||
AvatarData::setDisplayName(displayName);
|
AvatarData::setDisplayName(displayName);
|
||||||
// FIXME is this a sufficient replacement for tightBoundingRect?
|
// FIXME is this a sufficient replacement for tightBoundingRect?
|
||||||
glm::vec2 extent = textRenderer(DISPLAYNAME)->computeExtent(displayName);
|
glm::vec2 extent = textRenderer(DISPLAYNAME)->computeExtent(displayName);
|
||||||
_displayNameBoundingRect = QRect(QPoint(0, 0), QPoint((int)extent.x, (int)extent.y));
|
_displayNameBoundingRect = QRect(0, 0, (int)extent.x, (int)extent.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::setBillboard(const QByteArray& billboard) {
|
void Avatar::setBillboard(const QByteArray& billboard) {
|
||||||
|
|
Loading…
Reference in a new issue