Made the more of the OSG's referenced object desctructors protected to ensure

that they arn't created on the stack inappropriately.

Split the implemention of Matrix up so that it is a simple no referenced counted
class and can be safefly created on the stack.  To support referenced counting a
seperate subclass now exists, this is RefMatrix which inherits from both Matrix and
Object.
This commit is contained in:
Robert Osfield
2003-01-10 09:25:42 +00:00
parent f948a3de7c
commit f36bc69c58
53 changed files with 446 additions and 441 deletions

View File

@@ -187,16 +187,16 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
void updateCalculatedNearFar(const osg::Vec3& pos);
/** Add a drawable to current render graph.*/
inline void addDrawable(osg::Drawable* drawable,osg::Matrix* matrix);
inline void addDrawable(osg::Drawable* drawable,osg::RefMatrix* matrix);
/** Add a drawable and depth to current render graph.*/
inline void addDrawableAndDepth(osg::Drawable* drawable,osg::Matrix* matrix,float depth);
inline void addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth);
/** Add an attribute which is positioned related to the modelview matrix.*/
inline void addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr);
inline void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr);
/** reimplement CullStack's popProjectionMatrix() adding clamping of the projection matrix to the computed near and far.*/
void popProjectionMatrix();
virtual void popProjectionMatrix();
void setState(osg::State* state) { _state = state; }
osg::State* getState() { return _state.get(); }
@@ -252,7 +252,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
RenderLeafList _reuseRenderLeafList;
unsigned int _currentReuseRenderLeafIndex;
inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::Matrix* projection,osg::Matrix* matrix, float depth=0.0f);
inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth=0.0f);
osg::ref_ptr<osg::ImpostorSpriteManager> _impostorSpriteManager;
@@ -260,7 +260,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
};
inline void CullVisitor::addDrawable(osg::Drawable* drawable,osg::Matrix* matrix)
inline void CullVisitor::addDrawable(osg::Drawable* drawable,osg::RefMatrix* matrix)
{
if (_currentRenderGraph->leaves_empty())
{
@@ -274,7 +274,7 @@ inline void CullVisitor::addDrawable(osg::Drawable* drawable,osg::Matrix* matrix
}
/** Add a drawable and depth to current render graph.*/
inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::Matrix* matrix,float depth)
inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth)
{
if (_currentRenderGraph->leaves_empty())
{
@@ -288,12 +288,12 @@ inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::Matrix
}
/** Add an attribute which is positioned related to the modelview matrix.*/
inline void CullVisitor::addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr)
inline void CullVisitor::addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
{
_currentRenderBin->_stage->addPositionedAttribute(matrix,attr);
}
inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,osg::Matrix* projection,osg::Matrix* matrix, float depth)
inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth)
{
// skip of any already reused renderleaf.
while (_currentReuseRenderLeafIndex<_reuseRenderLeafList.size() &&

View File

@@ -51,8 +51,8 @@ class OSGUTIL_EXPORT Hit
osg::NodePath _nodePath;
osg::ref_ptr<osg::Geode> _geode;
osg::ref_ptr<osg::Drawable> _drawable;
osg::ref_ptr<osg::Matrix> _matrix;
osg::ref_ptr<osg::Matrix> _inverse;
osg::ref_ptr<osg::RefMatrix> _matrix;
osg::ref_ptr<osg::RefMatrix> _inverse;
VecIndexList _vecIndexList;
int _primitiveIndex;
@@ -102,8 +102,8 @@ class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor
IntersectState();
osg::ref_ptr<osg::Matrix> _matrix;
osg::ref_ptr<osg::Matrix> _inverse;
osg::ref_ptr<osg::RefMatrix> _matrix;
osg::ref_ptr<osg::RefMatrix> _inverse;
typedef std::pair<osg::ref_ptr<osg::LineSegment>,osg::ref_ptr<osg::LineSegment> > LineSegmentPair;
typedef std::vector< LineSegmentPair > LineSegmentList;

View File

@@ -24,17 +24,17 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
public:
inline RenderLeaf(osg::Drawable* drawable,osg::Matrix* projection,osg::Matrix* modelview, float depth=0.0f):
_parent(NULL),
inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f):
_parent(0),
_drawable(drawable),
_projection(projection),
_modelview(modelview),
_depth(depth) {}
inline void set(osg::Drawable* drawable,osg::Matrix* projection,osg::Matrix* modelview, float depth=0.0f)
inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f)
{
_parent = NULL;
_parent = 0;
_drawable = drawable;
_projection = projection,
_modelview = modelview,
@@ -43,10 +43,10 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
inline void reset()
{
_parent = NULL;
_drawable = NULL;
_projection = NULL;
_modelview = NULL;
_parent = 0;
_drawable = 0;
_projection = 0;
_modelview = 0;
_depth = 0.0f;
}
@@ -58,20 +58,20 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
public:
RenderGraph* _parent;
osg::Drawable* _drawable;
osg::ref_ptr<osg::Matrix> _projection;
osg::ref_ptr<osg::Matrix> _modelview;
float _depth;
RenderGraph* _parent;
osg::Drawable* _drawable;
osg::ref_ptr<osg::RefMatrix> _projection;
osg::ref_ptr<osg::RefMatrix> _modelview;
float _depth;
private:
/// disallow creation of blank RenderLeaf as this isn't useful.
RenderLeaf():
_parent(NULL),
_drawable(NULL),
_projection(NULL),
_modelview(NULL),
_parent(0),
_drawable(0),
_projection(0),
_modelview(0),
_depth(0.0f) {}
/// disallow copy construction.

View File

@@ -103,7 +103,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
return _renderStageLighting.get();
}
virtual void addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr)
virtual void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
{
getRenderStageLighting()->addPositionedAttribute(matrix,attr);
}

