[osg-users] Backing up osg State
I'd like to back-up some osg::StateAttribute for the simple purpose of restoring it, if some dialog in my application is rejected. I'd would like to have something as easy as Light* light; ref_ptrLight backup = new Light(*light, osg::CopyOp(osg::CopyOp::DEEP_COPY_ALL)); //back up *light = *backup; This obviously does not work, as Light has no assigment operator. Copying every attribute and resetting them manually seems like an easy work-around but is not forward compatible or maintainable. Copying the state and using the copy in case of rejection is also possible but quite ugly. Is there something I'm missing or is working around that the only way to do it? -- Philipp Moeller, GeometryFactory ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Backing up osg State
Hi Philipp On 25 January 2012 15:37, Philipp Moeller philipp.moel...@geometryfactory.com wrote: I'd like to back-up some osg::StateAttribute for the simple purpose of restoring it, if some dialog in my application is rejected. I'd would like to have something as easy as Light* light; ref_ptrLight backup = new Light(*light, osg::CopyOp(osg::CopyOp::DEEP_COPY_ALL)); //back up *light = *backup; This obviously does not work, as Light has no assigment operator. It should work as it has a copy constructor, it doesn't need a copy operator for this task. You can also call clone() if you want. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Backing up osg State
Robert Osfield robert.osfi...@gmail.com writes: Hi Philipp On 25 January 2012 15:37, Philipp Moeller philipp.moel...@geometryfactory.com wrote: I'd like to back-up some osg::StateAttribute for the simple purpose of restoring it, if some dialog in my application is rejected. I'd would like to have something as easy as Light* light; ref_ptrLight backup = new Light(*light, osg::CopyOp(osg::CopyOp::DEEP_COPY_ALL)); //back up *light = *backup; This obviously does not work, as Light has no assigment operator. It should work as it has a copy constructor, it doesn't need a copy operator for this task. The copy is not the problem the assignment is (The operator= is needed here as this is not the point of declaration). osg::Objects operator= is private which default deletes the assignment operator in all base classes and I don't really get why. So it looks like this is by design although it would be nice to have. You can also call clone() if you want. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Backing up osg State
Hi Philip, On 25 January 2012 16:45, Philipp Moeller The copy is not the problem the assignment is (The operator= is needed here as this is not the point of declaration). osg::Objects operator= is private which default deletes the assignment operator in all base classes and I don't really get why. So it looks like this is by design although it would be nice to have. There is no copy operator by design. Copying elements in a scene graph is rather open ended as the objects within the graph have children (UseData on osg::Light is a form of child) so you have think about what happens with the child objects - this is what CopyOp's role is, but this obviously isn't available with the standard C++ = operator. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org