Introduce NodeVisitor::className and libraryName()
This commit is contained in:
@@ -31,6 +31,8 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::
|
||||
CollectOccludersVisitor();
|
||||
virtual ~CollectOccludersVisitor();
|
||||
|
||||
META_NodeVisitor("osg","CollectOccludersVisitor")
|
||||
|
||||
virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); }
|
||||
|
||||
virtual void reset();
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
ComputeBoundsVisitor(TraversalMode traversalMode = TRAVERSE_ALL_CHILDREN);
|
||||
|
||||
META_NodeVisitor("osg","ComputeBoundsVisitor")
|
||||
|
||||
virtual void reset();
|
||||
|
||||
osg::BoundingBox& getBoundingBox() { return _bb; }
|
||||
|
||||
@@ -175,6 +175,8 @@ class OSG_EXPORT KdTreeBuilder : public osg::NodeVisitor
|
||||
|
||||
KdTreeBuilder(const KdTreeBuilder& rhs);
|
||||
|
||||
META_NodeVisitor("osg","KdTreeBuilder")
|
||||
|
||||
virtual KdTreeBuilder* clone() { return new KdTreeBuilder(*this); }
|
||||
|
||||
void apply(osg::Geode& geode);
|
||||
|
||||
@@ -42,6 +42,10 @@ class Transform;
|
||||
class Camera;
|
||||
class CameraView;
|
||||
|
||||
#define META_NodeVisitor(library,name) \
|
||||
virtual const char* libraryName() const { return #library; }\
|
||||
virtual const char* className() const { return #name; }
|
||||
|
||||
/** Visitor for type safe operations on osg::Nodes.
|
||||
Based on GOF's Visitor pattern. The NodeVisitor
|
||||
is useful for developing type safe operations to nodes
|
||||
@@ -82,6 +86,12 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
|
||||
NodeVisitor(VisitorType type,TraversalMode tm=TRAVERSE_NONE);
|
||||
|
||||
virtual ~NodeVisitor();
|
||||
|
||||
/** return the library name/namespapce of the visitor's. Should be defined by derived classes.*/
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
|
||||
/** return the name of the visitor's class type. Should be defined by derived classes.*/
|
||||
virtual const char* className() const { return "NodeVisitor"; }
|
||||
|
||||
/** Method to call to reset visitor. Useful if your visitor accumulates
|
||||
state during a traversal, and you plan to reuse the visitor.
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace osgAnimation
|
||||
BoneMap _map;
|
||||
BoneMapVisitor(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
|
||||
|
||||
META_NodeVisitor("osgAnimation","BoneMapVisitor")
|
||||
|
||||
void apply(osg::Node& node) { return; }
|
||||
void apply(osg::Transform& node)
|
||||
{
|
||||
|
||||
@@ -26,8 +26,12 @@ namespace osgAnimation
|
||||
{
|
||||
AnimationList _animations;
|
||||
unsigned int _nbLinkedTarget;
|
||||
|
||||
LinkVisitor(Animation* animation) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations.push_back(animation); _nbLinkedTarget = 0;}
|
||||
LinkVisitor(const AnimationList& animations) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations = animations; _nbLinkedTarget = 0;}
|
||||
|
||||
META_NodeVisitor("osgAnimation","LinkVisitor")
|
||||
|
||||
void apply(osg::Node& node)
|
||||
{
|
||||
osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(node.getUpdateCallback());
|
||||
|
||||
@@ -77,6 +77,9 @@ namespace osgAnimation
|
||||
{
|
||||
osg::ref_ptr<Skeleton> _root;
|
||||
BuildVertexTransformerVisitor(Skeleton* root): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _root = root;}
|
||||
|
||||
META_NodeVisitor("osgAnimation","BuildVertexTransformerVisitor")
|
||||
|
||||
void apply(osg::Geode& node)
|
||||
{
|
||||
int num = node.getNumDrawables();
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace osgDB {
|
||||
|
||||
SharedStateManager(unsigned int mode = SHARE_ALL);
|
||||
|
||||
META_NodeVisitor("osgDB","SharedStateManager")
|
||||
|
||||
void setShareMode(unsigned int mode);
|
||||
|
||||
unsigned int getShareMode() { return _shareMode; }
|
||||
|
||||
@@ -43,6 +43,7 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
|
||||
EventVisitor();
|
||||
virtual ~EventVisitor();
|
||||
|
||||
META_NodeVisitor("osgGA","EventVisitor")
|
||||
|
||||
void setActionAdapter(osgGA::GUIActionAdapter* actionAdapter) { _actionAdapter=actionAdapter; }
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ class OSGSIM_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor
|
||||
/** Default to traversing all children. */
|
||||
InsertImpostorsVisitor();
|
||||
|
||||
META_NodeVisitor("osgSim","InsertImpostorsVisitor")
|
||||
|
||||
void setImpostorThresholdRatio(float ratio) { _impostorThresholdRatio = ratio; }
|
||||
float getImpostorThresholdRatio() const { return _impostorThresholdRatio; }
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
|
||||
/// Copy constructor that does a shallow copy.
|
||||
CullVisitor(const CullVisitor&);
|
||||
|
||||
META_NodeVisitor("osgUtil","CullVisitor")
|
||||
|
||||
/** Create a shallow copy of the CullVisitor, used by CullVisitor::create() to clone the prototype. */
|
||||
virtual CullVisitor* clone() const { return new CullVisitor(*this); }
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor
|
||||
* alpha and stencil off.*/
|
||||
DisplayRequirementsVisitor();
|
||||
|
||||
META_NodeVisitor("osgUtil","DisplayRequirementsVisitor")
|
||||
|
||||
/** Set the DisplaySettings. */
|
||||
inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; }
|
||||
|
||||
@@ -32,6 +32,8 @@ class OSGUTIL_EXPORT DrawElementTypeSimplifierVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
META_NodeVisitor("osgUtil","DrawElementTypeSimplifierVisitor")
|
||||
|
||||
void apply(osg::Geode& node);
|
||||
};
|
||||
|
||||
|
||||
@@ -51,9 +51,10 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
|
||||
* display list/texture objects etc. Default mode is to compile
|
||||
* GL objects.
|
||||
*/
|
||||
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES);
|
||||
|
||||
|
||||
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES);
|
||||
|
||||
META_NodeVisitor("osg","GLObjectsVisitor")
|
||||
|
||||
virtual void reset()
|
||||
{
|
||||
_drawablesAppliedSet.clear();
|
||||
|
||||
@@ -102,6 +102,8 @@ class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor
|
||||
IntersectVisitor();
|
||||
virtual ~IntersectVisitor();
|
||||
|
||||
META_NodeVisitor("osgUtil","IntersectVisitor")
|
||||
|
||||
void reset();
|
||||
|
||||
/** Add a line segment to use for intersection testing during scene traversal.
|
||||
|
||||
@@ -137,6 +137,8 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
|
||||
|
||||
IntersectionVisitor(Intersector* intersector=0, ReadCallback* readCallback=0);
|
||||
|
||||
META_NodeVisitor("osgUtil","IntersectionVisitor")
|
||||
|
||||
virtual void reset();
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
|
||||
|
||||
Simplifier(double sampleRatio=1.0, double maximumError=FLT_MAX, double maximumLength=0.0);
|
||||
|
||||
META_NodeVisitor("osgUtil","Simplifier")
|
||||
|
||||
void setSampleRatio(float sampleRatio) { _sampleRatio = sampleRatio; }
|
||||
float getSampleRatio() const { return _sampleRatio; }
|
||||
|
||||
@@ -167,6 +167,8 @@ public:
|
||||
|
||||
StatsVisitor();
|
||||
|
||||
META_NodeVisitor("osgUtil","StatsVisitor")
|
||||
|
||||
void reset();
|
||||
|
||||
void apply(osg::Node& node);
|
||||
|
||||
@@ -41,9 +41,11 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
|
||||
UpdateVisitor();
|
||||
virtual ~UpdateVisitor();
|
||||
|
||||
META_NodeVisitor("osgUtil","UpdateVisitor")
|
||||
|
||||
virtual void reset();
|
||||
|
||||
/** During traversal each type of node calls its callbacks and its children traversed. */
|
||||
/** During traversal each type of node calls its callbacks and its children traversed. */
|
||||
virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); }
|
||||
|
||||
virtual void apply(osg::Geode& node) { handle_geode_callbacks(node); }
|
||||
|
||||
Reference in New Issue
Block a user