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:
parent
eb42926ab1
commit
adf5c91808
12
NEWS
12
NEWS
@ -2,7 +2,15 @@
|
|||||||
OSG News (most significant items from ChangeLog)
|
OSG News (most significant items from ChangeLog)
|
||||||
================================================
|
================================================
|
||||||
|
|
||||||
Support added for dynamic paging of Terrage databases.
|
Support added for dynamic paging of Terrage databases, the required
|
||||||
|
multi-threading is set up by defult. All the end user application need
|
||||||
|
to do is load the database and the paging then happens automatically -
|
||||||
|
without any need for intervention by the users application.
|
||||||
|
|
||||||
|
The app phase of operations on the scene graph has been renamed
|
||||||
|
the update phase to make its function clearer. The main phases are now
|
||||||
|
named now does update, cull, draw. The AppVisitor, set/getAppCallback etc
|
||||||
|
have be renamed UpdateVisitor, set/getUpdateCallback etc.
|
||||||
|
|
||||||
Added new osgshadowtexture demo which illustrates how to create
|
Added new osgshadowtexture demo which illustrates how to create
|
||||||
dynamic shadow textures in your scene.
|
dynamic shadow textures in your scene.
|
||||||
@ -14,8 +22,6 @@ OSG News (most significant items from ChangeLog)
|
|||||||
|
|
||||||
New osglogo demo.
|
New osglogo demo.
|
||||||
|
|
||||||
New osgshadowtexture demo.
|
|
||||||
|
|
||||||
|
|
||||||
13th November 2002 - OpenSceneGraph-0.9.2.tar.gz
|
13th November 2002 - OpenSceneGraph-0.9.2.tar.gz
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ SOURCE=..\..\src\osgUtil\HighlightMapGenerator.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\src\osgUtil\AppVisitor.cpp
|
SOURCE=..\..\src\osgUtil\UpdateVisitor.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ SOURCE=..\..\include\osgUtil\ReflectionMapGenerator
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\osgUtil\AppVisitor
|
SOURCE=..\..\include\osgUtil\UpdateVisitor
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
@ -172,21 +172,36 @@ class SG_EXPORT Drawable : public Object
|
|||||||
void compile(State& state);
|
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.*/
|
/** do customized app code.*/
|
||||||
virtual void app(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
|
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.*/
|
/** deprecated.*/
|
||||||
void setAppCallback(AppCallback* ac);
|
void setAppCallback(AppCallback* ac) { setUpdateCallback(ac); }
|
||||||
|
|
||||||
/** Get the non const AppCallback.*/
|
/** deprecated.*/
|
||||||
AppCallback* getAppCallback() { return _appCallback.get(); }
|
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
|
struct CullCallback : public virtual osg::Referenced
|
||||||
{
|
{
|
||||||
@ -381,7 +396,7 @@ class SG_EXPORT Drawable : public Object
|
|||||||
typedef osg::buffered_value<uint> GLObjectList;
|
typedef osg::buffered_value<uint> GLObjectList;
|
||||||
mutable GLObjectList _globjList;
|
mutable GLObjectList _globjList;
|
||||||
|
|
||||||
ref_ptr<AppCallback> _appCallback;
|
ref_ptr<UpdateCallback> _updateCallback;
|
||||||
ref_ptr<DrawCallback> _drawCallback;
|
ref_ptr<DrawCallback> _drawCallback;
|
||||||
ref_ptr<CullCallback> _cullCallback;
|
ref_ptr<CullCallback> _cullCallback;
|
||||||
|
|
||||||
|
@ -127,18 +127,29 @@ class SG_EXPORT Node : public Object
|
|||||||
inline unsigned int getNumParents() const { return _parents.size(); }
|
inline unsigned int getNumParents() const { return _parents.size(); }
|
||||||
|
|
||||||
|
|
||||||
/** Set app node callback, called during app traversal. */
|
/** Set update node callback, called during update traversal. */
|
||||||
void setAppCallback(NodeCallback* nc);
|
void setUpdateCallback(NodeCallback* nc);
|
||||||
|
|
||||||
/** Get app node callback, called during app traversal. */
|
/** Get update node callback, called during update traversal. */
|
||||||
inline NodeCallback* getAppCallback() { return _appCallback.get(); }
|
inline NodeCallback* getUpdateCallback() { return _updateCallback.get(); }
|
||||||
|
|
||||||
/** Get const app node callback, called during app traversal. */
|
/** Get const update node callback, called during update traversal. */
|
||||||
inline const NodeCallback* getAppCallback() const { return _appCallback.get(); }
|
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,
|
/** Get the number of Children of this node which require App traversal,
|
||||||
* since they have an AppCallback attached to them or their children.*/
|
* 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. */
|
/** 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::Group;
|
||||||
friend class osg::Drawable;
|
friend class osg::Drawable;
|
||||||
|
|
||||||
ref_ptr<NodeCallback> _appCallback;
|
ref_ptr<NodeCallback> _updateCallback;
|
||||||
unsigned int _numChildrenRequiringAppTraversal;
|
unsigned int _numChildrenRequiringUpdateTraversal;
|
||||||
void setNumChildrenRequiringAppTraversal(unsigned int num);
|
void setNumChildrenRequiringUpdateTraversal(unsigned int num);
|
||||||
|
|
||||||
ref_ptr<NodeCallback> _cullCallback;
|
ref_ptr<NodeCallback> _cullCallback;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class SG_EXPORT NodeVisitor : public Referenced
|
|||||||
enum VisitorType
|
enum VisitorType
|
||||||
{
|
{
|
||||||
NODE_VISITOR = 0,
|
NODE_VISITOR = 0,
|
||||||
APP_VISITOR,
|
UPDATE_VISITOR,
|
||||||
COLLECT_OCCLUDER_VISITOR,
|
COLLECT_OCCLUDER_VISITOR,
|
||||||
CULL_VISITOR
|
CULL_VISITOR
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
|
|||||||
virtual bool run();
|
virtual bool run();
|
||||||
|
|
||||||
// called on each frame redraw..return the time in ms for each operation.
|
// 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 cull(unsigned int viewport);
|
||||||
virtual float draw(unsigned int viewport);
|
virtual float draw(unsigned int viewport);
|
||||||
|
|
||||||
@ -163,10 +163,10 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
|
|||||||
struct StatsRecord
|
struct StatsRecord
|
||||||
{ // gwm Jul 2001, added for display of statistics
|
{ // gwm Jul 2001, added for display of statistics
|
||||||
StatsRecord():
|
StatsRecord():
|
||||||
timeApp(0), timeCull(0), timeDraw(0), timeFrame(0),
|
timeUpdate(0), timeCull(0), timeDraw(0), timeFrame(0),
|
||||||
frameend(0) {}
|
frameend(0) {}
|
||||||
|
|
||||||
float timeApp, timeCull, timeDraw, timeFrame;
|
float timeUpdate, timeCull, timeDraw, timeFrame;
|
||||||
osg::Timer_t frameend;
|
osg::Timer_t frameend;
|
||||||
};
|
};
|
||||||
StatsRecord times[3]; // store up to 3 frames worth of times
|
StatsRecord times[3]; // store up to 3 frames worth of times
|
||||||
|
@ -140,9 +140,9 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
|||||||
osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
|
osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
|
||||||
const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
|
const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
|
||||||
|
|
||||||
void setAppVisitor(osg::NodeVisitor* av) { _appVisitor = av; }
|
void setUpdateVisitor(osg::NodeVisitor* av) { _updateVisitor = av; }
|
||||||
osg::NodeVisitor* getAppVisitor() { return _appVisitor.get(); }
|
osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); }
|
||||||
const osg::NodeVisitor* getAppVisitor() const { return _appVisitor.get(); }
|
const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
|
||||||
|
|
||||||
void setCullVisitor(osgUtil::CullVisitor* cv) { _cullVisitor = cv; }
|
void setCullVisitor(osgUtil::CullVisitor* cv) { _cullVisitor = cv; }
|
||||||
osgUtil::CullVisitor* getCullVisitor() { return _cullVisitor.get(); }
|
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
|
* The init traversal is called once for each SceneView, and should
|
||||||
* be used to compile display list, texture objects intialize data
|
* be used to compile display list, texture objects intialize data
|
||||||
* not otherwise intializaed during scene graph loading. Note, is
|
* 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
|
* elsewhere. Also init() should only ever be called within a valid
|
||||||
* graphics context.*/
|
* graphics context.*/
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
/** Do app traversal of attached scene graph using App NodeVisitor.*/
|
/** 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.*/
|
/** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
|
||||||
virtual void cull();
|
virtual void cull();
|
||||||
@ -297,7 +300,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
|||||||
|
|
||||||
bool _initCalled;
|
bool _initCalled;
|
||||||
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
|
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
|
||||||
osg::ref_ptr<osg::NodeVisitor> _appVisitor;
|
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
|
||||||
osg::Node::NodeMask _cullMask;
|
osg::Node::NodeMask _cullMask;
|
||||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
|
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
|
||||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||||
//as published by the Free Software Foundation.
|
//as published by the Free Software Foundation.
|
||||||
|
|
||||||
#ifndef OSGUTIL_APPVISITOR
|
#ifndef OSGUTIL_UPDATEVISITOR
|
||||||
#define OSGUTIL_APPVISITOR 1
|
#define OSGUTIL_UPDATEVISITOR 1
|
||||||
|
|
||||||
#include <osg/NodeVisitor>
|
#include <osg/NodeVisitor>
|
||||||
#include <osg/Node>
|
#include <osg/Node>
|
||||||
@ -22,16 +22,16 @@
|
|||||||
namespace osgUtil {
|
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
|
* This visitor traverses the scene graph, call each nodes appCallback if
|
||||||
* it exists.
|
* it exists.
|
||||||
*/
|
*/
|
||||||
class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
|
class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AppVisitor();
|
UpdateVisitor();
|
||||||
virtual ~AppVisitor();
|
virtual ~UpdateVisitor();
|
||||||
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
@ -54,29 +54,29 @@ class OSGUTIL_EXPORT AppVisitor : public osg::NodeVisitor
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** prevent unwanted copy construction.*/
|
/** prevent unwanted copy construction.*/
|
||||||
AppVisitor(const AppVisitor&):osg::NodeVisitor() {}
|
UpdateVisitor(const UpdateVisitor&):osg::NodeVisitor() {}
|
||||||
|
|
||||||
/** prevent unwanted copy operator.*/
|
/** 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)
|
inline void handle_callbacks_and_traverse(osg::Node& node)
|
||||||
{
|
{
|
||||||
osg::NodeCallback* callback = node.getAppCallback();
|
osg::NodeCallback* callback = node.getUpdateCallback();
|
||||||
if (callback) (*callback)(&node,this);
|
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)
|
inline void handle_geode_callbacks(osg::Geode& node)
|
||||||
{
|
{
|
||||||
osg::NodeCallback* callback = node.getAppCallback();
|
osg::NodeCallback* callback = node.getUpdateCallback();
|
||||||
if (callback) (*callback)(&node,this);
|
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.
|
// call the app callbacks on the drawables.
|
||||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||||
{
|
{
|
||||||
osg::Drawable::AppCallback* callback = node.getDrawable(i)->getAppCallback();
|
osg::Drawable::UpdateCallback* callback = node.getDrawable(i)->getUpdateCallback();
|
||||||
if (callback) callback->app(this,node.getDrawable(i));
|
if (callback) callback->update(this,node.getDrawable(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -143,7 +143,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
positioned->addChild(glider);
|
positioned->addChild(glider);
|
||||||
|
|
||||||
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
|
osg::PositionAttitudeTransform* xform = new osg::PositionAttitudeTransform;
|
||||||
xform->setAppCallback(new osg::PositionAttitudeTransform::AnimationPathCallback(animationPath,0.0,1.0));
|
xform->setUpdateCallback(new osg::PositionAttitudeTransform::AnimationPathCallback(animationPath,0.0,1.0));
|
||||||
xform->addChild(positioned);
|
xform->addChild(positioned);
|
||||||
|
|
||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
@ -164,7 +164,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
positioned->addChild(cessna);
|
positioned->addChild(cessna);
|
||||||
|
|
||||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
||||||
xform->setAppCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath,0.0f,2.0));
|
xform->setUpdateCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath,0.0f,2.0));
|
||||||
xform->addChild(positioned);
|
xform->addChild(positioned);
|
||||||
|
|
||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
|
@ -49,13 +49,13 @@ void write_usage(std::ostream& out,const std::string& name)
|
|||||||
out << std::endl;
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppCallback : public osg::NodeCallback
|
class UpdateCallback : public osg::NodeCallback
|
||||||
{
|
{
|
||||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||||
{
|
{
|
||||||
std::cout<<"app callback - pre traverse"<<node<<std::endl;
|
std::cout<<"update callback - pre traverse"<<node<<std::endl;
|
||||||
traverse(node,nv);
|
traverse(node,nv);
|
||||||
std::cout<<"app callback - post traverse"<<node<<std::endl;
|
std::cout<<"update callback - post traverse"<<node<<std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,11 +100,11 @@ struct TransformCallback : public osg::Transform::ComputeTransformCallback
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DrawableAppCallback : public osg::Drawable::AppCallback
|
struct DrawableUpdateCallback : public osg::Drawable::UpdateCallback
|
||||||
{
|
{
|
||||||
virtual void app(osg::NodeVisitor*, osg::Drawable* drawable)
|
virtual void update(osg::NodeVisitor*, osg::Drawable* drawable)
|
||||||
{
|
{
|
||||||
std::cout<<"Drawable app callback "<<drawable<<std::endl;
|
std::cout<<"Drawable update callback "<<drawable<<std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -129,14 +129,14 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
|
|||||||
|
|
||||||
virtual void apply(osg::Node& node)
|
virtual void apply(osg::Node& node)
|
||||||
{
|
{
|
||||||
node.setAppCallback(new AppCallback());
|
node.setUpdateCallback(new UpdateCallback());
|
||||||
node.setCullCallback(new CullCallback());
|
node.setCullCallback(new CullCallback());
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(osg::Geode& geode)
|
virtual void apply(osg::Geode& geode)
|
||||||
{
|
{
|
||||||
geode.setAppCallback(new AppCallback());
|
geode.setUpdateCallback(new UpdateCallback());
|
||||||
|
|
||||||
//note, it makes no sense to attach a cull callback to the node
|
//note, it makes no sense to attach a cull callback to the node
|
||||||
//at there are no nodes to traverse below the geode, only
|
//at there are no nodes to traverse below the geode, only
|
||||||
@ -146,7 +146,7 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
|
|||||||
|
|
||||||
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
||||||
{
|
{
|
||||||
geode.getDrawable(i)->setAppCallback(new DrawableAppCallback());
|
geode.getDrawable(i)->setUpdateCallback(new DrawableUpdateCallback());
|
||||||
geode.getDrawable(i)->setCullCallback(new DrawableCullCallback());
|
geode.getDrawable(i)->setCullCallback(new DrawableCullCallback());
|
||||||
geode.getDrawable(i)->setDrawCallback(new DrawableDrawCallback());
|
geode.getDrawable(i)->setDrawCallback(new DrawableDrawCallback());
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
|
|||||||
osg::MatrixTransform* transform= new osg::MatrixTransform;
|
osg::MatrixTransform* transform= new osg::MatrixTransform;
|
||||||
|
|
||||||
osg::NodeCallback* nc = new osgUtil::TransformCallback(subgraph->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
osg::NodeCallback* nc = new osgUtil::TransformCallback(subgraph->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||||
transform->setAppCallback(nc);
|
transform->setUpdateCallback(nc);
|
||||||
|
|
||||||
osg::ClipNode* clipnode = new osg::ClipNode;
|
osg::ClipNode* clipnode = new osg::ClipNode;
|
||||||
osg::BoundingSphere bs = subgraph->getBound();
|
osg::BoundingSphere bs = subgraph->getBound();
|
||||||
|
@ -166,9 +166,9 @@ class MySceneView : public SceneView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// override the basic SceneView::app traversal.
|
// override the basic SceneView::app traversal.
|
||||||
virtual void app()
|
virtual void update()
|
||||||
{
|
{
|
||||||
SceneView::app();
|
SceneView::update();
|
||||||
switch (_viewerMode)
|
switch (_viewerMode)
|
||||||
{
|
{
|
||||||
case(MASTER):
|
case(MASTER):
|
||||||
|
@ -181,7 +181,7 @@ int main( int argc, char **argv )
|
|||||||
myTransform->addChild( createGeometryCube() );
|
myTransform->addChild( createGeometryCube() );
|
||||||
|
|
||||||
// move node in a circle at 90 degrees a sec.
|
// move node in a circle at 90 degrees a sec.
|
||||||
myTransform->setAppCallback(new MyTransformCallback(myTransform,osg::inDegrees(90.0f)));
|
myTransform->setUpdateCallback(new MyTransformCallback(myTransform,osg::inDegrees(90.0f)));
|
||||||
|
|
||||||
// add model to viewer.
|
// add model to viewer.
|
||||||
viewer.addViewport( myTransform );
|
viewer.addViewport( myTransform );
|
||||||
|
@ -632,7 +632,7 @@ osg::Node* createBackground()
|
|||||||
// create a tranform to move the background back and forward with.
|
// create a tranform to move the background back and forward with.
|
||||||
|
|
||||||
osg::MatrixTransform* transform = new osg::MatrixTransform();
|
osg::MatrixTransform* transform = new osg::MatrixTransform();
|
||||||
transform->setAppCallback(new MyTransformCallback(1.0f));
|
transform->setUpdateCallback(new MyTransformCallback(1.0f));
|
||||||
transform->addChild(geode);
|
transform->addChild(geode);
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
|
@ -124,7 +124,7 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
|||||||
animationPath->insert(8.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
|
animationPath->insert(8.0,osg::AnimationPath::ControlPoint(bb.corner(0)));
|
||||||
animationPath->setLoopMode(osg::AnimationPath::SWING);
|
animationPath->setLoopMode(osg::AnimationPath::SWING);
|
||||||
|
|
||||||
mt->setAppCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath));
|
mt->setUpdateCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create marker for point light.
|
// create marker for point light.
|
||||||
@ -225,7 +225,7 @@ osg::Node* createRoom(osg::Node* loadedModel)
|
|||||||
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
|
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform();
|
||||||
pat->setPivotPoint(loaded_bs.center());
|
pat->setPivotPoint(loaded_bs.center());
|
||||||
|
|
||||||
pat->setAppCallback(new ModelTransformCallback(loaded_bs));
|
pat->setUpdateCallback(new ModelTransformCallback(loaded_bs));
|
||||||
pat->addChild(loadedModel);
|
pat->addChild(loadedModel);
|
||||||
|
|
||||||
bs = pat->getBound();
|
bs = pat->getBound();
|
||||||
|
@ -145,7 +145,7 @@ osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio)
|
|||||||
|
|
||||||
|
|
||||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
||||||
xform->setAppCallback(new osgUtil::TransformCallback(bb.center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(30.0f)));
|
xform->setUpdateCallback(new osgUtil::TransformCallback(bb.center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(30.0f)));
|
||||||
xform->addChild(geode);
|
xform->addChild(geode);
|
||||||
|
|
||||||
return xform;
|
return xform;
|
||||||
|
@ -32,11 +32,11 @@
|
|||||||
PBuffer* g_pPixelBuffer;
|
PBuffer* g_pPixelBuffer;
|
||||||
|
|
||||||
|
|
||||||
class MyAppCallback : public osg::NodeCallback
|
class MyUpdateCallback : public osg::NodeCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MyAppCallback(osg::Node* subgraph):
|
MyUpdateCallback(osg::Node* subgraph):
|
||||||
_subgraph(subgraph) {}
|
_subgraph(subgraph) {}
|
||||||
|
|
||||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||||
@ -196,7 +196,7 @@ new_viewport->setViewport(0,0,width,height);
|
|||||||
|
|
||||||
// call back which cretes a deformation field to oscilate the model.
|
// call back which cretes a deformation field to oscilate the model.
|
||||||
class MyGeometryCallback :
|
class MyGeometryCallback :
|
||||||
public osg::Drawable::AppCallback,
|
public osg::Drawable::UpdateCallback,
|
||||||
public osg::Drawable::AttributeFunctor
|
public osg::Drawable::AttributeFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -539,14 +539,14 @@ texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP);
|
|||||||
|
|
||||||
polyGeom->setStateSet(stateset);
|
polyGeom->setStateSet(stateset);
|
||||||
|
|
||||||
polyGeom->setAppCallback(new MyGeometryCallback(origin,xAxis,yAxis,zAxis,1.0,1.0/width,0.2f));
|
polyGeom->setUpdateCallback(new MyGeometryCallback(origin,xAxis,yAxis,zAxis,1.0,1.0/width,0.2f));
|
||||||
|
|
||||||
osg::Geode* geode = new osg::Geode();
|
osg::Geode* geode = new osg::Geode();
|
||||||
geode->addDrawable(polyGeom);
|
geode->addDrawable(polyGeom);
|
||||||
|
|
||||||
osg::Group* parent = new osg::Group;
|
osg::Group* parent = new osg::Group;
|
||||||
|
|
||||||
parent->setAppCallback(new MyAppCallback(subgraph));
|
parent->setUpdateCallback(new MyUpdateCallback(subgraph));
|
||||||
|
|
||||||
parent->setCullCallback(new MyCullCallback(subgraph,texture));
|
parent->setCullCallback(new MyCullCallback(subgraph,texture));
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ int main( int argc, char **argv )
|
|||||||
loadedModelTransform->addChild(loadedModel);
|
loadedModelTransform->addChild(loadedModel);
|
||||||
|
|
||||||
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||||
loadedModelTransform->setAppCallback(nc);
|
loadedModelTransform->setUpdateCallback(nc);
|
||||||
|
|
||||||
osg::Group* rootNode = new osg::Group();
|
osg::Group* rootNode = new osg::Group();
|
||||||
// rootNode->addChild(loadedModelTransform);
|
// rootNode->addChild(loadedModelTransform);
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
#include <osgGLUT/glut>
|
#include <osgGLUT/glut>
|
||||||
#include <osgGLUT/Viewer>
|
#include <osgGLUT/Viewer>
|
||||||
|
|
||||||
class MyAppCallback : public osg::NodeCallback
|
class MyUpdateCallback : public osg::NodeCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MyAppCallback(osg::Node* subgraph):
|
MyUpdateCallback(osg::Node* subgraph):
|
||||||
_subgraph(subgraph) {}
|
_subgraph(subgraph) {}
|
||||||
|
|
||||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||||
@ -199,10 +199,9 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// call back which cretes a deformation field to oscilate the model.
|
// call back which cretes a deformation field to oscilate the model.
|
||||||
class MyGeometryCallback :
|
class MyGeometryCallback :
|
||||||
public osg::Drawable::AppCallback,
|
public osg::Drawable::UpdateCallback,
|
||||||
public osg::Drawable::AttributeFunctor
|
public osg::Drawable::AttributeFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -221,7 +220,7 @@ class MyGeometryCallback :
|
|||||||
_yAxis(y),
|
_yAxis(y),
|
||||||
_zAxis(z) {}
|
_zAxis(z) {}
|
||||||
|
|
||||||
virtual void app(osg::NodeVisitor* nv,osg::Drawable* drawable)
|
virtual void update(osg::NodeVisitor* nv,osg::Drawable* drawable)
|
||||||
{
|
{
|
||||||
const osg::FrameStamp* fs = nv->getFrameStamp();
|
const osg::FrameStamp* fs = nv->getFrameStamp();
|
||||||
double referenceTime = fs->getReferenceTime();
|
double referenceTime = fs->getReferenceTime();
|
||||||
@ -538,14 +537,14 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph)
|
|||||||
|
|
||||||
polyGeom->setStateSet(stateset);
|
polyGeom->setStateSet(stateset);
|
||||||
|
|
||||||
polyGeom->setAppCallback(new MyGeometryCallback(origin,xAxis,yAxis,zAxis,1.0,1.0/width,0.2f));
|
polyGeom->setUpdateCallback(new MyGeometryCallback(origin,xAxis,yAxis,zAxis,1.0,1.0/width,0.2f));
|
||||||
|
|
||||||
osg::Geode* geode = new osg::Geode();
|
osg::Geode* geode = new osg::Geode();
|
||||||
geode->addDrawable(polyGeom);
|
geode->addDrawable(polyGeom);
|
||||||
|
|
||||||
osg::Group* parent = new osg::Group;
|
osg::Group* parent = new osg::Group;
|
||||||
|
|
||||||
parent->setAppCallback(new MyAppCallback(subgraph));
|
parent->setUpdateCallback(new MyUpdateCallback(subgraph));
|
||||||
|
|
||||||
parent->setCullCallback(new MyCullCallback(subgraph,image));
|
parent->setCullCallback(new MyCullCallback(subgraph,image));
|
||||||
|
|
||||||
@ -629,7 +628,7 @@ int main( int argc, char **argv )
|
|||||||
loadedModelTransform->addChild(loadedModel);
|
loadedModelTransform->addChild(loadedModel);
|
||||||
|
|
||||||
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||||
loadedModelTransform->setAppCallback(nc);
|
loadedModelTransform->setUpdateCallback(nc);
|
||||||
|
|
||||||
osg::Group* rootNode = new osg::Group();
|
osg::Group* rootNode = new osg::Group();
|
||||||
// rootNode->addChild(loadedModelTransform);
|
// rootNode->addChild(loadedModelTransform);
|
||||||
|
@ -368,7 +368,7 @@ int main( int argc, char **argv )
|
|||||||
viewer.addViewport( rootNode );
|
viewer.addViewport( rootNode );
|
||||||
|
|
||||||
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
osg::NodeCallback* nc = new osgUtil::TransformCallback(loadedModelTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
|
||||||
loadedModelTransform->setAppCallback(nc);
|
loadedModelTransform->setUpdateCallback(nc);
|
||||||
|
|
||||||
// register trackball, flight and drive.
|
// register trackball, flight and drive.
|
||||||
viewer.registerCameraManipulator(new osgGA::TrackballManipulator);
|
viewer.registerCameraManipulator(new osgGA::TrackballManipulator);
|
||||||
|
@ -138,7 +138,7 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
|
|||||||
positioned->addChild(cessna);
|
positioned->addChild(cessna);
|
||||||
|
|
||||||
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
osg::MatrixTransform* xform = new osg::MatrixTransform;
|
||||||
xform->setAppCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath,0.0f,2.0));
|
xform->setUpdateCallback(new osg::MatrixTransform::AnimationPathCallback(animationPath,0.0f,2.0));
|
||||||
xform->addChild(positioned);
|
xform->addChild(positioned);
|
||||||
|
|
||||||
model->addChild(xform);
|
model->addChild(xform);
|
||||||
|
@ -381,13 +381,13 @@ class TextViewer: public osgGLUT::Viewer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual float app(unsigned int viewport)
|
virtual float update(unsigned int viewport)
|
||||||
{
|
{
|
||||||
float ret;
|
float ret;
|
||||||
ret=Viewer::app(viewport);
|
ret=Viewer::update(viewport);
|
||||||
if(_hudSceneView.valid() && viewport>=_viewportList.size()-1)
|
if(_hudSceneView.valid() && viewport>=_viewportList.size()-1)
|
||||||
{
|
{
|
||||||
_hudSceneView->app();
|
_hudSceneView->update();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
loadedModel->setStateSet(stateset);
|
loadedModel->setStateSet(stateset);
|
||||||
loadedModel->setAppCallback(new AnimateStateCallback());
|
loadedModel->setUpdateCallback(new AnimateStateCallback());
|
||||||
|
|
||||||
// add model to viewer.
|
// add model to viewer.
|
||||||
viewer.addViewport( loadedModel );
|
viewer.addViewport( loadedModel );
|
||||||
|
@ -195,7 +195,7 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom
|
|||||||
|
|
||||||
local_offset += local_delta;
|
local_offset += local_delta;
|
||||||
|
|
||||||
// top_transform->setAppCallback(new TextureCallback(texture));
|
// top_transform->setUpdateCallback(new TextureCallback(texture));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ osg::Node* createModel()
|
|||||||
// A bit hacky, and my plan is to reimplement the osg::scaleImage and
|
// A bit hacky, and my plan is to reimplement the osg::scaleImage and
|
||||||
// osg::Image::copySubImage() without using GLU which will get round
|
// osg::Image::copySubImage() without using GLU which will get round
|
||||||
// this current limitation.
|
// this current limitation.
|
||||||
geode->setAppCallback(new ConstructStateCallback());
|
geode->setUpdateCallback(new ConstructStateCallback());
|
||||||
|
|
||||||
return geode;
|
return geode;
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ DOFTransform::DOFTransform():
|
|||||||
_animationOn(true),
|
_animationOn(true),
|
||||||
_increasingFlags(0xffff)
|
_increasingFlags(0xffff)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(1);
|
setNumChildrenRequiringUpdateTraversal(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOFTransform::traverse(NodeVisitor& nv)
|
void DOFTransform::traverse(NodeVisitor& nv)
|
||||||
{
|
{
|
||||||
if (nv.getVisitorType()==NodeVisitor::APP_VISITOR)
|
if (nv.getVisitorType()==NodeVisitor::UPDATE_VISITOR)
|
||||||
{
|
{
|
||||||
animate();
|
animate();
|
||||||
}
|
}
|
||||||
|
@ -214,15 +214,15 @@ void Drawable::flushDeletedDisplayLists(uint contextID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Drawable::setAppCallback(AppCallback* ac)
|
void Drawable::setUpdateCallback(UpdateCallback* ac)
|
||||||
{
|
{
|
||||||
if (_appCallback==ac) return;
|
if (_updateCallback==ac) return;
|
||||||
|
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
if (_appCallback.valid()) --delta;
|
if (_updateCallback.valid()) --delta;
|
||||||
if (ac) ++delta;
|
if (ac) ++delta;
|
||||||
|
|
||||||
_appCallback = ac;
|
_updateCallback = ac;
|
||||||
|
|
||||||
if (delta!=0)
|
if (delta!=0)
|
||||||
{
|
{
|
||||||
@ -230,7 +230,7 @@ void Drawable::setAppCallback(AppCallback* ac)
|
|||||||
itr!=_parents.end();
|
itr!=_parents.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
(*itr)->setNumChildrenRequiringAppTraversal((*itr)->getNumChildrenRequiringAppTraversal()+delta);
|
(*itr)->setNumChildrenRequiringUpdateTraversal((*itr)->getNumChildrenRequiringUpdateTraversal()+delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ bool Geode::addDrawable( Drawable *drawable )
|
|||||||
// register as parent of drawable.
|
// register as parent of drawable.
|
||||||
drawable->addParent(this);
|
drawable->addParent(this);
|
||||||
|
|
||||||
if (drawable->getAppCallback())
|
if (drawable->getUpdateCallback())
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+1);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyBound();
|
dirtyBound();
|
||||||
@ -75,20 +75,20 @@ bool Geode::removeDrawable(unsigned int pos,unsigned int numDrawablesToRemove)
|
|||||||
endOfRemoveRange=_drawables.size();
|
endOfRemoveRange=_drawables.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int appCallbackRemoved = 0;
|
unsigned int updateCallbackRemoved = 0;
|
||||||
for(unsigned i=pos;i<endOfRemoveRange;++i)
|
for(unsigned i=pos;i<endOfRemoveRange;++i)
|
||||||
{
|
{
|
||||||
// remove this Geode from the child parent list.
|
// remove this Geode from the child parent list.
|
||||||
_drawables[i]->removeParent(this);
|
_drawables[i]->removeParent(this);
|
||||||
// update the number of app calbacks removed
|
// update the number of app calbacks removed
|
||||||
if (_drawables[i]->getAppCallback()) ++appCallbackRemoved;
|
if (_drawables[i]->getUpdateCallback()) ++updateCallbackRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
_drawables.erase(_drawables.begin()+pos,_drawables.begin()+endOfRemoveRange);
|
_drawables.erase(_drawables.begin()+pos,_drawables.begin()+endOfRemoveRange);
|
||||||
|
|
||||||
if (appCallbackRemoved)
|
if (updateCallbackRemoved)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()-appCallbackRemoved);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()-updateCallbackRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyBound();
|
dirtyBound();
|
||||||
@ -118,11 +118,11 @@ bool Geode::setDrawable( unsigned int i, Drawable* newDrawable )
|
|||||||
Drawable* origDrawable = _drawables[i].get();
|
Drawable* origDrawable = _drawables[i].get();
|
||||||
|
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
if (origDrawable->getAppCallback()) --delta;
|
if (origDrawable->getUpdateCallback()) --delta;
|
||||||
if (newDrawable->getAppCallback()) ++delta;
|
if (newDrawable->getUpdateCallback()) ++delta;
|
||||||
if (delta!=0)
|
if (delta!=0)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+delta);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove from origDrawable's parent list.
|
// remove from origDrawable's parent list.
|
||||||
|
@ -65,11 +65,11 @@ bool Group::addChild( Node *child )
|
|||||||
|
|
||||||
// could now require app traversal thanks to the new subgraph,
|
// could now require app traversal thanks to the new subgraph,
|
||||||
// so need to check and update if required.
|
// so need to check and update if required.
|
||||||
if (child->getNumChildrenRequiringAppTraversal()>0 ||
|
if (child->getNumChildrenRequiringUpdateTraversal()>0 ||
|
||||||
child->getAppCallback())
|
child->getUpdateCallback())
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(
|
setNumChildrenRequiringUpdateTraversal(
|
||||||
getNumChildrenRequiringAppTraversal()+1
|
getNumChildrenRequiringUpdateTraversal()+1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ bool Group::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
|
|||||||
// remove this Geode from the child parent list.
|
// remove this Geode from the child parent list.
|
||||||
child->removeParent(this);
|
child->removeParent(this);
|
||||||
|
|
||||||
if (child->getNumChildrenRequiringAppTraversal()>0 || child->getAppCallback()) ++appCallbackRemoved;
|
if (child->getNumChildrenRequiringUpdateTraversal()>0 || child->getUpdateCallback()) ++appCallbackRemoved;
|
||||||
|
|
||||||
if (child->getNumChildrenWithCullingDisabled()>0 || !child->getCullingActive()) ++numChildrenWithCullingDisabledRemoved;
|
if (child->getNumChildrenWithCullingDisabled()>0 || !child->getCullingActive()) ++numChildrenWithCullingDisabledRemoved;
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ bool Group::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
|
|||||||
|
|
||||||
if (appCallbackRemoved)
|
if (appCallbackRemoved)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()-appCallbackRemoved);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()-appCallbackRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numChildrenWithCullingDisabledRemoved)
|
if (numChildrenWithCullingDisabledRemoved)
|
||||||
@ -192,21 +192,21 @@ bool Group::setChild( unsigned int i, Node* newNode )
|
|||||||
// could now require app traversal thanks to the new subgraph,
|
// could now require app traversal thanks to the new subgraph,
|
||||||
// so need to check and update if required.
|
// so need to check and update if required.
|
||||||
int delta_numChildrenRequiringAppTraversal = 0;
|
int delta_numChildrenRequiringAppTraversal = 0;
|
||||||
if (origNode->getNumChildrenRequiringAppTraversal()>0 ||
|
if (origNode->getNumChildrenRequiringUpdateTraversal()>0 ||
|
||||||
origNode->getAppCallback())
|
origNode->getUpdateCallback())
|
||||||
{
|
{
|
||||||
--delta_numChildrenRequiringAppTraversal;
|
--delta_numChildrenRequiringAppTraversal;
|
||||||
}
|
}
|
||||||
if (newNode->getNumChildrenRequiringAppTraversal()>0 ||
|
if (newNode->getNumChildrenRequiringUpdateTraversal()>0 ||
|
||||||
newNode->getAppCallback())
|
newNode->getUpdateCallback())
|
||||||
{
|
{
|
||||||
++delta_numChildrenRequiringAppTraversal;
|
++delta_numChildrenRequiringAppTraversal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta_numChildrenRequiringAppTraversal!=0)
|
if (delta_numChildrenRequiringAppTraversal!=0)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(
|
setNumChildrenRequiringUpdateTraversal(
|
||||||
getNumChildrenRequiringAppTraversal()+delta_numChildrenRequiringAppTraversal
|
getNumChildrenRequiringUpdateTraversal()+delta_numChildrenRequiringAppTraversal
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ MatrixTransform::MatrixTransform(const MatrixTransform& transform,const CopyOp&
|
|||||||
_inverseDirty(transform._inverseDirty),
|
_inverseDirty(transform._inverseDirty),
|
||||||
_animationPath(dynamic_cast<AnimationPath*>(copyop(transform._animationPath.get())))
|
_animationPath(dynamic_cast<AnimationPath*>(copyop(transform._animationPath.get())))
|
||||||
{
|
{
|
||||||
if (_animationPath.valid()) setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+1);
|
if (_animationPath.valid()) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixTransform::MatrixTransform(const Matrix& mat )
|
MatrixTransform::MatrixTransform(const Matrix& mat )
|
||||||
@ -38,7 +38,7 @@ void MatrixTransform::traverse(NodeVisitor& nv)
|
|||||||
{
|
{
|
||||||
// if app traversal update the frame count.
|
// if app traversal update the frame count.
|
||||||
if (_animationPath.valid() &&
|
if (_animationPath.valid() &&
|
||||||
nv.getVisitorType()==NodeVisitor::APP_VISITOR &&
|
nv.getVisitorType()==NodeVisitor::UPDATE_VISITOR &&
|
||||||
nv.getFrameStamp())
|
nv.getFrameStamp())
|
||||||
{
|
{
|
||||||
double time = nv.getFrameStamp()->getReferenceTime();
|
double time = nv.getFrameStamp()->getReferenceTime();
|
||||||
@ -54,7 +54,7 @@ void MatrixTransform::AnimationPathCallback::operator()(Node* node, NodeVisitor*
|
|||||||
MatrixTransform* mt = dynamic_cast<MatrixTransform*>(node);
|
MatrixTransform* mt = dynamic_cast<MatrixTransform*>(node);
|
||||||
if (mt &&
|
if (mt &&
|
||||||
_animationPath.valid() &&
|
_animationPath.valid() &&
|
||||||
nv->getVisitorType()==NodeVisitor::APP_VISITOR &&
|
nv->getVisitorType()==NodeVisitor::UPDATE_VISITOR &&
|
||||||
nv->getFrameStamp())
|
nv->getFrameStamp())
|
||||||
{
|
{
|
||||||
double time = nv->getFrameStamp()->getReferenceTime();
|
double time = nv->getFrameStamp()->getReferenceTime();
|
||||||
|
@ -13,7 +13,7 @@ Node::Node()
|
|||||||
_bsphere_computed = false;
|
_bsphere_computed = false;
|
||||||
_nodeMask = 0xffffffff;
|
_nodeMask = 0xffffffff;
|
||||||
|
|
||||||
_numChildrenRequiringAppTraversal = 0;
|
_numChildrenRequiringUpdateTraversal = 0;
|
||||||
|
|
||||||
_cullingActive = true;
|
_cullingActive = true;
|
||||||
_numChildrenWithCullingDisabled = 0;
|
_numChildrenWithCullingDisabled = 0;
|
||||||
@ -27,8 +27,8 @@ Node::Node(const Node& node,const CopyOp& copyop):
|
|||||||
_bsphere_computed(node._bsphere_computed),
|
_bsphere_computed(node._bsphere_computed),
|
||||||
_name(node._name),
|
_name(node._name),
|
||||||
_parents(), // leave empty as parentList is managed by Group.
|
_parents(), // leave empty as parentList is managed by Group.
|
||||||
_appCallback(node._appCallback),
|
_updateCallback(node._updateCallback),
|
||||||
_numChildrenRequiringAppTraversal(0), // assume no children yet.
|
_numChildrenRequiringUpdateTraversal(0), // assume no children yet.
|
||||||
_cullCallback(node._cullCallback),
|
_cullCallback(node._cullCallback),
|
||||||
_cullingActive(node._cullingActive),
|
_cullingActive(node._cullingActive),
|
||||||
_numChildrenWithCullingDisabled(0), // assume no children yet.
|
_numChildrenWithCullingDisabled(0), // assume no children yet.
|
||||||
@ -77,24 +77,24 @@ osg::StateSet* Node::getOrCreateStateSet()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Node::setAppCallback(NodeCallback* nc)
|
void Node::setUpdateCallback(NodeCallback* nc)
|
||||||
{
|
{
|
||||||
// if no changes just return.
|
// if no changes just return.
|
||||||
if (_appCallback==nc) return;
|
if (_updateCallback==nc) return;
|
||||||
|
|
||||||
// app callback has been changed, will need to update
|
// app callback has been changed, will need to update
|
||||||
// both _appCallback and possibly the numChildrenRequiringAppTraversal
|
// both _updateCallback and possibly the numChildrenRequiringAppTraversal
|
||||||
// if the number of callbacks changes.
|
// if the number of callbacks changes.
|
||||||
|
|
||||||
|
|
||||||
// update the parents numChildrenRequiringAppTraversal
|
// update the parents numChildrenRequiringAppTraversal
|
||||||
// note, if _numChildrenRequiringAppTraversal!=0 then the
|
// note, if _numChildrenRequiringUpdateTraversal!=0 then the
|
||||||
// parents won't be affected by any app callback change,
|
// parents won't be affected by any app callback change,
|
||||||
// so no need to inform them.
|
// so no need to inform them.
|
||||||
if (_numChildrenRequiringAppTraversal==0 && !_parents.empty())
|
if (_numChildrenRequiringUpdateTraversal==0 && !_parents.empty())
|
||||||
{
|
{
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
if (_appCallback.valid()) --delta;
|
if (_updateCallback.valid()) --delta;
|
||||||
if (nc) ++delta;
|
if (nc) ++delta;
|
||||||
if (delta!=0)
|
if (delta!=0)
|
||||||
{
|
{
|
||||||
@ -105,32 +105,32 @@ void Node::setAppCallback(NodeCallback* nc)
|
|||||||
itr != _parents.end();
|
itr != _parents.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
(*itr)->setNumChildrenRequiringAppTraversal(
|
(*itr)->setNumChildrenRequiringUpdateTraversal(
|
||||||
(*itr)->getNumChildrenRequiringAppTraversal()+delta );
|
(*itr)->getNumChildrenRequiringUpdateTraversal()+delta );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the app callback itself.
|
// set the app callback itself.
|
||||||
_appCallback = nc;
|
_updateCallback = nc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setNumChildrenRequiringAppTraversal(unsigned int num)
|
void Node::setNumChildrenRequiringUpdateTraversal(unsigned int num)
|
||||||
{
|
{
|
||||||
// if no changes just return.
|
// if no changes just return.
|
||||||
if (_numChildrenRequiringAppTraversal==num) return;
|
if (_numChildrenRequiringUpdateTraversal==num) return;
|
||||||
|
|
||||||
// note, if _appCallback is set then the
|
// note, if _updateCallback is set then the
|
||||||
// parents won't be affected by any changes to
|
// parents won't be affected by any changes to
|
||||||
// _numChildrenRequiringAppTraversal so no need to inform them.
|
// _numChildrenRequiringUpdateTraversal so no need to inform them.
|
||||||
if (!_appCallback && !_parents.empty())
|
if (!_updateCallback && !_parents.empty())
|
||||||
{
|
{
|
||||||
|
|
||||||
// need to pass on changes to parents.
|
// need to pass on changes to parents.
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
if (_numChildrenRequiringAppTraversal>0) --delta;
|
if (_numChildrenRequiringUpdateTraversal>0) --delta;
|
||||||
if (num>0) ++delta;
|
if (num>0) ++delta;
|
||||||
if (delta!=0)
|
if (delta!=0)
|
||||||
{
|
{
|
||||||
@ -141,8 +141,8 @@ void Node::setNumChildrenRequiringAppTraversal(unsigned int num)
|
|||||||
itr != _parents.end();
|
itr != _parents.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
(*itr)->setNumChildrenRequiringAppTraversal(
|
(*itr)->setNumChildrenRequiringUpdateTraversal(
|
||||||
(*itr)->getNumChildrenRequiringAppTraversal()+delta
|
(*itr)->getNumChildrenRequiringUpdateTraversal()+delta
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ void Node::setNumChildrenRequiringAppTraversal(unsigned int num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finally update this objects value.
|
// finally update this objects value.
|
||||||
_numChildrenRequiringAppTraversal=num;
|
_numChildrenRequiringUpdateTraversal=num;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ void PositionAttitudeTransform::AnimationPathCallback::operator()(Node* node, No
|
|||||||
PositionAttitudeTransform* pat = dynamic_cast<PositionAttitudeTransform*>(node);
|
PositionAttitudeTransform* pat = dynamic_cast<PositionAttitudeTransform*>(node);
|
||||||
if (pat &&
|
if (pat &&
|
||||||
_animationPath.valid() &&
|
_animationPath.valid() &&
|
||||||
nv->getVisitorType()==NodeVisitor::APP_VISITOR &&
|
nv->getVisitorType()==NodeVisitor::UPDATE_VISITOR &&
|
||||||
nv->getFrameStamp())
|
nv->getFrameStamp())
|
||||||
{
|
{
|
||||||
double time = nv->getFrameStamp()->getReferenceTime();
|
double time = nv->getFrameStamp()->getReferenceTime();
|
||||||
|
@ -19,7 +19,7 @@ Sequence::Sequence() :
|
|||||||
_nrepsremain(0),
|
_nrepsremain(0),
|
||||||
_mode(STOP)
|
_mode(STOP)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(1);
|
setNumChildrenRequiringUpdateTraversal(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence::Sequence(const Sequence& seq, const CopyOp& copyop) :
|
Sequence::Sequence(const Sequence& seq, const CopyOp& copyop) :
|
||||||
@ -35,7 +35,7 @@ Sequence::Sequence(const Sequence& seq, const CopyOp& copyop) :
|
|||||||
_nrepsremain(seq._nrepsremain),
|
_nrepsremain(seq._nrepsremain),
|
||||||
_mode(seq._mode)
|
_mode(seq._mode)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+1);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::setTime(int frame, float t)
|
void Sequence::setTime(int frame, float t)
|
||||||
@ -105,7 +105,7 @@ void Sequence::setMode(SequenceMode mode)
|
|||||||
void Sequence::traverse(NodeVisitor& nv)
|
void Sequence::traverse(NodeVisitor& nv)
|
||||||
{
|
{
|
||||||
// if app traversal update the frame count.
|
// if app traversal update the frame count.
|
||||||
if (nv.getVisitorType()==NodeVisitor::APP_VISITOR && _mode == START && _nrepsremain)
|
if (nv.getVisitorType()==NodeVisitor::UPDATE_VISITOR && _mode == START && _nrepsremain)
|
||||||
{
|
{
|
||||||
const FrameStamp* framestamp = nv.getFrameStamp();
|
const FrameStamp* framestamp = nv.getFrameStamp();
|
||||||
if (framestamp)
|
if (framestamp)
|
||||||
|
@ -855,8 +855,8 @@ void PrimitiveShapeVisitor::apply(const Sphere& sphere)
|
|||||||
float rTop = cosf(lTop)*sphere.getRadius();
|
float rTop = cosf(lTop)*sphere.getRadius();
|
||||||
float zTop = sinf(lTop)*sphere.getRadius();
|
float zTop = sinf(lTop)*sphere.getRadius();
|
||||||
float vTop = vBase+vDelta;
|
float vTop = vBase+vDelta;
|
||||||
float nzTop= sinf(lTop);
|
//float nzTop= sinf(lTop);
|
||||||
float nRatioTop= cosf(lTop);
|
//float nRatioTop= cosf(lTop);
|
||||||
|
|
||||||
_functor.begin(GL_QUAD_STRIP);
|
_functor.begin(GL_QUAD_STRIP);
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void Viewer::requestWarpPointer(int x,int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Viewer::app(unsigned int viewport)
|
float Viewer::update(unsigned int viewport)
|
||||||
{
|
{
|
||||||
osg::Timer_t beforeApp = _timer.tick();
|
osg::Timer_t beforeApp = _timer.tick();
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ float Viewer::app(unsigned int viewport)
|
|||||||
// do app traversal.
|
// do app traversal.
|
||||||
|
|
||||||
getViewportSceneView(viewport)->setFrameStamp(_frameStamp.get());
|
getViewportSceneView(viewport)->setFrameStamp(_frameStamp.get());
|
||||||
getViewportSceneView(viewport)->app();
|
getViewportSceneView(viewport)->update();
|
||||||
|
|
||||||
osg::Timer_t beforeCull = _timer.tick();
|
osg::Timer_t beforeCull = _timer.tick();
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
|||||||
if (_printStats>=Statistics::STAT_GRAPHS && _printStats!=Statistics::STAT_PRIMSPERVIEW && _printStats!=Statistics::STAT_PRIMSPERBIN) { // more stats - graphs this time
|
if (_printStats>=Statistics::STAT_GRAPHS && _printStats!=Statistics::STAT_PRIMSPERVIEW && _printStats!=Statistics::STAT_PRIMSPERBIN) { // more stats - graphs this time
|
||||||
|
|
||||||
int sampleIndex = 2;
|
int sampleIndex = 2;
|
||||||
float timeApp=times[sampleIndex].timeApp;
|
float timeUpdate=times[sampleIndex].timeUpdate;
|
||||||
float timeCull=times[sampleIndex].timeCull;
|
float timeCull=times[sampleIndex].timeCull;
|
||||||
float timeDraw=times[sampleIndex].timeDraw;
|
float timeDraw=times[sampleIndex].timeDraw;
|
||||||
float timeFrame=times[sampleIndex].timeFrame;
|
float timeFrame=times[sampleIndex].timeFrame;
|
||||||
@ -524,7 +524,7 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
|||||||
|
|
||||||
char clin[72]; // buffer to print
|
char clin[72]; // buffer to print
|
||||||
glColor4fv((GLfloat * )&app_color);
|
glColor4fv((GLfloat * )&app_color);
|
||||||
sprintf(clin,"App %.2f ms.", timeApp);
|
sprintf(clin,"App %.2f ms.", timeUpdate);
|
||||||
displaytext((int)(.15f*tmax),(int)(0.98f*vh),clin);
|
displaytext((int)(.15f*tmax),(int)(0.98f*vh),clin);
|
||||||
|
|
||||||
glColor4fv((GLfloat * )&cull_color);
|
glColor4fv((GLfloat * )&cull_color);
|
||||||
@ -539,7 +539,7 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
|||||||
sprintf(clin,"Frame %.2f ms.", timeFrame);
|
sprintf(clin,"Frame %.2f ms.", timeFrame);
|
||||||
displaytext((int)(.75*tmax),(int)(0.98f*vh),clin);
|
displaytext((int)(.75*tmax),(int)(0.98f*vh),clin);
|
||||||
|
|
||||||
/* osg::notify(osg::NOTICE) << "Time of App "<<timeApp<<"ms "<< std::endl;
|
/* osg::notify(osg::NOTICE) << "Time of App "<<timeUpdate<<"ms "<< std::endl;
|
||||||
osg::notify(osg::NOTICE) << "Time of Cull "<<timeCull<<"ms "<< std::endl;
|
osg::notify(osg::NOTICE) << "Time of Cull "<<timeCull<<"ms "<< std::endl;
|
||||||
osg::notify(osg::NOTICE) << "Time of Draw "<<timeDraw<<"ms "<< std::endl;
|
osg::notify(osg::NOTICE) << "Time of Draw "<<timeDraw<<"ms "<< std::endl;
|
||||||
osg::notify(osg::NOTICE) << "Frame time "<<frameTime<< std::endl;
|
osg::notify(osg::NOTICE) << "Frame time "<<frameTime<< std::endl;
|
||||||
@ -568,15 +568,15 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
|||||||
for (i=0; i<3; i++) {
|
for (i=0; i<3; i++) {
|
||||||
glColor4fv((GLfloat * )&app_color);
|
glColor4fv((GLfloat * )&app_color);
|
||||||
glVertex2f(tstart,0.95f*vh);
|
glVertex2f(tstart,0.95f*vh);
|
||||||
glVertex2f(tstart+times[i].timeApp,0.95f*vh);
|
glVertex2f(tstart+times[i].timeUpdate,0.95f*vh);
|
||||||
glColor4fv((GLfloat * )&cull_color);
|
glColor4fv((GLfloat * )&cull_color);
|
||||||
glVertex2f(tstart+times[i].timeApp,0.93f*vh);
|
glVertex2f(tstart+times[i].timeUpdate,0.93f*vh);
|
||||||
glVertex2f(tstart+times[i].timeApp+times[i].timeCull, 0.93f*vh);
|
glVertex2f(tstart+times[i].timeUpdate+times[i].timeCull, 0.93f*vh);
|
||||||
glColor4fv((GLfloat * )&draw_color);
|
glColor4fv((GLfloat * )&draw_color);
|
||||||
glVertex2f(tstart+times[i].timeApp+times[i].timeCull, 0.91f*vh);
|
glVertex2f(tstart+times[i].timeUpdate+times[i].timeCull, 0.91f*vh);
|
||||||
glVertex2f(tstart+times[i].timeApp+times[i].timeCull+times[i].timeDraw, 0.91f*vh);
|
glVertex2f(tstart+times[i].timeUpdate+times[i].timeCull+times[i].timeDraw, 0.91f*vh);
|
||||||
glColor4fv((GLfloat * )&swap_color);
|
glColor4fv((GLfloat * )&swap_color);
|
||||||
glVertex2f(tstart+times[i].timeApp+times[i].timeCull+times[i].timeDraw, 0.90f*vh);
|
glVertex2f(tstart+times[i].timeUpdate+times[i].timeCull+times[i].timeDraw, 0.90f*vh);
|
||||||
glVertex2f(tstart+times[i].timeFrame, 0.90f*vh);
|
glVertex2f(tstart+times[i].timeFrame, 0.90f*vh);
|
||||||
tstart+=times[i].timeFrame;
|
tstart+=times[i].timeFrame;
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ void Viewer::display()
|
|||||||
_frameStamp->setReferenceTime(clockSeconds());
|
_frameStamp->setReferenceTime(clockSeconds());
|
||||||
|
|
||||||
// application traverasal.
|
// application traverasal.
|
||||||
times[2].timeApp=0.0f;
|
times[2].timeUpdate=0.0f;
|
||||||
|
|
||||||
// cull traverasal.
|
// cull traverasal.
|
||||||
times[2].timeCull=0.0f;
|
times[2].timeCull=0.0f;
|
||||||
@ -699,8 +699,8 @@ void Viewer::display()
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < getNumViewports(); i++ )
|
for(unsigned int i = 0; i < getNumViewports(); i++ )
|
||||||
{
|
{
|
||||||
// application traverasal.
|
// update traverasal.
|
||||||
times[2].timeApp+=app(i);
|
times[2].timeUpdate+=update(i);
|
||||||
|
|
||||||
|
|
||||||
// cull traverasal.
|
// cull traverasal.
|
||||||
|
@ -126,7 +126,7 @@ public:
|
|||||||
// so that it visits 'invisible' nodes to update visibility. Or could use
|
// so that it visits 'invisible' nodes to update visibility. Or could use
|
||||||
// a visitor with setTraversalMode(TraversalMode==TRAVERSE_ALL_CHILDREN)?
|
// a visitor with setTraversalMode(TraversalMode==TRAVERSE_ALL_CHILDREN)?
|
||||||
traverse(node,nv);
|
traverse(node,nv);
|
||||||
// std::cout<<"app callback - post traverse"<< (float)_frameStamp->getReferenceTime() <<std::endl;
|
// std::cout<<"update callback - post traverse"<< (float)_frameStamp->getReferenceTime() <<std::endl;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@ -752,7 +752,7 @@ class ReaderWriterGEO : public ReaderWriter
|
|||||||
if (!bhv.empty()) { // then check for a string content/colour.. action
|
if (!bhv.empty()) { // then check for a string content/colour.. action
|
||||||
bool ok=false;
|
bool ok=false;
|
||||||
geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB;
|
geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB;
|
||||||
text->setAppCallback(gcb);
|
text->setUpdateCallback(gcb);
|
||||||
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
||||||
rcitr!=bhv.end();
|
rcitr!=bhv.end();
|
||||||
++rcitr)
|
++rcitr)
|
||||||
@ -778,7 +778,7 @@ class ReaderWriterGEO : public ReaderWriter
|
|||||||
if (hasColorAction(bhv) || vinf->hasVertexActions()) {
|
if (hasColorAction(bhv) || vinf->hasVertexActions()) {
|
||||||
osg::Geometry *nugeom=gi.getGeom();
|
osg::Geometry *nugeom=gi.getGeom();
|
||||||
geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB;
|
geoBehaviourDrawableCB *gcb=new geoBehaviourDrawableCB;
|
||||||
nugeom->setAppCallback(gcb);
|
nugeom->setUpdateCallback(gcb);
|
||||||
nugeom->setUseDisplayList(false); // as we are updating arrays, cannot change colours
|
nugeom->setUseDisplayList(false); // as we are updating arrays, cannot change colours
|
||||||
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
||||||
rcitr!=bhv.end();
|
rcitr!=bhv.end();
|
||||||
@ -956,7 +956,7 @@ class ReaderWriterGEO : public ReaderWriter
|
|||||||
// also test for other properties of a unique material:
|
// also test for other properties of a unique material:
|
||||||
// - use material/vertex colours;
|
// - use material/vertex colours;
|
||||||
geoInfo gu(txidx,shademodel, bothsides);
|
geoInfo gu(txidx,shademodel, bothsides);
|
||||||
if (gu==&(*itrint) && !(*itrint).getGeom()->getAppCallback()) igeom=igidx;
|
if (gu==&(*itrint) && !(*itrint).getGeom()->getUpdateCallback()) igeom=igidx;
|
||||||
igidx++;
|
igidx++;
|
||||||
}
|
}
|
||||||
std::vector< georecord *>bhv=grec->getBehaviour(); // behaviours attached to facets, eg colour!
|
std::vector< georecord *>bhv=grec->getBehaviour(); // behaviours attached to facets, eg colour!
|
||||||
@ -1277,13 +1277,13 @@ class ReaderWriterGEO : public ReaderWriter
|
|||||||
{
|
{
|
||||||
if ((*rcitr)->getType()==DB_DSK_INTERNAL_VARS) {
|
if ((*rcitr)->getType()==DB_DSK_INTERNAL_VARS) {
|
||||||
theHeader->addInternalVars(**rcitr);
|
theHeader->addInternalVars(**rcitr);
|
||||||
// theHeader->setAppCallback(theHeader->getInternalVars());
|
// theHeader->setUpdateCallback(theHeader->getInternalVars());
|
||||||
}
|
}
|
||||||
if ((*rcitr)->getType()==DB_DSK_FLOAT_VAR) {
|
if ((*rcitr)->getType()==DB_DSK_FLOAT_VAR) {
|
||||||
if (theHeader) theHeader->addUserVar((**rcitr));
|
if (theHeader) theHeader->addUserVar((**rcitr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theHeader->setAppCallback(new geoHeaderCB);
|
theHeader->setUpdateCallback(new geoHeaderCB);
|
||||||
}
|
}
|
||||||
for (itr=geomatlist.begin(); itr< geomatlist.end(); itr++) {
|
for (itr=geomatlist.begin(); itr< geomatlist.end(); itr++) {
|
||||||
osg::Material *mt=new osg::Material;
|
osg::Material *mt=new osg::Material;
|
||||||
@ -1379,7 +1379,7 @@ class ReaderWriterGEO : public ReaderWriter
|
|||||||
if (!bhv.empty()) { // then add a DCS/matrix_transform
|
if (!bhv.empty()) { // then add a DCS/matrix_transform
|
||||||
mtr=new MatrixTransform;
|
mtr=new MatrixTransform;
|
||||||
geoBehaviourCB *gcb=new geoBehaviourCB;
|
geoBehaviourCB *gcb=new geoBehaviourCB;
|
||||||
mtr->setAppCallback(gcb);
|
mtr->setUpdateCallback(gcb);
|
||||||
|
|
||||||
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
for (std::vector< georecord *>::const_iterator rcitr=bhv.begin();
|
||||||
rcitr!=bhv.end();
|
rcitr!=bhv.end();
|
||||||
@ -1908,7 +1908,7 @@ void internalVars::update(const osg::FrameStamp *_frameStamp) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// std::cout<<"app callback - post traverse"<< (float)_frameStamp->getReferenceTime() <<std::endl;
|
// std::cout<<"update callback - post traverse"<< (float)_frameStamp->getReferenceTime() <<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now register with Registry to instantiate the above
|
// now register with Registry to instantiate the above
|
||||||
|
@ -616,7 +616,7 @@ void geoBehaviourCB::operator() (osg::Node *node, osg::NodeVisitor* nv)
|
|||||||
traverse(node,nv);
|
traverse(node,nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void geoBehaviourDrawableCB::app(osg::NodeVisitor *,osg::Drawable *dr) {
|
void geoBehaviourDrawableCB::update(osg::NodeVisitor *,osg::Drawable *dr) {
|
||||||
Matrix mtr;
|
Matrix mtr;
|
||||||
int prevvtr=-1; // previously moved vertex
|
int prevvtr=-1; // previously moved vertex
|
||||||
Vec3 pos;
|
Vec3 pos;
|
||||||
|
@ -20,12 +20,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class geoBehaviourDrawableCB: public osg::Drawable::AppCallback {
|
class geoBehaviourDrawableCB: public osg::Drawable::UpdateCallback {
|
||||||
public:
|
public:
|
||||||
geoBehaviourDrawableCB() { }
|
geoBehaviourDrawableCB() { }
|
||||||
~geoBehaviourDrawableCB() { }
|
~geoBehaviourDrawableCB() { }
|
||||||
void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);}
|
void addBehaviour(geoBehaviour *gb) {gblist.push_back(gb);}
|
||||||
void app(osg::NodeVisitor *,osg::Drawable *dr);
|
void update(osg::NodeVisitor *,osg::Drawable *dr);
|
||||||
private:
|
private:
|
||||||
std::vector<geoBehaviour *> gblist;
|
std::vector<geoBehaviour *> gblist;
|
||||||
};
|
};
|
||||||
|
@ -37,11 +37,11 @@ public:
|
|||||||
};
|
};
|
||||||
~geoHeader() {}
|
~geoHeader() {}
|
||||||
void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
void setUserUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
||||||
{ // pass the address of a user written function in the App process.
|
{ // pass the address of a user written function in the Update phase.
|
||||||
uvarupdate=ufn;
|
uvarupdate=ufn;
|
||||||
}
|
}
|
||||||
void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
void setExternUpdate(double (*ufn)(const double time,const double val, const std::string name) )
|
||||||
{ // pass the address of a user written function in the App process.
|
{ // pass the address of a user written function in the Update phase.
|
||||||
extvarupdate=ufn;
|
extvarupdate=ufn;
|
||||||
}
|
}
|
||||||
double (* uvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
double (* uvarupdate)(const double t, const double val, const std::string name); // called when variables are updated, you write this!
|
||||||
|
@ -8,7 +8,7 @@ namespace txp
|
|||||||
TerrapageNode::TerrapageNode():
|
TerrapageNode::TerrapageNode():
|
||||||
_pageManager(0)
|
_pageManager(0)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(1);
|
setNumChildrenRequiringUpdateTraversal(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrapageNode::TerrapageNode(const TerrapageNode& pager,const osg::CopyOp&):
|
TerrapageNode::TerrapageNode(const TerrapageNode& pager,const osg::CopyOp&):
|
||||||
@ -19,7 +19,7 @@ TerrapageNode::TerrapageNode(const TerrapageNode& pager,const osg::CopyOp&):
|
|||||||
_pageManager(0),
|
_pageManager(0),
|
||||||
_lastRecordEyePoint(pager._lastRecordEyePoint)
|
_lastRecordEyePoint(pager._lastRecordEyePoint)
|
||||||
{
|
{
|
||||||
setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+1);
|
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrapageNode::~TerrapageNode()
|
TerrapageNode::~TerrapageNode()
|
||||||
@ -32,7 +32,7 @@ void TerrapageNode::traverse(osg::NodeVisitor& nv)
|
|||||||
{
|
{
|
||||||
if (_pageManager)
|
if (_pageManager)
|
||||||
{
|
{
|
||||||
if (nv.getVisitorType()==osg::NodeVisitor::APP_VISITOR)
|
if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
|
||||||
{
|
{
|
||||||
updateSceneGraph();
|
updateSceneGraph();
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#include <osgUtil/AppVisitor>
|
|
||||||
|
|
||||||
using namespace osg;
|
|
||||||
using namespace osgUtil;
|
|
||||||
|
|
||||||
AppVisitor::AppVisitor():NodeVisitor(APP_VISITOR,TRAVERSE_ACTIVE_CHILDREN)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AppVisitor::~AppVisitor()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AppVisitor::reset()
|
|
||||||
{
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ include $(TOPDIR)/Make/makedefs
|
|||||||
|
|
||||||
|
|
||||||
CXXFILES = \
|
CXXFILES = \
|
||||||
AppVisitor.cpp\
|
UpdateVisitor.cpp\
|
||||||
CullVisitor.cpp\
|
CullVisitor.cpp\
|
||||||
DisplayListVisitor.cpp\
|
DisplayListVisitor.cpp\
|
||||||
DisplayRequirementsVisitor.cpp\
|
DisplayRequirementsVisitor.cpp\
|
||||||
|
@ -878,7 +878,7 @@ void Optimizer::RemoveRedundantNodesVisitor::apply(osg::Group& group)
|
|||||||
if (group.getNumParents()>0 && group.getNumChildren()<=1)
|
if (group.getNumParents()>0 && group.getNumChildren()<=1)
|
||||||
{
|
{
|
||||||
if (!group.getUserData() &&
|
if (!group.getUserData() &&
|
||||||
!group.getAppCallback() &&
|
!group.getUpdateCallback() &&
|
||||||
!group.getStateSet() &&
|
!group.getStateSet() &&
|
||||||
group.getNodeMask()==0xffffffff)
|
group.getNodeMask()==0xffffffff)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <osgUtil/SceneView>
|
#include <osgUtil/SceneView>
|
||||||
#include <osgUtil/AppVisitor>
|
#include <osgUtil/UpdateVisitor>
|
||||||
#include <osgUtil/DisplayListVisitor>
|
#include <osgUtil/DisplayListVisitor>
|
||||||
|
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
@ -80,7 +80,7 @@ void SceneView::setDefaults()
|
|||||||
_initVisitor = dlv;
|
_initVisitor = dlv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_appVisitor = new AppVisitor;
|
_updateVisitor = new UpdateVisitor;
|
||||||
|
|
||||||
_cullVisitor = new CullVisitor;
|
_cullVisitor = new CullVisitor;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ void SceneView::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneView::app()
|
void SceneView::update()
|
||||||
{
|
{
|
||||||
if (!_initCalled) init();
|
if (!_initCalled) init();
|
||||||
|
|
||||||
@ -155,19 +155,19 @@ void SceneView::app()
|
|||||||
std::cout<<" Number of active objects ="<<osg::Referenced::createdCount()-osg::Referenced::deletedCount()<<std::endl;
|
std::cout<<" Number of active objects ="<<osg::Referenced::createdCount()-osg::Referenced::deletedCount()<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_sceneData.valid() && _appVisitor.valid())
|
if (_sceneData.valid() && _updateVisitor.valid())
|
||||||
{
|
{
|
||||||
_appVisitor->reset();
|
_updateVisitor->reset();
|
||||||
|
|
||||||
_appVisitor->setFrameStamp(_frameStamp.get());
|
_updateVisitor->setFrameStamp(_frameStamp.get());
|
||||||
|
|
||||||
// use the frame number for the traversal number.
|
// use the frame number for the traversal number.
|
||||||
if (_frameStamp.valid())
|
if (_frameStamp.valid())
|
||||||
{
|
{
|
||||||
_appVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
_updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
_sceneData->accept(*_appVisitor.get());
|
_sceneData->accept(*_updateVisitor.get());
|
||||||
|
|
||||||
// now force a recompute of the bounding volume while we are still in
|
// now force a recompute of the bounding volume while we are still in
|
||||||
// the read/write app phase, this should prevent the need to recompute
|
// the read/write app phase, this should prevent the need to recompute
|
||||||
|
18
src/osgUtil/UpdateVisitor.cpp
Normal file
18
src/osgUtil/UpdateVisitor.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <osgUtil/UpdateVisitor>
|
||||||
|
|
||||||
|
using namespace osg;
|
||||||
|
using namespace osgUtil;
|
||||||
|
|
||||||
|
UpdateVisitor::UpdateVisitor():NodeVisitor(UPDATE_VISITOR,TRAVERSE_ACTIVE_CHILDREN)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpdateVisitor::~UpdateVisitor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpdateVisitor::reset()
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user