[osg-users] Deep cloning an active root scene node
Robert Lockyer
robert.lockyer at avalonholographics.com
Thu Feb 28 09:50:46 PST 2019
Hi all, my name is Rob.
I'm currently writing a plugin for an OSG based application. I effectively
want to create a snapshot of the application's scene graph state and pass
it to another thread where I can render to a texture, while the main
rendering thread continues with minimal interruption.
I'd like to do this because blocking the main thread with a
osgViewer::Viewer::frame() call causes the application to lock up and
prevents me from displaying a progress dialog. The scene I render takes a
long time because I render many camera views to a single texture.
I'm currently trying to do this:
osg::Node* sceneCopy =
dynamic_cast<osg::Node*>(sceneData_->clone(osg::CopyOp::DEEP_COPY_ALL));
Then passing this to another thread where I run:
viewer_ = new osgViewer::Viewer();
viewer_->setSceneData(sceneCopy);
However the behavior seems inconsistent. It either dies on a null reference
inside osgEarth somewhere or it renders an empty scene. I don't think I
fully understand the threading model of OSG, I've read a bit here and
there, but I think there's a lot I'm still missing.
Is there a safe way to copy the scene data and use it to run an isolated
viewer like this in parallel? Is it even safe to run two viewers in
parallel like this at all?
Cheers,
Rob
--
_This email and any attachments are confidential and may be privileged. Any
unauthorized use, disclosure, copying or distribution of the information
received is prohibited. If you are not the intended recipient please
contact the sender immediately by return email confirming that you have and
will delete all communications related to the email and any attachments
sent to you in error._
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190228/34b377c0/attachment.html>
More information about the osg-users
mailing list