Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/packaging/files_msys64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/mingw64/bin/libpcre2-16-0.dll
/mingw64/bin/libpng16-16.dll
/mingw64/bin/libssl-3-x64.dll
/mingw64/bin/libwinpthread-1.dll
/mingw64/bin/Qt6Core.dll
/mingw64/bin/Qt6Gui.dll
/mingw64/bin/Qt6Network.dll
Expand Down
37 changes: 2 additions & 35 deletions src/webots/engine/WbSimulationWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ WbSimulationWorld::WbSimulationWorld(WbTokenizer *tokenizer) :
}
}

mSleepRealTime = basicTimeStep();

WbPerformanceLog *log = WbPerformanceLog::instance();
if (log)
log->setTimeStep(basicTimeStep());
Expand Down Expand Up @@ -128,6 +126,7 @@ WbSimulationWorld::WbSimulationWorld(WbTokenizer *tokenizer) :
if (log)
log->stopMeasure(WbPerformanceLog::LOADING);

mTimer->setTimerType(Qt::PreciseTimer);
connect(mTimer, &QTimer::timeout, this, &WbSimulationWorld::triggerStepFromTimer);
const WbSimulationState *const s = WbSimulationState::instance();
connect(s, &WbSimulationState::rayTracingEnabled, this, &WbSimulationWorld::rayTracingEnabled);
Expand Down Expand Up @@ -185,37 +184,6 @@ void WbSimulationWorld::step() {

const double timeStep = basicTimeStep();

if (WbSimulationState::instance()->isRealTime()) {
const int elapsed = mRealTimeTimer.restart();

// computing the mean of an history of several elapsedTime
// improves significantly the stability of the algorithm
// in case of simulations where elapsedTime oscillates often
// above and below basicTimeStep.
// Moreover it improves the stability of simulations where
// basicTimeStep contains significant decimals
mElapsedTimeHistory.append(elapsed);
if (mElapsedTimeHistory.size() > qMax(4.0, 128.0 / timeStep)) // history size found empirically
mElapsedTimeHistory.pop_front();
double mean = 0.0;
foreach (const int &v, mElapsedTimeHistory)
mean += v;
mean /= mElapsedTimeHistory.size();

// useful hack: uncomment to run Webots at 90% of the real-time
// (if the real-time mode is enabled, of course)
// mean *= 0.90;

if (mean > timeStep && mSleepRealTime > 0.0) {
mSleepRealTime -= 0.03 * timeStep;
if (mSleepRealTime < 0)
mSleepRealTime = 0.0;
} else if (mean < timeStep)
mSleepRealTime += 0.03 * timeStep;

mTimer->start(mSleepRealTime);
}

emit physicsStepStarted();

if (log)
Expand Down Expand Up @@ -317,10 +285,9 @@ void WbSimulationWorld::modeChanged() {
WbSoundEngine::setMute(WbPreferences::instance()->value("Sound/mute").toBool());
break;
case WbSimulationState::REALTIME:
mRealTimeTimer.start();
WbSoundEngine::setPause(false);
WbSoundEngine::setMute(WbPreferences::instance()->value("Sound/mute").toBool());
mTimer->start(mSleepRealTime);
mTimer->start(basicTimeStep());
break;
case WbSimulationState::FAST:
WbSoundEngine::setPause(false);
Expand Down
3 changes: 0 additions & 3 deletions src/webots/engine/WbSimulationWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ protected slots:
WbOdeContext *mOdeContext;
WbPhysicsPlugin *mPhysicsPlugin;
QTimer *mTimer;
QElapsedTimer mRealTimeTimer;
double mSleepRealTime;
QList<int> mElapsedTimeHistory;
QVector<WbNode *> mAddedNode; // list of nodes added since the simulation started

void storeLastSaveTime() override;
Expand Down