dart
dart copied to clipboard
Secret upper limit for time step when using SimWindow
It turns out that the SimWindow class secretly does not support simulation time steps which exceed 1.0/30.0. This is because of this line. The variable mDisplayTimeout is equal to 1000.0/30.0 (it gets set here) so then if mWorld->getTimeStep() is greater than 1.0/30.0, then mDisplayTimeout/(mWorld->getTimeStep()*1000) will come up as 0. This instructs the window to run 0 simulation iterations per refresh.
One option would be to change the line to
int numIter = ceil(static_cast<double>(mDisplayTimeout) / (mWorld->getTimeStep() * 1000.0));
This would guarantee that a simulation timestep is always called at least once per refresh. I think a more satisfying solution would be to just have a variable in SimWindow that lets the user determine how many simulation iterations are run per refresh.