Improved the constness of parameters the Node::getWorldMatrices(..) method.

Added Drawable::getWorldMatrices(const Node*) method.
This commit is contained in:
Robert Osfield
2008-09-18 10:38:18 +00:00
parent 93d4090169
commit 0969a5384b
6 changed files with 27 additions and 6 deletions

View File

@@ -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.

View File

@@ -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. */

View File

@@ -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;

View File

@@ -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<Node*>(this)->accept(cpp);

View File

@@ -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,

View File

@@ -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,