Commit fcec5389 authored by VAN TOLL Wouter's avatar VAN TOLL Wouter
Browse files

GUI: Simplified the code for refreshing the visualization.

parent 695da29c
......@@ -198,28 +198,25 @@ void UMANSOpenGLWidget::SetPlaybackMultiplier(int value)
{
playbackMultiplier = value;
bool simulationWasPlaying = false;
// prepare a timer for automatically running the simulation
if (simulationTimer == nullptr)
simulationTimer = new QTimer(this);
else
{
disconnect(simulationTimer, SIGNAL(timeout()), this, SLOT(updateSimulation()));
if (simulationTimer->isActive())
{
simulationWasPlaying = true;
simulationTimer->stop();
}
}
simulationTimer->setInterval((int)(1000 * simulator->GetWorld()->GetDeltaTime() / playbackMultiplier));
connect(simulationTimer, SIGNAL(timeout()), this, SLOT(updateSimulation()));
// determine how many milliseconds should be between two simulation updates
int desiredRefreshTime = (int)(1000 * simulator->GetWorld()->GetDeltaTime() / playbackMultiplier);
// schedule a Qt timer for periodically updating the simulation
simulationTimer->setInterval(desiredRefreshTime);
connect(simulationTimer, SIGNAL(timeout()), this, SLOT(updateSimulation()));
// if the simulation was running before we changed this multiplier, make sure it continues running
if (simulationWasPlaying)
if (simulationRunning)
simulationTimer->start();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment