Added support for osg::MemoryManager which is based upon Paul Nettle's
memory manager published at flipcode.com. This can be turned on with the OSG_USE_MEMORY_MANGER option which then uses custom global new and delete operators as well as provide osgNew and osgDelete macro's which add ability to log line and file from which calls are made. Updated osg,osgUtil,osgDB,osgText and osgPlugins/osg to use osgNew/osgDelete, and fixed memory leaks highlighted by the new memory manager.
This commit is contained in:
@@ -299,7 +299,7 @@ void TriangleViewFrustumIntersect::intersect_triangle(const osg::Vec3& vert1, co
|
||||
|
||||
//construct line segment of two triangle vertices and check if they intersect any clipping plane
|
||||
//but within correct clipping plane triangle
|
||||
osg::ref_ptr<osg::LineSegment> s12 = new LineSegment(v1, v2);
|
||||
osg::ref_ptr<osg::LineSegment> s12 = osgNew LineSegment(v1, v2);
|
||||
|
||||
|
||||
//left triangle
|
||||
@@ -395,7 +395,7 @@ CullVisitor::CullVisitor()
|
||||
// unless there is bug somewhere...
|
||||
_cullingModeStack.push_back(CullViewState::ENABLE_ALL_CULLING);
|
||||
|
||||
_tvs = new CullViewState;
|
||||
_tvs = osgNew CullViewState;
|
||||
_tvs->_eyePoint.set(0.0f,0.0f,1.0f);
|
||||
_tvs->_centerPoint.set(0.0f,0.0f,0.0f);
|
||||
_tvs->_lookVector.set(0.0f,0.0f,-1.0f);
|
||||
@@ -416,7 +416,7 @@ CullVisitor::CullVisitor()
|
||||
_depthSortImpostorSprites = false;
|
||||
_impostorPixelErrorThreshold = 4.0f;
|
||||
_numFramesToKeepImpostorSprites = 10;
|
||||
_impostorSpriteManager = new ImpostorSpriteManager;
|
||||
_impostorSpriteManager = osgNew ImpostorSpriteManager;
|
||||
|
||||
//SandB change
|
||||
_detailedCulling = false;
|
||||
@@ -491,7 +491,7 @@ void CullVisitor::pushCullViewState(Matrix* matrix)
|
||||
{
|
||||
if (matrix)
|
||||
{
|
||||
osg::Matrix* inverse = new osg::Matrix;
|
||||
osg::Matrix* inverse = osgNew osg::Matrix;
|
||||
inverse->invert(*matrix);
|
||||
pushCullViewState(matrix,inverse);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ void CullVisitor::pushCullViewState(Matrix* matrix)
|
||||
void CullVisitor::pushCullViewState(Matrix* matrix,osg::Matrix* inverse)
|
||||
{
|
||||
|
||||
osg::ref_ptr<CullViewState> nvs = new CullViewState;
|
||||
osg::ref_ptr<CullViewState> nvs = osgNew CullViewState;
|
||||
|
||||
Matrix* inverse_world = NULL;
|
||||
|
||||
@@ -1359,7 +1359,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
// one for use.
|
||||
|
||||
// create the render to texture stage.
|
||||
ref_ptr<RenderToTextureStage> rtts = new RenderToTextureStage;
|
||||
ref_ptr<RenderToTextureStage> rtts = osgNew RenderToTextureStage;
|
||||
|
||||
// set up lighting.
|
||||
// currently ignore lights in the scene graph itself..
|
||||
@@ -1376,7 +1376,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
rtts->setRenderStageLighting(previous_stage->getRenderStageLighting());
|
||||
|
||||
|
||||
osg::Camera* camera = new osg::Camera(*_camera);
|
||||
osg::Camera* camera = osgNew osg::Camera(*_camera);
|
||||
rtts->setCamera(camera);
|
||||
|
||||
// record the render bin, to be restored after creation
|
||||
@@ -1391,7 +1391,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::Matrix* rotate_matrix = osgNew osg::Matrix(
|
||||
osg::Matrix::translate(-eye_local)*
|
||||
osg::Matrix::rotate(rotate_from,rotate_to)*
|
||||
osg::Matrix::translate(eye_local));
|
||||
@@ -1410,7 +1410,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
_calculated_znear = FLT_MAX;
|
||||
_calculated_zfar = -FLT_MAX;
|
||||
|
||||
ref_ptr<StateSet> dummyState = new StateSet;
|
||||
ref_ptr<StateSet> dummyState = osgNew StateSet;
|
||||
|
||||
|
||||
// dummyState->setMode(GL_BLEND,osg::StateAttribute::OVERRIDE_OFF);
|
||||
@@ -1647,7 +1647,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
|
||||
int center_x = _viewport->x()+_viewport->width()/2;
|
||||
int center_y = _viewport->y()+_viewport->height()/2;
|
||||
|
||||
Viewport* viewport = new Viewport;
|
||||
Viewport* viewport = osgNew Viewport;
|
||||
viewport->setViewport(center_x-new_s/2,center_y-new_t/2,new_s,new_t);
|
||||
rtts->setViewport(viewport);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ DisplayRequirementsVisitor::DisplayRequirementsVisitor()
|
||||
|
||||
void DisplayRequirementsVisitor::applyStateSet(StateSet& stateset)
|
||||
{
|
||||
if (!_ds) _ds = new osg::DisplaySettings;
|
||||
if (!_ds) _ds = osgNew osg::DisplaySettings;
|
||||
|
||||
unsigned int min = 0; // assume stencil not needed by this stateset.
|
||||
|
||||
@@ -63,7 +63,7 @@ void DisplayRequirementsVisitor::apply(Geode& geode)
|
||||
|
||||
void DisplayRequirementsVisitor::apply(Impostor& impostor)
|
||||
{
|
||||
if (!_ds) _ds = new osg::DisplaySettings;
|
||||
if (!_ds) _ds = osgNew osg::DisplaySettings;
|
||||
|
||||
unsigned int min = 1; // number alpha bits we need at least.
|
||||
if (min>_ds->getMinimumNumAlphaBits())
|
||||
|
||||
@@ -60,7 +60,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
|
||||
bool cameraSet = false;
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segDown = osgNew osg::LineSegment;
|
||||
segDown->set(ep,bp);
|
||||
iv.addLineSegment(segDown.get());
|
||||
|
||||
@@ -99,7 +99,7 @@ void DriveManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
bp = ep;
|
||||
bp.z() += _modelScale;
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segUp = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segUp = osgNew osg::LineSegment;
|
||||
segUp->set(ep,bp);
|
||||
iv.addLineSegment(segUp.get());
|
||||
|
||||
@@ -175,7 +175,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
|
||||
bool cameraSet = false;
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segDown = osgNew osg::LineSegment;
|
||||
segDown->set(ep,bp);
|
||||
iv.addLineSegment(segDown.get());
|
||||
|
||||
@@ -214,7 +214,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
bp = ep;
|
||||
bp.z() += _modelScale;
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segUp = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segUp = osgNew osg::LineSegment;
|
||||
segUp->set(ep,bp);
|
||||
iv.addLineSegment(segUp.get());
|
||||
|
||||
@@ -452,7 +452,7 @@ bool DriveManipulator::calcMovement()
|
||||
|
||||
// check to see if any obstruction in front.
|
||||
IntersectVisitor iv;
|
||||
osg::ref_ptr<osg::LineSegment> segForward = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segForward = osgNew osg::LineSegment;
|
||||
segForward->set(ep,ep+lv*(signedBuffer+distanceToMove));
|
||||
iv.addLineSegment(segForward.get());
|
||||
|
||||
@@ -477,7 +477,7 @@ bool DriveManipulator::calcMovement()
|
||||
|
||||
iv.reset();
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segNormal = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segNormal = osgNew osg::LineSegment;
|
||||
segNormal->set(fp,lfp);
|
||||
iv.addLineSegment(segNormal.get());
|
||||
|
||||
@@ -515,7 +515,7 @@ bool DriveManipulator::calcMovement()
|
||||
|
||||
iv.reset();
|
||||
|
||||
osg::ref_ptr<osg::LineSegment> segFall = new osg::LineSegment;
|
||||
osg::ref_ptr<osg::LineSegment> segFall = osgNew osg::LineSegment;
|
||||
segFall->set(lfp,dp);
|
||||
iv.addLineSegment(segFall.get());
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ void InsertImpostorsVisitor::insertImpostors()
|
||||
// to an impostor.
|
||||
Node::ParentList parentList = group->getParents();
|
||||
|
||||
Impostor* impostor = new Impostor;
|
||||
Impostor* impostor = osgNew Impostor;
|
||||
|
||||
// standard LOD settings
|
||||
impostor->addChild(group);
|
||||
@@ -141,7 +141,7 @@ void InsertImpostorsVisitor::insertImpostors()
|
||||
// to an impostor.
|
||||
Node::ParentList parentList = lod->getParents();
|
||||
|
||||
osg::Impostor* impostor = new Impostor;
|
||||
osg::Impostor* impostor = osgNew Impostor;
|
||||
|
||||
// standard LOD settings
|
||||
for(int ci=0;ci<lod->getNumChildren();++ci)
|
||||
|
||||
@@ -154,7 +154,7 @@ void IntersectVisitor::reset()
|
||||
_intersectStateStack.clear();
|
||||
|
||||
// create a empty IntersectState on the the intersectStateStack.
|
||||
IntersectState* nis = new IntersectState;
|
||||
IntersectState* nis = osgNew IntersectState;
|
||||
|
||||
_intersectStateStack.push_back(nis);
|
||||
|
||||
@@ -193,7 +193,7 @@ void IntersectVisitor::addLineSegment(LineSegment* seg)
|
||||
|
||||
// create a new segment transformed to local coordintes.
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
LineSegment* ns = new LineSegment;
|
||||
LineSegment* ns = osgNew LineSegment;
|
||||
|
||||
if (cis->_inverse.valid()) ns->mult(*seg,*(cis->_inverse));
|
||||
else *ns = *seg;
|
||||
@@ -205,21 +205,21 @@ void IntersectVisitor::addLineSegment(LineSegment* seg)
|
||||
|
||||
void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
{
|
||||
IntersectState* nis = new IntersectState;
|
||||
IntersectState* nis = osgNew IntersectState;
|
||||
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
|
||||
if (cis->_matrix.valid())
|
||||
{
|
||||
nis->_matrix = new Matrix;
|
||||
nis->_matrix = osgNew Matrix;
|
||||
nis->_matrix->mult(matrix,*(cis->_matrix));
|
||||
}
|
||||
else
|
||||
{
|
||||
nis->_matrix = new Matrix(matrix);
|
||||
nis->_matrix = osgNew Matrix(matrix);
|
||||
}
|
||||
|
||||
Matrix* inverse_world = new Matrix;
|
||||
Matrix* inverse_world = osgNew Matrix;
|
||||
inverse_world->invert(*(nis->_matrix));
|
||||
nis->_inverse = inverse_world;
|
||||
|
||||
@@ -231,7 +231,7 @@ void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
{
|
||||
if ((segMaskIn & mask))
|
||||
{
|
||||
LineSegment* seg = new LineSegment;
|
||||
LineSegment* seg = osgNew LineSegment;
|
||||
seg->mult(*(sitr->first),*inverse_world);
|
||||
nis->addLineSegmentPair(sitr->first.get(),seg);
|
||||
}
|
||||
@@ -540,7 +540,7 @@ void IntersectVisitor::apply(Transform& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
|
||||
osg::ref_ptr<Matrix> matrix = new Matrix;
|
||||
osg::ref_ptr<Matrix> matrix = osgNew Matrix;
|
||||
node.getLocalToWorldMatrix(*matrix,this);
|
||||
|
||||
pushMatrix(*matrix);
|
||||
|
||||
@@ -21,7 +21,7 @@ VertexCache::VertexCache(int size)
|
||||
{
|
||||
numEntries = size;
|
||||
|
||||
entries = new int[numEntries];
|
||||
entries = osgNew int[numEntries];
|
||||
|
||||
for(int i = 0; i < numEntries; i++)
|
||||
entries[i] = -1;
|
||||
@@ -169,7 +169,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed
|
||||
|
||||
// create the face info and add it to the list of faces, but only if this exact face doesn't already
|
||||
// exist in the list
|
||||
NvFaceInfo *faceInfo = new NvFaceInfo(v0, v1, v2);
|
||||
NvFaceInfo *faceInfo = osgNew NvFaceInfo(v0, v1, v2);
|
||||
if(!AlreadyExists(faceInfo, faceInfos))
|
||||
{
|
||||
faceInfos.push_back(faceInfo);
|
||||
@@ -180,7 +180,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed
|
||||
{
|
||||
|
||||
// create the info
|
||||
edgeInfo01 = new NvEdgeInfo(v0, v1);
|
||||
edgeInfo01 = osgNew NvEdgeInfo(v0, v1);
|
||||
|
||||
// update the linked list on both
|
||||
edgeInfo01->m_nextV0 = edgeInfos[v0];
|
||||
@@ -205,7 +205,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed
|
||||
{
|
||||
|
||||
// create the info
|
||||
edgeInfo12 = new NvEdgeInfo(v1, v2);
|
||||
edgeInfo12 = osgNew NvEdgeInfo(v1, v2);
|
||||
|
||||
// update the linked list on both
|
||||
edgeInfo12->m_nextV0 = edgeInfos[v1];
|
||||
@@ -230,7 +230,7 @@ void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &ed
|
||||
{
|
||||
|
||||
// create the info
|
||||
edgeInfo20 = new NvEdgeInfo(v2, v0);
|
||||
edgeInfo20 = osgNew NvEdgeInfo(v2, v0);
|
||||
|
||||
// update the linked list on both
|
||||
edgeInfo20->m_nextV0 = edgeInfos[v2];
|
||||
@@ -789,7 +789,7 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec&
|
||||
tempFaceList.push_back(allStrips[i]->m_faces[j]);
|
||||
|
||||
//and free memory
|
||||
delete allStrips[i];
|
||||
osgDelete allStrips[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -797,10 +797,10 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec&
|
||||
}
|
||||
}
|
||||
|
||||
bool *bVisitedList = new bool[tempFaceList.size()];
|
||||
bool *bVisitedList = osgNew bool[tempFaceList.size()];
|
||||
memset(bVisitedList, 0, tempFaceList.size()*sizeof(bool));
|
||||
|
||||
VertexCache* vcache = new VertexCache(cacheSize);
|
||||
VertexCache* vcache = osgNew VertexCache(cacheSize);
|
||||
|
||||
int bestNumHits = -1;
|
||||
int numHits;
|
||||
@@ -831,7 +831,7 @@ void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec&
|
||||
faceList.push_back(tempFaceList[bestIndex]);
|
||||
}
|
||||
|
||||
delete vcache;
|
||||
osgDelete vcache;
|
||||
delete[] bVisitedList;
|
||||
}
|
||||
|
||||
@@ -875,7 +875,7 @@ void NvStripifier::Stripify(const WordVec &in_indices, const int in_numVertices,
|
||||
int i;
|
||||
for(i = 0; i < (int)allStrips.size(); i++)
|
||||
{
|
||||
delete allStrips[i];
|
||||
osgDelete allStrips[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)allEdgeInfos.size(); i++)
|
||||
@@ -921,7 +921,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
|
||||
int j;
|
||||
for(j = 0; j < numTimes; j++)
|
||||
{
|
||||
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
||||
currentStrip = osgNew NvStripInfo(startInfo, 0, -1);
|
||||
|
||||
for(int faceCtr = j*threshold; faceCtr < threshold+(j*threshold); faceCtr++)
|
||||
{
|
||||
@@ -935,7 +935,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
|
||||
|
||||
if(numLeftover != 0)
|
||||
{
|
||||
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
||||
currentStrip = osgNew NvStripInfo(startInfo, 0, -1);
|
||||
|
||||
for(int k = 0; k < numLeftover; k++)
|
||||
{
|
||||
@@ -948,8 +948,8 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
|
||||
else
|
||||
{
|
||||
//we're not just doing a tempStrips.push_back(allBigStrips[i]) because
|
||||
// this way we can delete allBigStrips later to free the memory
|
||||
currentStrip = new NvStripInfo(startInfo, 0, -1);
|
||||
// this way we can osgDelete allBigStrips later to free the memory
|
||||
currentStrip = osgNew NvStripInfo(startInfo, 0, -1);
|
||||
|
||||
for(unsigned int j = 0; j < allStrips[i]->m_faces.size(); j++)
|
||||
currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]);
|
||||
@@ -966,7 +966,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
|
||||
if(tempStrips2.size() != 0)
|
||||
{
|
||||
//Optimize for the vertex cache
|
||||
VertexCache* vcache = new VertexCache(cacheSize);
|
||||
VertexCache* vcache = osgNew VertexCache(cacheSize);
|
||||
|
||||
float bestNumHits = -1.0f;
|
||||
float numHits;
|
||||
@@ -1025,7 +1025,7 @@ NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
|
||||
outStrips.push_back(tempStrips2[bestIndex]);
|
||||
}
|
||||
|
||||
delete vcache;
|
||||
osgDelete vcache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1195,7 +1195,7 @@ int numSamples)
|
||||
//
|
||||
// PHASE 1: Set up numSamples * numEdges experiments
|
||||
//
|
||||
NvStripInfoVec *experiments = new NvStripInfoVec [numSamples * 6];
|
||||
NvStripInfoVec *experiments = osgNew NvStripInfoVec [numSamples * 6];
|
||||
int experimentIndex = 0;
|
||||
std::set <NvFaceInfo*> resetPoints;
|
||||
int i;
|
||||
@@ -1226,32 +1226,32 @@ int numSamples)
|
||||
|
||||
// build the strip off of this face's 0-1 edge
|
||||
NvEdgeInfo *edge01 = FindEdgeInfo(allEdgeInfos, nextFace->m_v0, nextFace->m_v1);
|
||||
NvStripInfo *strip01 = new NvStripInfo(NvStripStartInfo(nextFace, edge01, true), stripId++, experimentId++);
|
||||
NvStripInfo *strip01 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge01, true), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip01);
|
||||
|
||||
// build the strip off of this face's 1-0 edge
|
||||
NvEdgeInfo *edge10 = FindEdgeInfo(allEdgeInfos, nextFace->m_v0, nextFace->m_v1);
|
||||
NvStripInfo *strip10 = new NvStripInfo(NvStripStartInfo(nextFace, edge10, false), stripId++, experimentId++);
|
||||
NvStripInfo *strip10 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge10, false), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip10);
|
||||
|
||||
// build the strip off of this face's 1-2 edge
|
||||
NvEdgeInfo *edge12 = FindEdgeInfo(allEdgeInfos, nextFace->m_v1, nextFace->m_v2);
|
||||
NvStripInfo *strip12 = new NvStripInfo(NvStripStartInfo(nextFace, edge12, true), stripId++, experimentId++);
|
||||
NvStripInfo *strip12 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge12, true), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip12);
|
||||
|
||||
// build the strip off of this face's 2-1 edge
|
||||
NvEdgeInfo *edge21 = FindEdgeInfo(allEdgeInfos, nextFace->m_v1, nextFace->m_v2);
|
||||
NvStripInfo *strip21 = new NvStripInfo(NvStripStartInfo(nextFace, edge21, false), stripId++, experimentId++);
|
||||
NvStripInfo *strip21 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge21, false), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip21);
|
||||
|
||||
// build the strip off of this face's 2-0 edge
|
||||
NvEdgeInfo *edge20 = FindEdgeInfo(allEdgeInfos, nextFace->m_v2, nextFace->m_v0);
|
||||
NvStripInfo *strip20 = new NvStripInfo(NvStripStartInfo(nextFace, edge20, true), stripId++, experimentId++);
|
||||
NvStripInfo *strip20 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge20, true), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip20);
|
||||
|
||||
// build the strip off of this face's 0-2 edge
|
||||
NvEdgeInfo *edge02 = FindEdgeInfo(allEdgeInfos, nextFace->m_v2, nextFace->m_v0);
|
||||
NvStripInfo *strip02 = new NvStripInfo(NvStripStartInfo(nextFace, edge02, false), stripId++, experimentId++);
|
||||
NvStripInfo *strip02 = osgNew NvStripInfo(NvStripStartInfo(nextFace, edge02, false), stripId++, experimentId++);
|
||||
experiments[experimentIndex++].push_back(strip02);
|
||||
}
|
||||
|
||||
@@ -1276,7 +1276,7 @@ int numSamples)
|
||||
{
|
||||
|
||||
// create the new strip info
|
||||
stripIter = new NvStripInfo(startInfo, stripId++, experimentId);
|
||||
stripIter = osgNew NvStripInfo(startInfo, stripId++, experimentId);
|
||||
|
||||
// build the next strip
|
||||
stripIter->Build(allEdgeInfos, allFaceInfos);
|
||||
@@ -1319,13 +1319,13 @@ int numSamples)
|
||||
int numStrips = experiments[i].size();
|
||||
for (int j = 0; j < numStrips; j++)
|
||||
{
|
||||
delete experiments[i][j];
|
||||
osgDelete experiments[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete the array that we used for all experiments
|
||||
delete [] experiments;
|
||||
// osgDelete the array that we used for all experiments
|
||||
osgDelete [] experiments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1525,7 +1525,7 @@ MyVertexVec& optimizedVerts)
|
||||
|
||||
//caches oldIndex --> newIndex conversion
|
||||
int *indexCache;
|
||||
indexCache = new int[vertices.size()];
|
||||
indexCache = osgNew int[vertices.size()];
|
||||
|
||||
memset(indexCache, -1, sizeof(int)*vertices.size());
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Transform& transform)
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::ref_ptr<osg::Matrix> matrix = new osg::Matrix;
|
||||
osg::ref_ptr<osg::Matrix> matrix = osgNew osg::Matrix;
|
||||
transform.getLocalToWorldMatrix(*matrix,this);
|
||||
|
||||
if (!_matrixStack.empty())
|
||||
@@ -526,7 +526,7 @@ void Optimizer::FlattenStaticTransformsVisitor::removeTransforms()
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Transform> transform = titr->first;
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
osg::ref_ptr<osg::Group> group = osgNew osg::Group;
|
||||
|
||||
int i;
|
||||
for(i=0;i<transform->getNumChildren();++i)
|
||||
@@ -695,7 +695,7 @@ void Optimizer::CombineLODsVisitor::combineLODs()
|
||||
}
|
||||
|
||||
// create new LOD containing all other LOD's children.
|
||||
osg::LOD* newLOD = new osg::LOD;
|
||||
osg::LOD* newLOD = osgNew osg::LOD;
|
||||
newLOD->setName("newLOD");
|
||||
newLOD->setCenter(bb.center());
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_prioritizeTextures = false;
|
||||
|
||||
_viewport = new Viewport;
|
||||
_viewport = osgNew Viewport;
|
||||
|
||||
_initCalled = false;
|
||||
|
||||
@@ -49,21 +49,21 @@ SceneView::~SceneView()
|
||||
|
||||
void SceneView::setDefaults()
|
||||
{
|
||||
_globalState = new osg::StateSet;
|
||||
_globalState = osgNew osg::StateSet;
|
||||
|
||||
_lightingMode=HEADLIGHT;
|
||||
_light = new osg::Light;
|
||||
_light = osgNew osg::Light;
|
||||
_light->setLightNum(0);
|
||||
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
|
||||
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
|
||||
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f));
|
||||
|
||||
_state = new State;
|
||||
_state = osgNew State;
|
||||
|
||||
_camera = new Camera(_displaySettings.get());
|
||||
_camera = osgNew Camera(_displaySettings.get());
|
||||
|
||||
_rendergraph = new RenderGraph;
|
||||
_renderStage = new RenderStage;
|
||||
_rendergraph = osgNew RenderGraph;
|
||||
_renderStage = osgNew RenderStage;
|
||||
|
||||
|
||||
//#ifndef __sgi
|
||||
@@ -71,15 +71,15 @@ void SceneView::setDefaults()
|
||||
// lighting state with the display list, and the display list visitor doesn't currently apply
|
||||
// state before creating display lists. So will disable the init visitor default, this won't
|
||||
// affect functionality since the display lists will be created as and when needed.
|
||||
DisplayListVisitor* dlv = new DisplayListVisitor();
|
||||
DisplayListVisitor* dlv = osgNew DisplayListVisitor();
|
||||
dlv->setState(_state.get());
|
||||
dlv->setNodeMaskOverride(0xffffffff);
|
||||
_initVisitor = dlv;
|
||||
//#endif
|
||||
|
||||
_appVisitor = new AppVisitor;
|
||||
_appVisitor = osgNew AppVisitor;
|
||||
|
||||
_cullVisitor = new CullVisitor;
|
||||
_cullVisitor = osgNew CullVisitor;
|
||||
|
||||
_cullVisitor->setRenderGraph(_rendergraph.get());
|
||||
_cullVisitor->setRenderStage(_renderStage.get());
|
||||
@@ -94,16 +94,16 @@ void SceneView::setDefaults()
|
||||
_globalState->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||
|
||||
// set up an alphafunc by default to speed up blending operations.
|
||||
osg::AlphaFunc* alphafunc = new osg::AlphaFunc;
|
||||
osg::AlphaFunc* alphafunc = osgNew osg::AlphaFunc;
|
||||
alphafunc->setFunction(osg::AlphaFunc::GREATER,0.0f);
|
||||
_globalState->setAttributeAndModes(alphafunc, osg::StateAttribute::ON);
|
||||
|
||||
// set up an alphafunc by default to speed up blending operations.
|
||||
osg::TexEnv* texenv = new osg::TexEnv;
|
||||
osg::TexEnv* texenv = osgNew osg::TexEnv;
|
||||
texenv->setMode(osg::TexEnv::MODULATE);
|
||||
_globalState->setAttributeAndModes(texenv, osg::StateAttribute::ON);
|
||||
|
||||
osg::LightModel* lightmodel = new osg::LightModel;
|
||||
osg::LightModel* lightmodel = osgNew osg::LightModel;
|
||||
lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
|
||||
_globalState->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
|
||||
|
||||
@@ -163,8 +163,8 @@ void SceneView::cull()
|
||||
|
||||
_camera->setScreenDistance(_displaySettings->getScreenDistance());
|
||||
|
||||
_cameraLeft = new osg::Camera(*_camera);
|
||||
_cameraRight = new osg::Camera(*_camera);
|
||||
_cameraLeft = osgNew osg::Camera(*_camera);
|
||||
_cameraRight = osgNew osg::Camera(*_camera);
|
||||
|
||||
float iod = _displaySettings->getEyeSeperation();
|
||||
|
||||
@@ -216,11 +216,11 @@ void SceneView::cullStage(osg::Camera* camera, osgUtil::CullVisitor* cullVisitor
|
||||
}
|
||||
|
||||
// get the camera's modelview
|
||||
osg::Matrix* modelview = new osg::Matrix(camera->getModelViewMatrix());
|
||||
osg::Matrix* modelview = osgNew osg::Matrix(camera->getModelViewMatrix());
|
||||
|
||||
|
||||
// take a copy of camera, and init it home
|
||||
osg::Camera* local_camera = new Camera(*camera);
|
||||
osg::Camera* local_camera = osgNew Camera(*camera);
|
||||
local_camera->home();
|
||||
local_camera->attachTransform(osg::Camera::NO_ATTACHED_TRANSFORM);
|
||||
|
||||
@@ -364,8 +364,8 @@ void SceneView::draw()
|
||||
break;
|
||||
case(osg::DisplaySettings::ANAGLYPHIC):
|
||||
{
|
||||
osg::ref_ptr<osg::ColorMask> red = new osg::ColorMask;
|
||||
osg::ref_ptr<osg::ColorMask> green = new osg::ColorMask;
|
||||
osg::ref_ptr<osg::ColorMask> red = osgNew osg::ColorMask;
|
||||
osg::ref_ptr<osg::ColorMask> green = osgNew osg::ColorMask;
|
||||
|
||||
red->setMask(true,false,false,true);
|
||||
green->setMask(false,true,true,true);
|
||||
@@ -408,7 +408,7 @@ void SceneView::drawStage(osgUtil::RenderStage* renderStage)
|
||||
osg::notify(osg::WARN) << " creating a state automatically."<< std::endl;
|
||||
|
||||
// note the constructor for osg::State will set ContextID to 0.
|
||||
_state = new osg::State;
|
||||
_state = osgNew osg::State;
|
||||
}
|
||||
// we in theory should be able to
|
||||
_state->reset();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
using namespace osgUtil;
|
||||
|
||||
SceneViewManipulator::SceneViewManipulator():
|
||||
_cm(new TrackballManipulator),
|
||||
_gm(new StateSetManipulator)
|
||||
_cm(osgNew TrackballManipulator),
|
||||
_gm(osgNew StateSetManipulator)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ void SmoothingVisitor::smooth(osg::GeoSet& gset)
|
||||
int ncoords = gset.getNumCoords();
|
||||
osg::Vec3 *coords = gset.getCoords();
|
||||
osg::GeoSet::IndexPointer cindex = gset.getCoordIndices();
|
||||
osg::Vec3 *norms = new osg::Vec3[ncoords];
|
||||
osg::Vec3 *norms = osgNew osg::Vec3[ncoords];
|
||||
|
||||
int j;
|
||||
for(j = 0; j < ncoords; j++ )
|
||||
|
||||
@@ -48,7 +48,7 @@ void createStrips(
|
||||
assert(nStripCount > 0);
|
||||
|
||||
noPrims = strips.size()+leftoverFaces.size();
|
||||
*lens = new int [noPrims];
|
||||
*lens = osgNew int [noPrims];
|
||||
|
||||
int* lensPtr = *lens;
|
||||
|
||||
@@ -61,7 +61,7 @@ void createStrips(
|
||||
|
||||
noIndices += leftoverFaces.size()*3;
|
||||
|
||||
*osg_indices = new osg::ushort[noIndices];
|
||||
*osg_indices = osgNew osg::ushort[noIndices];
|
||||
osg::ushort *osg_indicesPtr = *osg_indices;
|
||||
|
||||
for (i = 0; i < strips.size(); i++)
|
||||
|
||||
Reference in New Issue
Block a user