Moving Window looses ODE objects

If I move the render window while my dice are bouncing around, often, but not always, the objects (dice) fly right through the walls?

What dices are you talking about?

I see no reason why moving the window could cause that. Provide more information, please.

He’s most likely using a dynamic timestep based on globalClock.getDt(), which is a (very) large number when you move the window because the framerate is nearly none when you move the window.

Use a fixed timestep instead and see if that helps.

Yep, was using


Changed to


MUCH better. Works great. Thanks!

Using time varying time stamps sound logical but is not recommended and discouraged by ODE. But the problem with using a completely fixed time stamp shows up when you run bellow 30fps and your game slows down. I would recommend some math to make sure you always do 60 physical frames per second even if the frame rate does not match by doing couple of physical frames per render frame in that case.

At the very least you can do:

quickStep(min(0.1, globalClock.getDt())

This will prevent too large of a “hiccup” in the simulation.

For a fixed timestep you might do something like this in a task:

MAX_DT = 0.1
STEP_TIME = 1.0 / 60.0 # (60 FPS simulation)

simtime += min(MAX_DT, globalClock.getDt())
steps = int(simtime / STEP_TIME)
if steps:
    simtime = simtime % STEP_TIME
    for i in range(steps):
        # here you might put code that needs
        # to run after each physics step,
        # such as manually setting some objects
        # velocity
    # here you might put code that needs to
    # run each render frame, for example to
    # match panda nodes to ODE nodes

Thanks for all the help.

For now I’ve left it fixed. It works well although I do loose a die now and then? But eh.

It is just a simple thing I’ve done to learn the basics and have a bit of fun since I’m not real busy at the moment.

Since it ‘evolved’ it needs some re-factoring and I’m not sure it belongs in anything called ‘showcase’ but I’ll stick a link in there just for grins.

And tack the link here too- this is everything, I 'packpanda’d it…

teedee, your fixed time simulation looks great! Kind of what I have. And you probably never want to use the “quickStep(min(0.1, globalClock.getDt())” method because there is a lot of issues with running with changing time stamps such as when object come to rest they can all of a sudden jump up and down as you turn the camera and FPS changes a bit.