Setting alternate application code update rate from panda framerate


Hi all

Is it possible to set the update rate of application code independently of the panda3d framerate?

In the default single threaded mode, panda runs the app code, then the cull and draw cycle. I have sucessfully used threading-model Cull to move rendering to a different thread, and then created a new task chain via:
self.taskMgr.setupTaskChain('controlLoop', numThreads=1,tickClock=False,frameSync=False)
that runs independent of the frame rate.

However, this uses as much CPU as is available, and the update rate for the code is uncapped. I have tried adding a new ClockObject with mode set to M_limited and updating that within one of the tasks in the chain, but that lowered my framerate to 2fps.

Any suggestions? I am open to outside-the-box answers like “change your code so it doesn’t depend on an update rate” if anyone knows a thing or two about PID-style controllers.


Hmm, great question. It sounds almost like we should allow passing a separate ClockObject per task chain. It is possible to create a separate task manager altogether with a separate clock, but I don’t know if that’s the right solution here.

You could create a task at the end and simply time.sleep() for as long as is needed to limit the frame rate to the desired amount.