Hi all -- I wanted to alert everyone to a possible performance issue with the FLATTEN_STATIC_TRANSFORMS flag in osgUtil::Optimizer. As this flag is set by default, it could affect anyone who uses the Optimizer. However, the problem is limited to instances of static Transform nodes, or in other words, static Transform nodes that have multiple parents.

The issue is being discussed in two other threads, but the subjects are a bit obtuse, so I wanted to bring it to everyone's attention in this separate thread. The other discussion threads to check are:
  osg-users: mergeGeodes crash
  osg-submissions: Optimizer fix for FSTV
The attached test model in "mergeGeodes crash" demonstrate the issue, and the stats display in osgviewer plainly shows the problem.

Summary of the issue: FLATTEN_STATIC_TRANSFORMS replaces static Transform nodes with Group nodes. To do this, it adds all the children of the Transform node to the new Group. However, if the transform has multiple parents, children are added redundantly to the Group, causing them to appear as children multiple times incorrectly.

Example: Suppose you have a static Transform with two parents, and one child called NodeA. The FLATTEN_STATIC_TRANSFORMS operation will add a new Group to each of the parents (which is correct), but the new Group will end up with _two_ children, both are references to the same NodeA. The result is that NodeA, which should be instanced twice, is now instanced four times, and therefore visited four times by the cull traversal. Drawable children of NodeA will be drawn four times instead of twice.

Note that this addition of redundant nodes issue has been present since svn revision 115 back in 2001. This problem has been with us for a long long time.

This may or may not be a performance impact. In testing I've done with a few models that I know use instancing/multiparenting of Transforms, the additional cost of the redundant node processing seems to be outweighed by the fact that FLATTEN_STATIC_TRANSFORMS combined with REMOVE_REDUNDANT_NODES produces a significant net reduction in the cull traversal. But this will vary from one model to the next, and will depend on things like how deeply nested your scene graph is, and more importantly how many times (if at all) your scene graph uses instances of Transform nodes.

The point of this post is to bring it to your attention so that you can do your own benchmarking and make your own determination on a course of action.

Thanks,
--
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466

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

Reply via email to