diff --git a/include/osg/Matrixd b/include/osg/Matrixd index 0bb3a6a98..cb0f8f2da 100644 --- a/include/osg/Matrixd +++ b/include/osg/Matrixd @@ -339,15 +339,16 @@ class RefMatrixd : public Object, public Matrixd { public: - RefMatrixd():Matrixd() {} - RefMatrixd( const Matrixd& other) : Matrixd(other) {} - RefMatrixd( const Matrixf& other) : Matrixd(other) {} + RefMatrixd():Object(false), Matrixd() {} + RefMatrixd( const Matrixd& other) : Object(false), Matrixd(other) {} + RefMatrixd( const Matrixf& other) : Object(false), Matrixd(other) {} RefMatrixd( const RefMatrixd& other) : Object(other), Matrixd(other) {} - explicit RefMatrixd( Matrixd::value_type const * const def ):Matrixd(def) {} + explicit RefMatrixd( Matrixd::value_type const * const def ):Object(false), Matrixd(def) {} RefMatrixd( Matrixd::value_type a00, Matrixd::value_type a01, Matrixd::value_type a02, Matrixd::value_type a03, Matrixd::value_type a10, Matrixd::value_type a11, Matrixd::value_type a12, Matrixd::value_type a13, Matrixd::value_type a20, Matrixd::value_type a21, Matrixd::value_type a22, Matrixd::value_type a23, Matrixd::value_type a30, Matrixd::value_type a31, Matrixd::value_type a32, Matrixd::value_type a33): + Object(false), Matrixd(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, diff --git a/include/osg/Matrixf b/include/osg/Matrixf index 1d11b3aec..16842acef 100644 --- a/include/osg/Matrixf +++ b/include/osg/Matrixf @@ -340,15 +340,16 @@ class RefMatrixf : public Object, public Matrixf { public: - RefMatrixf():Matrixf() {} - RefMatrixf( const Matrixf& other) : Matrixf(other) {} - RefMatrixf( const Matrixd& other) : Matrixf(other) {} + RefMatrixf():Object(false), Matrixf() {} + RefMatrixf( const Matrixf& other) : Object(false), Matrixf(other) {} + RefMatrixf( const Matrixd& other) : Object(false), Matrixf(other) {} RefMatrixf( const RefMatrixf& other) : Object(other), Matrixf(other) {} - explicit RefMatrixf( Matrixf::value_type const * const def ):Matrixf(def) {} + explicit RefMatrixf( Matrixf::value_type const * const def ):Object(false), Matrixf(def) {} RefMatrixf( Matrixf::value_type a00, Matrixf::value_type a01, Matrixf::value_type a02, Matrixf::value_type a03, Matrixf::value_type a10, Matrixf::value_type a11, Matrixf::value_type a12, Matrixf::value_type a13, Matrixf::value_type a20, Matrixf::value_type a21, Matrixf::value_type a22, Matrixf::value_type a23, Matrixf::value_type a30, Matrixf::value_type a31, Matrixf::value_type a32, Matrixf::value_type a33): + Object(false), Matrixf(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, diff --git a/include/osg/Object b/include/osg/Object index 4816df540..47db0741f 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -52,6 +52,8 @@ class OSG_EXPORT Object : public Referenced concrete classes and can be constructed.*/ inline Object():Referenced(),_dataVariance(DYNAMIC) {} + inline explicit Object(bool threadSafeRefUnref):Referenced(threadSafeRefUnref),_dataVariance(DYNAMIC) {} + /** Copy constructor, optional CopyOp object can be used to control * shallow vs deep copying of dynamic data.*/ Object(const Object&,const CopyOp& copyop=CopyOp::SHALLOW_COPY); diff --git a/include/osg/Referenced b/include/osg/Referenced index fb69c7db7..174c7d6d5 100644 --- a/include/osg/Referenced +++ b/include/osg/Referenced @@ -46,6 +46,8 @@ class OSG_EXPORT Referenced Referenced(); + explicit Referenced(bool threadSafeRefUnref); + Referenced(const Referenced&); inline Referenced& operator = (const Referenced&) { return *this; } diff --git a/include/osgUtil/RenderLeaf b/include/osgUtil/RenderLeaf index cc0851269..636d17b09 100644 --- a/include/osgUtil/RenderLeaf +++ b/include/osgUtil/RenderLeaf @@ -34,6 +34,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f): + osg::Referenced(false), _parent(0), _drawable(drawable), _projection(projection), @@ -76,6 +77,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced /// disallow creation of blank RenderLeaf as this isn't useful. RenderLeaf(): + osg::Referenced(false), _parent(0), _drawable(0), _projection(0), @@ -83,7 +85,7 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced _depth(0.0f) {} /// disallow copy construction. - RenderLeaf(const RenderLeaf&):osg::Referenced() {} + RenderLeaf(const RenderLeaf&):osg::Referenced(false) {} /// disallow copy operator. RenderLeaf& operator = (const RenderLeaf&) { return *this; } diff --git a/include/osgUtil/StateGraph b/include/osgUtil/StateGraph index 01d068e76..7b82322ed 100644 --- a/include/osgUtil/StateGraph +++ b/include/osgUtil/StateGraph @@ -60,6 +60,7 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced StateGraph(): + osg::Referenced(false), _parent(NULL), _stateset(NULL), _depth(0), @@ -70,6 +71,7 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced } StateGraph(StateGraph* parent,const osg::StateSet* stateset): + osg::Referenced(false), _parent(parent), _stateset(stateset), _depth(0), diff --git a/src/osg/Referenced.cpp b/src/osg/Referenced.cpp index 013599472..671bf2cb2 100644 --- a/src/osg/Referenced.cpp +++ b/src/osg/Referenced.cpp @@ -62,6 +62,14 @@ Referenced::Referenced(): if (s_useThreadSafeReferenceCounting) _refMutex = new OpenThreads::Mutex; } +Referenced::Referenced(bool threadSafeRefUnref): + _refMutex(0), + _refCount(0), + _observers(0) +{ + if (threadSafeRefUnref) _refMutex = new OpenThreads::Mutex; +} + Referenced::Referenced(const Referenced&): _refMutex(0), _refCount(0), diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 69614387b..31ff43271 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -992,7 +992,7 @@ void CullVisitor::apply(Projection& node) _computed_zfar = -FLT_MAX; - ref_ptr matrix = createOrReuseMatrix(node.getMatrix()); + ref_ptr matrix = createOrReuseMatrix(node.getMatrix()); pushProjectionMatrix(matrix.get()); //osg::notify(osg::INFO)<<"Push projection "<<*matrix<