Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of restart() #26

Open
SimonBirrell opened this issue Nov 1, 2018 · 1 comment
Open

Use of restart() #26

SimonBirrell opened this issue Nov 1, 2018 · 1 comment

Comments

@SimonBirrell
Copy link

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

@georgmartius
Copy link
Owner

georgmartius commented Nov 1, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants