From Kristofer Tingdahl, reimplement of AntiSquish node to avoid the use of an update callback.

From Robert Osfield, small ammendments to clean up header.
This commit is contained in:
Robert Osfield
2014-01-20 11:00:09 +00:00
parent 6246cd5d85
commit 15399bbf35
2 changed files with 110 additions and 100 deletions

View File

@@ -17,20 +17,15 @@
#include <osgManipulator/Export>
#include <osg/Matrix>
#include <osg/CopyOp>
#include <osg/NodeVisitor>
#include <osg/NodeCallback>
#include <osg/MatrixTransform>
#include <osg/Quat>
#include <osg/Vec3>
#include <osg/Transform>
#include <OpenThreads/Mutex>
namespace osgManipulator {
/**
* Class that performs the Anti Squish by making the scaling uniform along all axes.
*/
class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform
class OSGMANIPULATOR_EXPORT AntiSquish: public osg::Transform
{
public :
AntiSquish();
@@ -48,7 +43,7 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform
{
_pivot = pvt;
_usePivot = true;
_dirty = true;
_cacheDirty = true;
}
const osg::Vec3d& getPivot() const { return _pivot; }
@@ -57,18 +52,19 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform
{
_position = pos;
_usePosition = true;
_dirty = true;
_cacheDirty = true;
}
const osg::Vec3d& getPosition() const { return _position; }
osg::Matrix computeUnSquishedMatrix(const osg::Matrix&, bool& flag);
bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const;
bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const;
protected:
virtual ~AntiSquish();
osg::NodeCallback* _asqCallback;
bool computeUnSquishedMatrix(const osg::NodeVisitor*,osg::Matrix&) const;
osg::Vec3d _pivot;
bool _usePivot;
@@ -76,8 +72,10 @@ class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform
osg::Vec3d _position;
bool _usePosition;
bool _dirty;
osg::Matrix _cachedLocalToWorld;
mutable OpenThreads::Mutex _cacheLock;
mutable bool _cacheDirty;
mutable osg::Matrix _cacheLocalToWorld;
mutable osg::Matrix _cache;
};
}