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:
@@ -182,6 +182,11 @@ class SG_EXPORT AnimationPathCallback : public NodeCallback
|
||||
double _timeMultiplier;
|
||||
double _firstTime;
|
||||
mutable double _animationTime;
|
||||
|
||||
protected:
|
||||
|
||||
~AnimationPathCallback(){}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
|
||||
Camera(const Camera&);
|
||||
Camera& operator=(const Camera&);
|
||||
virtual ~Camera();
|
||||
|
||||
/** Range of projection types.
|
||||
* ORTHO2D is a special case of ORTHO where the near and far planes
|
||||
@@ -217,7 +216,7 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
* basic LookAt values.
|
||||
* note: Camera internals maintains the both EYE_TO_MODEL and MODEL_TO_EYE
|
||||
* internally and ensures that they are the inverse of one another.*/
|
||||
void attachTransform(TransformMode mode, Matrix* modelTransform=0);
|
||||
void attachTransform(TransformMode mode, RefMatrix* modelTransform=0);
|
||||
|
||||
Matrix* getTransform(TransformMode mode);
|
||||
|
||||
@@ -287,6 +286,8 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Camera();
|
||||
|
||||
void copy(const Camera&);
|
||||
|
||||
// projection details.
|
||||
@@ -314,9 +315,9 @@ class SG_EXPORT Camera: public osg::Referenced
|
||||
Vec3 _center;
|
||||
Vec3 _up;
|
||||
|
||||
TransformMode _attachedTransformMode;
|
||||
ref_ptr<Matrix> _eyeToModelTransform;
|
||||
ref_ptr<Matrix> _modelToEyeTransform;
|
||||
TransformMode _attachedTransformMode;
|
||||
ref_ptr<RefMatrix> _eyeToModelTransform;
|
||||
ref_ptr<RefMatrix> _modelToEyeTransform;
|
||||
|
||||
float _screenDistance;
|
||||
|
||||
|
||||
@@ -51,10 +51,10 @@ class SG_EXPORT CullStack
|
||||
void pushViewport(osg::Viewport* viewport);
|
||||
void popViewport();
|
||||
|
||||
void pushProjectionMatrix(osg::Matrix* matrix);
|
||||
void pushProjectionMatrix(osg::RefMatrix* matrix);
|
||||
void popProjectionMatrix();
|
||||
|
||||
void pushModelViewMatrix(osg::Matrix* matrix);
|
||||
void pushModelViewMatrix(osg::RefMatrix* matrix);
|
||||
void popModelViewMatrix();
|
||||
|
||||
inline float getFrustumVolume() { if (_frustumVolume<0.0f) computeFrustumVolume(); return _frustumVolume; }
|
||||
@@ -138,10 +138,10 @@ class SG_EXPORT CullStack
|
||||
|
||||
|
||||
inline osg::Viewport* getViewport();
|
||||
inline osg::Matrix& getModelViewMatrix();
|
||||
inline osg::Matrix& getProjectionMatrix();
|
||||
inline osg::RefMatrix& getModelViewMatrix();
|
||||
inline osg::RefMatrix& getProjectionMatrix();
|
||||
inline osg::Matrix getWindowMatrix();
|
||||
inline const osg::Matrix& getMVPW();
|
||||
inline const osg::RefMatrix& getMVPW();
|
||||
|
||||
inline const osg::Vec3& getEyeLocal() const { return _eyePointStack.back(); }
|
||||
|
||||
@@ -169,7 +169,7 @@ class SG_EXPORT CullStack
|
||||
// base set of shadow volume occluder to use in culling.
|
||||
ShadowVolumeOccluderList _occluderList;
|
||||
|
||||
typedef fast_back_stack< ref_ptr<Matrix> > MatrixStack;
|
||||
typedef fast_back_stack< ref_ptr<RefMatrix> > MatrixStack;
|
||||
|
||||
MatrixStack _projectionStack;
|
||||
|
||||
@@ -192,13 +192,13 @@ class SG_EXPORT CullStack
|
||||
unsigned int _bbCornerNear;
|
||||
unsigned int _bbCornerFar;
|
||||
|
||||
osg::Matrix _identity;
|
||||
ref_ptr<osg::RefMatrix> _identity;
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Matrix> > MatrixList;
|
||||
typedef std::vector< osg::ref_ptr<osg::RefMatrix> > MatrixList;
|
||||
MatrixList _reuseMatrixList;
|
||||
unsigned int _currentReuseMatrixIndex;
|
||||
|
||||
inline osg::Matrix* createOrReuseMatrix(const osg::Matrix& value);
|
||||
inline osg::RefMatrix* createOrReuseMatrix(const osg::Matrix& value);
|
||||
|
||||
|
||||
};
|
||||
@@ -215,7 +215,7 @@ inline osg::Viewport* CullStack::getViewport()
|
||||
}
|
||||
}
|
||||
|
||||
inline osg::Matrix& CullStack::getModelViewMatrix()
|
||||
inline osg::RefMatrix& CullStack::getModelViewMatrix()
|
||||
{
|
||||
if (!_modelviewStack.empty())
|
||||
{
|
||||
@@ -223,11 +223,11 @@ inline osg::Matrix& CullStack::getModelViewMatrix()
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity;
|
||||
return *_identity;
|
||||
}
|
||||
}
|
||||
|
||||
inline osg::Matrix& CullStack::getProjectionMatrix()
|
||||
inline osg::RefMatrix& CullStack::getProjectionMatrix()
|
||||
{
|
||||
if (!_projectionStack.empty())
|
||||
{
|
||||
@@ -235,7 +235,7 @@ inline osg::Matrix& CullStack::getProjectionMatrix()
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity;
|
||||
return *_identity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,11 +248,11 @@ inline osg::Matrix CullStack::getWindowMatrix()
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity;
|
||||
return *_identity;
|
||||
}
|
||||
}
|
||||
|
||||
inline const osg::Matrix& CullStack::getMVPW()
|
||||
inline const osg::RefMatrix& CullStack::getMVPW()
|
||||
{
|
||||
if (!_MVPW_Stack.empty())
|
||||
{
|
||||
@@ -266,11 +266,11 @@ inline const osg::Matrix& CullStack::getMVPW()
|
||||
}
|
||||
else
|
||||
{
|
||||
return _identity;
|
||||
return *_identity;
|
||||
}
|
||||
}
|
||||
|
||||
inline Matrix* CullStack::createOrReuseMatrix(const osg::Matrix& value)
|
||||
inline RefMatrix* CullStack::createOrReuseMatrix(const osg::Matrix& value)
|
||||
{
|
||||
// skip of any already reused matrix.
|
||||
while (_currentReuseMatrixIndex<_reuseMatrixList.size() &&
|
||||
@@ -284,13 +284,13 @@ inline Matrix* CullStack::createOrReuseMatrix(const osg::Matrix& value)
|
||||
// there return it to be reused.
|
||||
if (_currentReuseMatrixIndex<_reuseMatrixList.size())
|
||||
{
|
||||
Matrix* matrix = _reuseMatrixList[_currentReuseMatrixIndex++].get();
|
||||
RefMatrix* matrix = _reuseMatrixList[_currentReuseMatrixIndex++].get();
|
||||
matrix->set(value);
|
||||
return matrix;
|
||||
}
|
||||
|
||||
// otherwise need to create new matrix.
|
||||
osg::Matrix* matrix = new Matrix(value);
|
||||
osg::RefMatrix* matrix = new RefMatrix(value);
|
||||
_reuseMatrixList.push_back(matrix);
|
||||
++_currentReuseMatrixIndex;
|
||||
return matrix;
|
||||
|
||||
@@ -35,8 +35,6 @@ class SG_EXPORT CullingSet : public Referenced
|
||||
}
|
||||
}
|
||||
|
||||
~CullingSet();
|
||||
|
||||
typedef std::vector<ShadowVolumeOccluder> OccluderList;
|
||||
|
||||
typedef unsigned int Mask;
|
||||
@@ -202,6 +200,8 @@ class SG_EXPORT CullingSet : public Referenced
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~CullingSet();
|
||||
|
||||
Mask _mask;
|
||||
Polytope _frustum;
|
||||
OccluderList _occluderList;
|
||||
|
||||
@@ -107,6 +107,7 @@ class SG_EXPORT DOFTransform : public Transform
|
||||
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DOFTransform() {}
|
||||
|
||||
Vec3 _minHPR;
|
||||
|
||||
@@ -38,9 +38,6 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
DisplaySettings(const DisplaySettings& vs);
|
||||
|
||||
virtual ~DisplaySettings();
|
||||
|
||||
|
||||
|
||||
DisplaySettings& operator = (const DisplaySettings& vs);
|
||||
|
||||
@@ -135,6 +132,8 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DisplaySettings();
|
||||
|
||||
void copy(const DisplaySettings& vs);
|
||||
|
||||
bool _stereo;
|
||||
|
||||
@@ -28,7 +28,6 @@ class SG_EXPORT FrameStamp : public Referenced
|
||||
|
||||
FrameStamp();
|
||||
FrameStamp(const FrameStamp& fs);
|
||||
~FrameStamp();
|
||||
|
||||
FrameStamp& operator = (const FrameStamp& fs);
|
||||
|
||||
@@ -40,9 +39,14 @@ class SG_EXPORT FrameStamp : public Referenced
|
||||
|
||||
void setCalendarTime(const tm& calendarTime);
|
||||
void getCalendarTime(tm& calendarTime) const;
|
||||
|
||||
|
||||
// keep public to allow it to be permit allocation which is
|
||||
// not on the heap used osgcluster
|
||||
virtual ~FrameStamp();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// note no dynamic memory is used so that data can be passed
|
||||
// via a simple memory copy or within a data packet across
|
||||
// the network.
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace osg {
|
||||
|
||||
class Quat;
|
||||
|
||||
class SG_EXPORT Matrix : public Object
|
||||
class SG_EXPORT Matrix
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -31,15 +31,7 @@ class SG_EXPORT Matrix : public Object
|
||||
float a20, float a21, float a22, float a23,
|
||||
float a30, float a31, float a32, float a33);
|
||||
|
||||
virtual Object* cloneType() const { return new Matrix(); } \
|
||||
virtual Object* clone(const CopyOp&) const { return new Matrix(*this); } \
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Matrix*>(obj)!=NULL; } \
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "Matrix"; }
|
||||
|
||||
virtual ~Matrix() {}
|
||||
|
||||
|
||||
~Matrix() {}
|
||||
|
||||
int compare(const Matrix& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
|
||||
|
||||
@@ -238,6 +230,36 @@ class SG_EXPORT Matrix : public Object
|
||||
|
||||
};
|
||||
|
||||
class RefMatrix : public Object, public Matrix
|
||||
{
|
||||
public:
|
||||
|
||||
RefMatrix():Matrix() {}
|
||||
RefMatrix( const Matrix& other) : Matrix(other) {}
|
||||
RefMatrix( const RefMatrix& other) : Object(other), Matrix(other) {}
|
||||
explicit RefMatrix( float const * const def ):Matrix(def) {}
|
||||
RefMatrix( float a00, float a01, float a02, float a03,
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23,
|
||||
float a30, float a31, float a32, float a33):
|
||||
Matrix(a00, a01, a02, a03,
|
||||
a10, a11, a12, a13,
|
||||
a20, a21, a22, a23,
|
||||
a30, a31, a32, a33) {}
|
||||
|
||||
virtual Object* cloneType() const { return new RefMatrix(); }
|
||||
virtual Object* clone(const CopyOp&) const { return new RefMatrix(*this); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const RefMatrix*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "Matrix"; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~RefMatrix() {}
|
||||
};
|
||||
|
||||
|
||||
//static utility methods
|
||||
inline Matrix Matrix::identity(void)
|
||||
{
|
||||
|
||||
@@ -29,26 +29,26 @@ class SG_EXPORT MatrixTransform : public Transform
|
||||
META_Node(osg, MatrixTransform);
|
||||
|
||||
/** Set the transform's matrix.*/
|
||||
void setMatrix(const Matrix& mat) { (*_matrix) = mat; _inverseDirty=true; dirtyBound(); }
|
||||
void setMatrix(const Matrix& mat) { _matrix = mat; _inverseDirty=true; dirtyBound(); }
|
||||
|
||||
/** Get the matrix. */
|
||||
inline const Matrix& getMatrix() const { return *_matrix; }
|
||||
inline const Matrix& getMatrix() const { return _matrix; }
|
||||
|
||||
/** pre multiply the transforms matrix.*/
|
||||
void preMult(const Matrix& mat) { _matrix->preMult(mat); _inverseDirty=true; dirtyBound(); }
|
||||
void preMult(const Matrix& mat) { _matrix.preMult(mat); _inverseDirty=true; dirtyBound(); }
|
||||
|
||||
/** post multiply the transforms matrix.*/
|
||||
void postMult(const Matrix& mat) { _matrix->postMult(mat); _inverseDirty=true; dirtyBound(); }
|
||||
void postMult(const Matrix& mat) { _matrix.postMult(mat); _inverseDirty=true; dirtyBound(); }
|
||||
|
||||
/** Get the inverse matrix. */
|
||||
inline const Matrix& getInverseMatrix() const
|
||||
{
|
||||
if (_inverseDirty)
|
||||
{
|
||||
_inverse->invert(*_matrix);
|
||||
_inverse.invert(_matrix);
|
||||
_inverseDirty = false;
|
||||
}
|
||||
return *_inverse;
|
||||
return _inverse;
|
||||
}
|
||||
|
||||
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
|
||||
@@ -60,8 +60,8 @@ class SG_EXPORT MatrixTransform : public Transform
|
||||
|
||||
virtual ~MatrixTransform();
|
||||
|
||||
ref_ptr<Matrix> _matrix;
|
||||
mutable ref_ptr<Matrix> _inverse;
|
||||
Matrix _matrix;
|
||||
mutable Matrix _inverse;
|
||||
mutable bool _inverseDirty;
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,6 @@
|
||||
// GNU Lesser General Public License (LGPL) version 2.1 as published
|
||||
// by the Free Software Foundation appearing in the file COPYING included in
|
||||
// this distribution.
|
||||
//
|
||||
// Licensees holding valid OpenSceneGraph Professional Licenses (OSGPL) may use
|
||||
// this file in accordance with the OpenSceneGraph Professional License
|
||||
// Agreement provided to you by OpenSceneGraph Professional Services.
|
||||
//
|
||||
// See http::/www.openscenegraph.org/licensing.html for details on and pricing
|
||||
// of the OpenSceneGraph Professional license.
|
||||
|
||||
|
||||
#ifndef OSG_NODE
|
||||
|
||||
@@ -73,7 +73,7 @@ class SG_EXPORT NodeCallback : public virtual Object {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
ref_ptr<NodeCallback> _nestedCallback;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class SG_EXPORT PositionAttitudeTransform : public Transform
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~PositionAttitudeTransform() {}
|
||||
|
||||
Vec3 _position;
|
||||
Quat _attitude;
|
||||
|
||||
@@ -149,6 +149,8 @@ class PrimitiveSet : public Object
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~PrimitiveSet() {}
|
||||
|
||||
Type _primitiveType;
|
||||
GLenum _mode;
|
||||
};
|
||||
@@ -202,6 +204,8 @@ class SG_EXPORT DrawArrays : public PrimitiveSet
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawArrays() {}
|
||||
|
||||
GLint _first;
|
||||
GLsizei _count;
|
||||
};
|
||||
@@ -273,6 +277,8 @@ class SG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorSizei
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawArrayLengths() {}
|
||||
|
||||
GLint _first;
|
||||
};
|
||||
|
||||
@@ -313,6 +319,10 @@ class SG_EXPORT DrawElementsUByte : public PrimitiveSet, public VectorUByte
|
||||
virtual unsigned int getNumIndices() const { return size(); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsUByte() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -353,6 +363,10 @@ class SG_EXPORT DrawElementsUShort : public PrimitiveSet, public VectorUShort
|
||||
virtual unsigned int getNumIndices() const { return size(); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsUShort() {}
|
||||
};
|
||||
|
||||
class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
|
||||
@@ -392,6 +406,10 @@ class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
|
||||
virtual unsigned int getNumIndices() const { return size(); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsUInt() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ class SG_EXPORT Projection : public Group
|
||||
META_Node(osg, Projection);
|
||||
|
||||
/** Set the transform's matrix.*/
|
||||
void setMatrix(const Matrix& mat) { (*_matrix) = mat; }
|
||||
void setMatrix(const Matrix& mat) { _matrix = mat; }
|
||||
|
||||
/** Get the transform's matrix. */
|
||||
inline const Matrix& getMatrix() const { return *_matrix; }
|
||||
inline const Matrix& getMatrix() const { return _matrix; }
|
||||
|
||||
/** preMult transform.*/
|
||||
void preMult(const Matrix& mat) { _matrix->preMult(mat); }
|
||||
void preMult(const Matrix& mat) { _matrix.preMult(mat); }
|
||||
|
||||
/** postMult transform.*/
|
||||
void postMult(const Matrix& mat) { _matrix->postMult(mat); }
|
||||
void postMult(const Matrix& mat) { _matrix.postMult(mat); }
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Projection();
|
||||
|
||||
ref_ptr<Matrix> _matrix;
|
||||
Matrix _matrix;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -104,11 +104,11 @@ class SG_EXPORT ShadowVolumeOccluder
|
||||
|
||||
protected:
|
||||
|
||||
float _volume;
|
||||
NodePath _nodePath;
|
||||
ref_ptr<const Matrix> _projectionMatrix;
|
||||
Polytope _occluderVolume;
|
||||
HoleList _holeList;
|
||||
float _volume;
|
||||
NodePath _nodePath;
|
||||
ref_ptr<const RefMatrix> _projectionMatrix;
|
||||
Polytope _occluderVolume;
|
||||
HoleList _holeList;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -71,6 +71,9 @@ class SG_EXPORT Shape : public Object
|
||||
Must be defined by derived classes.*/
|
||||
virtual void accept(ConstShapeVisitor&) const =0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Shape() {}
|
||||
};
|
||||
|
||||
// forward declartions of Shape types.
|
||||
|
||||
@@ -58,8 +58,6 @@ class SG_EXPORT State : public Referenced
|
||||
public :
|
||||
|
||||
State();
|
||||
|
||||
virtual ~State();
|
||||
|
||||
/** push stateset onto state stack.*/
|
||||
void pushStateSet(const StateSet* dstate);
|
||||
@@ -73,7 +71,7 @@ class SG_EXPORT State : public Referenced
|
||||
/** reset the state object to an empty stack.*/
|
||||
void reset();
|
||||
|
||||
inline void applyProjectionMatrix(const osg::Matrix* matrix)
|
||||
inline void applyProjectionMatrix(const osg::RefMatrix* matrix)
|
||||
{
|
||||
if (_projection!=matrix)
|
||||
{
|
||||
@@ -97,7 +95,7 @@ class SG_EXPORT State : public Referenced
|
||||
return *_projection;
|
||||
}
|
||||
|
||||
inline void applyModelViewMatrix(const osg::Matrix* matrix)
|
||||
inline void applyModelViewMatrix(const osg::RefMatrix* matrix)
|
||||
{
|
||||
if (_modelView!=matrix)
|
||||
{
|
||||
@@ -551,15 +549,16 @@ class SG_EXPORT State : public Referenced
|
||||
typedef std::vector<AttributePair> AttributeVec;
|
||||
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual ~State();
|
||||
|
||||
|
||||
unsigned int _contextID;
|
||||
ref_ptr<FrameStamp> _frameStamp;
|
||||
|
||||
ref_ptr<const Matrix> _identity;
|
||||
ref_ptr<const Matrix> _projection;
|
||||
ref_ptr<const Matrix> _modelView;
|
||||
ref_ptr<const RefMatrix> _identity;
|
||||
ref_ptr<const RefMatrix> _projection;
|
||||
ref_ptr<const RefMatrix> _modelView;
|
||||
|
||||
ref_ptr<DisplaySettings> _displaySettings;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace osg {
|
||||
* each trifan or tristrip = (length-2) triangles and so on.
|
||||
*/
|
||||
|
||||
class Statistics : public osg::Referenced, public osg::Drawable::PrimitiveFunctor{
|
||||
class Statistics : public osg::Drawable::PrimitiveFunctor{
|
||||
public:
|
||||
|
||||
typedef std::pair<unsigned int,unsigned int> PrimitivePair;
|
||||
@@ -37,8 +37,6 @@ class Statistics : public osg::Referenced, public osg::Drawable::PrimitiveFuncto
|
||||
reset();
|
||||
};
|
||||
|
||||
~Statistics() {}; // no dynamic allocations, so no need to free
|
||||
|
||||
enum statsType
|
||||
{
|
||||
STAT_NONE, // default
|
||||
@@ -86,7 +84,7 @@ class Statistics : public osg::Referenced, public osg::Drawable::PrimitiveFuncto
|
||||
|
||||
void setBinNo(int n) { _binNo=n;}
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
int numDrawables, nummat, nbins;
|
||||
int nlights;
|
||||
@@ -99,6 +97,7 @@ public:
|
||||
PrimtiveValueMap _primitiveCount;
|
||||
GLenum _currentPrimtiveFunctorMode;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ to by an osg::ref_ptr.
|
||||
*/
|
||||
class SG_EXPORT Test: public osg::Referenced
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef TestVisitor Visitor; // Test is redundant
|
||||
|
||||
@@ -38,7 +38,9 @@ public:
|
||||
|
||||
virtual bool accept( Visitor& ) = 0;
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual ~Test() {}
|
||||
|
||||
std::string _name;
|
||||
};
|
||||
@@ -112,7 +114,7 @@ the traversal to be short-cicuited at any point during the visitation.
|
||||
*/
|
||||
class TestVisitor
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
//..Should we enter this node and its children?
|
||||
virtual bool visitEnter( TestSuite* ) { return true; }
|
||||
@@ -122,7 +124,8 @@ public:
|
||||
|
||||
//..Returns true to continue to next Composite
|
||||
virtual bool visitLeave( TestSuite* ) { return true; }
|
||||
protected:
|
||||
|
||||
protected:
|
||||
|
||||
TestVisitor() {}
|
||||
TestVisitor( const TestVisitor& ) {}
|
||||
@@ -135,7 +138,7 @@ TestCase, is the supplies the interface for a Composite pattern's
|
||||
*/
|
||||
class TestCase : public Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef TestContext Context; // Test in TestContext? is redundant
|
||||
|
||||
@@ -144,6 +147,10 @@ public:
|
||||
virtual bool accept( Visitor& v ) { return v.visit( this ); }
|
||||
|
||||
virtual void run( const Context& ) = 0; // Subclass OSGUTX_EXPORT Responsibility
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TestCase() {}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -152,14 +159,14 @@ indicate problems during the run of a TestCase.
|
||||
*/
|
||||
class TestX
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
TestX(const std::string& s):_what(s) {}
|
||||
virtual ~TestX() {}
|
||||
|
||||
const std::string& what() const { return _what; }
|
||||
|
||||
private:
|
||||
private:
|
||||
std::string _what;
|
||||
};
|
||||
|
||||
@@ -168,7 +175,7 @@ A TestFailureX indicates a failure in the tested component.
|
||||
*/
|
||||
class TestFailureX: public TestX
|
||||
{
|
||||
public:
|
||||
public:
|
||||
TestFailureX(const std::string& s):TestX(s) {}
|
||||
};
|
||||
|
||||
@@ -180,7 +187,7 @@ run which prevents the component from being tested.
|
||||
*/
|
||||
class TestErrorX: public TestX
|
||||
{
|
||||
public:
|
||||
public:
|
||||
TestErrorX(const std::string& s):TestX(s) {}
|
||||
};
|
||||
|
||||
@@ -197,7 +204,7 @@ class TestCase_ : public TestCase
|
||||
{
|
||||
typedef void (FixtureT::*TestMethodPtr)( const Context& );
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
// Constructor adds the TestMethod pointer
|
||||
TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
|
||||
@@ -212,7 +219,9 @@ public:
|
||||
( FixtureT().*_pTestMethod )( ctx );
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual ~TestCase_() {}
|
||||
|
||||
TestMethodPtr _pTestMethod;
|
||||
};
|
||||
@@ -223,7 +232,7 @@ and allows aggregation of Tests into hierarchies.
|
||||
*/
|
||||
class SG_EXPORT TestSuite : public Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
TestSuite( const std::string& name );
|
||||
|
||||
@@ -237,7 +246,9 @@ public:
|
||||
|
||||
virtual bool accept( Test::Visitor& v );
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual ~TestSuite() {}
|
||||
|
||||
typedef std::vector< osg::ref_ptr<Test> > Tests;
|
||||
Tests _tests; // Collection of Suites and/or Cases
|
||||
@@ -250,7 +261,7 @@ primarily, it provides access to the root suite.
|
||||
class SG_EXPORT TestGraph
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
static TestGraph& instance();
|
||||
|
||||
@@ -283,7 +294,7 @@ public:
|
||||
*/
|
||||
TestSuite* suite(const std::string& path, TestSuite* tsuite = 0,bool createIfNecessary = false);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
/**
|
||||
Does the same job as the version of suite listed above, but the path
|
||||
@@ -312,7 +323,7 @@ class SG_EXPORT TestQualifier : public TestVisitor
|
||||
{
|
||||
enum { SEPCHAR = '.' };
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
// Entering a composite: Push its name on the Path
|
||||
virtual bool visitEnter( TestSuite* pSuite );
|
||||
@@ -323,7 +334,7 @@ public:
|
||||
// Provide read-only access to the current qualifier
|
||||
const std::string& currentPath() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
std::string _path; // Current qualifier
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <osg/Vec4>
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@@ -140,22 +139,17 @@ class SG_EXPORT VertexProgram : public StateAttribute
|
||||
inline void setVertexProgram( const char* program ) { _vertexProgram = program; }
|
||||
/** Get the vertex program.*/
|
||||
inline const std::string& getVertexProgram() const { return _vertexProgram; }
|
||||
/** Load vertex program from file. */
|
||||
// inline void loadVertexProgram( const std::string& filename ) {
|
||||
// _vertexProgram = loadProgramFile( filename ); }
|
||||
|
||||
|
||||
/** Program Parameters */
|
||||
inline void setProgramLocalParameter(const GLuint index, const Vec4& p)
|
||||
{
|
||||
{
|
||||
_programLocalParameters[index] = p;
|
||||
}
|
||||
}
|
||||
|
||||
/** Matrix */
|
||||
inline void setMatrix(const GLenum mode, const Matrix& matrix)
|
||||
{
|
||||
assert(mode>=GL_MATRIX0_ARB && mode<=GL_MATRIX31_ARB);
|
||||
_matrixList[mode] = new Matrix(matrix);
|
||||
_matrixList[mode] = matrix;
|
||||
}
|
||||
|
||||
virtual void apply(State& state) const;
|
||||
@@ -171,7 +165,7 @@ class SG_EXPORT VertexProgram : public StateAttribute
|
||||
typedef std::map<GLuint,Vec4> LocalParamList;
|
||||
LocalParamList _programLocalParameters;
|
||||
|
||||
typedef std::map<GLenum,ref_ptr<Matrix> > MatrixList;
|
||||
typedef std::map<GLenum,Matrix> MatrixList;
|
||||
MatrixList _matrixList;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class ref_ptr
|
||||
ref_ptr() :_ptr(0L) {}
|
||||
ref_ptr(T* t):_ptr(t) { if (_ptr) _ptr->ref(); }
|
||||
ref_ptr(const ref_ptr& rp):_ptr(rp._ptr) { if (_ptr) _ptr->ref(); }
|
||||
~ref_ptr() { if (_ptr) _ptr->unref(); }
|
||||
~ref_ptr() { if (_ptr) _ptr->unref(); _ptr=0; }
|
||||
|
||||
inline ref_ptr& operator = (const ref_ptr& rp)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,12 @@ typedef std::deque<std::string> FilePathList;
|
||||
The RegisterReaderWriterProxy can be used to automatically
|
||||
register at runtime a reader/writer with the Registry.
|
||||
*/
|
||||
class OSGDB_EXPORT Registry
|
||||
class OSGDB_EXPORT Registry : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
static Registry* instance();
|
||||
|
||||
~Registry();
|
||||
|
||||
|
||||
/** read the command line string list, removing any matched control sequences.*/
|
||||
void readCommandLine(std::vector<std::string>& commandLine);
|
||||
|
||||
@@ -142,7 +139,9 @@ class OSGDB_EXPORT Registry
|
||||
static void convertStringPathIntoFilePathList(const std::string& paths,FilePathList& filepath);
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual ~Registry();
|
||||
|
||||
typedef std::map<std::string,osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap;
|
||||
typedef std::vector<osg::ref_ptr<ReaderWriter> > ReaderWriterList;
|
||||
|
||||
@@ -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() &&
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user