I’m having a little trouble with creating a loading screen for a game I’m making with Panda3D. Levels in the game take about 10 - 15 seconds to load, and having the program freeze for that long (when using panda without threads to load and attach nodes to the scenegraph) just is rather odd.
I’ve experimented with Windows threads to try and get a quick loading thread up (which i probably did wrongly anyway), however, my program crashes at random intervals usually with the error message:
“Assertion failed: obj->_flag == (PN_int32)DCF_deleted, file c:\temp\mkpr\built\include\deletedChain.T, line 49”
The program does work when my load function was done in the same thread as panda’s main loop though. :\
Levels should not take 10 - 15 seconds to load you are probably reading an egg convert it to a bam for speed up or use a bam cache so panda bam’s it up for u automatically. Threading on the other hand opens up a whole new bag of warms and random crashes.
On the contrary, some forms of AI (Neural Nets/Precalculated Nodes for Pathfinding), do take relatively long to load. At any rate, it’s not panda elements that cause this pause. Maybe I should place my other panda-unrelated loading code in the thread instead.
Still wondering if there is actually a way to load panda elements without crashing randomly though.
If you download the Panda source and compile it yourself using the ppremake build interface, you can enable threading within Panda by defining:
#define HAVE_THREADS 1
in your Config.pp file. There is more information in the build documentation.
Once you have build a thread-aware version of Panda, you can load models asynchronously (in a sub-thread) with the loader.loadModel(filename, callback = myCallback) interface. See direct/src/showbase/Loader.py for more information on its usage.