Added osg::MemoryManger which is currently based on Paul Nettle's memory manager
published at flipcode. I havn't adopted Paul's macro's for new/delete etc, but use osg prefixed versions instead to allow greater flexiblity in handling include ordering. Have fixed a couple of new/delete[] problems which existed as a result. To use the MemoryManager to track memory usage simply add -DOSG_USE_MEMEORY_TRACKING to the compile line. Have yet to move the osg from using new to osgNew, will do this next.
This commit is contained in:
@@ -75,7 +75,7 @@ Node *makeTerrain( void )
|
||||
Vec3 *v = new Vec3[m*n];
|
||||
Vec2 *t = new Vec2[m*n];
|
||||
Vec4 *col = new Vec4[1];
|
||||
osg::ushort *cidx = new osg::ushort;
|
||||
osg::ushort *cidx = new osg::ushort[1];
|
||||
osg::ushort *idx = new osg::ushort[m*n*2];
|
||||
int *lens = new int[m];
|
||||
|
||||
|
||||
@@ -68,19 +68,19 @@ osg::Drawable* createMirrorSurface(float xMin,float xMax,float yMin,float yMax,f
|
||||
// set up the geoset.
|
||||
osg::GeoSet* gset = new osg::GeoSet;
|
||||
|
||||
osg::Vec3* coords = new osg::Vec3 [4];
|
||||
osg::Vec3* coords = new osg::Vec3[4];
|
||||
coords[0].set(xMin,yMax,z);
|
||||
coords[1].set(xMin,yMin,z);
|
||||
coords[2].set(xMax,yMin,z);
|
||||
coords[3].set(xMax,yMax,z);
|
||||
gset->setCoords(coords);
|
||||
|
||||
osg::Vec3* norms = new osg::Vec3 [1];
|
||||
osg::Vec3* norms = new osg::Vec3[1];
|
||||
norms[0].set(0.0f,0.0f,1.0f);
|
||||
gset->setNormals(norms);
|
||||
gset->setNormalBinding(osg::GeoSet::BIND_OVERALL);
|
||||
|
||||
osg::Vec2* tcoords = new osg::Vec2 [4];
|
||||
osg::Vec2* tcoords = new osg::Vec2[4];
|
||||
tcoords[0].set(0.0f,1.0f);
|
||||
tcoords[1].set(0.0f,0.0f);
|
||||
tcoords[2].set(1.0f,0.0f);
|
||||
@@ -88,7 +88,7 @@ osg::Drawable* createMirrorSurface(float xMin,float xMax,float yMin,float yMax,f
|
||||
gset->setTextureCoords(tcoords);
|
||||
gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
|
||||
osg::Vec4* colours = new osg::Vec4;
|
||||
osg::Vec4* colours = new osg::Vec4[1];
|
||||
colours->set(1.0f,1.0f,1.0,1.0f);
|
||||
gset->setColors(colours);
|
||||
gset->setColorBinding(osg::GeoSet::BIND_OVERALL);
|
||||
|
||||
@@ -205,14 +205,14 @@ Geode* osg::createGeodeForImage(osg::Image* image,const float s,const float t)
|
||||
osg::GeoSet* gset = new osg::GeoSet;
|
||||
gset->setStateSet(dstate);
|
||||
|
||||
osg::Vec3* coords = new Vec3 [4];
|
||||
osg::Vec3* coords = new Vec3[4];
|
||||
coords[0].set(-x,0.0f,y);
|
||||
coords[1].set(-x,0.0f,-y);
|
||||
coords[2].set(x,0.0f,-y);
|
||||
coords[3].set(x,0.0f,y);
|
||||
gset->setCoords(coords);
|
||||
|
||||
osg::Vec2* tcoords = new Vec2 [4];
|
||||
osg::Vec2* tcoords = new Vec2[4];
|
||||
tcoords[0].set(0.0f,1.0f);
|
||||
tcoords[1].set(0.0f,0.0f);
|
||||
tcoords[2].set(1.0f,0.0f);
|
||||
@@ -220,7 +220,7 @@ Geode* osg::createGeodeForImage(osg::Image* image,const float s,const float t)
|
||||
gset->setTextureCoords(tcoords);
|
||||
gset->setTextureBinding(osg::GeoSet::BIND_PERVERTEX);
|
||||
|
||||
osg::Vec4* colours = new Vec4;
|
||||
osg::Vec4* colours = new Vec4[1];
|
||||
colours->set(1.0f,1.0f,1.0,1.0f);
|
||||
gset->setColors(colours);
|
||||
gset->setColorBinding(osg::GeoSet::BIND_OVERALL);
|
||||
|
||||
@@ -36,6 +36,7 @@ C++FILES = \
|
||||
LineWidth.cpp\
|
||||
LOD.cpp\
|
||||
Material.cpp\
|
||||
MemoryManager.cpp\
|
||||
Matrix.cpp\
|
||||
Node.cpp\
|
||||
NodeCallback.cpp\
|
||||
@@ -111,6 +112,7 @@ TARGET_INCLUDE_FILES = \
|
||||
osg/Math\
|
||||
osg/Matrix\
|
||||
osg/MemoryAdapter\
|
||||
osg/MemoryManager\
|
||||
osg/Node\
|
||||
osg/NodeCallback\
|
||||
osg/NodeVisitor\
|
||||
|
||||
1601
src/osg/MemoryManager.cpp
Normal file
1601
src/osg/MemoryManager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user