[osg-users] Must I call setDataVariance(DYNAMIC) to a group node?

111 views
Skip to first unread message

ttaw

unread,
Mar 5, 2014, 10:35:47 PM3/5/14
to osg-users
There's a saying on internet that setDataVariance(DYNAMIC) must be called to a group node which is to be changed while updating. But in my opinion, it's unnecessary because the child drawable pointers and stateset pointers are saved in ReaderLeaf as a ref_ptr if OSGUTIL_RENDERBACKEND_USE_REF_PTR is defined. In fact, this macro is defined in the begining of the file "RenderLeaf".Even if one or more child nodes were removed while updating, the drawables wouldn't be deleted and no crash would happen. We must set a node dynamic only when its stateset is to be changed or its drawables are to be changed. But I'm not sure of this and want to know if I'm right.Could anybody tell me the truth?Thanks.
------------------
Failure is the mother of success.
Wu Zhicheng
 

Robert Osfield

unread,
Mar 6, 2014, 6:44:15 AM3/6/14
to OpenSceneGraph Users
HI Wu,

You only need to set the Node DataVariance as a hint to the osgUtil::Optimizer that is typically only used after loading a new model, the Node DataVariance is not used during the update, event, cull or draw traversals.

However, when using DrawThreadPerContext or CullThreadPerCameraDrawThreadPerContext threading models the StateSet and Drawable DataVariance is used to prevent dynamic leaves of the scene graph being updated and rendered at the same time - the draw traversal holds back the main thread till all the dynamic objects have been dispatched.

Robert.


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


Cary, Karl A.

unread,
Mar 6, 2014, 7:00:18 AM3/6/14
to OpenSceneGraph Users

This is actually something I have been curious about for exactly how it is done as well. What about if you have a Geode who you are going to add or remove drawables to. Do you make those drawables DYNAMIC?

Robert Osfield

unread,
Mar 6, 2014, 8:22:06 AM3/6/14
to OpenSceneGraph Users
HI Karl,

On 6 March 2014 12:00, Cary, Karl A. <KARL....@leidos.com> wrote:

This is actually something I have been curious about for exactly how it is done as well. What about if you have a Geode who you are going to add or remove drawables to. Do you make those drawables DYNAMIC?


It's only the contents of StateSet and Drawables that your need to mark as DYNAMIC if their contents are changing.  If only  their ownership is changing they you'd don't need to set them to DYNAMIC, even if you remove the StateSet or Drawable from the scene graph it's still safe as the rendering back end takes a reference to StateSet and Drawables that it's about to render.
 
Robert.

 

Cary, Karl A.

unread,
Mar 6, 2014, 8:30:18 AM3/6/14
to OpenSceneGraph Users

I think my final question about then is, what about MatrixTransforms? If I have a Matrix Transform with an updateCallback that sets it’s matrix every frame, would it matter if it was static or dynamic?

 

From: osg-user...@lists.openscenegraph.org [mailto:osg-user...@lists.openscenegraph.org] On Behalf Of Robert Osfield
Sent: Thursday, March 06, 2014 8:22 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Must I call setDataVariance(DYNAMIC) to a group node?

 

HI Karl,

Robert Osfield

unread,
Mar 6, 2014, 8:33:38 AM3/6/14
to OpenSceneGraph Users
On 6 March 2014 13:30, Cary, Karl A. <KARL....@leidos.com> wrote:

I think my final question about then is, what about MatrixTransforms? If I have a Matrix Transform with an updateCallback that sets it’s matrix every frame, would it matter if it was static or dynamic?


As I said in my previous explanation, Node do not need to be set to DYNAMIC for the purposes of update, event, cull and draw traveresals.  The only part of the OSG that checks the DataVariance of Nodes is the osgUtil::Optimizer.  So NO.

Robert.

ttaw

unread,
Mar 6, 2014, 2:07:52 PM3/6/14
to osg-users
It doesn't matter. As Robert says, the node's hint is used only in optimizing.
 
From: "Cary, Karl A." <KARL.A.CARY@leidos.com>
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] Must I call setDataVariance(DYNAMIC) to a
group node?
Message-ID:
<A6ADC5E93524E14AACDB379B5271010010F4FAAF@EMP-EXMR103.corp.leidos.com>
Content-Type: text/plain; charset="us-ascii"

I think my final question about then is, what about MatrixTransforms? If I have a Matrix Transform with an updateCallback that sets it's matrix every frame, would it matter if it was static or dynamic?

From: osg-users-bounces@lists.openscenegraph.org [mailto:osg-users-bounces@lists.openscenegraph.org] On Behalf Of Robert Osfield
Sent: Thursday, March 06, 2014 8:22 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Must I call setDataVariance(DYNAMIC) to a group node?

HI Karl,

On 6 March 2014 12:00, Cary, Karl A. <KARL.A.CARY@leidos.com<mailto:KARL.A.CARY@leidos.com>> wrote:
This is actually something I have been curious about for exactly how it is done as well. What about if you have a Geode who you are going to add or remove drawables to. Do you make those drawables DYNAMIC?

It's only the contents of StateSet and Drawables that your need to mark as DYNAMIC if their contents are changing.  If only  their ownership is changing they you'd don't need to set them to DYNAMIC, even if you remove the StateSet or Drawable from the scene graph it's still safe as the rendering back end takes a reference to StateSet and Drawables that it's about to render.

Robert.

Reply all
Reply to author
Forward
0 new messages