Changeset 12330 for OpenSceneGraph/trunk/src/osg/CopyOp.cpp
- Timestamp:
- 04/28/11 18:33:14 (2 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/CopyOp.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/CopyOp.cpp
r10671 r12330 27 27 { \ 28 28 if (obj && _flags&FLAG) \ 29 return dynamic_cast<TYPE*>( obj->clone(*this)); \29 return osg::clone(obj, *this); \ 30 30 else \ 31 31 return const_cast<TYPE*>(obj); \ 32 32 } 33 33 34 COPY_OP( Object, DEEP_COPY_OBJECTS ) 35 COPY_OP( Node, DEEP_COPY_NODES ) 36 COPY_OP( Drawable, DEEP_COPY_DRAWABLES ) 37 COPY_OP( StateSet, DEEP_COPY_STATESETS ) 38 COPY_OP( Texture, DEEP_COPY_TEXTURES ) 39 COPY_OP( Image, DEEP_COPY_IMAGES ) 40 COPY_OP( Array, DEEP_COPY_ARRAYS ) 41 COPY_OP( PrimitiveSet, DEEP_COPY_PRIMITIVES ) 42 COPY_OP( Shape, DEEP_COPY_SHAPES ) 43 COPY_OP( Uniform, DEEP_COPY_UNIFORMS ) 34 COPY_OP( Object, DEEP_COPY_OBJECTS ) 35 COPY_OP( Node, DEEP_COPY_NODES ) 36 COPY_OP( StateSet, DEEP_COPY_STATESETS ) 37 COPY_OP( Image, DEEP_COPY_IMAGES ) 38 COPY_OP( Uniform, DEEP_COPY_UNIFORMS ) 39 COPY_OP( StateAttributeCallback, DEEP_COPY_CALLBACKS ) 40 COPY_OP( Drawable, DEEP_COPY_DRAWABLES ) 41 COPY_OP( Texture, DEEP_COPY_TEXTURES ) 42 COPY_OP( Array, DEEP_COPY_ARRAYS ) 43 COPY_OP( PrimitiveSet, DEEP_COPY_PRIMITIVES ) 44 COPY_OP( Shape, DEEP_COPY_SHAPES ) 44 45 45 46 Referenced* CopyOp::operator() (const Referenced* ref) const … … 59 60 else 60 61 { 61 return dynamic_cast<StateAttribute*>(attr->clone(*this));62 return osg::clone(attr, *this); 62 63 } 63 64 } … … 66 67 } 67 68 68 69 69 NodeCallback* CopyOp::operator() (const NodeCallback* nc) const 70 70 { … … 72 72 { 73 73 // deep copy the full chain of callback 74 osg::NodeCallback* first = dynamic_cast<osg::NodeCallback*>(nc->clone(*this)); 74 osg::NodeCallback* first = osg::clone(nc, *this); 75 if (!first) return 0; 76 75 77 first->setNestedCallback(0); 76 78 nc = nc->getNestedCallback(); 77 79 while (nc) 78 80 { 79 osg::NodeCallback* ucb = dynamic_cast<osg::NodeCallback*>(nc->clone(*this)); 80 ucb->setNestedCallback(0); 81 first->addNestedCallback(ucb); 81 osg::NodeCallback* ucb = osg::clone(nc, *this); 82 if (ucb) 83 { 84 ucb->setNestedCallback(0); 85 first->addNestedCallback(ucb); 86 } 82 87 nc = nc->getNestedCallback(); 83 88 } … … 87 92 return const_cast<NodeCallback*>(nc); 88 93 } 89 90 91 StateAttributeCallback* CopyOp::operator() (const StateAttributeCallback* sc) const92 {93 if (sc && _flags&DEEP_COPY_CALLBACKS)94 {95 // deep copy the full chain of callback96 StateAttributeCallback* cb = dynamic_cast<StateAttributeCallback*>(sc->clone(*this));97 return cb;98 }99 else100 return const_cast<StateAttributeCallback*>(sc);101 }102
