Renamed all instance of AppCallback/AppVisitor to UpdateCallback/UpdateVisitor

inline with the decision to rename the "app phase" the "update phase".
This commit is contained in:
Robert Osfield
2002-12-19 15:55:40 +00:00
parent eb42926ab1
commit adf5c91808
44 changed files with 239 additions and 205 deletions

View File

@@ -172,21 +172,36 @@ class SG_EXPORT Drawable : public Object
void compile(State& state);
struct AppCallback : public virtual osg::Referenced
struct UpdateCallback : public virtual osg::Referenced
{
/** do customized app code.*/
virtual void update(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
};
/** Set the UpdateCallback which allows users to attach customize the undating of an object during the app traversal.*/
void setUpdateCallback(UpdateCallback* ac);
/** Get the non const UpdateCallback.*/
UpdateCallback* getUpdateCallback() { return _updateCallback.get(); }
#ifdef USE_DEPRECATED_API
struct AppCallback : public UpdateCallback
{
/** do customized app code.*/
virtual void app(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
virtual void update(osg::NodeVisitor *visitor, osg::Drawable* drawable) { app(visitor,drawable); }
};
/** Set the AppCallback which allows users to attach customize the undating of an object during the app traversal.*/
void setAppCallback(AppCallback* ac);
/** deprecated.*/
void setAppCallback(AppCallback* ac) { setUpdateCallback(ac); }
/** Get the non const AppCallback.*/
AppCallback* getAppCallback() { return _appCallback.get(); }
/** deprecated.*/
AppCallback* getAppCallback() { return getUpdateCallback(); }
/** Get the const AppCallback.*/
const AppCallback* getAppCallback() const { return _appCallback.get(); }
/** deprecated.*/
const AppCallback* getAppCallback() const { return getUpdateCallback(); }
#endif
struct CullCallback : public virtual osg::Referenced
{
@@ -381,7 +396,7 @@ class SG_EXPORT Drawable : public Object
typedef osg::buffered_value<uint> GLObjectList;
mutable GLObjectList _globjList;
ref_ptr<AppCallback> _appCallback;
ref_ptr<UpdateCallback> _updateCallback;
ref_ptr<DrawCallback> _drawCallback;
ref_ptr<CullCallback> _cullCallback;

View File

@@ -127,18 +127,29 @@ class SG_EXPORT Node : public Object
inline unsigned int getNumParents() const { return _parents.size(); }
/** Set app node callback, called during app traversal. */
void setAppCallback(NodeCallback* nc);
/** Set update node callback, called during update traversal. */
void setUpdateCallback(NodeCallback* nc);
/** Get app node callback, called during app traversal. */
inline NodeCallback* getAppCallback() { return _appCallback.get(); }
/** Get update node callback, called during update traversal. */
inline NodeCallback* getUpdateCallback() { return _updateCallback.get(); }
/** Get const app node callback, called during app traversal. */
inline const NodeCallback* getAppCallback() const { return _appCallback.get(); }
/** Get const update node callback, called during update traversal. */
inline const NodeCallback* getUpdateCallback() const { return _updateCallback.get(); }
#ifdef USE_DEPRECATED_API
/** deprecated. */
void setAppCallback(NodeCallback* nc) { setUpdateCallback(nc); }
/** deprecated. */
inline NodeCallback* getAppCallback() { return getUpdateCallback(); }
/** deprecated. */
inline const NodeCallback* getAppCallback() const { return getUpdateCallback(); }
#endif
/** Get the number of Children of this node which require App traversal,
* since they have an AppCallback attached to them or their children.*/
inline unsigned int getNumChildrenRequiringAppTraversal() const { return _numChildrenRequiringAppTraversal; }
inline unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; }
/** Set cull node callback, called during cull traversal. */
@@ -256,9 +267,9 @@ class SG_EXPORT Node : public Object
friend class osg::Group;
friend class osg::Drawable;
ref_ptr<NodeCallback> _appCallback;
unsigned int _numChildrenRequiringAppTraversal;
void setNumChildrenRequiringAppTraversal(unsigned int num);
ref_ptr<NodeCallback> _updateCallback;
unsigned int _numChildrenRequiringUpdateTraversal;
void setNumChildrenRequiringUpdateTraversal(unsigned int num);
ref_ptr<NodeCallback> _cullCallback;

View File

@@ -58,7 +58,7 @@ class SG_EXPORT NodeVisitor : public Referenced
enum VisitorType
{
NODE_VISITOR = 0,
APP_VISITOR,
UPDATE_VISITOR,
COLLECT_OCCLUDER_VISITOR,
CULL_VISITOR
};

View File

@@ -60,7 +60,7 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
virtual bool run();
// called on each frame redraw..return the time in ms for each operation.
virtual float app(unsigned int viewport);
virtual float update(unsigned int viewport);
virtual float cull(unsigned int viewport);
virtual float draw(unsigned int viewport);
@@ -163,10 +163,10 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
struct StatsRecord
{ // gwm Jul 2001, added for display of statistics
StatsRecord():
timeApp(0), timeCull(0), timeDraw(0), timeFrame(0),
timeUpdate(0), timeCull(0), timeDraw(0), timeFrame(0),
frameend(0) {}
float timeApp, timeCull, timeDraw, timeFrame;
float timeUpdate, timeCull, timeDraw, timeFrame;
osg::Timer_t frameend;
};
StatsRecord times[3]; // store up to 3 frames worth of times

View File

@@ -140,9 +140,9 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
void setAppVisitor(osg::NodeVisitor* av) { _appVisitor = av; }
osg::NodeVisitor* getAppVisitor() { return _appVisitor.get(); }
const osg::NodeVisitor* getAppVisitor() const { return _appVisitor.get(); }
void setUpdateVisitor(osg::NodeVisitor* av) { _updateVisitor = av; }
osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); }
const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
void setCullVisitor(osgUtil::CullVisitor* cv) { _cullVisitor = cv; }
osgUtil::CullVisitor* getCullVisitor() { return _cullVisitor.get(); }
@@ -261,13 +261,16 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
* The init traversal is called once for each SceneView, and should
* be used to compile display list, texture objects intialize data
* not otherwise intializaed during scene graph loading. Note, is
* called automatically by app&cull if it hasn't already been called
* called automatically by update&cull if it hasn't already been called
* elsewhere. Also init() should only ever be called within a valid
* graphics context.*/
virtual void init();
/** Do app traversal of attached scene graph using App NodeVisitor.*/
virtual void app();
virtual void update();
#ifdef USE_DEPREACTED_API
virtual void app() { update(); }
#endif
/** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
virtual void cull();
@@ -297,7 +300,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
bool _initCalled;
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
osg::ref_ptr<osg::NodeVisitor> _appVisitor;
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
osg::Node::NodeMask _cullMask;
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;

View File

@@ -2,8 +2,8 @@
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSGUTIL_APPVISITOR
#define OSGUTIL_APPVISITOR 1
#ifndef OSGUTIL_UPDATEVISITOR
#define OSGUTIL_UPDATEVISITOR 1
#include <osg/NodeVisitor>
#include <osg/Node>
@@ -22,16 +22,16 @@
namespace osgUtil {
/**
* Basic AppVisitor implementation for animating a scene.
* Basic UpdateVisitor implementation for animating a scene.
* This visitor traverses the scene graph, call each nodes appCallback if
* it exists.
*/
class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
{
public:
AppVisitor();
virtual ~AppVisitor();
UpdateVisitor();
virtual ~UpdateVisitor();
virtual void reset();
@@ -54,29 +54,29 @@ class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
protected:
/** prevent unwanted copy construction.*/
AppVisitor(const AppVisitor&):osg::NodeVisitor() {}
UpdateVisitor(const UpdateVisitor&):osg::NodeVisitor() {}
/** prevent unwanted copy operator.*/
AppVisitor& operator = (const AppVisitor&) { return *this; }
UpdateVisitor& operator = (const UpdateVisitor&) { return *this; }
inline void handle_callbacks_and_traverse(osg::Node& node)
{
osg::NodeCallback* callback = node.getAppCallback();
osg::NodeCallback* callback = node.getUpdateCallback();
if (callback) (*callback)(&node,this);
else if (node.getNumChildrenRequiringAppTraversal()>0) traverse(node);
else if (node.getNumChildrenRequiringUpdateTraversal()>0) traverse(node);
}
inline void handle_geode_callbacks(osg::Geode& node)
{
osg::NodeCallback* callback = node.getAppCallback();
osg::NodeCallback* callback = node.getUpdateCallback();
if (callback) (*callback)(&node,this);
else if (node.getNumChildrenRequiringAppTraversal()>0) traverse(node);
else if (node.getNumChildrenRequiringUpdateTraversal()>0) traverse(node);
// call the app callbacks on the drawables.
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable::AppCallback* callback = node.getDrawable(i)->getAppCallback();
if (callback) callback->app(this,node.getDrawable(i));
osg::Drawable::UpdateCallback* callback = node.getDrawable(i)->getUpdateCallback();
if (callback) callback->update(this,node.getDrawable(i));
}
}