Re: [osg-users] Modifying scenegraph and update

2010-06-01 Thread Robert Osfield
Hi Jimmy,

The OSG doesn't support general multi-threaded update, you have to
serialize all the updates and make sure they happen during the update
phase of the frame.

Support for general mult-threaded update would complicate the scene
graph design, implementation, usage and have a big hit on performance,
so it's something I've strongly avoided.

It isn't difficult to manage applications so that they do single
threaded update, which route is best for you will depend upon your
needs.  You don't provide any information about what you are trying to
do and why so it's rather too open ended to go suggest what you should
do.

Robert.

On Tue, Jun 1, 2010 at 5:47 AM, Jimmy Lin dummy...@gmail.com wrote:
 Hi,

 On relative issue.

 What if viewer-frame() is running on different thread that is different to 
 the thread that modifies the scene graph. In that case I don't really have 
 the control when is frame() get called. the modification can happen during 
 the rendering time, which I guess is bad.

 I tried use lock/unlock wrap around frame() and where ever I modify the 
 scene, but this introduce serious performance issue.

 The only solution I can think of is use UpdateCallback. but wouldn't the same 
 problem happens when modify the update callback at the same time as frame() 
 doing the updatetraversal? or does OSG have a way to protect the data during 
 the updatetraversal ??

 Or is there other approach you can advice me.


 Thank you!

 Cheers,
 Jimmy

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=28388#28388





 ___
 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] Modifying scenegraph and update

2010-05-31 Thread Jimmy Lin
Hi,

On relative issue.

What if viewer-frame() is running on different thread that is different to the 
thread that modifies the scene graph. In that case I don't really have the 
control when is frame() get called. the modification can happen during the 
rendering time, which I guess is bad.

I tried use lock/unlock wrap around frame() and where ever I modify the scene, 
but this introduce serious performance issue.

The only solution I can think of is use UpdateCallback. but wouldn't the same 
problem happens when modify the update callback at the same time as frame() 
doing the updatetraversal? or does OSG have a way to protect the data during 
the updatetraversal ??

Or is there other approach you can advice me.


Thank you!

Cheers,
Jimmy

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28388#28388





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


Re: [osg-users] Modifying scenegraph and update

2010-03-05 Thread Alberto Luaces
Martin Beckett writes:

 I am modifying the scene, adding geometries, vertices etc and i have no 
 control over when a draw traversal takes place.

 I am being carefull to ensure the geometry is always valid, eg. by adding 
 vertices first then updating the PrimitiveSet but none of these operations 
 are really atomic.

 Is there some lock/unlock mechanism in OSG or I is it happening by magic?

This is done through the method Object::setDataVariance(), setting it to
STATIC or DYNAMIC. In your case, you should mark that object DYNAMIC in
order to prevent OSG accesing it while you are modifying the mesh.

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


Re: [osg-users] Modifying scenegraph and update

2010-03-05 Thread Martin Beckett
Thanks - I think I am misunderstanding the threading in OSG.
In the gui I though frame() was called at 60fps, eg with a model rotating in 
the view.

If I have a gui thread (say a non-modal dialog) that modifies the scene then I 
need to make sure that I don't have an invalid drawable/vertex array 
combination at any point.

In my own code I was used to having a semaphore that prevented a repaint while 
the data was being modified - but didn't see anything like that in OSG

I will take a look at the suggestion

Cheers,
Martin

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=25260#25260





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


Re: [osg-users] Modifying scenegraph and update

2010-03-05 Thread Jim Brooks
  Is there some lock/unlock mechanism in OSG or I is it happening by magic?

This is done through the method Object::setDataVariance(), setting it to
STATIC or DYNAMIC. In your case, you should mark that object DYNAMIC in
order to prevent OSG accesing it while you are modifying the mesh.

Not exactly, just setting a node as DYNAMIC
doesn't mean the app can safely alter a node at any time.

See the OSG QuickStartGuide.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Modifying scenegraph and update

2010-03-05 Thread Jim Brooks
  Is there some lock/unlock mechanism in OSG or I is it happening by magic?

This is done through the method Object::setDataVariance(), setting it to
STATIC or DYNAMIC. In your case, you should mark that object DYNAMIC in
order to prevent OSG accesing it while you are modifying the mesh.

Not exactly, just setting a node as DYNAMIC
doesn't mean the app can safely alter a node at any time.

See the OSG QuickStartGuide.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Modifying scenegraph and update

2010-03-05 Thread Robert Osfield
HI Martin,

On Fri, Mar 5, 2010 at 4:25 PM, Martin Beckett m...@mgbeckett.com wrote:

 Thanks - I think I am misunderstanding the threading in OSG.
 In the gui I though frame() was called at 60fps, eg with a model rotating
 in the view.

 If I have a gui thread (say a non-modal dialog) that modifies the scene
 then I need to make sure that I don't have an invalid drawable/vertex array
 combination at any point.

 In my own code I was used to having a semaphore that prevented a repaint
 while the data was being modified - but didn't see anything like that in OSG


You have to either pass a custom operation to the viewer to run at each
frame to do the update, or a callback to make sure the the operation gets
called at the appropriate time for the viewer, or to hold back the
viewer.frame() till after you've made your changes.   Since you control when
frame is called it should be straight forward if you want to add a high
level sync.

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