osg::NodeCallback migration to vsg #1075
-
Hello, I'm trying to migrate osg code to vsg. In this code I'm using osg::NodeCallback extensively. Thank you very much |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi, Vsg is very different from Osg, so callbacks are not present instead we have to use event handlers and node visitors. Vsg doesnt seem have concept of draw,cull and update passes, it depends on the Vulkan pipeline that you setup in the scene instead, so a CallBack doesn't make much sense here. Bottom line is you will have to do it yourself somehow based on your use case. |
Beta Was this translation helpful? Give feedback.
-
Could you explain what you are using the callbacks for? The VSG by design doesn't have callbacks like OSG does, neither scene graph strictly needs them, and having them adds memory and branching penalty that all nodes have to pay for even if the nodes that have any callbacks assigned to them. Not having them in the VSG is one of the reasons traversals can be an order of magnitude faster than the OSG. Like the OSG the VSG has virtual void accept(..) and void travers(..) methods which you can override to customize behaviour. The node callbacks in the OSG are just in effect an alternative to subclassing a node to override the traverse(..) method, everything you can do with a node callback you can do by subclassing from a node and override the traverse method, Rather than have two ways of doing the same thing, the VSG just aims to make it easy to subclass nodes and override the accept()/traverse(). You have to subclass and override the callback anyway so it's not actually any more code. Another approach to override nodes is to use a viewer level vsg::EventHandler or an update vsg::Operation. The vsg::EventHandler base class is similar in role to the osgGA::GUIEventHandler. The OSG also a osg::Operation base class. Doing all the update operations together is more efficient trawling a scene graph for update callbacks, so again this is performance and complexity issue that I've decide avoid. My plan is to have a special node in the VSG that you can attach event handlers and update operations to, these will just provide a mechanism for the event handler and operations to be assigned to/removed from the Viewer rather than get invoked themselves. As a general note, it may be possible to move the work done in callbacks into a combination of compute, mesh, vertex or fragment shaders. |
Beta Was this translation helpful? Give feedback.
Could you explain what you are using the callbacks for?
The VSG by design doesn't have callbacks like OSG does, neither scene graph strictly needs them, and having them adds memory and branching penalty that all nodes have to pay for even if the nodes that have any callbacks assigned to them. Not having them in the VSG is one of the reasons traversals can be an order of magnitude faster than the OSG.
Like the OSG the VSG has virtual void accept(..) and void travers(..) methods which you can override to customize behaviour. The node callbacks in the OSG are just in effect an alternative to subclassing a node to override the traverse(..) method, everything you can do with a node callback yo…