Decoupling the physics update rate from the rest of the application

I’m modeling some vehicles represented by bullet nodes in a simulation that have propulsion forces that I’m calculating and sending to bullet. In order to get accurate results (since I can’t change what bullet integrates), I have to step the simulation slowly. I also have a planner that periodically should calculate what these forces should be at a slower rate than the physics is stepped.

The best way I could think of to achieve this is to create a new TaskManager and set it’s clock to a non-realtime clock with my desired update rate. Then I could set a task to run the physics update and another with doTaskLater to trigger the planner periodically. However, I haven’t found an example of how to create a new TaskManager to do this, so I’m not sure of the correct approach. Any advice or comments would be appreciated!

Have you tried a “doMethodLater” task, with the referenced method returning “task.again”? (See this manual page for more.)

I don’t know offhand whether it would have the accuracy that you want, but it might be worth a try, especially as it’s pretty simple to set up.

I think the issue doing it this way is that the delay set there is reckoned based on the clock in the global task manager (see AsyncTaskManager — Panda3D Manual). I would like the delay to be reckoned based on my new non-realtime clock that I set up and also leave the usual global task manager running to deal with the GUI.

I mean, how much difference does it make? Will it not amount to (close to) the same thing…?

You should still effectively have updates at set intervals.