I haven’t been able to find anything on this (but have sworn there WAS a topic on it).
When I go to attach a mesh to the rootNode on runtime it causes the game to lag for a moment (3 or 4 seconds). I think this has something to do with a lack of thread implementation, but I wanted to make sure that was it (as I’ve seen countless posts claiming that people might use threads for something it doesn’t need to be used for). I don’t have access to any example code, but I’ll try to recall exactly how I went about it.
If certain conditions were met in the simpleUpdate method I would have it put a mesh on the rootNode. It was a decently large mesh but it would lag only while it was being placed on the rootNode.
Any idea on what’s happening and how to remedy the problem?
anything you do in the update loop will “lag” the game. none of the update() calls happen simultaneously. the loop goes through and calls update() one at a time on each appstate and control within the same thread.
to get around this use the thread pool executor to do everything along the lines of asset.loadModel() outside of the game loop, then once its loaded use app.enque() to attach the model to the rootnode. (make sure you dont attach anything to the rootnode from your loading thread)
@mjbmitch said:
When you folks are referring to the "game loop", you're talking about the simpleUpdate, right? Should I use simpleRender instead for attaching meshes?
The mesh is a custom model made with vertices, etc. all through the code; it is not an asset.
It’s all the render loop, game loop, etc… all the same.
How long does it take to make your mesh? You may want to do that on another thread.