Re: [osg-users] How to correct remove objects from scene graph and destruct they not in render thread?

2012-02-17 Thread Robert Osfield
Hi Mikhail,

If you want to remove elements from the scene graph but delay
destruction to be done in a background thread the way to do it take a
ref_ptr to the subgraph you want to remove to prevent it from being
deleted, then remove the subgraph from the scene within the update
phase of the viewer frame, then pass this ref_ptr to the background
thread.  Personally I wouldn't use co-opt the DatabasePager for doing
this - although it does supports this already, conceptually it doesn't
make for a clean application.

Robert.

On 17 February 2012 07:10, Mikhail I. Izmestev izmmish...@gmail.com wrote:
 Hi,

 To remove heavy in destruction objects (which will free large buffers and
 etc.) I use method like in DatabasePager - hold object references and pass
 they to another thread for destructing.

 But there is one case which cause crash.

        (root)
           |
      (some nodes)
         (...)
      |        |
   (nodeA)  (nodeB)
      \        /
        \    /
       (nodeC)
          |
        (...)
          |
       (nodeD)

 So we have nodeC with two parents, and in some moment we want to delete
 subgraph with nodeA.
 We remove from graph parents of nodeA and hold it reference to be destructed
 later in another thread.
 Another thread decrease reference for parents of nodeA and initialize
 destruction, so nodeA have no more references and it want to be deleted, it
 inform children about that and request to remove it from parent list.
 But in render thread we still render main graph and it traverse nodeC, but
 someone like nodeD changed it's matrix, this process require to dirtyBound,
 and dirtyBound inform all parents about this and tries to walk backward for
 all parents and nodeA too.

 So one thread iterate _parent vector, second thread change this vector, and
 in result CRASH!

 Looks like DatabasePager affects this problem too.

 What you can advice in this case?

 Mikhail.
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to correct remove objects from scene graph and destruct they not in render thread?

2012-02-17 Thread Mikhail I. Izmestev

17.02.2012 16:11, Robert Osfield пишет:

Hi Mikhail,

If you want to remove elements from the scene graph but delay
destruction to be done in a background thread the way to do it take a
ref_ptr  to the subgraph you want to remove to prevent it from being
deleted, then remove the subgraph from the scene within the update
phase of the viewer frame, then pass this ref_ptr  to the background
thread.  Personally I wouldn't use co-opt the DatabasePager for doing
this - although it does supports this already, conceptually it doesn't
make for a clean application.



Yes, I'm doing this as you explained.
But you are not answer how to avoid crash in case described by me.

Mikhail.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org