[osg-users] DEEP_COPY_USERDATA isn't that deep

Chris Djali krizdjali at gmail.com
Sun Oct 20 12:48:56 PDT 2019


Hi,

It's been pointed out to me that the DefaultUserDataContainer object list can be a little bit more deeply copied with this change:


Code:
--- a/src/osg/UserDataContainer.cpp
+++ b/src/osg/UserDataContainer.cpp
@@ -56,7 +56,10 @@ DefaultUserDataContainer::DefaultUserDataContainer(const DefaultUserDataContaine
         itr != udc._objectList.end();
         ++itr)
     {
-        _objectList.push_back(copyop(itr->get()));
+        if (copyop.getCopyFlags()&osg::CopyOp::DEEP_COPY_USERDATA)
+            _objectList.push_back(osg::clone(itr->get(), copyop));
+        else
+            _objectList.push_back(copyop(itr->get()));
     }
 }




This will make _objectList at least point to copies of the objects instead of literally the same objects, which is a step in the right direction, but those copies will still be shallow copies.

Cheers,
Chris

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76837#76837







More information about the osg-users mailing list