thread and rendering

Hello,

In my game, I use a main thread, a second thread to listen to network, and another one to update node position (with interpolation calculation).

Is it possible I have thread error, because some node are in modification in interpolation thread, and rendered in another one?

How to avoid this? Is it possible to call a render() myself, and around this call, to do some lock acquire, on my objects, before they are rendered?

Thank you

Some operations in Panda aren’t thread-safe, but updating the position of a node should be. Are there particular issues you’re running into?

Assertion failed: _cdata->_last_update _cdata->_next_update at line 1474 of c:\buildslave\release_sdk_win32\build\panda3d\panda\src\pgraph\pandaNode.I
:thread(error): Exception occurred within PythonThread Thread-9
Traceback (most recent call last):
File "C:\pascal\shimstar\0.4\shimstarclient0.4\shimstar\game\gameinspace.py", line 867, in run
Bullet.listOfBullet[b].move()
File "C:\pascal\shimstar\0.4\shimstarclient0.4\shimstar\items\bullet.py", line 122, in move
self.node.setPos(self.node,Vec3(0,1*dt*self.speed,0))
AssertionError: _cdata->_last_update _cdata->_next_update at line 1474 of c:\buildslave\release_sdk_win32\build\panda3d\panda\src\pgraph\pandaNode.I

It is something hard to know what is wrong in error through thread… but it is the trace, maybe you have something in mind seeing that.

Thank you

Hmm, that does sound problematic. Are you using Panda’s threading modules (from stdpy)? Or do you use task chains? Or do you use Python’s built-in threading modules?

from direct.stdpy import threading
...
class GameInSpace(DirectObject,threading.Thread):

I have few taks, for pickmouse, and explosion animation, but not using same game objects, and not modifying nodepath anyway from game objects (as ship or bullet).

Can you check if this problem still occurs when you enable a threading-model in Panda?

what do you mean? What have I to do, to use this?

panda3d.org/manual/index.ph … r_Pipeline
Especially the last section.

First point, I think I have to be sure, that my app thread is necessary, or an infinite loop is enough, it is maybe a misconception.
In fact I have an infinite loop, looking at changing game state, and so on, and to separate different step of my game, I threaded the part concerning looping object, and move ship.
Maybe I can just call a run method after looking at state changing…

But, I read the article… And I wonder really how it works.
Do you have to create yourself the thread or the cull and draw are threaded by panda because declaration in prc?

Have you a way for developer, to tell when to draw (not at my mind)…?
Is there a way when you check a nodepath, to know if there is a rendering in progress (to wait, before modifying nodepath)?

The only way to do things and be sure that Panda isn’t rendering anything is to do your processing on the main thread.

If you can’t get setPos working in an alternate thread, you could still use a secondary thread for networking, but write the data that you receive to some sort of message queue to communicate it the main thread, in which you actually update the positions.

However, I’d be interested in seeing if putting “threading-model CullDraw” in your Config.prc solves the error you were having.

Ok I will try to pût config in prc.
The error is a little hard to reproduce, because a lot of thing. But I Will try.

But the main information was to know that panda object have to be changed in main thread.
IT is very important to know that.

Thank you