You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two issues. First of all, setting restart() to return TRUE doesn't always exit this look, because of the logic of the condition. Secondly, restart() is often not called at all! I think that's because if C++ figure that !simulation_time_reached is TRUE then there's no point in executing restart().
This seems to work for me. If I return TRUE, the main loop exits. If I return FALSE it doesn't. The restart() function always gets executed (unless the loop is exitting for some other reason).
What do you think?
Thanks
Simon
The text was updated successfully, but these errors were encountered:
Hi Simon,
I think the original logic was as follows:
when the simulation time is reached the restart function is called to decide
whether the it should restart or not. So a restart can be initated earlier by
setting simulation_time_reached=true in the normal callback functions and then
also returning true in restart, but I understand that your solution is maybe
better.
Regards,
Georg
On Thursday 01 November 2018 09:09:14 Simon Birrell wrote:
Hi,
I have a question about the usage of restart() when subclassing Simulation.
The main loop in simulation.cpp starts like this:
```
while ( ( noGraphics || !viewer->done()) &&
(!simulation_time_reached ||
restart(odeHandle,osgHandle,globalData)) ) { ```
Two issues. First of all, setting restart() to return TRUE doesn't always
exit this look, because of the logic of the condition. Secondly, restart()
is often not called at all! I think that's because if C++ figure that
!simulation_time_reached is TRUE then there's no point in executing
restart().
I would propose the following:
```
while ( ( noGraphics || !viewer->done()) &&
(!simulation_time_reached &&
restart(odeHandle,osgHandle,globalData)) ) { ```
This seems to work for me. If I return TRUE, the main loop exits. If I
return FALSE it doesn't. The restart() function always gets executed
(unless the loop is exitting for some other reason).
What do you think?
Thanks
Simon
Hi,
I have a question about the usage of restart() when subclassing Simulation.
The main loop in simulation.cpp starts like this:
Two issues. First of all, setting restart() to return TRUE doesn't always exit this look, because of the logic of the condition. Secondly, restart() is often not called at all! I think that's because if C++ figure that !simulation_time_reached is TRUE then there's no point in executing restart().
I would propose the following:
This seems to work for me. If I return TRUE, the main loop exits. If I return FALSE it doesn't. The restart() function always gets executed (unless the loop is exitting for some other reason).
What do you think?
Thanks
Simon
The text was updated successfully, but these errors were encountered: