[osg-users] modify children in node callback?

2009-03-02 Thread Cory Riddell
In general, is it ok to modify child nodes in a node callback method?
That is, children of the node for which the callback was called?

I assume it must be. If not, how do you add or remove nodes of a scene
graph while running?

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


Re: [osg-users] modify children in node callback?

2009-03-02 Thread Brian R Hill
Cory,

You can't modify the hierarchy during an active traversal - this will mess
up the traversal. You need to cache your updates and perform them between
traversals.

Brian

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery.
NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
any order or other contract unless pursuant to explicit written agreement
or government initiative expressly permitting the use of e-mail for such
purpose. •
-osg-users-boun...@lists.openscenegraph.org wrote: -

To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
From: Cory Riddell c...@codeware.com
Sent by: osg-users-boun...@lists.openscenegraph.org
Date: 03/02/2009 02:45PM
Subject: [osg-users] modify children in node callback?

In general, is it ok to modify child nodes in a node callback method?
That is, children of the node for which the callback was called?

I assume it must be. If not, how do you add or remove nodes of a scene
graph while running?

Cory
___
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] modify children in node callback?

2009-03-02 Thread Cory Riddell
Thanks Brian, that makes sense.

Is there a pre (or post) traversal callback that I can hook to make the
changes, or must I manually mange the  frame loop to make the changes?

Cory

Brian R Hill wrote:
 Cory,

 You can't modify the hierarchy during an active traversal - this will mess
 up the traversal. You need to cache your updates and perform them between
 traversals.

 Brian

 This is a PRIVATE message. If you are not the intended recipient, please
 delete without copying and kindly advise us by e-mail of the mistake in
 delivery.
 NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
 any order or other contract unless pursuant to explicit written agreement
 or government initiative expressly permitting the use of e-mail for such
 purpose. •
 -osg-users-boun...@lists.openscenegraph.org wrote: -

 To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
 From: Cory Riddell c...@codeware.com
 Sent by: osg-users-boun...@lists.openscenegraph.org
 Date: 03/02/2009 02:45PM
 Subject: [osg-users] modify children in node callback?

 In general, is it ok to modify child nodes in a node callback method?
 That is, children of the node for which the callback was called?

 I assume it must be. If not, how do you add or remove nodes of a scene
 graph while running?

 Cory
 ___
 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
   
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] modify children in node callback?

2009-03-02 Thread Brian R Hill
I usually do it in the main loop, something like:

while(!viewer.done())
{
 // do updates here
 update_scene_graph(...);

 viewer.frame();
}

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery.
NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
any order or other contract unless pursuant to explicit written agreement
or government initiative expressly permitting the use of e-mail for such
purpose. •
-osg-users-boun...@lists.openscenegraph.org wrote: -

To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
From: Cory Riddell c...@codeware.com
Sent by: osg-users-boun...@lists.openscenegraph.org
Date: 03/02/2009 03:41PM
Subject: Re: [osg-users] modify children in node callback?

Thanks Brian, that makes sense.

Is there a pre (or post) traversal callback that I can hook to make the
changes, or must I manually mange the  frame loop to make the changes?

Cory

Brian R Hill wrote:
 Cory,

 You can't modify the hierarchy during an active traversal - this will
mess
 up the traversal. You need to cache your updates and perform them between
 traversals.

 Brian

 This is a PRIVATE message. If you are not the intended recipient, please
 delete without copying and kindly advise us by e-mail of the mistake in
 delivery.
 NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
 any order or other contract unless pursuant to explicit written agreement
 or government initiative expressly permitting the use of e-mail for such
 purpose. •
 -osg-users-boun...@lists.openscenegraph.org wrote: -

 To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
 From: Cory Riddell c...@codeware.com
 Sent by: osg-users-boun...@lists.openscenegraph.org
 Date: 03/02/2009 02:45PM
 Subject: [osg-users] modify children in node callback?

 In general, is it ok to modify child nodes in a node callback method?
 That is, children of the node for which the callback was called?

 I assume it must be. If not, how do you add or remove nodes of a scene
 graph while running?

 Cory
 ___
 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

___
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] modify children in node callback?

2009-03-02 Thread Thrall, Bryan
Brian R Hill wrote on Monday, March 02, 2009 2:29 PM:
 You can't modify the hierarchy during an active traversal - this will
mess
 up the traversal. You need to cache your updates and perform them
between
 traversals.

Changes to the scenegraph should be made during the update traversal
(so, inside an UpdateCallback), which is single-threaded so it is safe.
The easiest way to prevent certain nodes from being traversed is to
modify their node mask (the Camera also needs its traversal mask set so
it will ignore these nodes).

The main problem with removing/adding nodes is invalidating iterators,
so I think it should be safe to add or remove children of the node
currently being visited in the update pass; at the point of the
UpdateCallback, I wouldn't expect any iterators to be iterating over
that node's child list.

 -osg-users-boun...@lists.openscenegraph.org wrote: -
 
 To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
 From: Cory Riddell c...@codeware.com
 Sent by: osg-users-boun...@lists.openscenegraph.org
 Date: 03/02/2009 02:45PM
 Subject: [osg-users] modify children in node callback?
 
 In general, is it ok to modify child nodes in a node callback method?
 That is, children of the node for which the callback was called?
 
 I assume it must be. If not, how do you add or remove nodes of a scene
 graph while running?
 
 Cory
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

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

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] modify children in node callback?

2009-03-02 Thread Brian R Hill
Bryan,

Thanks for pointing that out. I've always just done it outside of all the
traversals and never looked for other ways - probably has something to do
with the old dog, no new tricks thing :)

Brian

-osg-users-boun...@lists.openscenegraph.org wrote: -

To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
From: Thrall, Bryan bryan.thr...@flightsafety.com
Sent by: osg-users-boun...@lists.openscenegraph.org
Date: 03/02/2009 04:00PM
Subject: Re: [osg-users] modify children in node callback?

Brian R Hill wrote on Monday, March 02, 2009 2:29 PM:
 You can't modify the hierarchy during an active traversal - this will
mess
 up the traversal. You need to cache your updates and perform them
between
 traversals.

Changes to the scenegraph should be made during the update traversal
(so, inside an UpdateCallback), which is single-threaded so it is safe.
The easiest way to prevent certain nodes from being traversed is to
modify their node mask (the Camera also needs its traversal mask set so
it will ignore these nodes).

The main problem with removing/adding nodes is invalidating iterators,
so I think it should be safe to add or remove children of the node
currently being visited in the update pass; at the point of the
UpdateCallback, I wouldn't expect any iterators to be iterating over
that node's child list.

 -osg-users-boun...@lists.openscenegraph.org wrote: -

 To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
 From: Cory Riddell c...@codeware.com
 Sent by: osg-users-boun...@lists.openscenegraph.org
 Date: 03/02/2009 02:45PM
 Subject: [osg-users] modify children in node callback?

 In general, is it ok to modify child nodes in a node callback method?
 That is, children of the node for which the callback was called?

 I assume it must be. If not, how do you add or remove nodes of a scene
 graph while running?

 Cory
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

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

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



--
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
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