From 0969a5384bcafea43117e6fddaf9f7057f901e02 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 18 Sep 2008 10:38:18 +0000 Subject: [PATCH] Improved the constness of parameters the Node::getWorldMatrices(..) method. Added Drawable::getWorldMatrices(const Node*) method. --- include/osg/Drawable | 3 +++ include/osg/Node | 2 +- src/osg/Drawable.cpp | 13 +++++++++++++ src/osg/Node.cpp | 6 +++--- src/osgWrappers/osg/Drawable.cpp | 5 +++++ src/osgWrappers/osg/Node.cpp | 4 ++-- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/osg/Drawable b/include/osg/Drawable index 5017519fc..e3462be35 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -156,6 +156,9 @@ class OSG_EXPORT Drawable : public Object */ inline unsigned int getNumParents() const { return _parents.size(); } + /** Get the list of matrices that transform this node from local coordinates to world coordinates. + * The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */ + MatrixList getWorldMatrices(const osg::Node* haltTraversalAtNode=0) const; /** Set the StateSet attached to the Drawable. diff --git a/include/osg/Node b/include/osg/Node index c638a6f5f..379d5fe89 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -134,7 +134,7 @@ class OSG_EXPORT Node : public Object /** Get the list of matrices that transform this node from local coordinates to world coordinates. * The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */ - MatrixList getWorldMatrices(osg::Node* haltTraversalAtNode=0) const; + MatrixList getWorldMatrices(const osg::Node* haltTraversalAtNode=0) const; /** Set update node callback, called during update traversal. */ diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index 99f564a5d..e5ef9a7c1 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -250,6 +250,19 @@ Drawable::~Drawable() dirtyDisplayList(); } +osg::MatrixList Drawable::getWorldMatrices(const osg::Node* haltTraversalAtNode) const +{ + osg::MatrixList matrices; + for(ParentList::const_iterator itr = _parents.begin(); + itr != _parents.end(); + ++itr) + { + osg::MatrixList localMatrices = (*itr)->getWorldMatrices(haltTraversalAtNode); + matrices.insert(matrices.end(), localMatrices.begin(), localMatrices.end()); + } + return matrices; +} + void Drawable::computeDataVariance() { if (getDataVariance() != UNSPECIFIED) return; diff --git a/src/osg/Node.cpp b/src/osg/Node.cpp index 667e011e2..c5f945ef6 100644 --- a/src/osg/Node.cpp +++ b/src/osg/Node.cpp @@ -28,7 +28,7 @@ namespace osg class CollectParentPaths : public NodeVisitor { public: - CollectParentPaths(osg::Node* haltTraversalAtNode=0) : + CollectParentPaths(const osg::Node* haltTraversalAtNode=0) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS), _haltTraversalAtNode(haltTraversalAtNode) { @@ -46,7 +46,7 @@ namespace osg } } - Node* _haltTraversalAtNode; + const Node* _haltTraversalAtNode; NodePath _nodePath; NodePathList _nodePaths; }; @@ -191,7 +191,7 @@ NodePathList Node::getParentalNodePaths(osg::Node* haltTraversalAtNode) const return cpp._nodePaths; } -MatrixList Node::getWorldMatrices(osg::Node* haltTraversalAtNode) const +MatrixList Node::getWorldMatrices(const osg::Node* haltTraversalAtNode) const { CollectParentPaths cpp(haltTraversalAtNode); const_cast(this)->accept(cpp); diff --git a/src/osgWrappers/osg/Drawable.cpp b/src/osgWrappers/osg/Drawable.cpp index ff197f950..a04e50e4c 100644 --- a/src/osgWrappers/osg/Drawable.cpp +++ b/src/osgWrappers/osg/Drawable.cpp @@ -128,6 +128,11 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Drawable) __unsigned_int__getNumParents, "Get the number of parents of node. ", "the number of parents of this node. "); + I_MethodWithDefaults1(osg::MatrixList, getWorldMatrices, IN, const osg::Node *, haltTraversalAtNode, 0, + Properties::NON_VIRTUAL, + __MatrixList__getWorldMatrices__C5_osg_Node_P1, + "Get the list of matrices that transform this node from local coordinates to world coordinates. ", + "The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. "); I_Method1(void, setStateSet, IN, osg::StateSet *, stateset, Properties::NON_VIRTUAL, __void__setStateSet__StateSet_P1, diff --git a/src/osgWrappers/osg/Node.cpp b/src/osgWrappers/osg/Node.cpp index c736d25df..22eddedeb 100644 --- a/src/osgWrappers/osg/Node.cpp +++ b/src/osgWrappers/osg/Node.cpp @@ -135,9 +135,9 @@ BEGIN_OBJECT_REFLECTOR(osg::Node) __NodePathList__getParentalNodePaths__osg_Node_P1, "Get the list of node paths parent paths. ", "The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. "); - I_MethodWithDefaults1(osg::MatrixList, getWorldMatrices, IN, osg::Node *, haltTraversalAtNode, 0, + I_MethodWithDefaults1(osg::MatrixList, getWorldMatrices, IN, const osg::Node *, haltTraversalAtNode, 0, Properties::NON_VIRTUAL, - __MatrixList__getWorldMatrices__osg_Node_P1, + __MatrixList__getWorldMatrices__C5_osg_Node_P1, "Get the list of matrices that transform this node from local coordinates to world coordinates. ", "The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. "); I_Method1(void, setUpdateCallback, IN, osg::NodeCallback *, nc,