Show
Ignore:
Timestamp:
10/22/09 12:33:16 (4 years ago)
Author:
robert
Message:

From Cedric Pinson, "Here a patch to be able to clone stateattribute, in order to do that i
moved the StateAttribute::Callback structure to a file
StateAttributeCallback? with the same behavior as NodeCallback?.
"

Files:
1 modified

Legend:

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

    r9599 r10671  
    1717#include <osg/Export> 
    1818#include <osg/Object> 
     19#include <osg/StateAttributeCallback> 
    1920#include <osg/GL> 
    2021 
     
    191192         
    192193        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            {} 
    194197         
    195198 
     
    282285            return true; 
    283286        } 
    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; 
    296290 
    297291        /** 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); 
    299293 
    300294        /** Get the non const UpdateCallback.*/ 
    301         Callback* getUpdateCallback() { return _updateCallback.get(); } 
     295        StateAttributeCallback* getUpdateCallback() { return _updateCallback.get(); } 
    302296 
    303297        /** Get the const UpdateCallback.*/ 
    304         const Callback* getUpdateCallback() const { return _updateCallback.get(); } 
     298        const StateAttributeCallback* getUpdateCallback() const { return _updateCallback.get(); } 
    305299 
    306300 
    307301        /** 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); 
    309303 
    310304        /** Get the non const EventCallback.*/ 
    311         Callback* getEventCallback() { return _eventCallback.get(); } 
     305        StateAttributeCallback* getEventCallback() { return _eventCallback.get(); } 
    312306 
    313307        /** Get the const EventCallback.*/ 
    314         const Callback* getEventCallback() const { return _eventCallback.get(); } 
     308        const StateAttributeCallback* getEventCallback() const { return _eventCallback.get(); } 
    315309 
    316310     
     
    344338        friend class osg::StateSet; 
    345339 
    346         ref_ptr<Callback>   _updateCallback; 
    347         ref_ptr<Callback>   _eventCallback; 
     340        ref_ptr<StateAttributeCallback>   _updateCallback; 
     341        ref_ptr<StateAttributeCallback>   _eventCallback; 
    348342}; 
    349343