Changeset 10362

Show
Ignore:
Timestamp:
06/18/09 12:01:39 (5 years ago)
Author:
robert
Message:

From Cedric Pinson and Robert Osfield, addition of NodeCallbacks? to osg::CopyOp? and osg::Node copy constructor.

Location:
OpenSceneGraph/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/CopyOp

    r9407 r10362  
    3131class PrimitiveSet; 
    3232class Shape; 
     33class NodeCallback; 
    3334 
    3435/** Copy Op(erator) used to control whether shallow or deep copy is used 
     
    5354            DEEP_COPY_SHAPES            = 1<<9, 
    5455            DEEP_COPY_UNIFORMS          = 1<<10, 
     56            DEEP_COPY_NODECALLBACKS     = 1<<11, 
    5557            DEEP_COPY_ALL               = 0x7FFFFFFF 
    5658        }; 
     
    7375        virtual Shape*          operator() (const Shape* shape) const; 
    7476        virtual Uniform*        operator() (const Uniform* shape) const; 
     77        virtual NodeCallback*   operator() (const NodeCallback* nodecallback) const; 
    7578 
    7679    protected: 
  • OpenSceneGraph/trunk/src/osg/CopyOp.cpp

    r6459 r10362  
    6666 
    6767 
     68NodeCallback* CopyOp::operator() (const NodeCallback* nc) const 
     69{ 
     70    if (nc && _flags&DEEP_COPY_NODECALLBACKS) 
     71    { 
     72        // deep copy the full chain of callback 
     73        osg::NodeCallback* first = dynamic_cast<osg::NodeCallback*>(nc->clone(*this)); 
     74        first->setNestedCallback(0); 
     75        nc = nc->getNestedCallback(); 
     76        while (nc)  
     77        { 
     78            osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(nc->clone(*this)); 
     79            ucb->setNestedCallback(0); 
     80            first->addNestedCallback(ucb); 
     81            nc = nc->getNestedCallback(); 
     82        } 
     83        return first; 
     84    } 
     85    else 
     86        return const_cast<NodeCallback*>(nc); 
     87} 
  • OpenSceneGraph/trunk/src/osg/Node.cpp

    r9897 r10362  
    7575        _boundingSphereComputed(node._boundingSphereComputed), 
    7676        _parents(), // leave empty as parentList is managed by Group. 
    77         _updateCallback(node._updateCallback), 
     77        _updateCallback(copyop(node._updateCallback.get())), 
    7878        _numChildrenRequiringUpdateTraversal(0), // assume no children yet. 
    7979        _numChildrenRequiringEventTraversal(0), // assume no children yet. 
    80         _cullCallback(node._cullCallback), 
     80        _cullCallback(copyop(node._cullCallback.get())), 
    8181        _cullingActive(node._cullingActive), 
    8282        _numChildrenWithCullingDisabled(0), // assume no children yet.