Refactored AutoTransform so that it dynamically computes the rotation, scale and matrices during the cull traversal to enable usage in multi-view, multi-threaded applications
This commit is contained in:
@@ -37,16 +37,14 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
virtual const char* className() const { return "AutoTransform"; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
|
||||
virtual void accept(NodeVisitor& nv);
|
||||
|
||||
virtual AutoTransform* asAutoTransform() { return this; }
|
||||
virtual const AutoTransform* asAutoTransform() const { return this; }
|
||||
|
||||
inline void setPosition(const Vec3d& pos) { _position = pos; _matrixDirty=true; dirtyBound(); }
|
||||
inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); }
|
||||
inline const Vec3d& getPosition() const { return _position; }
|
||||
|
||||
|
||||
inline void setRotation(const Quat& quat) { _rotation = quat; _matrixDirty=true; dirtyBound(); }
|
||||
inline void setRotation(const Quat& quat) { _rotation = quat; dirtyBound(); }
|
||||
inline const Quat& getRotation() const { return _rotation; }
|
||||
|
||||
inline void setScale(double scale) { setScale(osg::Vec3(scale,scale,scale)); }
|
||||
@@ -60,7 +58,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
void setMaximumScale(double maximumScale) { _maximumScale = maximumScale; }
|
||||
double getMaximumScale() const { return _maximumScale; }
|
||||
|
||||
inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); }
|
||||
inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; dirtyBound(); }
|
||||
inline const Vec3d& getPivotPoint() const { return _pivotPoint; }
|
||||
|
||||
|
||||
@@ -91,7 +89,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
/** Get the front face direction normal. */
|
||||
inline const Vec3& getNormal() const { return _normal; }
|
||||
|
||||
void setAutoScaleToScreen(bool autoScaleToScreen) { _autoScaleToScreen = autoScaleToScreen; _matrixDirty=true; }
|
||||
void setAutoScaleToScreen(bool autoScaleToScreen) { _autoScaleToScreen = autoScaleToScreen; }
|
||||
|
||||
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
|
||||
|
||||
@@ -120,21 +118,14 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
|
||||
mutable Quat _rotation;
|
||||
mutable Vec3d _scale;
|
||||
mutable bool _firstTimeToInitEyePoint;
|
||||
mutable osg::Vec3 _previousEyePoint;
|
||||
mutable osg::Vec3 _previousLocalUp;
|
||||
mutable Viewport::value_type _previousWidth;
|
||||
mutable Viewport::value_type _previousHeight;
|
||||
mutable osg::Matrixd _previousProjection;
|
||||
mutable osg::Vec3d _previousPosition;
|
||||
|
||||
double _minimumScale;
|
||||
double _maximumScale;
|
||||
double _autoScaleTransitionWidthRatio;
|
||||
|
||||
void computeMatrix() const;
|
||||
osg::Matrixd computeMatrix(const osg::NodeVisitor* nv) const;
|
||||
|
||||
mutable bool _matrixDirty;
|
||||
mutable bool _matrixInitalized;
|
||||
mutable osg::Matrixd _cachedMatrix;
|
||||
|
||||
enum AxisAligned
|
||||
|
||||
@@ -143,8 +143,14 @@ class OSG_EXPORT CullStack : public osg::CullSettings
|
||||
inline const CullingSet& getCurrentCullingSet() const { return *_back_modelviewCullingStack; }
|
||||
|
||||
inline osg::Viewport* getViewport();
|
||||
inline const osg::Viewport* getViewport() const;
|
||||
|
||||
inline osg::RefMatrix* getModelViewMatrix();
|
||||
inline const osg::RefMatrix* getModelViewMatrix() const;
|
||||
|
||||
inline osg::RefMatrix* getProjectionMatrix();
|
||||
inline const osg::RefMatrix* getProjectionMatrix() const;
|
||||
|
||||
inline osg::Matrix getWindowMatrix() const;
|
||||
inline const osg::RefMatrix* getMVPW();
|
||||
|
||||
@@ -224,38 +230,32 @@ class OSG_EXPORT CullStack : public osg::CullSettings
|
||||
|
||||
inline osg::Viewport* CullStack::getViewport()
|
||||
{
|
||||
if (!_viewportStack.empty())
|
||||
{
|
||||
return _viewportStack.back().get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
return _viewportStack.empty() ? 0 : _viewportStack.back().get();
|
||||
}
|
||||
|
||||
inline const osg::Viewport* CullStack::getViewport() const
|
||||
{
|
||||
return _viewportStack.empty() ? 0 : _viewportStack.back().get();
|
||||
}
|
||||
|
||||
inline osg::RefMatrix* CullStack::getModelViewMatrix()
|
||||
{
|
||||
if (!_modelviewStack.empty())
|
||||
{
|
||||
return _modelviewStack.back().get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity.get();
|
||||
}
|
||||
return _modelviewStack.empty() ? _identity.get() : _modelviewStack.back().get();
|
||||
}
|
||||
|
||||
inline const osg::RefMatrix* CullStack::getModelViewMatrix() const
|
||||
{
|
||||
return _modelviewStack.empty() ? _identity.get() : _modelviewStack.back().get();
|
||||
}
|
||||
|
||||
inline osg::RefMatrix* CullStack::getProjectionMatrix()
|
||||
{
|
||||
if (!_projectionStack.empty())
|
||||
{
|
||||
return _projectionStack.back().get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity.get();
|
||||
}
|
||||
return _projectionStack.empty() ? _identity.get() : _projectionStack.back().get();
|
||||
}
|
||||
|
||||
inline const osg::RefMatrix* CullStack::getProjectionMatrix() const
|
||||
{
|
||||
return _projectionStack.empty() ? _identity.get() : _projectionStack.back().get();
|
||||
}
|
||||
|
||||
inline osg::Matrix CullStack::getWindowMatrix() const
|
||||
|
||||
Reference in New Issue
Block a user