physics.stop() causing problems?

It may be just my code, but has anyone noticed that when you do physics.stop(), all kinds of problems are caused in execution of subsequent code? Like nil exceptions where there shouldn’t be any (in completely physics-unrelated code, in a different module)?

In order to fix that, I just made sure I call physics.start() at the beginning of the program, and never call physics.stop(). All the problems disappeared. Still - the stop shouldn’t be doing that.

Don’t have the code to show the bug since it happens fairly randomly in a big-ass project. [import]uid: 160496 topic_id: 29762 reply_id: 329762[/import]

Hi Mike,
Out of curiosity, does the same happen when you pause the physics? Or only on stop? I’ve never actually used physics.stop, since pause meets my needs… it would be nice to know if this weird behavior occurs on both calls, or just on stop.

Brent [import]uid: 9747 topic_id: 29762 reply_id: 119414[/import]

Brent, I just checked and pause() does not seem to cause problems.

Since I destroy all physics objects (obviously) when switching between scenes, I really don’t have to do physics.stop(), just was doing it for cleanup’s completeness sake. In fact, now that I think about it, I don’t see why physics.stop() should be called ever. [import]uid: 160496 topic_id: 29762 reply_id: 119415[/import]

The problem is caused by not completely removing all physics objects from the old simulation before calling start again. Deleting a scene is not actually enough to clean up the physics simulation completely. I had to iterate through the display group containing all my physics objects and delete and nil out each one first before calling stop to prevent the random crashing you describe.

[import]uid: 9422 topic_id: 29762 reply_id: 119427[/import]

To clarify, Stephen - it is not enough to display.remove the display group to which the physics bodies belong? [import]uid: 160496 topic_id: 29762 reply_id: 119430[/import]

Intuitively it seems like removing a display group of physics objects should completely destroy those objects. It was my experience, months ago when I ran into this issue, that to *really* completely remove all the physics objects from the simulation I had to iterate through and delete each physics object one at a time, otherwise I’d get the random crash described above. (Maybe simply deleting the group still leaves references to the objects in memory?) Perhaps things have changed and that’s no longer necessary, but if you’re experiencing this type of crash it might be worth a test to see if deleting each object, rather than just the display group, fixes things. [import]uid: 9422 topic_id: 29762 reply_id: 119569[/import]

Intuitively it seems like removing a display group of physics objects should completely destroy those objects. It was my experience, months ago when I ran into this issue, that to *really* completely remove all the physics objects from the simulation I had to iterate through and delete each physics object one at a time, otherwise I’d get the random crash described above. (Maybe simply deleting the group still leaves references to the objects in memory?) Perhaps things have changed and that’s no longer necessary, but if you’re experiencing this type of crash it might be worth a test to see if deleting each object, rather than just the display group, fixes things. [import]uid: 9422 topic_id: 29762 reply_id: 119569[/import]