[osg-users] Insight into osg::Operation

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Thu Jun 4 12:15:23 PDT 2015


Hi,

I need some help with the osg::Operation.
What I'm trying to achieve seems relatively simple. After loading a 
model, I want some background operation to visit with an intersections 
visitor.
Pseudo code:
Load Node
Create osg::Operation-derived ref_ptr and do
     mThreadedOperations->add(operation);
     viewer->addUpdateOperation(operation);
during runtime (e.g. before viewer.frame())

Unfortunately I'm experiencing crashes (vector iterator not 
dereferenceable etc) in the intersection visitor ( to be more exact: in 
the node->accept(*mIntersectionVisitor))
It works flawlessly if I let the body of the operation execute blocking 
after loading.

In my osg::Operation::operator()(osg::Object*) implementation I'm using 
the following scheme:

osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
     if (viewer)
     {
         return;
     }
     else
     {
         runTheIntersectionVisitor(); ...
     }
Is there anything else I need to know? Examples for the osg::Operation 
are rare and I don't see from the given implementation if I need to lock 
anything.

Can someone give some insight on this?

Cheers
Sebastian



More information about the osg-users mailing list