Changeset 10671
- Timestamp:
- 10/22/09 12:33:16 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 10 modified
-
include/osg/CopyOp (modified) (4 diffs)
-
include/osg/ImageSequence (modified) (1 diff)
-
include/osg/StateAttribute (modified) (4 diffs)
-
include/osgAnimation/UpdateCallback (modified) (3 diffs)
-
src/osg/CMakeLists.txt (modified) (1 diff)
-
src/osg/CopyOp.cpp (modified) (3 diffs)
-
src/osg/StateAttribute.cpp (modified) (2 diffs)
-
src/osg/StateSet.cpp (modified) (4 diffs)
-
src/osgAnimation/UpdateCallback.cpp (modified) (3 diffs)
-
src/osgPlugins/osg/StateAttribute.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/CopyOp
r10362 r10671 25 25 class StateSet; 26 26 class StateAttribute; 27 class StateAttributeCallback; 27 28 class Uniform; 28 29 class Node; … … 32 33 class Shape; 33 34 class NodeCallback; 35 34 36 35 37 /** Copy Op(erator) used to control whether shallow or deep copy is used … … 54 56 DEEP_COPY_SHAPES = 1<<9, 55 57 DEEP_COPY_UNIFORMS = 1<<10, 56 DEEP_COPY_ NODECALLBACKS= 1<<11,58 DEEP_COPY_CALLBACKS = 1<<11, 57 59 DEEP_COPY_ALL = 0x7FFFFFFF 58 60 }; … … 76 78 virtual Uniform* operator() (const Uniform* shape) const; 77 79 virtual NodeCallback* operator() (const NodeCallback* nodecallback) const; 80 virtual StateAttributeCallback* operator() (const StateAttributeCallback* stateattributecallback) const; 78 81 79 82 protected: -
OpenSceneGraph/trunk/include/osg/ImageSequence
r8990 r10671 106 106 virtual void update(NodeVisitor* nv); 107 107 108 struct OSG_EXPORT UpdateCallback : public osg::StateAttribute ::Callback108 struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback 109 109 { 110 110 virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv); -
OpenSceneGraph/trunk/include/osg/StateAttribute
r9599 r10671 17 17 #include <osg/Export> 18 18 #include <osg/Object> 19 #include <osg/StateAttributeCallback> 19 20 #include <osg/GL> 20 21 … … 191 192 192 193 StateAttribute(const StateAttribute& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY): 193 Object(sa,copyop) {} 194 Object(sa,copyop), 195 _updateCallback(copyop(sa._updateCallback.get())) 196 {} 194 197 195 198 … … 282 285 return true; 283 286 } 284 285 struct Callback : public virtual osg::Object 286 { 287 Callback() {} 288 289 Callback(const Callback&,const CopyOp&) {} 290 291 META_Object(osg,Callback); 292 293 /** do customized update code.*/ 294 virtual void operator () (StateAttribute*, NodeVisitor*) {} 295 }; 287 288 // provide callback for backwards compatibility. 289 typedef osg::StateAttributeCallback Callback; 296 290 297 291 /** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal.*/ 298 void setUpdateCallback( Callback* uc);292 void setUpdateCallback(StateAttributeCallback* uc); 299 293 300 294 /** Get the non const UpdateCallback.*/ 301 Callback* getUpdateCallback() { return _updateCallback.get(); }295 StateAttributeCallback* getUpdateCallback() { return _updateCallback.get(); } 302 296 303 297 /** Get the const UpdateCallback.*/ 304 const Callback* getUpdateCallback() const { return _updateCallback.get(); }298 const StateAttributeCallback* getUpdateCallback() const { return _updateCallback.get(); } 305 299 306 300 307 301 /** Set the EventCallback which allows users to attach customize the updating of an object during the Event traversal.*/ 308 void setEventCallback( Callback* ec);302 void setEventCallback(StateAttributeCallback* ec); 309 303 310 304 /** Get the non const EventCallback.*/ 311 Callback* getEventCallback() { return _eventCallback.get(); }305 StateAttributeCallback* getEventCallback() { return _eventCallback.get(); } 312 306 313 307 /** Get the const EventCallback.*/ 314 const Callback* getEventCallback() const { return _eventCallback.get(); }308 const StateAttributeCallback* getEventCallback() const { return _eventCallback.get(); } 315 309 316 310 … … 344 338 friend class osg::StateSet; 345 339 346 ref_ptr< Callback> _updateCallback;347 ref_ptr< Callback> _eventCallback;340 ref_ptr<StateAttributeCallback> _updateCallback; 341 ref_ptr<StateAttributeCallback> _eventCallback; 348 342 }; 349 343 -
OpenSceneGraph/trunk/include/osgAnimation/UpdateCallback
r10593 r10671 37 37 virtual void updateLink() = 0; 38 38 virtual const std::string& getName() const = 0; 39 40 virtual ~AnimationUpdateCallbackBase() {}41 39 }; 42 40 … … 131 129 132 130 133 class OSGANIMATION_EXPORT UpdateMaterial : public AnimationUpdateCallback<osg::StateAttribute ::Callback>131 class OSGANIMATION_EXPORT UpdateMaterial : public AnimationUpdateCallback<osg::StateAttributeCallback> 134 132 { 135 133 protected: … … 148 146 bool needLink() const; 149 147 bool link(osgAnimation::Channel* channel); 148 osgAnimation::Vec4Target* getDiffuse(); 150 149 }; 151 150 -
OpenSceneGraph/trunk/src/osg/CMakeLists.txt
r10650 r10671 141 141 ${HEADER_PATH}/State 142 142 ${HEADER_PATH}/StateAttribute 143 ${HEADER_PATH}/StateAttributeCallback 143 144 ${HEADER_PATH}/StateSet 144 145 ${HEADER_PATH}/Stats -
OpenSceneGraph/trunk/src/osg/CopyOp.cpp
r10362 r10671 19 19 #include <osg/PrimitiveSet> 20 20 #include <osg/Shape> 21 #include <osg/StateAttribute> 21 22 22 23 using namespace osg; … … 68 69 NodeCallback* CopyOp::operator() (const NodeCallback* nc) const 69 70 { 70 if (nc && _flags&DEEP_COPY_ NODECALLBACKS)71 if (nc && _flags&DEEP_COPY_CALLBACKS) 71 72 { 72 73 // deep copy the full chain of callback … … 86 87 return const_cast<NodeCallback*>(nc); 87 88 } 89 90 91 StateAttributeCallback* CopyOp::operator() (const StateAttributeCallback* sc) const 92 { 93 if (sc && _flags&DEEP_COPY_CALLBACKS) 94 { 95 // deep copy the full chain of callback 96 StateAttributeCallback* cb = dynamic_cast<StateAttributeCallback*>(sc->clone(*this)); 97 return cb; 98 } 99 else 100 return const_cast<StateAttributeCallback*>(sc); 101 } 102 -
OpenSceneGraph/trunk/src/osg/StateAttribute.cpp
r9354 r10671 43 43 44 44 45 void StateAttribute::setUpdateCallback( Callback* uc)45 void StateAttribute::setUpdateCallback(StateAttributeCallback* uc) 46 46 { 47 47 osg::notify(osg::INFO)<<"StateAttribute::Setting Update callbacks"<<std::endl; … … 70 70 } 71 71 72 void StateAttribute::setEventCallback( Callback* ec)72 void StateAttribute::setEventCallback(StateAttributeCallback* ec) 73 73 { 74 74 osg::notify(osg::INFO)<<"StateAttribute::Setting Event callbacks"<<std::endl; -
OpenSceneGraph/trunk/src/osg/StateSet.cpp
r9989 r10671 1674 1674 ++itr) 1675 1675 { 1676 StateAttribute ::Callback* callback = itr->second.first->getUpdateCallback();1676 StateAttributeCallback* callback = itr->second.first->getUpdateCallback(); 1677 1677 if (callback) (*callback)(itr->second.first.get(),nv); 1678 1678 } … … 1687 1687 ++itr) 1688 1688 { 1689 StateAttribute ::Callback* callback = itr->second.first->getUpdateCallback();1689 StateAttributeCallback* callback = itr->second.first->getUpdateCallback(); 1690 1690 if (callback) (*callback)(itr->second.first.get(),nv); 1691 1691 } … … 1748 1748 ++itr) 1749 1749 { 1750 StateAttribute ::Callback* callback = itr->second.first->getEventCallback();1750 StateAttributeCallback* callback = itr->second.first->getEventCallback(); 1751 1751 if (callback) (*callback)(itr->second.first.get(),nv); 1752 1752 } … … 1761 1761 ++itr) 1762 1762 { 1763 StateAttribute ::Callback* callback = itr->second.first->getEventCallback();1763 StateAttributeCallback* callback = itr->second.first->getEventCallback(); 1764 1764 if (callback) (*callback)(itr->second.first.get(),nv); 1765 1765 } -
OpenSceneGraph/trunk/src/osgAnimation/UpdateCallback.cpp
r10561 r10671 123 123 UpdateMaterial::UpdateMaterial(const UpdateMaterial& apc,const osg::CopyOp& copyop) 124 124 : osg::Object(apc, copyop), 125 AnimationUpdateCallback<osg::StateAttribute ::Callback>(apc, copyop)125 AnimationUpdateCallback<osg::StateAttributeCallback>(apc, copyop) 126 126 { 127 127 _diffuse = new osgAnimation::Vec4Target(apc._diffuse->getValue()); … … 129 129 130 130 UpdateMaterial::UpdateMaterial(const std::string& name): 131 AnimationUpdateCallback<osg::StateAttribute ::Callback>(name)131 AnimationUpdateCallback<osg::StateAttributeCallback>(name) 132 132 { 133 133 _diffuse = new osgAnimation::Vec4Target(osg::Vec4(1,0,1,1)); … … 145 145 } 146 146 147 148 osgAnimation::Vec4Target* UpdateMaterial::getDiffuse() { return _diffuse.get(); } 147 149 void UpdateMaterial::update(osg::Material& material) 148 150 { -
OpenSceneGraph/trunk/src/osgPlugins/osg/StateAttribute.cpp
r9389 r10671 30 30 StateAttribute& stateAttribute = static_cast<StateAttribute&>(obj); 31 31 32 static ref_ptr<StateAttribute ::Callback> s_callback = new osg::StateAttribute::Callback;32 static ref_ptr<StateAttributeCallback> s_callback = new osg::StateAttributeCallback; 33 33 while (fr.matchSequence("UpdateCallback {")) 34 34 { 35 35 //int entry = fr[0].getNoNestedBrackets(); 36 36 fr += 2; 37 StateAttribute ::Callback* callback = dynamic_cast<StateAttribute::Callback*>(fr.readObjectOfType(*s_callback));37 StateAttributeCallback* callback = dynamic_cast<StateAttributeCallback*>(fr.readObjectOfType(*s_callback)); 38 38 if (callback) { 39 39 stateAttribute.setUpdateCallback(callback); … … 46 46 //int entry = fr[0].getNoNestedBrackets(); 47 47 fr += 2; 48 StateAttribute ::Callback* callback = dynamic_cast<StateAttribute::Callback*>(fr.readObjectOfType(*s_callback));48 StateAttributeCallback* callback = dynamic_cast<StateAttributeCallback*>(fr.readObjectOfType(*s_callback)); 49 49 if (callback) { 50 50 stateAttribute.setEventCallback(callback);
