Display real-time percentage in paused mode, if different than 100%
PiperOrigin-RevId: 474519561 Change-Id: I54eea97f305dc9b57b9513d6ab5cd75368c2cd45
This commit is contained in:
committed by
Copybara-Service
parent
549437ca52
commit
0a0acb3419
+20
-16
@@ -1759,27 +1759,31 @@ void Simulate::render() {
|
|||||||
this->loadrequest ? "loading" : "pause", nullptr, &this->con);
|
this->loadrequest ? "loading" : "pause", nullptr, &this->con);
|
||||||
}
|
}
|
||||||
|
|
||||||
// show realtime label
|
// get desired and actual percent-of-real-time
|
||||||
if (this->run) {
|
float desiredRealtime = this->percentRealTime[this->realTimeIndex];
|
||||||
// get desired and actual percent-of-real-time
|
float actualRealtime = 100 / this->measuredSlowdown;
|
||||||
float desiredRealtime = this->percentRealTime[this->realTimeIndex];
|
|
||||||
float actualRealtime = 100 / this->measuredSlowdown;
|
|
||||||
|
|
||||||
// check if real-time tracking is misaligned by more than than 10%
|
// if running, check for misalignment of more than 10%
|
||||||
bool misalignment = mju_abs(actualRealtime - desiredRealtime) > 0.1 * desiredRealtime;
|
float realtime_offset = mju_abs(actualRealtime - desiredRealtime);
|
||||||
|
bool misaligned = this->run && realtime_offset > 0.1 * desiredRealtime;
|
||||||
|
|
||||||
// display realtime overlay if not 100% or there is misalignment
|
// draw realtime overlay
|
||||||
if (desiredRealtime != 100.0 || misalignment) {
|
if (desiredRealtime != 100.0 || misaligned) {
|
||||||
char overlay[30];
|
char rtlabel[30];
|
||||||
if (misalignment) {
|
|
||||||
std::snprintf(overlay, sizeof(overlay), "%g%% (%-.1f%%)", desiredRealtime, actualRealtime);
|
// print desired realtime
|
||||||
} else {
|
int labelsize = std::snprintf(rtlabel, sizeof(rtlabel), "%g%%", desiredRealtime);
|
||||||
std::snprintf(overlay, sizeof(overlay), "%g%%", desiredRealtime);
|
|
||||||
}
|
// if misaligned, append to label
|
||||||
mjr_overlay(mjFONT_BIG, mjGRID_TOPLEFT, smallrect, overlay, nullptr, &this->con);
|
if (misaligned) {
|
||||||
|
std::snprintf(rtlabel+labelsize, sizeof(rtlabel)-labelsize, " (%-4.1f%%)", actualRealtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw overlay
|
||||||
|
mjr_overlay(mjFONT_BIG, mjGRID_TOPLEFT, smallrect, rtlabel, nullptr, &this->con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// show ui 0
|
// show ui 0
|
||||||
if (this->ui0_enable) {
|
if (this->ui0_enable) {
|
||||||
mjui_render(&this->ui0, &this->uistate, &this->con);
|
mjui_render(&this->ui0, &this->uistate, &this->con);
|
||||||
|
|||||||
Reference in New Issue
Block a user