Hi Martin,

In general you shouldn't remove items from the scene during the cull
traversal.  If you app is running single thread you sometime can get away
with it, but its not something to do routinely and when you do it you have
be very very careful to invalidate any iterators held by calling methods.

In your case doing the removeDrawables is probably having problems with
deleting more objects that their are in the array.  If you want to remove
all drawables, then you should use removeDrawable(0, getNumDrawables()) NOT
removeDrawable(1, getNumDrawables()) as the OSG like C and C++ indexes
everything relative to 0.

As for culling, culling doesn't normally mean deleting, it usually would
entail not traversing a subgraph so just don't call the apply on the node
visitor.

Robert.

On 5/10/07, Martin Weier <[EMAIL PROTECTED]> wrote:

I have a problem with removing drawables from a geode. I created a class
which inherits from osg::Geode. In my class I overwrite the accept
method. The goal is to implement my own culling mechanism. So I check if
the node visitor is a cullvisitor. Then I want to remove all drawables
and add new ones, depending on the camera position.
The Code looks like this.

void WWOsgNode::accept(osg::NodeVisitor &nv)
{
if(nv.getVisitorType() == nv.CULL_VISITOR)
   {
   printf("I am a cull Vistor\n");

    try {
    this->removeDrawables(1,this->getNumDrawables());
   }
    catch(...)
   {
   printf("Something wrong while removing stuff\n");
   }

   printf("Number of drawables in Displaylist:
%d\n",this->getNumDrawables());
   ...
}

this crashes the program. The program runs when I remove the
removeDrawables call. I already tried to iterate over all drawables
removing everyone with removeDrawable. This causes the same problems. I
can provide a backtrace if this helps. My OpenSceneGraph version is 1.2
on Ubuntu Feisty compiled from source. I tried other version of
OpenSceneGraph so I guess I am doing something wrong.
What am I missing?
I hope somebody can help

Martin
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to