for necessity I had to integrate OSGEarth rendering into a dll running on Java.
So I created a class, which extends the osgEarth :: GeoTransform class, which has to simulate a boat(Vessel) model, so it will have its attitude, position, size and .obj model.
This node is put as a child of the mapNode.
So far everything ok.
My problem arises when, I need to generate thousands of these nodes, with different physical characteristics, at runtime(each node has different position, size, name, orientation).
In fact, the dll randomly crashes, in detail, the run () method of the viewer.
Now I ask you, having one thread rendering the OSGEarth structure and another thread pushing these nodes at runtime, adding and removing them, is it possible that there are conflicts between threads accessing the same resource?
Also, to add children to the mapNode at runtime, does it make sense to call a callBack method on the mapNode?
There are strict rules about when it is safe to make changes to a live scene graph in OSG. You must only do it during the OSG Update or Event traversal (unless you are running in SingleThreaded mode). If you are making changes to an osg::Drawable or an osg::StateSet, you should also set its data variance to DYNAMIC to prevent overlap with the draw thread.
In an environment like yours, you will generally need to marshal these add/update operations over to a legal thread (OSG update/event) by placing them on a thread-safe queue and then reading from that queue on the OSG side.