mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:30:38 +02:00
Merge pull request #4220 from sethalves/rework-bandwidth-meter
fix several signed/unsigned comps, avoid sprintf in overlay code
This commit is contained in:
commit
af91eee5a0
7 changed files with 58 additions and 66 deletions
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
// Semantic and Index types to retreive the JointTrackers of this MotionTracker
|
// Semantic and Index types to retreive the JointTrackers of this MotionTracker
|
||||||
typedef std::string Semantic;
|
typedef std::string Semantic;
|
||||||
typedef int Index;
|
typedef uint32_t Index;
|
||||||
static const Index INVALID_SEMANTIC = -1;
|
static const Index INVALID_SEMANTIC = -1;
|
||||||
static const Index INVALID_PARENT = -2;
|
static const Index INVALID_PARENT = -2;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public slots:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int _deviceTrackerId;
|
int _deviceTrackerId;
|
||||||
int _subTrackerId;
|
uint _subTrackerId;
|
||||||
|
|
||||||
// cache for the spatial
|
// cache for the spatial
|
||||||
SpatialEvent _eventCache;
|
SpatialEvent _eventCache;
|
||||||
|
|
|
@ -929,14 +929,13 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
||||||
|
|
||||||
// Show on-screen msec timer
|
// Show on-screen msec timer
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) {
|
||||||
char frameTimer[10];
|
|
||||||
quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
|
quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
|
||||||
sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
|
QString frameTimer = QString("%1\n").arg((int)(mSecsNow % 1000));
|
||||||
int timerBottom =
|
int timerBottom =
|
||||||
(Menu::getInstance()->isOptionChecked(MenuOption::Stats))
|
(Menu::getInstance()->isOptionChecked(MenuOption::Stats))
|
||||||
? 80 : 20;
|
? 80 : 20;
|
||||||
drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom,
|
drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom,
|
||||||
0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT);
|
||||||
}
|
}
|
||||||
nodeBoundsDisplay.drawOverlay();
|
nodeBoundsDisplay.drawOverlay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,9 +236,8 @@ void OctreeStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t ser
|
||||||
serverCount++;
|
serverCount++;
|
||||||
|
|
||||||
if (serverCount > _octreeServerLabelsCount) {
|
if (serverCount > _octreeServerLabelsCount) {
|
||||||
char label[128] = { 0 };
|
QString label = QString("%1 Server %2").arg(serverTypeName).arg(serverCount);
|
||||||
sprintf(label, "%s Server %d", serverTypeName, serverCount);
|
int thisServerRow = _octreeServerLables[serverCount-1] = AddStatItem(label.toUtf8().constData());
|
||||||
int thisServerRow = _octreeServerLables[serverCount-1] = AddStatItem(label);
|
|
||||||
_labels[thisServerRow]->setTextFormat(Qt::RichText);
|
_labels[thisServerRow]->setTextFormat(Qt::RichText);
|
||||||
_labels[thisServerRow]->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
_labels[thisServerRow]->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
connect(_labels[thisServerRow], SIGNAL(linkActivated(const QString&)), this, SLOT(moreless(const QString&)));
|
connect(_labels[thisServerRow], SIGNAL(linkActivated(const QString&)), this, SLOT(moreless(const QString&)));
|
||||||
|
|
|
@ -256,25 +256,20 @@ void Stats::display(
|
||||||
|
|
||||||
int columnOneHorizontalOffset = horizontalOffset;
|
int columnOneHorizontalOffset = horizontalOffset;
|
||||||
|
|
||||||
char serverNodes[30];
|
QString serverNodes = QString("Servers: %1").arg(totalServers);
|
||||||
sprintf(serverNodes, "Servers: %d", totalServers);
|
QString avatarNodes = QString("Avatars: %1").arg(totalAvatars);
|
||||||
char avatarNodes[30];
|
QString framesPerSecond = QString("Framerate: %1 FPS").arg(fps, 3, 'f', 0);
|
||||||
sprintf(avatarNodes, "Avatars: %d", totalAvatars);
|
|
||||||
char framesPerSecond[30];
|
|
||||||
sprintf(framesPerSecond, "Framerate: %3.0f FPS", fps);
|
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, serverNodes, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, serverNodes.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond.toUtf8().constData(), color);
|
||||||
|
|
||||||
// TODO: the display of these timing details should all be moved to JavaScript
|
// TODO: the display of these timing details should all be moved to JavaScript
|
||||||
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) {
|
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) {
|
||||||
// Timing details...
|
// Timing details...
|
||||||
const int TIMER_OUTPUT_LINE_LENGTH = 1000;
|
|
||||||
char perfLine[TIMER_OUTPUT_LINE_LENGTH];
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE * 4; // skip 4 lines to be under the other columns
|
verticalOffset += STATS_PELS_PER_LINE * 4; // skip 4 lines to be under the other columns
|
||||||
drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font,
|
drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font,
|
||||||
"-------------------------------------------------------- Function "
|
"-------------------------------------------------------- Function "
|
||||||
|
@ -301,12 +296,13 @@ void Stats::display(
|
||||||
QString functionName = j.value();
|
QString functionName = j.value();
|
||||||
const PerformanceTimerRecord& record = allRecords.value(functionName);
|
const PerformanceTimerRecord& record = allRecords.value(functionName);
|
||||||
|
|
||||||
sprintf(perfLine, "%120s: %8.4f [%6llu]", qPrintable(functionName),
|
QString perfLine = QString("%1: %2 [%3]").
|
||||||
(float)record.getMovingAverage() / (float)USECS_PER_MSEC,
|
arg(QString(qPrintable(functionName)), 120).
|
||||||
record.getCount());
|
arg((float)record.getMovingAverage() / (float)USECS_PER_MSEC, 8, 'f', 3).
|
||||||
|
arg(record.getCount(), 6);
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font, perfLine, color);
|
drawText(columnOneHorizontalOffset, verticalOffset, scale, rotation, font, perfLine.toUtf8().constData(), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,17 +316,15 @@ void Stats::display(
|
||||||
}
|
}
|
||||||
horizontalOffset += 5;
|
horizontalOffset += 5;
|
||||||
|
|
||||||
char packetsPerSecondString[30];
|
QString packetsPerSecondString = QString("Packets In/Out: %1/%2").arg(inPacketsPerSecond).arg(outPacketsPerSecond);
|
||||||
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
|
QString averageMegabitsPerSecond = QString("Mbps In/Out: %1/%2").
|
||||||
char averageMegabitsPerSecond[30];
|
arg((float)inKbitsPerSecond * 1.0f / 1000.0f).
|
||||||
sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f",
|
arg((float)outKbitsPerSecond * 1.0f / 1000.0f);
|
||||||
(float)inKbitsPerSecond * 1.0f / 1000.0f,
|
|
||||||
(float)outKbitsPerSecond * 1.0f / 1000.0f);
|
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond.toUtf8().constData(), color);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,44 +369,44 @@ void Stats::display(
|
||||||
horizontalOffset += 5;
|
horizontalOffset += 5;
|
||||||
|
|
||||||
|
|
||||||
char audioPing[30];
|
QString audioPing;
|
||||||
if (pingAudio >= 0) {
|
if (pingAudio >= 0) {
|
||||||
sprintf(audioPing, "Audio ping: %d", pingAudio);
|
audioPing = QString("Audio ping: %1").arg(pingAudio);
|
||||||
} else {
|
} else {
|
||||||
sprintf(audioPing, "Audio ping: --");
|
audioPing = QString("Audio ping: --");
|
||||||
}
|
}
|
||||||
|
|
||||||
char avatarPing[30];
|
QString avatarPing;
|
||||||
if (pingAvatar >= 0) {
|
if (pingAvatar >= 0) {
|
||||||
sprintf(avatarPing, "Avatar ping: %d", pingAvatar);
|
avatarPing = QString("Avatar ping: %1").arg(pingAvatar);
|
||||||
} else {
|
} else {
|
||||||
sprintf(avatarPing, "Avatar ping: --");
|
avatarPing = QString("Avatar ping: --");
|
||||||
}
|
}
|
||||||
|
|
||||||
char voxelAvgPing[30];
|
QString voxelAvgPing;
|
||||||
if (pingVoxel >= 0) {
|
if (pingVoxel >= 0) {
|
||||||
sprintf(voxelAvgPing, "Entities avg ping: %d", pingVoxel);
|
voxelAvgPing = QString("Entities avg ping: %1").arg(pingVoxel);
|
||||||
} else {
|
} else {
|
||||||
sprintf(voxelAvgPing, "Entities avg ping: --");
|
voxelAvgPing = QString("Entities avg ping: --");
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, audioPing, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, audioPing.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPing, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPing.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelAvgPing, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelAvgPing.toUtf8().constData(), color);
|
||||||
|
|
||||||
if (_expanded) {
|
if (_expanded) {
|
||||||
char voxelMaxPing[30];
|
QString voxelMaxPing;
|
||||||
if (pingVoxel >= 0) { // Average is only meaningful if pingVoxel is valid.
|
if (pingVoxel >= 0) { // Average is only meaningful if pingVoxel is valid.
|
||||||
sprintf(voxelMaxPing, "Voxel max ping: %d", pingOctreeMax);
|
voxelMaxPing = QString("Voxel max ping: %1").arg(pingOctreeMax);
|
||||||
} else {
|
} else {
|
||||||
sprintf(voxelMaxPing, "Voxel max ping: --");
|
voxelMaxPing = QString("Voxel max ping: --");
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelMaxPing, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, voxelMaxPing.toUtf8().constData(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalOffset = 0;
|
verticalOffset = 0;
|
||||||
|
@ -429,35 +423,35 @@ void Stats::display(
|
||||||
}
|
}
|
||||||
horizontalOffset += 5;
|
horizontalOffset += 5;
|
||||||
|
|
||||||
char avatarPosition[200];
|
QString avatarPosition = QString("Position: %1, %2, %3").
|
||||||
sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z);
|
arg(avatarPos.x, -1, 'f', 1).
|
||||||
char avatarVelocity[30];
|
arg(avatarPos.y, -1, 'f', 1).
|
||||||
sprintf(avatarVelocity, "Velocity: %.1f", glm::length(myAvatar->getVelocity()));
|
arg(avatarPos.z, -1, 'f', 1);
|
||||||
char avatarBodyYaw[30];
|
QString avatarVelocity = QString("Velocity: %1").arg(glm::length(myAvatar->getVelocity()), -1, 'f', 1);
|
||||||
sprintf(avatarBodyYaw, "Yaw: %.1f", myAvatar->getBodyYaw());
|
QString avatarBodyYaw = QString("Yaw: %1").arg(myAvatar->getBodyYaw(), -1, 'f', 1);
|
||||||
char avatarMixerStats[200];
|
QString avatarMixerStats;
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPosition, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarPosition.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarVelocity, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarVelocity.toUtf8().constData(), color);
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarBodyYaw, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarBodyYaw.toUtf8().constData(), color);
|
||||||
|
|
||||||
if (_expanded) {
|
if (_expanded) {
|
||||||
SharedNodePointer avatarMixer = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::AvatarMixer);
|
SharedNodePointer avatarMixer = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::AvatarMixer);
|
||||||
if (avatarMixer) {
|
if (avatarMixer) {
|
||||||
sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
|
avatarMixerStats = QString("Avatar Mixer: %1 kbps, %2 pps").
|
||||||
roundf(bandwidthRecorder->getAverageInputKilobitsPerSecond(NodeType::AudioMixer) +
|
arg(roundf(bandwidthRecorder->getAverageInputKilobitsPerSecond(NodeType::AudioMixer) +
|
||||||
bandwidthRecorder->getAverageOutputKilobitsPerSecond(NodeType::AudioMixer)),
|
bandwidthRecorder->getAverageOutputKilobitsPerSecond(NodeType::AudioMixer))).
|
||||||
roundf(bandwidthRecorder->getAverageInputPacketsPerSecond(NodeType::AudioMixer) +
|
arg(roundf(bandwidthRecorder->getAverageInputPacketsPerSecond(NodeType::AudioMixer) +
|
||||||
bandwidthRecorder->getAverageOutputPacketsPerSecond(NodeType::AudioMixer)));
|
bandwidthRecorder->getAverageOutputPacketsPerSecond(NodeType::AudioMixer)));
|
||||||
} else {
|
} else {
|
||||||
sprintf(avatarMixerStats, "No Avatar Mixer");
|
avatarMixerStats = QString("No Avatar Mixer");
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalOffset += STATS_PELS_PER_LINE;
|
verticalOffset += STATS_PELS_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarMixerStats, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarMixerStats.toUtf8().constData(), color);
|
||||||
|
|
||||||
stringstream downloads;
|
stringstream downloads;
|
||||||
downloads << "Downloads: ";
|
downloads << "Downloads: ";
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
AudioFilterBank() :
|
AudioFilterBank() :
|
||||||
_sampleRate(0.0f),
|
_sampleRate(0.0f),
|
||||||
_frameCount(0) {
|
_frameCount(0) {
|
||||||
for (int i = 0; i < _channelCount; ++i) {
|
for (uint32_t i = 0; i < _channelCount; ++i) {
|
||||||
_buffer[ i ] = NULL;
|
_buffer[ i ] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ Texture::Size Texture::resize(Type type, const Element& texelFormat, uint16 widt
|
||||||
|
|
||||||
// Evaluate the new size with the new format
|
// Evaluate the new size with the new format
|
||||||
const int DIM_SIZE[] = {1, 1, 1, 6};
|
const int DIM_SIZE[] = {1, 1, 1, 6};
|
||||||
int size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize();
|
uint32_t size = DIM_SIZE[_type] *_width * _height * _depth * _numSamples * texelFormat.getSize();
|
||||||
|
|
||||||
// If size change then we need to reset
|
// If size change then we need to reset
|
||||||
if (changed || (size != getSize())) {
|
if (changed || (size != getSize())) {
|
||||||
|
|
Loading…
Reference in a new issue