Here is my repro case for the 10000 children of a switch node causing
massive cull times.
Just enable the stats with the 's' key. Even though most children are
turned off, they seem to be processed in the cull traversal - the
culling dominates the render time.
I do not understand enough of OpenSceneGraph to exactly pinpoint the
cause, maybe Robert can shed a bit of light as to what is going on.
Christian
/* OpenSceneGraph example, osgminimalglsl.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* file: examples/osgrepro.cpp
*
* Showing why it's a bad idea to put 10000 children into an osg::Switch
* observe the culling times!!!
*/
#include <osg/ArgumentParser>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/Switch>
#include <osg/PositionAttitudeTransform>
#include <osg/Drawable>
#include <osgText/Text>
using namespace osg;
int main(int argc, char **argv)
{
osg::ArgumentParser arg(&argc, argv);
// construct the viewer.
osgViewer::Viewer viewer(arg);
// use a geode with a Box ShapeDrawable
osg::Switch* sw = new osg::Switch();
for (int y=0; y<100; ++y)
{
for (int x=0; x<100; ++x)
{
osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform();
pat->setPosition(osg::Vec3(10*x,10*y,0));
osg::Geode *geode = new osg::Geode();
osgText::Text *text = new osgText::Text();
text->setText("foo");
text->setAlignment(osgText::TextBase::CENTER_BOTTOM);
text->setAutoRotateToScreen(true);
text->setDataVariance(osg::Object::DYNAMIC);
geode->addDrawable(text);
pat->addChild(geode);
sw->addChild(pat);
// turn on only a small subset of childs
sw->setChildValue(pat, rand() % 100 == 0);
}
}
viewer.addEventHandler(new osgViewer::StatsHandler);
// run the osg::Viewer using our model
viewer.setSceneData( sw );
return viewer.run();
}
/*EOF*/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org