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:
@@ -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));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user