View File

@@ -31,10 +31,10 @@ class OSGUTIL_EXPORT RenderStageLighting : public osg::Object
virtual void reset();
typedef std::pair< const osg::StateAttribute*, osg::ref_ptr<osg::Matrix> > AttrMatrixPair;
typedef std::pair< const osg::StateAttribute*, osg::ref_ptr<osg::RefMatrix> > AttrMatrixPair;
typedef std::vector< AttrMatrixPair > AttrMatrixList;
virtual void addPositionedAttribute(osg::Matrix* matrix,const osg::StateAttribute* attr)
virtual void addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr)
{
_attrList.push_back(AttrMatrixPair(attr,matrix));
}

View File

@@ -126,14 +126,14 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
const osg::Camera* getCamera() const { return _camera.get(); }
/** set a projection matrix. Note, this will override a camera's projection matrix if it is not NULL.*/
void setProjectionMatrix(osg::Matrix* matrix) { _projectionMatrix = matrix; }
osg::Matrix* getProjectionMatrix() { return _projectionMatrix.get(); }
const osg::Matrix* getProjectionMatrix() const { return _projectionMatrix.get(); }
void setProjectionMatrix(osg::RefMatrix* matrix) { _projectionMatrix = matrix; }
osg::RefMatrix* getProjectionMatrix() { return _projectionMatrix.get(); }
const osg::RefMatrix* getProjectionMatrix() const { return _projectionMatrix.get(); }
/** set a modelview matrix. Note, this will override a camera's modelview matrix if it is not NULL.*/
void setModelViewMatrix(osg::Matrix* matrix) { _modelviewMatrix = matrix; }
osg::Matrix* getModelViewMatrix() { return _modelviewMatrix.get(); }
const osg::Matrix* getModelViewMatrix() const { return _modelviewMatrix.get(); }
void setModelViewMatrix(osg::RefMatrix* matrix) { _modelviewMatrix = matrix; }
osg::RefMatrix* getModelViewMatrix() { return _modelviewMatrix.get(); }
const osg::RefMatrix* getModelViewMatrix() const { return _modelviewMatrix.get(); }
void setInitVisitor(osg::NodeVisitor* av) { _initVisitor = av; }
@@ -283,7 +283,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
virtual ~SceneView();
/** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
virtual void cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage);
virtual void cullStage(osg::RefMatrix* projection,osg::RefMatrix* modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage);
const osg::Matrix computeMVPW() const;
@@ -293,8 +293,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
osg::ref_ptr<osg::StateSet> _globalState;
osg::ref_ptr<osg::Light> _light;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Matrix> _projectionMatrix;
osg::ref_ptr<osg::Matrix> _modelviewMatrix;
osg::ref_ptr<osg::RefMatrix> _projectionMatrix;
osg::ref_ptr<osg::RefMatrix> _modelviewMatrix;
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
osg::ref_ptr<osg::State> _state;