diff --git a/include/osg/CollectOccludersVisitor b/include/osg/CollectOccludersVisitor index c029e0de6..8846ec3f9 100644 --- a/include/osg/CollectOccludersVisitor +++ b/include/osg/CollectOccludersVisitor @@ -22,7 +22,7 @@ class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::C CollectOccludersVisitor(); virtual ~CollectOccludersVisitor(); - virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); } + virtual CollectOccludersVisitor* cloneType() const { return osgNew CollectOccludersVisitor(); } virtual void reset(); diff --git a/include/osg/MemoryManager b/include/osg/MemoryManager index 844dd83ff..99dee3644 100644 --- a/include/osg/MemoryManager +++ b/include/osg/MemoryManager @@ -27,19 +27,20 @@ typedef struct tag_au { - size_t actualSize; - size_t reportedSize; - void *actualAddress; - void *reportedAddress; - char sourceFile[40]; - char sourceFunc[40]; + size_t actualSize; + size_t reportedSize; + void *actualAddress; + void *reportedAddress; + char sourceFile[40]; + char sourceFunc[40]; unsigned int sourceLine; unsigned int allocationType; - bool breakOnDealloc; - bool breakOnRealloc; + bool breakOnDealloc; + bool breakOnRealloc; unsigned int allocationNumber; - struct tag_au *next; - struct tag_au *prev; + struct tag_au *next; + struct tag_au *prev; + bool printedOutUnintializedInfo; } sAllocUnit; typedef struct diff --git a/include/osgDB/Registry b/include/osgDB/Registry index d8f936633..ea0850dea 100644 --- a/include/osgDB/Registry +++ b/include/osgDB/Registry @@ -209,7 +209,7 @@ class RegisterDotOsgWrapperProxy { if (Registry::instance()) { - _wrapper = new DotOsgWrapper(proto,name,associates,readFunc,writeFunc,readWriteMode); + _wrapper = osgNew DotOsgWrapper(proto,name,associates,readFunc,writeFunc,readWriteMode); Registry::instance()->addDotOsgWrapper(_wrapper.get()); } } @@ -235,7 +235,7 @@ class RegisterReaderWriterProxy { if (Registry::instance()) { - _rw = new T; + _rw = osgNew T; Registry::instance()->addReaderWriter(_rw.get()); } } diff --git a/include/osgGLUT/Viewer b/include/osgGLUT/Viewer index d92292354..023841e4f 100644 --- a/include/osgGLUT/Viewer +++ b/include/osgGLUT/Viewer @@ -144,14 +144,21 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter int flat_shade; float frRate; // gwm Jul 2001 added convolved ('averaged') frame rate int _printStats; // gwm Jul 2001 change from bool - struct { // gwm Jul 2001, added for display of statistics + + struct StatsRecord + { // gwm Jul 2001, added for display of statistics + StatsRecord(): + timeApp(0), timeCull(0), timeDraw(0), timeFrame(0), + frameend(0) {} + float timeApp, timeCull, timeDraw, timeFrame; osg::Timer_t frameend; - } times[3]; // store up to 3 frames worth of times + }; + StatsRecord times[3]; // store up to 3 frames worth of times + bool _useDisplayLists; osg::Timer _timer; - osg::Timer_t _tickRatePerSecond; osg::Timer_t _initialTick; osg::Timer_t _lastFrameTick; osg::Timer_t _frameTick; diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 23a6f974d..11bc3c4fc 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -44,7 +44,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac CullVisitor(); virtual ~CullVisitor(); - virtual CullVisitor* cloneType() const { return new CullVisitor(); } + virtual CullVisitor* cloneType() const { return osgNew CullVisitor(); } virtual void reset(); @@ -318,7 +318,7 @@ inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable, } // otherwise need to create new renderleaf. - RenderLeaf* renderleaf = new RenderLeaf(drawable,projection,matrix,depth); + RenderLeaf* renderleaf = osgNew RenderLeaf(drawable,projection,matrix,depth); _reuseRenderLeafList.push_back(renderleaf); ++_currentReuseRenderLeafIndex; return renderleaf; diff --git a/include/osgUtil/DepthSortedBin b/include/osgUtil/DepthSortedBin index 1a1c629a4..6096f6410 100644 --- a/include/osgUtil/DepthSortedBin +++ b/include/osgUtil/DepthSortedBin @@ -16,8 +16,8 @@ class OSGUTIL_EXPORT DepthSortedBin : public RenderBin DepthSortedBin(); - virtual osg::Object* cloneType() const { return new DepthSortedBin(); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new DepthSortedBin(); } // note only implements a clone of type. + virtual osg::Object* cloneType() const { return osgNew DepthSortedBin(); } + virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew DepthSortedBin(); } // note only implements a clone of type. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* libraryName() const { return "osgUtil"; } virtual const char* className() const { return "DepthSortedBin"; } diff --git a/include/osgUtil/RenderBin b/include/osgUtil/RenderBin index f96c53297..29d127f55 100644 --- a/include/osgUtil/RenderBin +++ b/include/osgUtil/RenderBin @@ -37,8 +37,8 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object RenderBin(); - virtual osg::Object* cloneType() const { return new RenderBin(); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderBin(); } // note only implements a clone of type. + virtual osg::Object* cloneType() const { return osgNew RenderBin(); } + virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderBin(); } // note only implements a clone of type. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* libraryName() const { return "osgUtil"; } virtual const char* className() const { return "RenderBin"; } @@ -93,7 +93,7 @@ class RegisterRenderBinProxy public: RegisterRenderBinProxy() { - _rb = new T; + _rb = osgNew T; RenderBin::addRenderBinPrototype(_rb.get()); } diff --git a/include/osgUtil/RenderGraph b/include/osgUtil/RenderGraph index 466aa63cf..f5d815477 100644 --- a/include/osgUtil/RenderGraph +++ b/include/osgUtil/RenderGraph @@ -51,21 +51,24 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced _parent(NULL), _stateset(NULL), _depth(0), - _averageDistance(0) + _averageDistance(0), + _userData(NULL) { } RenderGraph(RenderGraph* parent,const osg::StateSet* stateset): _parent(parent), - _stateset(stateset) + _stateset(stateset), + _depth(0), + _averageDistance(0), + _userData(NULL) { if (_parent) _depth = _parent->_depth + 1; - else _depth = 0; } ~RenderGraph() {} - RenderGraph* cloneType() const { return new RenderGraph; } + RenderGraph* cloneType() const { return osgNew RenderGraph; } void setUserData(osg::Referenced* obj) { _userData = obj; } osg::Referenced* getUserData() { return _userData.get(); } @@ -125,7 +128,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced // create a state group and insert it into the children list // then return the state group. - RenderGraph* sg = new RenderGraph(this,stateset); + RenderGraph* sg = osgNew RenderGraph(this,stateset); _children[stateset] = sg; return sg; } diff --git a/include/osgUtil/RenderStage b/include/osgUtil/RenderStage index b434e0a8b..fe6184c23 100644 --- a/include/osgUtil/RenderStage +++ b/include/osgUtil/RenderStage @@ -28,8 +28,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin RenderStage(); - virtual osg::Object* cloneType() const { return new RenderStage(); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderStage(); } // note only implements a clone of type. + virtual osg::Object* cloneType() const { return osgNew RenderStage(); } + virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderStage(); } // note only implements a clone of type. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* className() const { return "RenderStage"; } @@ -96,7 +96,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin RenderStageLighting* getRenderStageLighting() const { - if (!_renderStageLighting.valid()) _renderStageLighting = new RenderStageLighting; + if (!_renderStageLighting.valid()) _renderStageLighting = osgNew RenderStageLighting; return _renderStageLighting.get(); } diff --git a/include/osgUtil/RenderStageLighting b/include/osgUtil/RenderStageLighting index 0cac20693..913f1de1b 100644 --- a/include/osgUtil/RenderStageLighting +++ b/include/osgUtil/RenderStageLighting @@ -23,8 +23,8 @@ class OSGUTIL_EXPORT RenderStageLighting : public osg::Object RenderStageLighting(); - virtual osg::Object* cloneType() const { return new RenderStageLighting(); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderStageLighting(); } // note only implements a clone of type. + virtual osg::Object* cloneType() const { return osgNew RenderStageLighting(); } + virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderStageLighting(); } // note only implements a clone of type. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* libraryName() const { return "osgUtil"; } virtual const char* className() const { return "RenderStageLighting"; } diff --git a/include/osgUtil/RenderToTextureStage b/include/osgUtil/RenderToTextureStage index 66866bb10..de4181158 100644 --- a/include/osgUtil/RenderToTextureStage +++ b/include/osgUtil/RenderToTextureStage @@ -23,8 +23,8 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage RenderToTextureStage(); - virtual osg::Object* cloneType() const { return new RenderToTextureStage(); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderToTextureStage(); } // note only implements a clone of type. + virtual osg::Object* cloneType() const { return osgNew RenderToTextureStage(); } + virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderToTextureStage(); } // note only implements a clone of type. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=0L; } virtual const char* libraryName() const { return "osgUtil"; } virtual const char* className() const { return "RenderToTextureStage"; } diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index 4b4477b04..e0e3a604c 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -55,7 +55,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced else { // ensure that _viewport is always valid. - _viewport = new osg::Viewport; + _viewport = osgNew osg::Viewport; } } diff --git a/src/Demos/osgcube/osgcube.cpp b/src/Demos/osgcube/osgcube.cpp index 7c03d68e2..c50511508 100644 --- a/src/Demos/osgcube/osgcube.cpp +++ b/src/Demos/osgcube/osgcube.cpp @@ -168,16 +168,18 @@ int main( int argc, char **argv ) for(int i=1;iaddChild( createGeometryCube() ); - + // move node in a circle at 90 degrees a sec. myTransform->setAppCallback(new MyTransformCallback(myTransform,osg::inDegrees(90.0f))); diff --git a/src/osg/MemoryManager.cpp b/src/osg/MemoryManager.cpp index 5eecc0d51..1c4bb053a 100644 --- a/src/osg/MemoryManager.cpp +++ b/src/osg/MemoryManager.cpp @@ -502,12 +502,14 @@ sMStats m_getMemoryStatistics() else ++numNotMatching; } - if (numMatching>0) + if (numMatching>0 && !allocUnit->printedOutUnintializedInfo) { // possible unitialized data? std::cout<<"possible uninitilized memory numMatching="<sourceFile<<"' sourceLine="<sourceLine<printedOutUnintializedInfo=true; + return false; } return true; diff --git a/src/osgGLUT/Viewer.cpp b/src/osgGLUT/Viewer.cpp index 3675916a4..b2531bb78 100644 --- a/src/osgGLUT/Viewer.cpp +++ b/src/osgGLUT/Viewer.cpp @@ -117,7 +117,8 @@ Viewer::Viewer() _initialTick = _timer.tick(); _frameTick = _initialTick; - frRate=0; // added by gwm to display fram Rate smoothed + _lastFrameTick = _initialTick; + frRate=0; _focusedViewport = 0; // The viewport with mouse/keyboard focus @@ -125,6 +126,19 @@ Viewer::Viewer() _frameStamp = osgNew osg::FrameStamp; _displaySettings = osgNew osg::DisplaySettings; + + + + + + + + + + + + + } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 054dc095b..dafb2eb12 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -82,7 +82,6 @@ CullVisitor::CullVisitor() //_tsm = LOOK_VECTOR_DISTANCE; _tsm = OBJECT_EYE_POINT_DISTANCE; - _computeNearFar = COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES; _computed_znear = FLT_MAX; _computed_zfar = -FLT_MAX; @@ -93,6 +92,11 @@ CullVisitor::CullVisitor() _numFramesToKeepImpostorSprites = 10; _impostorSpriteManager = osgNew ImpostorSpriteManager; + _currentRenderGraph = NULL; + _currentRenderBin = NULL; + + _currentReuseRenderLeafIndex=0; + }