Changed the osg::Billboard comution so that it get passed in the current

modelview matrix rathan than an identity matrix, this matrix is then modified
locally.

Changed the osg::Matrix set methods so they are inline.

Added a few useful comments to MemoryManager.cpp to help people understand
the assert's better.
This commit is contained in:
Robert Osfield
2002-04-17 09:48:19 +00:00
parent b76888ffb9
commit e17261c45f
7 changed files with 49 additions and 49 deletions

View File

@@ -83,7 +83,7 @@ class SG_EXPORT Billboard : public Geode
struct ComputeBillboardCallback : public osg::Referenced
{
/** Get the transformation matrix which moves from local coords to world coords.*/
virtual const bool computeMatrix(const Matrix& matrix, const Billboard* billboard, const Vec3& eye_local, const Vec3& up_local, const Vec3& pos_local) const;
virtual const bool computeMatrix(const Matrix& modelview, const Billboard* billboard, const Vec3& eye_local, const Vec3& pos_local) const;
};
friend struct osg::Billboard::ComputeBillboardCallback;
@@ -99,12 +99,12 @@ class SG_EXPORT Billboard : public Geode
const ComputeBillboardCallback* getComputeBillboardCallback() const { return _computeBillboardCallback.get(); }
inline const bool getMatrix(Matrix& matrix, const Vec3& eye_local, const Vec3& up_local, const Vec3& pos_local) const
inline const bool getMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const
{
if (_computeBillboardCallback.valid())
return _computeBillboardCallback->computeMatrix(matrix,this,eye_local,up_local,pos_local);
return _computeBillboardCallback->computeMatrix(modelview,this,eye_local,pos_local);
else
return computeMatrix(matrix,eye_local,up_local,pos_local);
return computeMatrix(modelview,eye_local,pos_local);
}
protected:
@@ -113,7 +113,7 @@ class SG_EXPORT Billboard : public Geode
virtual const bool computeBound() const;
virtual const bool computeMatrix(Matrix& matrix, const Vec3& eye_local, const Vec3& up_local, const Vec3& pos_local) const;
virtual const bool computeMatrix(Matrix& modelview, const Vec3& eye_local, const Vec3& pos_local) const;
enum AxisAligned
{

View File

@@ -12,6 +12,7 @@
#include <string.h>
#include <iostream>
#include <algorithm>
namespace osg {
@@ -37,7 +38,7 @@ class SG_EXPORT Matrix : public Object
virtual ~Matrix() {}
Matrix& operator = (const Matrix& );
int compare(const Matrix& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); }
@@ -56,7 +57,23 @@ class SG_EXPORT Matrix : public Object
void set( float const * const );
inline Matrix& operator = (const Matrix& other)
{
if( &other == this ) return *this;
set((float const * const)(other._mat));
return *this;
}
inline void set(const Matrix& other)
{
set((float const * const)(other._mat));
}
inline void set(float const * const ptr)
{
std::copy(ptr,ptr+16,(float*)(_mat));
}
void set( float a00, float a01, float a02, float a03,
float a10, float a11, float a12, float a13,
float a20, float a21, float a22, float a23,

View File

@@ -408,7 +408,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
MatrixList _reuseMatrixList;
unsigned int _currentReuseMatrixIndex;
inline osg::Matrix* createOrReuseMatrix()
inline osg::Matrix* createOrReuseMatrix(const osg::Matrix value)
{
// skip of any already reused matrix.
while (_currentReuseMatrixIndex<_reuseMatrixList.size() &&
@@ -423,12 +423,12 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
if (_currentReuseMatrixIndex<_reuseMatrixList.size())
{
osg::Matrix* matrix = _reuseMatrixList[_currentReuseMatrixIndex++].get();
matrix->makeIdentity();
matrix->set(value);
return matrix;
}
// otherwise need to create new matrix.
osg::Matrix* matrix = new osg::Matrix();
osg::Matrix* matrix = new osg::Matrix(value);
_reuseMatrixList.push_back(matrix);
++_currentReuseMatrixIndex;
return matrix;