[osg-users] Best Practices and Switches

Robert Osfield robert.osfield at gmail.com
Tue Apr 30 10:16:53 PDT 2019


Hi David,

On Tue, 30 Apr 2019 at 17:38, David Heitbrink <david-heitbrink at uiowa.edu> wrote:
> I have some scenes with tons of osgSim::MultiSwitch's, I think for some of my scenes it can be in the low 1000s. For a scene these are typically setup once, and then rarely changed. From what I understand a lot of the optimize operations do not work across switches, which makes sense, I would think it would be hard to merge geometry with something that can change.
>
> Since these switches rarely change, I was thinking about loading my switch options from a file, then just removing the switches, and attaching the selected child of the multi-switch to its parent. In general is this a solid approach, or is just setting "DataVariance" to static for the switch good enough?
>
> Typically the object size under these switches are pretty small. Often times they are just 4 triangles.

Having 1000's of Switch nodes can create a CPU load that ideally is
only somethng you'd want to pay for if you are actively using them as
Switches.  If the Switches just get to one state and for the rest of
the applications life remain the same then just replacing them with
the subgraph that is enabled should provide a performance gain.

Another alternative would be to use the osg::Node::setNodeMask(uint
mask) instead of a Switch.  It doesn't have exactly the same
functionality as the switch but can be close enough for many tasks and
as all nodes have a NodeMask and they are always checked during
traversal you don't pay any extra cost in using the NodeMask as a
switch.

Robert.


More information about the osg-users mailing list