I've had some problems in the past with the StaticObjectDetectionVisitor and the Optimizer (assume "sharing" part of the Optimizer) doing some things to my scene graph which cause it to render incorrectly when I don't specify my DataVariance as being DYNAMIC.
Is there a reason why there is a StaticObjectDetectionVisitor being done when setSceneData() is performed independent of the Optimizer settings? Is the DataVariance value used by something other than the Optimizer?
Paul P.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
In all the OSG 2.x series the DataVariance is used during the draw
traversal to monitor when all DYNAMIC StateSet and Drawables have been
dispatched, as once they have been the next frame can be started in a
parallel with the remaining STATIC objects are rendered (in
DrawThreadPerContex, CullThreadPerCameraDrawThreadPerContext threading
models.)
Robert.
Gordon
__________________________________________________________
Gordon Tomlinson
Product Manager 3D
Email : gtomlinson @ overwatch.textron.com
__________________________________________________________
(C): (+1) 571-265-2612
(W): (+1) 703-437-7651
"Self defence is not a function of learning tricks
but is a function of how quickly and intensely one
can arouse one's instinct for survival"
- Master Tambo Tetsura
----- Original Message ----
From: Robert Osfield <robert....@gmail.com>
To: OpenSceneGraph Users <osg-...@lists.openscenegraph.org>
Sent: Wednesday, September 17, 2008 8:06:47 AM
Subject: Re: [osg-users] DataVariance
Hi Paul,
In all the OSG 2.x series the DataVariance is used during the draw
traversal to monitor when all DYNAMIC StateSet and Drawables have been
dispatched, as once they have been the next frame can be started in a
parallel with the remaining STATIC objects are rendered (in
DrawThreadPerContex, CullThreadPerCameraDrawThreadPerContext threading
models.)
Robert.
On Wed, Sep 17, 2008 at 12:54 PM, <paul...@yahoo.com> wrote:
I can't say why your app might be hanging. Do the standard OSG
example hang on your machine?
Try running the view single threaded as something that might at least
flesh out whether threading is an issue at all.
Robert.
Clearly, it's something in this app that is causing problems. In the problem case, I'm rendering to two different image buffers and then reading the images out on the CPU. My scene is a "normal" scene except I have two cameras with each rendering to these different textures (i.e. a top and bottom view of the scene). I also have another camera rendering an orthogonal projection on top of the scene.
Paul P.
You will have to debug this on your own I'm afraid, this type of issue
is not something one can resolve without seeing it first hand.
The best I can do is recommend that look into the using DataVariance
set to DYNAMIC on all StateSet and Drawable that you have in your
scene. This is the most likely cause of problems like this, but we've
already recommended this and you've made no comment whether you've
tried this. There have been lots written on this topic on osg-users
so please don't overlook the archives.
Robert.
One thing I have considered is changing the design of osg::Statesets and
osg::StateAttribute to immutable classes. So once the stuff is created
you can only change it by cloning it. At least for those objects you
don't have to think about datavariance anymore.
Attached you will find a 'setup' design pattern, which helps you
spawning immutable objects.
Richard
PS.: Just an idea.
SetDataVariance dataVariance;
root->accept(dataVariance);
Where:
class SetDataVariance : public osg::NodeVisitor
{
public:
SetDataVariance(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{};
virtual void apply(osg::Node& node);
virtual void apply(osg::Geode &node);
};
void SetDataVariance::apply(osg::Node& node)
{
node.getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
traverse(node);
}
void SetDataVariance::apply(osg::Geode& geode)
{
geode.getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
geode.setDataVariance(osg::Object::DYNAMIC);
for(unsigned int i=0;i<geode.getNumDrawables();++i)
{
osg::Drawable* drawable = geode.getDrawable(i);
if (drawable)
{
drawable->getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
drawable->setDataVariance(osg::Object::DYNAMIC);
}
}
}
Removing a portion of my scene graph and the problem goes away (or is hidden).. In particular, if I remove the node->addDrawable(geometry), the problem goes away. The problem exists even if node->addDrawable( new osg::Geometry). In addition, turning off optimization doesn't seem to help. As I said before, using single threaded viewer and it works fine.
Any idea what is going on?
Could you try the CullDrawThreadPerContext thread model to see if that
works safely. If it does then the issue is almost certainly down to
some StateSet or Drawable in your scene graph that you are modifying
the contents that don't have the DataVariance set to DYNAMIC.
Robert.
If the problem is with stateset and Drawable not being set to DYNAMIC, why wouldn't my SetDataVariance NodeVisitor (see below) convert everything to DYNAMIC. I call this during my initialization of the scene graph.
On Mon, Nov 24, 2008 at 3:57 PM, <paul...@yahoo.com> wrote:
> Using CullDrawThreadPerContext and it works..
>
> If the problem is with stateset and Drawable not being set to DYNAMIC, why wouldn't my SetDataVariance NodeVisitor (see below) convert everything to DYNAMIC. I call this during my initialization of the scene graph.
Your visitor shouldn't use getOrCreateStateSet as this will be
creating a StateSet on all nodes and drawables. Use getStateSet and
an if statement to protect.
As to why it doesn't seem to fix the threading problem you have.
We'll I can't help you here. You have to debug your app, as I don't
have it in front of me, and I have plenty of work to do myself.
Robert.