diff --git a/examples/osgcallback/osgcallback.cpp b/examples/osgcallback/osgcallback.cpp index a919c709f..f9ada5b18 100644 --- a/examples/osgcallback/osgcallback.cpp +++ b/examples/osgcallback/osgcallback.cpp @@ -46,27 +46,6 @@ class DrawableDrawCallback : public osg::Drawable::DrawCallback } }; -struct TransformCallback : public osg::Transform::ComputeTransformCallback -{ - /** Get the transformation matrix which moves from local coords to world coords.*/ - virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform* transform, osg::NodeVisitor* nv) const - { - std::cout<<"computeLocalToWorldMatrix - pre transform->computeLocalToWorldMatrix"<computeLocalToWorldMatrix(matrix,nv); - std::cout<<"computeLocalToWorldMatrix - post transform->computeLocalToWorldMatrix"<computeWorldToLocalMatrix"<computeWorldToLocalMatrix(matrix,nv); - std::cout<<"computeWorldToLocalMatrix - post transform->computeWorldToLocalMatrix"<(nv); if (cv) @@ -41,8 +42,10 @@ struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransfo } /** Get the transformation matrix which moves from world coords to local coords.*/ - virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const + virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { + std::cout<<"computing transform"<(nv); if (cv) { @@ -67,7 +70,7 @@ osg::Group* createModel() clearNode->setRequiresClear(false); // we've got base and sky to do it. // use a transform to make the sky and base around with the eye point. - osg::Transform* transform = new osg::Transform; + osg::Transform* transform = new MoveEarthySkyWithEyePointTransform; // transform's value isn't knowm until in the cull traversal so its bounding // volume is can't be determined, therefore culling will be invalid, @@ -76,10 +79,6 @@ osg::Group* createModel() // this node or any other branch above this transform. transform->setCullingActive(false); - // set the compute transform callback to do all the work of - // determining the transform according to the current eye point. - transform->setComputeTransformCallback(new MoveEarthySkyWithEyePointCallback); - // add the sky and base layer. transform->addChild(makeSky()); // bin number -2 so drawn first. transform->addChild(makeBase()); // bin number -1 so draw second. diff --git a/examples/osgvertexprogram/osgvertexprogram.cpp b/examples/osgvertexprogram/osgvertexprogram.cpp index e55531b41..d670b1829 100644 --- a/examples/osgvertexprogram/osgvertexprogram.cpp +++ b/examples/osgvertexprogram/osgvertexprogram.cpp @@ -196,10 +196,11 @@ public: }; -struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransformCallback +class MoveEarthySkyWithEyePointTransform : public osg::Transform { +public: /** Get the transformation matrix which moves from local coords to world coords.*/ - virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const + virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) @@ -211,7 +212,7 @@ struct MoveEarthySkyWithEyePointCallback : public osg::Transform::ComputeTransfo } /** Get the transformation matrix which moves from world coords to local coords.*/ - virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,const osg::Transform*, osg::NodeVisitor* nv) const + virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const { osgUtil::CullVisitor* cv = dynamic_cast(nv); if (cv) @@ -262,9 +263,8 @@ osg::Node* createSkyBox() geode->addDrawable(drawable); - osg::Transform* transform = new osg::Transform; + osg::Transform* transform = new MoveEarthySkyWithEyePointTransform; transform->setCullingActive(false); - transform->setComputeTransformCallback(new MoveEarthySkyWithEyePointCallback); transform->addChild(geode); osg::ClearNode* clearNode = new osg::ClearNode; diff --git a/include/osg/Billboard b/include/osg/Billboard index ea502c5a2..c785fea68 100644 --- a/include/osg/Billboard +++ b/include/osg/Billboard @@ -93,14 +93,7 @@ class SG_EXPORT Billboard : public Geode virtual bool removeDrawable( Drawable *gset ); - - - inline bool getMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const - { - return computeMatrix(modelview,eye_local,pos_local); - } - - virtual bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const; + bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const; protected: diff --git a/include/osg/Transform b/include/osg/Transform index 50296b3bc..051724234 100644 --- a/include/osg/Transform +++ b/include/osg/Transform @@ -105,55 +105,6 @@ class SG_EXPORT Transform : public Group ReferenceFrame getReferenceFrame() const { return _referenceFrame; } - - /** Callback attached to an Transform to specify how to compute the - * modelview transformation for the transform below the Transform - * node. */ - struct ComputeTransformCallback : public virtual osg::Referenced - { - /** Get the transformation matrix which moves from local coords - * to world coords.*/ - virtual bool computeLocalToWorldMatrix(Matrix& matrix,const Transform* transform, NodeVisitor* nv) const = 0; - - /** Get the transformation matrix which moves from world coords - * to local coords.*/ - virtual bool computeWorldToLocalMatrix(Matrix& matrix,const Transform* transform, NodeVisitor* nv) const = 0; - }; - - /** Set the ComputerTransfromCallback which allows users to attach - * custom computation of the local transformation as seen by cull - * traversers and the like. */ - void setComputeTransformCallback(ComputeTransformCallback* ctc) { _computeTransformCallback=ctc; dirtyBound(); } - - /** Get the non const ComputerTransfromCallback.*/ - ComputeTransformCallback* getComputeTransformCallback() { return _computeTransformCallback.get(); } - - /** Get the const ComputerTransfromCallback.*/ - const ComputeTransformCallback* getComputeTransformCallback() const { return _computeTransformCallback.get(); } - - - /** Get the transformation matrix which moves from local coords to - * world coords. - * Returns true if the Matrix passed in has been updated. */ - inline bool getLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const - { - if (_computeTransformCallback.valid()) - return _computeTransformCallback->computeLocalToWorldMatrix(matrix,this,nv); - else - return computeLocalToWorldMatrix(matrix,nv); - } - - /** Get the transformation matrix which moves from world coords to - * local coords. - * Return true if the Matrix passed in has been updated. */ - inline bool getWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const - { - if (_computeTransformCallback.valid()) - return _computeTransformCallback->computeWorldToLocalMatrix(matrix,this,nv); - else - return computeWorldToLocalMatrix(matrix,nv); - } - virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const { if (_referenceFrame==RELATIVE_TO_PARENTS) @@ -190,9 +141,6 @@ class SG_EXPORT Transform : public Group * computeMatrix if required.) */ virtual bool computeBound() const; - - ref_ptr _computeTransformCallback; - ReferenceFrame _referenceFrame; }; diff --git a/src/osg/CollectOccludersVisitor.cpp b/src/osg/CollectOccludersVisitor.cpp index 75c5e0ae3..6dd2489f3 100644 --- a/src/osg/CollectOccludersVisitor.cpp +++ b/src/osg/CollectOccludersVisitor.cpp @@ -80,7 +80,7 @@ void CollectOccludersVisitor::apply(osg::Transform& node) pushCurrentMask(); ref_ptr matrix = createOrReuseMatrix(getModelViewMatrix()); - node.getLocalToWorldMatrix(*matrix,this); + node.computeLocalToWorldMatrix(*matrix,this); pushModelViewMatrix(matrix.get()); handle_cull_callbacks_and_traverse(node); diff --git a/src/osg/Transform.cpp b/src/osg/Transform.cpp index 2dbb47d82..7caeea81f 100644 --- a/src/osg/Transform.cpp +++ b/src/osg/Transform.cpp @@ -38,11 +38,11 @@ class TransformVisitor : public NodeVisitor { if (_coordMode==LOCAL_TO_WORLD) { - transform.getLocalToWorldMatrix(_matrix,this); + transform.computeLocalToWorldMatrix(_matrix,this); } else // worldToLocal { - transform.getWorldToLocalMatrix(_matrix,this); + transform.computeWorldToLocalMatrix(_matrix,this); } } @@ -95,12 +95,6 @@ Matrix osg::computeEyeToLocal(const Matrix& modelview,NodePath& nodePath) - - - - - - Transform::Transform() { _referenceFrame = RELATIVE_TO_PARENTS; @@ -108,7 +102,6 @@ Transform::Transform() Transform::Transform(const Transform& transform,const CopyOp& copyop): Group(transform,copyop), - _computeTransformCallback(transform._computeTransformCallback), _referenceFrame(transform._referenceFrame) { } @@ -136,7 +129,7 @@ bool Transform::computeBound() const // to handle this case gracefully, normally this should not be a problem. Matrix l2w; - getLocalToWorldMatrix(l2w,NULL); + computeLocalToWorldMatrix(l2w,NULL); Vec3 xdash = _bsphere._center; xdash.x() += _bsphere._radius; diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index ea39c0381..8871070f6 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -393,7 +393,7 @@ void CullVisitor::apply(Billboard& node) RefMatrix* billboard_matrix = createOrReuseMatrix(modelview); - node.getMatrix(*billboard_matrix,eye_local,pos); + node.computeMatrix(*billboard_matrix,eye_local,pos); float d = distance(pos,modelview); @@ -499,7 +499,7 @@ void CullVisitor::apply(Transform& node) if (node_state) pushStateSet(node_state); ref_ptr matrix = createOrReuseMatrix(getModelViewMatrix()); - node.getLocalToWorldMatrix(*matrix,this); + node.computeLocalToWorldMatrix(*matrix,this); pushModelViewMatrix(matrix.get()); handle_cull_callbacks_and_traverse(node); diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index 0bbd024bf..286393c91 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -593,7 +593,7 @@ void IntersectVisitor::apply(Transform& node) if (!enterNode(node)) return; osg::ref_ptr matrix = new RefMatrix; - node.getLocalToWorldMatrix(*matrix,this); + node.computeLocalToWorldMatrix(*matrix,this); pushMatrix(*matrix); diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index c4ea2b3c0..b04cbfe9b 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -525,11 +525,11 @@ class CollectLowestTransformsVisitor : public osg::NodeVisitor else if (transform->getReferenceFrame()==osg::Transform::RELATIVE_TO_ABSOLUTE) _moreThanOneMatrixRequired=true; else { - if (_transformSet.empty()) transform->getLocalToWorldMatrix(_firstMatrix,0); + if (_transformSet.empty()) transform->computeLocalToWorldMatrix(_firstMatrix,0); else { osg::Matrix matrix; - transform->getLocalToWorldMatrix(_firstMatrix,0); + transform->computeLocalToWorldMatrix(_firstMatrix,0); if (_firstMatrix!=matrix) _moreThanOneMatrixRequired=true; } } @@ -1029,7 +1029,7 @@ void Optimizer::RemoveRedundantNodesVisitor::apply(osg::Transform& transform) { static osg::Matrix identity; osg::Matrix matrix; - transform.getWorldToLocalMatrix(matrix,NULL); + transform.computeWorldToLocalMatrix(matrix,NULL); if (matrix==identity) { _redundantNodeList.insert(&transform);