From b546c63139ee0337604fe3c5a898f8ac9839cd23 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 Aug 2002 21:40:38 +0000 Subject: [PATCH] Changed instances of new across to use osgNew to help debugging, and fixed an unitialized variable in Sequence. --- include/osg/Sequence | 12 ++++++++---- include/osg/UnitTestFramework | 4 ++-- src/osg/ClipNode.cpp | 12 ++++++------ src/osg/Sequence.cpp | 29 +++++++++++++++++------------ src/osg/UnitTestFramework.cpp | 4 ++-- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/osg/Sequence b/include/osg/Sequence index 3d9fa921b..d4e814614 100644 --- a/include/osg/Sequence +++ b/include/osg/Sequence @@ -34,7 +34,8 @@ public : const float getTime(int frame) const; /** Interval modes */ - enum LoopMode { + enum LoopMode + { LOOP, SWING }; @@ -43,7 +44,8 @@ public : void setInterval(LoopMode mode, int begin, int end); /** Get sequence mode & interval. */ - inline void getInterval(LoopMode& mode, int& begin, int& end) const { + inline void getInterval(LoopMode& mode, int& begin, int& end) const + { mode = _loopMode; begin = _begin; end = _end; @@ -53,13 +55,15 @@ public : void setDuration(float speed, int nreps = -1); /** Get duration */ - inline void getDuration(float& speed, int& nreps) const { + inline void getDuration(float& speed, int& nreps) const + { speed = _speed; nreps = _nreps; } /** Sequence modes */ - enum SequenceMode { + enum SequenceMode + { START, STOP, PAUSE, diff --git a/include/osg/UnitTestFramework b/include/osg/UnitTestFramework index 24ab0685d..78327bf74 100644 --- a/include/osg/UnitTestFramework +++ b/include/osg/UnitTestFramework @@ -459,7 +459,7 @@ Starts a TestSuite singleton function { \ static osg::ref_ptr s_suite = 0; \ if ( s_suite == 0 ) { \ - s_suite = new osgUtx::TestSuite( #tsuite ); + s_suite = osgNew osgUtx::TestSuite( #tsuite ); @@ -468,7 +468,7 @@ Adds a test case to a suite object being created in a TestSuite singleton functi @see OSGUTX_BEGIN_TESTSUITE, OSGUTX_END_TESTSUITE */ #define OSGUTX_ADD_TESTCASE( tfixture, tmethod ) \ - s_suite->add( new osgUtx::TestCase_( \ + s_suite->add( osgNew osgUtx::TestCase_( \ #tmethod, &tfixture::tmethod ) ); /** diff --git a/src/osg/ClipNode.cpp b/src/osg/ClipNode.cpp index 59824977d..f7ca6423a 100644 --- a/src/osg/ClipNode.cpp +++ b/src/osg/ClipNode.cpp @@ -28,14 +28,14 @@ void ClipNode::createClipBox(const BoundingBox& bb,unsigned int clipPlaneNumberB { _planes.clear(); - _planes.push_back(new ClipPlane(clipPlaneNumberBase ,1.0,0.0,0.0,-bb.xMin())); - _planes.push_back(new ClipPlane(clipPlaneNumberBase+1,-1.0,0.0,0.0,bb.xMax())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase ,1.0,0.0,0.0,-bb.xMin())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase+1,-1.0,0.0,0.0,bb.xMax())); - _planes.push_back(new ClipPlane(clipPlaneNumberBase+2,0.0,1.0,0.0,-bb.yMin())); - _planes.push_back(new ClipPlane(clipPlaneNumberBase+3,0.0,-1.0,0.0,bb.yMax())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase+2,0.0,1.0,0.0,-bb.yMin())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase+3,0.0,-1.0,0.0,bb.yMax())); - _planes.push_back(new ClipPlane(clipPlaneNumberBase+4,0.0,0.0,1.0,-bb.zMin())); - _planes.push_back(new ClipPlane(clipPlaneNumberBase+5,0.0,0.0,-1.0,bb.zMax())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase+4,0.0,0.0,1.0,-bb.zMin())); + _planes.push_back(osgNew ClipPlane(clipPlaneNumberBase+5,0.0,0.0,-1.0,bb.zMax())); setLocalStateSetModes(_value); } diff --git a/src/osg/Sequence.cpp b/src/osg/Sequence.cpp index 93654eeb5..a49a4cd36 100644 --- a/src/osg/Sequence.cpp +++ b/src/osg/Sequence.cpp @@ -8,26 +8,31 @@ using namespace osg; Sequence::Sequence() : Switch(), _last(-1.0f), - _step(1) + _step(1), + _loopMode(LOOP), + _begin(0), + _end(-1), + _speed(0), + _nreps(0), + _nrepsremain(0), + _mode(STOP) { - _frameTime.clear(); - setInterval(LOOP, 0, -1); - setMode(STOP); - setNumChildrenRequiringAppTraversal(1); } Sequence::Sequence(const Sequence& seq, const CopyOp& copyop) : Switch(seq, copyop), _last(seq._last), - _frameTime(seq._frameTime), - _step(seq._step) + _step(seq._step), + _loopMode(seq._loopMode), + _begin(seq._begin), + _end(seq._end), + _speed(seq._speed), + _nreps(seq._nreps), + _nrepsremain(seq._nrepsremain), + _mode(seq._mode) { - setInterval(seq._loopMode, seq._begin, seq._end); - setDuration(seq._speed, seq._nreps); - setMode(seq._mode); - - setNumChildrenRequiringAppTraversal(1); + setNumChildrenRequiringAppTraversal(getNumChildrenRequiringAppTraversal()+1); } void Sequence::setTime(int frame, float t) diff --git a/src/osg/UnitTestFramework.cpp b/src/osg/UnitTestFramework.cpp index 32780234d..2737006cb 100644 --- a/src/osg/UnitTestFramework.cpp +++ b/src/osg/UnitTestFramework.cpp @@ -141,7 +141,7 @@ TestSuite* TestGraph::suite( if(createIfNecessary){ - TestSuite* childSuite = new TestSuite(*it); + TestSuite* childSuite = osgNew TestSuite(*it); tsuite->add(childSuite); return suite(it, end, childSuite, createIfNecessary); } @@ -149,7 +149,7 @@ TestSuite* TestGraph::suite( return 0; } -TestGraph::TestGraph(): root_(new TestSuite("root")) +TestGraph::TestGraph(): root_(osgNew TestSuite("root")) { }