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:
parent
f948a3de7c
commit
f36bc69c58
@ -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;
|
||||
|
||||
|
@ -48,7 +48,7 @@ Node *makeTank( void )
|
||||
|
||||
getDatabaseCenterRadius( dbcenter, &dbradius );
|
||||
|
||||
ref_ptr<Matrix> mat = new Matrix(
|
||||
Matrix mat(
|
||||
0.05, 0, 0, 0,
|
||||
0, 0.05, 0, 0,
|
||||
0, 0, 0.05, 0,
|
||||
@ -142,7 +142,7 @@ Node *makeTank( void )
|
||||
}
|
||||
|
||||
for( i = 0; i < c; i++ )
|
||||
conv( vc[i], *mat, vc[i] );
|
||||
conv( vc[i], mat, vc[i] );
|
||||
|
||||
gset->addPrimitiveSet(new DrawArrays(PrimitiveSet::TRIANGLE_FAN,prev_c,c-prev_c));
|
||||
|
||||
|
@ -123,12 +123,12 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv)
|
||||
zfar *= 1.1f;
|
||||
|
||||
// set up projection.
|
||||
osg::Matrix* projection = new osg::Matrix;
|
||||
osg::RefMatrix* projection = new osg::RefMatrix;
|
||||
projection->makeFrustum(-right,right,-top,top,znear,zfar);
|
||||
|
||||
cv.pushProjectionMatrix(projection);
|
||||
|
||||
osg::Matrix* matrix = new osg::Matrix;
|
||||
osg::RefMatrix* matrix = new osg::RefMatrix;
|
||||
matrix->makeLookAt(bs.center()+osg::Vec3(0.0f,2.0f,0.0f)*bs.radius(),bs.center(),osg::Vec3(0.0f,0.0f,1.0f));
|
||||
|
||||
cv.pushModelViewMatrix(matrix);
|
||||
|
@ -128,12 +128,12 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv)
|
||||
zfar *= 1.1f;
|
||||
|
||||
// set up projection.
|
||||
osg::Matrix* projection = new osg::Matrix;
|
||||
osg::RefMatrix* projection = new osg::RefMatrix;
|
||||
projection->makeFrustum(-right,right,-top,top,znear,zfar);
|
||||
|
||||
cv.pushProjectionMatrix(projection);
|
||||
|
||||
osg::Matrix* matrix = new osg::Matrix;
|
||||
osg::RefMatrix* matrix = new osg::RefMatrix;
|
||||
matrix->makeLookAt(bs.center()+osg::Vec3(0.0f,2.0f,0.0f)*bs.radius(),bs.center(),osg::Vec3(0.0f,0.0f,1.0f));
|
||||
|
||||
cv.pushModelViewMatrix(matrix);
|
||||
|
@ -125,12 +125,12 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull
|
||||
float right = top;
|
||||
|
||||
// set up projection.
|
||||
osg::Matrix* projection = new osg::Matrix;
|
||||
osg::RefMatrix* projection = new osg::RefMatrix;
|
||||
projection->makeFrustum(-right,right,-top,top,znear,zfar);
|
||||
|
||||
cv.pushProjectionMatrix(projection);
|
||||
|
||||
osg::Matrix* matrix = new osg::Matrix;
|
||||
osg::RefMatrix* matrix = new osg::RefMatrix;
|
||||
matrix->makeLookAt(_position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f));
|
||||
|
||||
|
||||
|
@ -359,7 +359,7 @@ Vec3 Camera::getSideVector() const
|
||||
}
|
||||
|
||||
|
||||
void Camera::attachTransform(TransformMode mode, Matrix* matrix)
|
||||
void Camera::attachTransform(TransformMode mode, RefMatrix* matrix)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
@ -369,7 +369,7 @@ void Camera::attachTransform(TransformMode mode, Matrix* matrix)
|
||||
if (_eyeToModelTransform.valid())
|
||||
{
|
||||
_attachedTransformMode = mode;
|
||||
if (!_modelToEyeTransform.valid()) _modelToEyeTransform = new Matrix;
|
||||
if (!_modelToEyeTransform.valid()) _modelToEyeTransform = new RefMatrix;
|
||||
if (!_modelToEyeTransform->invert(*_eyeToModelTransform))
|
||||
{
|
||||
notify(WARN)<<"Warning: Camera::attachTransform() failed to invert _modelToEyeTransform"<<std::endl;
|
||||
@ -388,7 +388,7 @@ void Camera::attachTransform(TransformMode mode, Matrix* matrix)
|
||||
if (_modelToEyeTransform.valid())
|
||||
{
|
||||
_attachedTransformMode = mode;
|
||||
if (!_eyeToModelTransform.valid()) _eyeToModelTransform = new Matrix;
|
||||
if (!_eyeToModelTransform.valid()) _eyeToModelTransform = new RefMatrix;
|
||||
if (!_eyeToModelTransform->invert(*_modelToEyeTransform))
|
||||
{
|
||||
notify(WARN)<<"Warning: Camera::attachTransform() failed to invert _modelToEyeTransform"<<std::endl;
|
||||
|
@ -67,7 +67,7 @@ void CollectOccludersVisitor::apply(osg::Transform& node)
|
||||
// push the culling mode.
|
||||
pushCurrentMask();
|
||||
|
||||
ref_ptr<osg::Matrix> matrix = createOrReuseMatrix(getModelViewMatrix());
|
||||
ref_ptr<osg::RefMatrix> matrix = createOrReuseMatrix(getModelViewMatrix());
|
||||
node.getLocalToWorldMatrix(*matrix,this);
|
||||
pushModelViewMatrix(matrix.get());
|
||||
|
||||
@ -86,7 +86,7 @@ void CollectOccludersVisitor::apply(osg::Projection& node)
|
||||
// push the culling mode.
|
||||
pushCurrentMask();
|
||||
|
||||
ref_ptr<osg::Matrix> matrix = createOrReuseMatrix(node.getMatrix());
|
||||
ref_ptr<osg::RefMatrix> matrix = createOrReuseMatrix(node.getMatrix());
|
||||
pushProjectionMatrix(matrix.get());
|
||||
|
||||
handle_cull_callbacks_and_traverse(node);
|
||||
|
@ -10,7 +10,8 @@ CullStack::CullStack()
|
||||
_frustumVolume=-1.0f;
|
||||
_bbCornerNear = 0;
|
||||
_bbCornerFar = 7;
|
||||
_currentReuseMatrixIndex=0;
|
||||
_currentReuseMatrixIndex=0;
|
||||
_identity = new RefMatrix();
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +127,7 @@ void CullStack::popViewport()
|
||||
_MVPW_Stack.pop_back();
|
||||
}
|
||||
|
||||
void CullStack::pushProjectionMatrix(Matrix* matrix)
|
||||
void CullStack::pushProjectionMatrix(RefMatrix* matrix)
|
||||
{
|
||||
_projectionStack.push_back(matrix);
|
||||
|
||||
@ -181,7 +182,7 @@ void CullStack::popProjectionMatrix()
|
||||
popCullingSet();
|
||||
}
|
||||
|
||||
void CullStack::pushModelViewMatrix(Matrix* matrix)
|
||||
void CullStack::pushModelViewMatrix(RefMatrix* matrix)
|
||||
{
|
||||
_modelviewStack.push_back(matrix);
|
||||
|
||||
|
@ -1,30 +1,17 @@
|
||||
#include <osg/DisplaySettings>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace osg;
|
||||
using namespace std;
|
||||
|
||||
class DisplaySettingsPtr
|
||||
{
|
||||
public:
|
||||
DisplaySettingsPtr() : _ptr(0L) {}
|
||||
DisplaySettingsPtr(DisplaySettings* t): _ptr(t) {}
|
||||
DisplaySettingsPtr(const DisplaySettingsPtr& rp):_ptr(rp._ptr) { }
|
||||
~DisplaySettingsPtr() { if (_ptr) delete _ptr; _ptr=0L; }
|
||||
|
||||
inline DisplaySettings* get() { return _ptr; }
|
||||
|
||||
DisplaySettings* _ptr;
|
||||
};
|
||||
|
||||
DisplaySettings* DisplaySettings::instance()
|
||||
{
|
||||
static DisplaySettingsPtr s_displaySettings = new DisplaySettings;
|
||||
static ref_ptr<DisplaySettings> s_displaySettings = new DisplaySettings;
|
||||
return s_displaySettings.get();
|
||||
}
|
||||
|
||||
|
||||
DisplaySettings::DisplaySettings(const DisplaySettings& vs):Referenced()
|
||||
{
|
||||
copy(vs);
|
||||
|
@ -24,12 +24,12 @@ using namespace osg;
|
||||
|
||||
|
||||
|
||||
Matrix::Matrix() : Object()
|
||||
Matrix::Matrix()
|
||||
{
|
||||
makeIdentity();
|
||||
}
|
||||
|
||||
Matrix::Matrix( const Matrix& other) : Object()
|
||||
Matrix::Matrix( const Matrix& other)
|
||||
{
|
||||
set( (const float *) other._mat );
|
||||
}
|
||||
|
@ -5,14 +5,12 @@ using namespace osg;
|
||||
MatrixTransform::MatrixTransform():
|
||||
_inverseDirty(false)
|
||||
{
|
||||
_matrix = new Matrix;
|
||||
_inverse = new Matrix;
|
||||
}
|
||||
|
||||
MatrixTransform::MatrixTransform(const MatrixTransform& transform,const CopyOp& copyop):
|
||||
Transform(transform,copyop),
|
||||
_matrix(new Matrix(*transform._matrix)),
|
||||
_inverse(new Matrix(*transform._inverse)),
|
||||
_matrix(transform._matrix),
|
||||
_inverse(transform._inverse),
|
||||
_inverseDirty(transform._inverseDirty)
|
||||
{
|
||||
}
|
||||
@ -21,8 +19,7 @@ MatrixTransform::MatrixTransform(const Matrix& mat )
|
||||
{
|
||||
_referenceFrame = RELATIVE_TO_PARENTS;
|
||||
|
||||
_matrix = new Matrix(mat);
|
||||
_inverse = new Matrix();
|
||||
_matrix = mat;
|
||||
_inverseDirty = false;
|
||||
}
|
||||
|
||||
@ -35,11 +32,11 @@ bool MatrixTransform::computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) con
|
||||
{
|
||||
if (_referenceFrame==RELATIVE_TO_PARENTS)
|
||||
{
|
||||
matrix.preMult(*_matrix);
|
||||
matrix.preMult(_matrix);
|
||||
}
|
||||
else // absolute
|
||||
{
|
||||
matrix = *_matrix;
|
||||
matrix = _matrix;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -4,18 +4,17 @@ using namespace osg;
|
||||
|
||||
Projection::Projection()
|
||||
{
|
||||
_matrix = new Matrix;
|
||||
}
|
||||
|
||||
Projection::Projection(const Projection& projection,const CopyOp& copyop):
|
||||
Group(projection,copyop),
|
||||
_matrix(new Matrix(*projection._matrix))
|
||||
_matrix(projection._matrix)
|
||||
{
|
||||
}
|
||||
|
||||
Projection::Projection(const Matrix& mat )
|
||||
{
|
||||
_matrix = new Matrix(mat);
|
||||
_matrix = mat;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,8 +170,8 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex
|
||||
|
||||
CullingSet& cullingset = cullStack.getCurrentCullingSet();
|
||||
|
||||
const Matrix& MV = cullStack.getModelViewMatrix();
|
||||
const Matrix& P = cullStack.getProjectionMatrix();
|
||||
const RefMatrix& MV = cullStack.getModelViewMatrix();
|
||||
const RefMatrix& P = cullStack.getProjectionMatrix();
|
||||
|
||||
// take a reference to the NodePath to this occluder.
|
||||
_nodePath = nodePath;
|
||||
|
@ -10,7 +10,7 @@ using namespace osg;
|
||||
State::State()
|
||||
{
|
||||
_contextID = 0;
|
||||
_identity = new osg::Matrix(); // default Matrix constructs to identity.
|
||||
_identity = new osg::RefMatrix(); // default RefMatrix constructs to identity.
|
||||
_projection = _identity;
|
||||
_modelView = _identity;
|
||||
|
||||
|
@ -91,7 +91,7 @@ void VertexProgram::apply(State& state) const
|
||||
++itr)
|
||||
{
|
||||
::glMatrixMode((*itr).first);
|
||||
::glLoadMatrixf((*itr).second->ptr());
|
||||
::glLoadMatrixf((*itr).second.ptr());
|
||||
}
|
||||
::glMatrixMode(GL_MODELVIEW); // restore matrix mode
|
||||
}
|
||||
|
@ -28,22 +28,9 @@ void PrintFilePathList(std::ostream& stream,const FilePathList& filepath)
|
||||
}
|
||||
}
|
||||
|
||||
class RegistryPtr
|
||||
{
|
||||
public:
|
||||
RegistryPtr() : _ptr(0L) {}
|
||||
RegistryPtr(Registry* t): _ptr(t) {}
|
||||
RegistryPtr(const RegistryPtr& rp):_ptr(rp._ptr) { }
|
||||
~RegistryPtr() { if (_ptr) delete _ptr; _ptr=0L; }
|
||||
|
||||
inline Registry* get() { return _ptr; }
|
||||
|
||||
Registry* _ptr;
|
||||
};
|
||||
|
||||
Registry* Registry::instance()
|
||||
{
|
||||
static RegistryPtr s_nodeFactory = new Registry;
|
||||
static ref_ptr<Registry> s_nodeFactory = new Registry;
|
||||
return s_nodeFactory.get();
|
||||
}
|
||||
|
||||
|
@ -611,14 +611,14 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
||||
* RO, July 2001.
|
||||
*/
|
||||
|
||||
Statistics *primStats=new Statistics[maxbins]; // array of bin stats
|
||||
std::vector<Statistics> primStats(maxbins); // array of bin stats
|
||||
ViewportList::iterator itr;
|
||||
for(itr=_viewportList.begin();
|
||||
itr!=_viewportList.end();
|
||||
++itr)
|
||||
{
|
||||
osgUtil::RenderStage *stage = itr->sceneView->getRenderStage();
|
||||
stage->getPrims(primStats, maxbins);
|
||||
stage->getPrims(&primStats.front(), maxbins);
|
||||
}
|
||||
int nbinsUsed=(primStats[0].getBins()<maxbins)?primStats[0].getBins():maxbins;
|
||||
int ntop=0; // offset
|
||||
@ -628,7 +628,6 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
||||
//osg::notify(osg::INFO) << "ntop "<< ntop<< std::endl;
|
||||
}
|
||||
maxbins=(primStats[0].getBins()>maxbins)?primStats[0].getBins():maxbins;
|
||||
delete [] primStats; // free up
|
||||
}
|
||||
if (_printStats==Statistics::STAT_DC) { // yet more stats - read the depth complexity
|
||||
int wid=_ww, ht=_wh; // temporary local screen size - must change during this section
|
||||
@ -1207,12 +1206,12 @@ void Viewer::keyboard(unsigned char key, int x, int y)
|
||||
cov.pushViewport(sceneView->getViewport());
|
||||
|
||||
if (sceneView->getProjectionMatrix()) cov.pushProjectionMatrix(sceneView->getProjectionMatrix());
|
||||
else if (sceneView->getCamera()) cov.pushProjectionMatrix(new Matrix(sceneView->getCamera()->getProjectionMatrix()));
|
||||
else cov.pushProjectionMatrix(new Matrix());
|
||||
else if (sceneView->getCamera()) cov.pushProjectionMatrix(new RefMatrix(sceneView->getCamera()->getProjectionMatrix()));
|
||||
else cov.pushProjectionMatrix(new RefMatrix());
|
||||
|
||||
if (sceneView->getModelViewMatrix()) cov.pushModelViewMatrix(sceneView->getModelViewMatrix());
|
||||
else if (sceneView->getCamera()) cov.pushModelViewMatrix(new Matrix(sceneView->getCamera()->getModelViewMatrix()));
|
||||
else cov.pushModelViewMatrix(new Matrix());
|
||||
else if (sceneView->getCamera()) cov.pushModelViewMatrix(new RefMatrix(sceneView->getCamera()->getModelViewMatrix()));
|
||||
else cov.pushModelViewMatrix(new RefMatrix());
|
||||
|
||||
sceneView->getSceneData()->accept(cov);
|
||||
|
||||
|
@ -55,7 +55,7 @@ bool Geometry_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (!Primitive_readLocalData(fr,geom)) ++fr;
|
||||
if (!Primitive_readLocalData(fr,geom)) fr.advanceOverCurrentFieldOrBlock();
|
||||
}
|
||||
|
||||
++fr;
|
||||
|
@ -1,64 +1,49 @@
|
||||
#include "osg/Matrix"
|
||||
#include "Matrix.h"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool Matrix_readLocalData(Object& obj, Input& fr);
|
||||
bool Matrix_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
// register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_MatrixFuncProxy
|
||||
(
|
||||
new osg::Matrix,
|
||||
"Matrix",
|
||||
"Object Matrix",
|
||||
&Matrix_readLocalData,
|
||||
&Matrix_writeLocalData
|
||||
);
|
||||
|
||||
bool Matrix_readLocalData(Object& obj, Input& fr)
|
||||
bool readMatrix(osg::Matrix& matrix, osgDB::Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
Matrix& matrix = static_cast<Matrix&>(obj);
|
||||
|
||||
bool matched = true;
|
||||
for(int k=0;k<16 && matched;++k)
|
||||
|
||||
if (fr.matchSequence("Matrix {"))
|
||||
{
|
||||
matched = fr[k].isFloat();
|
||||
}
|
||||
if (matched)
|
||||
{
|
||||
int k=0;
|
||||
for(int i=0;i<4;++i)
|
||||
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
fr += 2;
|
||||
|
||||
int row=0;
|
||||
int col=0;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
if (fr[0].getFloat(matrix(row,col)))
|
||||
{
|
||||
fr[k].getFloat(matrix(i,j));
|
||||
k++;
|
||||
++col;
|
||||
if (col>=4)
|
||||
{
|
||||
col = 0;
|
||||
++row;
|
||||
}
|
||||
++fr;
|
||||
}
|
||||
else fr.advanceOverCurrentFieldOrBlock();
|
||||
}
|
||||
fr += 16;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
bool Matrix_writeLocalData(const Object& obj, Output& fw)
|
||||
bool writeMatrix(const osg::Matrix& matrix, osgDB::Output& fw)
|
||||
{
|
||||
const Matrix& matrix = static_cast<const Matrix&>(obj);
|
||||
|
||||
fw.indent() << "Matrix {";
|
||||
fw.moveIn();
|
||||
fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << std::endl;
|
||||
fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << std::endl;
|
||||
fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << std::endl;
|
||||
fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << std::endl;
|
||||
fw.moveOut();
|
||||
fw.indent() << "}";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
#include "Matrix.h"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
@ -54,17 +56,12 @@ bool MatrixTransform_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Matrix s_matrix;
|
||||
}
|
||||
|
||||
if (Matrix* tmpMatrix = static_cast<Matrix*>(fr.readObjectOfType(s_matrix)))
|
||||
Matrix matrix;
|
||||
if (readMatrix(matrix,fr))
|
||||
{
|
||||
|
||||
transform.setMatrix(*tmpMatrix);
|
||||
|
||||
delete tmpMatrix;
|
||||
|
||||
transform.setMatrix(matrix);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
@ -76,7 +73,7 @@ bool MatrixTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const MatrixTransform& transform = static_cast<const MatrixTransform&>(obj);
|
||||
|
||||
fw.writeObject(transform.getMatrix());
|
||||
writeMatrix(transform.getMatrix(),fw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
|
||||
#include "Matrix.h"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
@ -27,11 +29,10 @@ bool Projection_readLocalData(Object& obj, Input& fr)
|
||||
Projection &myobj = static_cast<Projection &>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
static Matrix s_matrix;
|
||||
|
||||
if (Matrix* tmpMatrix = static_cast<Matrix*>(fr.readObjectOfType(s_matrix)))
|
||||
Matrix matrix;
|
||||
if (readMatrix(matrix,fr))
|
||||
{
|
||||
myobj.setMatrix(*tmpMatrix);
|
||||
myobj.setMatrix(matrix);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
@ -43,7 +44,7 @@ bool Projection_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const Projection& myobj = static_cast<const Projection&>(obj);
|
||||
|
||||
fw.writeObject(myobj.getMatrix());
|
||||
writeMatrix(myobj.getMatrix(),fw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -297,106 +297,6 @@ bool Cylinder_writeLocalData(const Object& obj, Output& fw)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// forward declare functions to use later.
|
||||
bool InfinitePlane_readLocalData(Object& obj, Input& fr);
|
||||
bool InfinitePlane_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
//register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_InfinitePlaneFuncProxy
|
||||
(
|
||||
new osg::InfinitePlane,
|
||||
"InfinitePlane",
|
||||
"Object InfinitePlane",
|
||||
&InfinitePlane_readLocalData,
|
||||
&InfinitePlane_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool InfinitePlane_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
//InfinitePlane& infplane = static_cast<InfinitePlane&>(obj);
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool InfinitePlane_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
//const InfinitePlane& infplane = static_cast<const InfinitePlane&>(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool TriangleMesh_readLocalData(Object& obj, Input& fr);
|
||||
bool TriangleMesh_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
//register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_TriangleMeshFuncProxy
|
||||
(
|
||||
new osg::TriangleMesh,
|
||||
"TriangleMesh",
|
||||
"Object ",
|
||||
&TriangleMesh_readLocalData,
|
||||
&TriangleMesh_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool TriangleMesh_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
// TriangleMesh& mesh = static_cast<TriangleMesh&>(obj);
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool TriangleMesh_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
// const TriangleMesh& mesh = static_cast<const TriangleMesh&>(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// forward declare functions to use later.
|
||||
bool ConvexHull_readLocalData(Object& obj, Input& fr);
|
||||
bool ConvexHull_writeLocalData(const Object& obj, Output& fw);
|
||||
|
||||
//register the read and write functions with the osgDB::Registry.
|
||||
RegisterDotOsgWrapperProxy g_ConvexHullFuncProxy
|
||||
(
|
||||
new osg::ConvexHull,
|
||||
"ConvexHull",
|
||||
"Object ",
|
||||
&ConvexHull_readLocalData,
|
||||
&ConvexHull_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool ConvexHull_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
// ConvexHull& geom = static_cast<ConvexHull&>(obj);
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool ConvexHull_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
// const ConvexHull& geom = static_cast<const ConvexHull&>(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// forward declare functions to use later.
|
||||
bool HeightField_readLocalData(Object& obj, Input& fr);
|
||||
@ -632,3 +532,106 @@ bool CompositeShape_writeLocalData(const Object& obj, Output& fw)
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// // forward declare functions to use later.
|
||||
// bool InfinitePlane_readLocalData(Object& obj, Input& fr);
|
||||
// bool InfinitePlane_writeLocalData(const Object& obj, Output& fw);
|
||||
//
|
||||
// //register the read and write functions with the osgDB::Registry.
|
||||
// RegisterDotOsgWrapperProxy g_InfinitePlaneFuncProxy
|
||||
// (
|
||||
// new osg::InfinitePlane,
|
||||
// "InfinitePlane",
|
||||
// "Object InfinitePlane",
|
||||
// &InfinitePlane_readLocalData,
|
||||
// &InfinitePlane_writeLocalData,
|
||||
// DotOsgWrapper::READ_AND_WRITE
|
||||
// );
|
||||
//
|
||||
// bool InfinitePlane_readLocalData(Object& obj, Input& fr)
|
||||
// {
|
||||
// bool iteratorAdvanced = false;
|
||||
//
|
||||
// //InfinitePlane& infplane = static_cast<InfinitePlane&>(obj);
|
||||
//
|
||||
// return iteratorAdvanced;
|
||||
// }
|
||||
//
|
||||
// bool InfinitePlane_writeLocalData(const Object& obj, Output& fw)
|
||||
// {
|
||||
// //const InfinitePlane& infplane = static_cast<const InfinitePlane&>(obj);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// // forward declare functions to use later.
|
||||
// bool TriangleMesh_readLocalData(Object& obj, Input& fr);
|
||||
// bool TriangleMesh_writeLocalData(const Object& obj, Output& fw);
|
||||
//
|
||||
// //register the read and write functions with the osgDB::Registry.
|
||||
// RegisterDotOsgWrapperProxy g_TriangleMeshFuncProxy
|
||||
// (
|
||||
// new osg::TriangleMesh,
|
||||
// "TriangleMesh",
|
||||
// "Object ",
|
||||
// &TriangleMesh_readLocalData,
|
||||
// &TriangleMesh_writeLocalData,
|
||||
// DotOsgWrapper::READ_AND_WRITE
|
||||
// );
|
||||
//
|
||||
// bool TriangleMesh_readLocalData(Object& obj, Input& fr)
|
||||
// {
|
||||
// bool iteratorAdvanced = false;
|
||||
//
|
||||
// // TriangleMesh& mesh = static_cast<TriangleMesh&>(obj);
|
||||
//
|
||||
// return iteratorAdvanced;
|
||||
// }
|
||||
//
|
||||
// bool TriangleMesh_writeLocalData(const Object& obj, Output& fw)
|
||||
// {
|
||||
// // const TriangleMesh& mesh = static_cast<const TriangleMesh&>(obj);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
// // forward declare functions to use later.
|
||||
// bool ConvexHull_readLocalData(Object& obj, Input& fr);
|
||||
// bool ConvexHull_writeLocalData(const Object& obj, Output& fw);
|
||||
//
|
||||
// //register the read and write functions with the osgDB::Registry.
|
||||
// RegisterDotOsgWrapperProxy g_ConvexHullFuncProxy
|
||||
// (
|
||||
// new osg::ConvexHull,
|
||||
// "ConvexHull",
|
||||
// "Object ",
|
||||
// &ConvexHull_readLocalData,
|
||||
// &ConvexHull_writeLocalData,
|
||||
// DotOsgWrapper::READ_AND_WRITE
|
||||
// );
|
||||
//
|
||||
// bool ConvexHull_readLocalData(Object& obj, Input& fr)
|
||||
// {
|
||||
// bool iteratorAdvanced = false;
|
||||
//
|
||||
// // ConvexHull& geom = static_cast<ConvexHull&>(obj);
|
||||
//
|
||||
// return iteratorAdvanced;
|
||||
// }
|
||||
//
|
||||
// bool ConvexHull_writeLocalData(const Object& obj, Output& fw)
|
||||
// {
|
||||
// // const ConvexHull& geom = static_cast<const ConvexHull&>(obj);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
|
@ -113,7 +113,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
|
||||
osg::Matrix matrix = cv->getModelViewMatrix();
|
||||
osg::Matrix& projection = cv->getProjectionMatrix();
|
||||
osg::RefMatrix& projection = cv->getProjectionMatrix();
|
||||
osgUtil::RenderGraph* rg = cv->getCurrentRenderGraph();
|
||||
|
||||
if (rg->leaves_empty())
|
||||
|
@ -259,7 +259,7 @@ void CullVisitor::apply(Geode& node)
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
Matrix& matrix = getModelViewMatrix();
|
||||
RefMatrix& matrix = getModelViewMatrix();
|
||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||
{
|
||||
Drawable* drawable = node.getDrawable(i);
|
||||
@ -304,7 +304,7 @@ void CullVisitor::apply(Billboard& node)
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
const Vec3& eye_local = getEyeLocal();
|
||||
const Matrix& modelview = getModelViewMatrix();
|
||||
const RefMatrix& modelview = getModelViewMatrix();
|
||||
|
||||
for(unsigned int i=0;i<node.getNumDrawables();++i)
|
||||
{
|
||||
@ -314,7 +314,7 @@ void CullVisitor::apply(Billboard& node)
|
||||
// need to modify isCulled to handle the billboard offset.
|
||||
// if (isCulled(drawable->getBound())) continue;
|
||||
|
||||
Matrix* billboard_matrix = createOrReuseMatrix(modelview);
|
||||
RefMatrix* billboard_matrix = createOrReuseMatrix(modelview);
|
||||
|
||||
node.getMatrix(*billboard_matrix,eye_local,pos);
|
||||
|
||||
@ -347,7 +347,7 @@ void CullVisitor::apply(LightSource& node)
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
Matrix& matrix = getModelViewMatrix();
|
||||
RefMatrix& matrix = getModelViewMatrix();
|
||||
StateAttribute* light = node.getLight();
|
||||
if (light)
|
||||
{
|
||||
@ -366,7 +366,7 @@ void CullVisitor::apply(ClipNode& node)
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
Matrix& matrix = getModelViewMatrix();
|
||||
RefMatrix& matrix = getModelViewMatrix();
|
||||
|
||||
const ClipNode::ClipPlaneList& planes = node.getClipPlaneList();
|
||||
for(ClipNode::ClipPlaneList::const_iterator itr=planes.begin();
|
||||
@ -413,7 +413,7 @@ void CullVisitor::apply(Transform& node)
|
||||
StateSet* node_state = node.getStateSet();
|
||||
if (node_state) pushStateSet(node_state);
|
||||
|
||||
ref_ptr<osg::Matrix> matrix = createOrReuseMatrix(getModelViewMatrix());
|
||||
ref_ptr<RefMatrix> matrix = createOrReuseMatrix(getModelViewMatrix());
|
||||
node.getLocalToWorldMatrix(*matrix,this);
|
||||
pushModelViewMatrix(matrix.get());
|
||||
|
||||
@ -447,7 +447,7 @@ void CullVisitor::apply(Projection& node)
|
||||
_computed_znear = FLT_MAX;
|
||||
_computed_zfar = -FLT_MAX;
|
||||
|
||||
ref_ptr<osg::Matrix> matrix = createOrReuseMatrix(node.getMatrix());
|
||||
ref_ptr<osg::RefMatrix> matrix = createOrReuseMatrix(node.getMatrix());
|
||||
pushProjectionMatrix(matrix.get());
|
||||
|
||||
handle_cull_callbacks_and_traverse(node);
|
||||
@ -580,7 +580,7 @@ void CullVisitor::apply(Impostor& node)
|
||||
// within the impostor distance threshold therefore attempt
|
||||
// to use impostor instead.
|
||||
|
||||
Matrix& matrix = getModelViewMatrix();
|
||||
RefMatrix& matrix = getModelViewMatrix();
|
||||
|
||||
// search for the best fit ImpostorSprite;
|
||||
ImpostorSprite* impostorSprite = node.findBestImpostorSprite(eyeLocal);
|
||||
@ -748,7 +748,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
zfar *= 1.1f;
|
||||
|
||||
// set up projection.
|
||||
osg::Matrix* projection = new osg::Matrix;
|
||||
osg::RefMatrix* projection = new osg::RefMatrix;
|
||||
if (isPerspectiveProjection)
|
||||
{
|
||||
// deal with projection issue move the top and right points
|
||||
@ -768,7 +768,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
Vec3 rotate_from = bs.center()-eye_local;
|
||||
Vec3 rotate_to = getLookVectorLocal();
|
||||
|
||||
osg::Matrix* rotate_matrix = new osg::Matrix(
|
||||
osg::RefMatrix* rotate_matrix = new osg::RefMatrix(
|
||||
osg::Matrix::translate(-eye_local)*
|
||||
osg::Matrix::rotate(rotate_from,rotate_to)*
|
||||
osg::Matrix::translate(eye_local)*
|
||||
|
@ -215,15 +215,15 @@ void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
|
||||
if (cis->_matrix.valid())
|
||||
{
|
||||
nis->_matrix = new Matrix;
|
||||
nis->_matrix = new RefMatrix;
|
||||
nis->_matrix->mult(matrix,*(cis->_matrix));
|
||||
}
|
||||
else
|
||||
{
|
||||
nis->_matrix = new Matrix(matrix);
|
||||
nis->_matrix = new RefMatrix(matrix);
|
||||
}
|
||||
|
||||
Matrix* inverse_world = new Matrix;
|
||||
RefMatrix* inverse_world = new RefMatrix;
|
||||
inverse_world->invert(*(nis->_matrix));
|
||||
nis->_inverse = inverse_world;
|
||||
|
||||
@ -527,7 +527,7 @@ void IntersectVisitor::apply(Transform& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
|
||||
osg::ref_ptr<Matrix> matrix = new Matrix;
|
||||
osg::ref_ptr<RefMatrix> matrix = new RefMatrix;
|
||||
node.getLocalToWorldMatrix(*matrix,this);
|
||||
|
||||
pushMatrix(*matrix);
|
||||
|
@ -206,8 +206,8 @@ void SceneView::cull()
|
||||
_state->setDisplaySettings(_displaySettings.get());
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Matrix> projection = _projectionMatrix.get();
|
||||
osg::ref_ptr<osg::Matrix> modelview = _modelviewMatrix.get();
|
||||
osg::ref_ptr<osg::RefMatrix> projection = _projectionMatrix.get();
|
||||
osg::ref_ptr<osg::RefMatrix> modelview = _modelviewMatrix.get();
|
||||
|
||||
if (_camera.valid())
|
||||
{
|
||||
@ -235,15 +235,15 @@ void SceneView::cull()
|
||||
if (_displaySettings.valid())
|
||||
_camera->setScreenDistance(_displaySettings->getScreenDistance());
|
||||
|
||||
if (!projection) projection = new osg::Matrix(_camera->getProjectionMatrix());
|
||||
if (!modelview) modelview = new osg::Matrix(_camera->getModelViewMatrix());
|
||||
if (!projection) projection = new osg::RefMatrix(_camera->getProjectionMatrix());
|
||||
if (!modelview) modelview = new osg::RefMatrix(_camera->getModelViewMatrix());
|
||||
|
||||
//cout <<"fovx="<<_camera->calc_fovx()<<endl;
|
||||
|
||||
}
|
||||
|
||||
if (!projection) projection = new osg::Matrix();
|
||||
if (!modelview) modelview = new osg::Matrix();
|
||||
if (!projection) projection = new osg::RefMatrix();
|
||||
if (!modelview) modelview = new osg::RefMatrix();
|
||||
|
||||
if (!_cullVisitor)
|
||||
{
|
||||
@ -288,18 +288,18 @@ void SceneView::cull()
|
||||
if (_displaySettings->getStereoMode()==osg::DisplaySettings::LEFT_EYE)
|
||||
{
|
||||
// set up the left eye.
|
||||
osg::ref_ptr<osg::Matrix> projectionLeft = new osg::Matrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
osg::ref_ptr<osg::RefMatrix> projectionLeft = new osg::RefMatrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Matrix> modelviewLeft = new osg::Matrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
es,0.0f,0.0f,1.0f));
|
||||
osg::ref_ptr<osg::RefMatrix> modelviewLeft = new osg::RefMatrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
es,0.0f,0.0f,1.0f));
|
||||
|
||||
_cullVisitor->setTraversalMask(_cullMaskLeft);
|
||||
cullStage(projectionLeft.get(),modelviewLeft.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
@ -313,17 +313,17 @@ void SceneView::cull()
|
||||
else if (_displaySettings->getStereoMode()==osg::DisplaySettings::RIGHT_EYE)
|
||||
{
|
||||
// set up the right eye.
|
||||
osg::ref_ptr<osg::Matrix> projectionRight = new osg::Matrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
-iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
osg::ref_ptr<osg::RefMatrix> projectionRight = new osg::RefMatrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
-iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
|
||||
osg::ref_ptr<osg::Matrix> modelviewRight = new osg::Matrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
-es,0.0f,0.0f,1.0f));
|
||||
osg::ref_ptr<osg::RefMatrix> modelviewRight = new osg::RefMatrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
-es,0.0f,0.0f,1.0f));
|
||||
|
||||
_cullVisitor->setTraversalMask(_cullMaskRight);
|
||||
cullStage(projectionRight.get(),modelviewRight.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
@ -348,14 +348,14 @@ void SceneView::cull()
|
||||
|
||||
|
||||
// set up the left eye.
|
||||
osg::ref_ptr<osg::Matrix> projectionLeft = new osg::Matrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
osg::ref_ptr<osg::RefMatrix> projectionLeft = new osg::RefMatrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Matrix> modelviewLeft = new osg::Matrix( (*modelview) *
|
||||
osg::ref_ptr<osg::RefMatrix> modelviewLeft = new osg::RefMatrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
@ -366,17 +366,17 @@ void SceneView::cull()
|
||||
|
||||
|
||||
// set up the right eye.
|
||||
osg::ref_ptr<osg::Matrix> projectionRight = new osg::Matrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
-iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
osg::ref_ptr<osg::RefMatrix> projectionRight = new osg::RefMatrix(osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
-iod/(2.0f*sd),0.0f,1.0f,0.0f,
|
||||
0.0f,0.0f,0.0f,1.0f)*
|
||||
(*projection));
|
||||
|
||||
osg::ref_ptr<osg::Matrix> modelviewRight = new osg::Matrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
-es,0.0f,0.0f,1.0f));
|
||||
osg::ref_ptr<osg::RefMatrix> modelviewRight = new osg::RefMatrix( (*modelview) *
|
||||
osg::Matrix(1.0f,0.0f,0.0f,0.0f,
|
||||
0.0f,1.0f,0.0f,0.0f,
|
||||
0.0f,0.0f,1.0f,0.0f,
|
||||
-es,0.0f,0.0f,1.0f));
|
||||
|
||||
_cullVisitorRight->setTraversalMask(_cullMaskRight);
|
||||
cullStage(projectionRight.get(),modelviewRight.get(),_cullVisitorRight.get(),_rendergraphRight.get(),_renderStageRight.get());
|
||||
@ -407,7 +407,7 @@ void SceneView::cull()
|
||||
|
||||
}
|
||||
|
||||
void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage)
|
||||
void SceneView::cullStage(osg::RefMatrix* projection,osg::RefMatrix* modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage)
|
||||
{
|
||||
|
||||
if (!_sceneData || !_viewport->valid()) return;
|
||||
|
Loading…
Reference in New Issue
Block a user