diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d758262..84890624c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ PROJECT(OpenSceneGraph) SET(OPENSCENEGRAPH_MAJOR_VERSION 2) SET(OPENSCENEGRAPH_MINOR_VERSION 9) SET(OPENSCENEGRAPH_PATCH_VERSION 11) -SET(OPENSCENEGRAPH_SOVERSION 69) +SET(OPENSCENEGRAPH_SOVERSION 70) # set to 0 when not a release candidate, non zero means that any generated # svn tags will be treated as release candidates of given number diff --git a/examples/osganimationmakepath/osganimationmakepath.cpp b/examples/osganimationmakepath/osganimationmakepath.cpp index c0e2e36ea..69416e925 100644 --- a/examples/osganimationmakepath/osganimationmakepath.cpp +++ b/examples/osganimationmakepath/osganimationmakepath.cpp @@ -88,7 +88,7 @@ osg::Timer_t _startTime; osg::Timer_t _currentTime; bool _playing; - int _lastUpdate; + unsigned int _lastUpdate; }; @@ -150,7 +150,7 @@ public: osg::Timer_t _startTime; osg::Timer_t _currentTime; bool _playing; - int _lastUpdate; + unsigned int _lastUpdate; }; // This won't really give good results in any situation, but it does demonstrate diff --git a/examples/osganimationnode/osganimationnode.cpp b/examples/osganimationnode/osganimationnode.cpp index 7728776dd..bf7d6632a 100644 --- a/examples/osganimationnode/osganimationnode.cpp +++ b/examples/osganimationnode/osganimationnode.cpp @@ -80,7 +80,7 @@ public: osg::Timer_t _startTime; osg::Timer_t _currentTime; bool _playing; - int _lastUpdate; + unsigned int _lastUpdate; }; @@ -143,7 +143,7 @@ public: osg::Timer_t _startTime; osg::Timer_t _currentTime; bool _playing; - int _lastUpdate; + unsigned int _lastUpdate; }; diff --git a/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp b/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp index 9584c6e10..0fd26dea6 100644 --- a/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp +++ b/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp @@ -91,7 +91,7 @@ class ElevationLayerBlendingCallback : public osg::NodeCallback typedef std::vector Elevations; ElevationLayerBlendingCallback(osgFX::MultiTextureControl* mtc, const Elevations& elevations, float animationTime=4.0f): - _previousFrame(-1), + _previousFrame(0), _previousTime(0.0), _animationTime(animationTime), _currentElevation(0.0), @@ -105,7 +105,7 @@ class ElevationLayerBlendingCallback : public osg::NodeCallback { float deltaTime = 0.01f; - if (_previousFrame!=-1) + if (_previousFrame!=0) { deltaTime = float(nv->getFrameStamp()->getReferenceTime() - _previousTime); } @@ -171,7 +171,7 @@ class ElevationLayerBlendingCallback : public osg::NodeCallback traverse(node,nv); } - int _previousFrame; + unsigned int _previousFrame; double _previousTime; float _animationTime; double _currentElevation; diff --git a/examples/osgposter/PosterPrinter.cpp b/examples/osgposter/PosterPrinter.cpp index 42f04abb4..74d2f5d5f 100644 --- a/examples/osgposter/PosterPrinter.cpp +++ b/examples/osgposter/PosterPrinter.cpp @@ -43,7 +43,7 @@ public: if ( nv->getFrameStamp() && updateTimeStamp ) { double timeStamp = nv->getFrameStamp()?nv->getFrameStamp()->getReferenceTime():0.0; - int frameNumber = nv->getFrameStamp()?nv->getFrameStamp()->getFrameNumber():0; + unsigned int frameNumber = nv->getFrameStamp()?nv->getFrameStamp()->getFrameNumber():0; pagedLOD->setFrameNumberOfLastTraversal( frameNumber ); pagedLOD->setTimeStamp( numChildren-1, timeStamp ); diff --git a/examples/osgposter/PosterPrinter.h b/examples/osgposter/PosterPrinter.h index 444d1e659..952d36b7a 100644 --- a/examples/osgposter/PosterPrinter.h +++ b/examples/osgposter/PosterPrinter.h @@ -142,7 +142,7 @@ protected: bool _isRunning; bool _isFinishing; - int _lastBindingFrame; + unsigned int _lastBindingFrame; int _tileRows; int _tileColumns; int _currentRow; diff --git a/examples/osguserstats/osguserstats.cpp b/examples/osguserstats/osguserstats.cpp index 5420ba77e..1eaf8bf73 100644 --- a/examples/osguserstats/osguserstats.cpp +++ b/examples/osguserstats/osguserstats.cpp @@ -87,7 +87,7 @@ void updateUserStats(osgViewer::Viewer& viewer) // use that frame's timings because it's probably not finished // rendering yet (in multithreaded viewer modes). So we'll use the // timings for framenumber-2 for this demo. - int framenumber = viewer.getFrameStamp()->getFrameNumber(); + unsigned int framenumber = viewer.getFrameStamp()->getFrameNumber(); // Get the update time and the viewer main camera's cull time. We use // getAveragedAttribute() in order to get the actual time elapsed as @@ -131,7 +131,7 @@ void startTiming(osgViewer::Viewer& viewer, const std::string& name) { osg::Timer_t tick = osg::Timer::instance()->tick(); double currentTime = osg::Timer::instance()->delta_s(viewer.getStartTick(), tick); - int framenumber = viewer.getFrameStamp()->getFrameNumber(); + unsigned int framenumber = viewer.getFrameStamp()->getFrameNumber(); viewer.getViewerStats()->setAttribute(framenumber, name + " begin", currentTime); } @@ -142,7 +142,7 @@ void endTiming(osgViewer::Viewer& viewer, const std::string& name) { osg::Timer_t tick = osg::Timer::instance()->tick(); double currentTime = osg::Timer::instance()->delta_s(viewer.getStartTick(), tick); - int framenumber = viewer.getFrameStamp()->getFrameNumber(); + unsigned int framenumber = viewer.getFrameStamp()->getFrameNumber(); viewer.getViewerStats()->setAttribute(framenumber, name + " end", currentTime); diff --git a/include/osg/DeleteHandler b/include/osg/DeleteHandler index c896a379d..0d10e7a1f 100644 --- a/include/osg/DeleteHandler +++ b/include/osg/DeleteHandler @@ -32,7 +32,7 @@ class OSG_EXPORT DeleteHandler { public: - typedef std::pair FrameNumberObjectPair; + typedef std::pair FrameNumberObjectPair; typedef std::list ObjectsToDeleteList; DeleteHandler(int numberOfFramesToRetainObjects=0); @@ -44,15 +44,15 @@ class OSG_EXPORT DeleteHandler * The ability to retain objects for several frames is useful to prevent premature deletion when objects * are still be used the graphics threads that are using double buffering of rendering data structures with * non ref_ptr<> pointers to scene graph elements.*/ - void setNumFramesToRetainObjects(int numberOfFramesToRetainObjects) { _numFramesToRetainObjects = numberOfFramesToRetainObjects; } + void setNumFramesToRetainObjects(unsigned int numberOfFramesToRetainObjects) { _numFramesToRetainObjects = numberOfFramesToRetainObjects; } - int getNumFramesToRetainObjects() const { return _numFramesToRetainObjects; } + unsigned int getNumFramesToRetainObjects() const { return _numFramesToRetainObjects; } /** Set the current frame number so that subsequent deletes get tagged as associated with this frame.*/ - void setFrameNumber(int frameNumber) { _currentFrameNumber = frameNumber; } + void setFrameNumber(unsigned int frameNumber) { _currentFrameNumber = frameNumber; } /** Get the current frame number.*/ - int getFrameNumber() const { return _currentFrameNumber; } + unsigned int getFrameNumber() const { return _currentFrameNumber; } inline void doDelete(const Referenced* object) { delete object; } @@ -76,10 +76,10 @@ class OSG_EXPORT DeleteHandler _currentFrameNumber(0) {} DeleteHandler operator = (const DeleteHandler&) { return *this; } - int _numFramesToRetainObjects; - int _currentFrameNumber; - OpenThreads::Mutex _mutex; - ObjectsToDeleteList _objectsToDelete; + unsigned int _numFramesToRetainObjects; + unsigned int _currentFrameNumber; + OpenThreads::Mutex _mutex; + ObjectsToDeleteList _objectsToDelete; }; diff --git a/include/osg/FrameStamp b/include/osg/FrameStamp index 3126bfa27..7cdea2164 100644 --- a/include/osg/FrameStamp +++ b/include/osg/FrameStamp @@ -40,8 +40,8 @@ class OSG_EXPORT FrameStamp : public Referenced FrameStamp& operator = (const FrameStamp& fs); - void setFrameNumber(int fnum) { _frameNumber = fnum; } - int getFrameNumber() const { return _frameNumber; } + void setFrameNumber(unsigned int fnum) { _frameNumber = fnum; } + unsigned int getFrameNumber() const { return _frameNumber; } void setReferenceTime(double refTime) { _referenceTime = refTime; } double getReferenceTime() const { return _referenceTime; } @@ -63,9 +63,9 @@ class OSG_EXPORT FrameStamp : public Referenced // via a simple memory copy or within a data packet across // the network. - int _frameNumber; - double _referenceTime; - double _simulationTime; + unsigned int _frameNumber; + double _referenceTime; + double _simulationTime; // member variables of time.h's tm structure, copied here to // ensure that all data is not dynamic. The tm structure itself diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index 86b98911c..9b502c377 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -42,6 +42,8 @@ class Transform; class Camera; class CameraView; +const unsigned int UNINITIALIZED_FRAME_NUMBER=0xffffffff; + #define META_NodeVisitor(library,name) \ virtual const char* libraryName() const { return #library; }\ virtual const char* className() const { return #name; } @@ -109,10 +111,10 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced inline VisitorType getVisitorType() const { return _visitorType; } /** Set the traversal number. Typically used to denote the frame count.*/ - inline void setTraversalNumber(int fn) { _traversalNumber = fn; } + inline void setTraversalNumber(unsigned int fn) { _traversalNumber = fn; } /** Get the traversal number. Typically used to denote the frame count.*/ - inline int getTraversalNumber() const { return _traversalNumber; } + inline unsigned int getTraversalNumber() const { return _traversalNumber; } /** Set the FrameStamp that this traversal is associated with.*/ inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; } @@ -326,7 +328,7 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced protected: VisitorType _visitorType; - int _traversalNumber; + unsigned int _traversalNumber; ref_ptr _frameStamp; diff --git a/include/osg/OcclusionQueryNode b/include/osg/OcclusionQueryNode index b0f47bb9f..8d9674f4e 100644 --- a/include/osg/OcclusionQueryNode +++ b/include/osg/OcclusionQueryNode @@ -122,8 +122,8 @@ public: unsigned int getVisibilityThreshold() const { return _visThreshold; } // Specifies how many frames to wait before issuing another query. - void setQueryFrameCount( int frames ) { _queryFrameCount = frames; } - int getQueryFrameCount() const { return _queryFrameCount; } + void setQueryFrameCount( unsigned int frames ) { _queryFrameCount = frames; } + unsigned int getQueryFrameCount() const { return _queryFrameCount; } // Indicate whether or not the bounding box used in the occlusion query test // should be rendered. Handy for debugging and development. @@ -179,7 +179,7 @@ protected: // Tracks the last frame number that we performed a query. // User can set how many times (See setQueryFrameCount). - typedef std::map< const osg::Camera*, int > FrameCountMap; + typedef std::map< const osg::Camera*, unsigned int > FrameCountMap; FrameCountMap _frameCountMap; mutable OpenThreads::Mutex _frameCountMutex; @@ -188,7 +188,7 @@ protected: // User-settable variables unsigned int _visThreshold; - int _queryFrameCount; + unsigned int _queryFrameCount; bool _debugBB; diff --git a/include/osg/PagedLOD b/include/osg/PagedLOD index 1972f9448..3f2711e4f 100644 --- a/include/osg/PagedLOD +++ b/include/osg/PagedLOD @@ -71,8 +71,8 @@ class OSG_EXPORT PagedLOD : public LOD float _priorityOffset; float _priorityScale; double _timeStamp; - int _frameNumber; - int _frameNumberOfLastReleaseGLObjects; + unsigned int _frameNumber; + unsigned int _frameNumberOfLastReleaseGLObjects; osg::ref_ptr _databaseRequest; }; @@ -96,8 +96,8 @@ class OSG_EXPORT PagedLOD : public LOD double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; } unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); } - void setFrameNumber(unsigned int childNo, int frameNumber) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._frameNumber=frameNumber; } - double getFrameNumber(unsigned int childNo) const { return _perRangeDataList[childNo]._frameNumber; } + void setFrameNumber(unsigned int childNo, unsigned int frameNumber) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._frameNumber=frameNumber; } + unsigned getFrameNumber(unsigned int childNo) const { return _perRangeDataList[childNo]._frameNumber; } unsigned int getNumFrameNumbers() const { return _perRangeDataList.size(); } @@ -114,10 +114,10 @@ class OSG_EXPORT PagedLOD : public LOD /** Set the frame number of the last time that this PageLOD node was traversed. * Note, this frame number is automatically set by the traverse() method for all traversals (update, cull etc.). */ - inline void setFrameNumberOfLastTraversal(int frameNumber) { _frameNumberOfLastTraversal=frameNumber; } + inline void setFrameNumberOfLastTraversal(unsigned int frameNumber) { _frameNumberOfLastTraversal=frameNumber; } /** Get the frame number of the last time that this PageLOD node was traversed.*/ - inline int getFrameNumberOfLastTraversal() const { return _frameNumberOfLastTraversal; } + inline unsigned int getFrameNumberOfLastTraversal() const { return _frameNumberOfLastTraversal; } /** Set the number of children that the PagedLOD must keep around, even if they are older than their expiry time.*/ @@ -137,11 +137,7 @@ class OSG_EXPORT PagedLOD : public LOD * The removed children are added to the removeChildren list passed into the method, * this allows the children to be deleted later at the caller's discretion. * Return true if children are removed, false otherwise. */ - virtual bool removeExpiredChildren(double expiryTime, int expiryFrame, NodeList& removedChildren); - - /** Release the GL Objects of the children from the PagedLOD which haven't been visited since specified expiry time and expiry frame number. - * Return true if any children have release called upon them, false otherwise. */ - virtual bool releaseGLObjectsOnExpiredChildren(double releaseTime, int releaseFrame); + virtual bool removeExpiredChildren(double expiryTime, unsigned int expiryFrame, NodeList& removedChildren); protected : @@ -152,7 +148,7 @@ class OSG_EXPORT PagedLOD : public LOD ref_ptr _databaseOptions; std::string _databasePath; - int _frameNumberOfLastTraversal; + unsigned int _frameNumberOfLastTraversal; unsigned int _numChildrenThatCannotBeExpired; bool _disableExternalChildrenPaging; diff --git a/include/osg/Stats b/include/osg/Stats index 129a892fc..0a4dc4ae0 100644 --- a/include/osg/Stats +++ b/include/osg/Stats @@ -38,15 +38,15 @@ class OSG_EXPORT Stats : public osg::Referenced void allocate(unsigned int numberOfFrames); - int getEarliestFrameNumber() const { return _latestFrameNumber < static_cast(_attributeMapList.size()) ? 0 : _latestFrameNumber - static_cast(_attributeMapList.size()) + 1; } - int getLatestFrameNumber() const { return _latestFrameNumber; } + unsigned int getEarliestFrameNumber() const { return _latestFrameNumber < static_cast(_attributeMapList.size()) ? 0 : _latestFrameNumber - static_cast(_attributeMapList.size()) + 1; } + unsigned int getLatestFrameNumber() const { return _latestFrameNumber; } typedef std::map AttributeMap; typedef std::vector AttributeMapList; - bool setAttribute(int frameNumber, const std::string& attributeName, double value); + bool setAttribute(unsigned int frameNumber, const std::string& attributeName, double value); - inline bool getAttribute(int frameNumber, const std::string& attributeName, double& value) const + inline bool getAttribute(unsigned int frameNumber, const std::string& attributeName, double& value) const { OpenThreads::ScopedLock lock(_mutex); return getAttributeNoMutex(frameNumber, attributeName, value); @@ -54,15 +54,15 @@ class OSG_EXPORT Stats : public osg::Referenced bool getAveragedAttribute(const std::string& attributeName, double& value, bool averageInInverseSpace=false) const; - bool getAveragedAttribute(int startFrameNumber, int endFrameNumber, const std::string& attributeName, double& value, bool averageInInverseSpace=false) const; + bool getAveragedAttribute(unsigned int startFrameNumber, unsigned int endFrameNumber, const std::string& attributeName, double& value, bool averageInInverseSpace=false) const; - inline AttributeMap& getAttributeMap(int frameNumber) + inline AttributeMap& getAttributeMap(unsigned int frameNumber) { OpenThreads::ScopedLock lock(_mutex); return getAttributeMapNoMutex(frameNumber); } - inline const AttributeMap& getAttributeMap(int frameNumber) const + inline const AttributeMap& getAttributeMap(unsigned int frameNumber) const { OpenThreads::ScopedLock lock(_mutex); return getAttributeMapNoMutex(frameNumber); @@ -87,13 +87,13 @@ class OSG_EXPORT Stats : public osg::Referenced virtual ~Stats() {} - bool getAttributeNoMutex(int frameNumber, const std::string& attributeName, double& value) const; + bool getAttributeNoMutex(unsigned int frameNumber, const std::string& attributeName, double& value) const; - AttributeMap& getAttributeMapNoMutex(int frameNumber); - const AttributeMap& getAttributeMapNoMutex(int frameNumber) const; + AttributeMap& getAttributeMapNoMutex(unsigned int frameNumber); + const AttributeMap& getAttributeMapNoMutex(unsigned int frameNumber) const; - int getIndex(int frameNumber) const + int getIndex(unsigned int frameNumber) const { // reject frame that are in the future if (frameNumber > _latestFrameNumber) return -1; @@ -109,8 +109,8 @@ class OSG_EXPORT Stats : public osg::Referenced mutable OpenThreads::Mutex _mutex; - int _baseFrameNumber; - int _latestFrameNumber; + unsigned int _baseFrameNumber; + unsigned int _latestFrameNumber; AttributeMapList _attributeMapList; AttributeMap _invalidAttributeMap; diff --git a/include/osg/Version b/include/osg/Version index 84c1a2259..0453ca8d6 100644 --- a/include/osg/Version +++ b/include/osg/Version @@ -21,7 +21,7 @@ extern "C" { #define OPENSCENEGRAPH_MAJOR_VERSION 2 #define OPENSCENEGRAPH_MINOR_VERSION 9 #define OPENSCENEGRAPH_PATCH_VERSION 11 -#define OPENSCENEGRAPH_SOVERSION 69 +#define OPENSCENEGRAPH_SOVERSION 70 /* Convenience macro that can be used to decide whether a feature is present or not i.e. * #if OSG_MIN_VERSION_REQUIRED(2,9,5) diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 1c45dceab..02a9e4519 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -104,8 +104,8 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl void setName(const std::string& name) { _name = name; } const std::string& getName() const { return _name; } - void setDone(bool done) { _done = done; } - bool getDone() const { return _done; } + void setDone(bool done) { _done.exchange(done?1:0); } + bool getDone() const { return _done!=0; } void setActive(bool active) { _active = active; } bool getActive() const { return _active; } @@ -118,7 +118,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl virtual ~DatabaseThread(); - volatile bool _done; + OpenThreads::Atomic _done; volatile bool _active; DatabasePager* _pager; Mode _mode; @@ -163,7 +163,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl /** Find all PagedLOD nodes in a subgraph and register them with * the DatabasePager so it can keep track of expired nodes. * note, should be only be called from the update thread. */ - virtual void registerPagedLODs(osg::Node* subgraph, int frameNumber = 0); + virtual void registerPagedLODs(osg::Node* subgraph, unsigned int frameNumber = 0); /** Set the incremental compile operation. * Used to manage the OpenGL object compilation and merging of subgraphs in a way that avoids overloading @@ -273,7 +273,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl virtual PagedLODList* clone() = 0; virtual void clear() = 0; virtual unsigned int size() = 0; - virtual void removeExpiredChildren(int numberChildrenToRemove, double expiryTime, int expiryFrame, ObjectList& childrenRemoved, bool visitActive) = 0; + virtual void removeExpiredChildren(int numberChildrenToRemove, double expiryTime, unsigned int expiryFrame, ObjectList& childrenRemoved, bool visitActive) = 0; virtual void removeNodes(osg::NodeList& nodesToRemove) = 0; virtual void insertPagedLOD(const osg::observer_ptr& plod) = 0; virtual bool containsPagedLOD(const osg::observer_ptr& plod) const = 0; @@ -309,10 +309,10 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl bool _valid; std::string _fileName; - int _frameNumberFirstRequest; + unsigned int _frameNumberFirstRequest; double _timestampFirstRequest; float _priorityFirstRequest; - int _frameNumberLastRequest; + unsigned int _frameNumberLastRequest; double _timestampLastRequest; float _priorityLastRequest; unsigned int _numOfRequests; @@ -362,7 +362,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl DatabasePager* _pager; RequestList _requestList; OpenThreads::Mutex _requestMutex; - int _frameNumberLastPruned; + unsigned int _frameNumberLastPruned; protected: virtual ~RequestQueue(); @@ -427,7 +427,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl int _numFramesActive; mutable OpenThreads::Mutex _numFramesActiveMutex; - volatile int _frameNumber; + OpenThreads::Atomic _frameNumber; osg::ref_ptr _fileRequestQueue; osg::ref_ptr _httpRequestQueue; diff --git a/include/osgParticle/ParticleProcessor b/include/osgParticle/ParticleProcessor index cd6e8e923..85fa7bd99 100644 --- a/include/osgParticle/ParticleProcessor +++ b/include/osgParticle/ParticleProcessor @@ -172,7 +172,7 @@ namespace osgParticle //added- 1/17/06- bgandere@nps.edu //a var to keep from doing multiple updates - int _frameNumber; + unsigned int _frameNumber; }; // INLINE FUNCTIONS diff --git a/include/osgParticle/ParticleSystem b/include/osgParticle/ParticleSystem index 97e4d7e85..c4886ef14 100644 --- a/include/osgParticle/ParticleSystem +++ b/include/osgParticle/ParticleSystem @@ -176,7 +176,7 @@ namespace osgParticle inline virtual void reuseParticle(int i) { _deadparts.push(&(_particles[i])); } /// Get the last frame number. - inline int getLastFrameNumber() const; + inline unsigned int getLastFrameNumber() const; /// Get the unique delta time for emitters and updaters to use inline double& getDeltaTime( double currentTime ); @@ -294,7 +294,7 @@ namespace osgParticle bool _bounds_computed; Particle _def_ptemp; - mutable int _last_frame; + mutable unsigned int _last_frame; mutable bool _dirty_dt; bool _freeze_on_cull; @@ -403,7 +403,7 @@ namespace osgParticle _particles[i].kill(); } - inline int ParticleSystem::getLastFrameNumber() const + inline unsigned int ParticleSystem::getLastFrameNumber() const { return _last_frame; } diff --git a/include/osgParticle/ParticleSystemUpdater b/include/osgParticle/ParticleSystemUpdater index ef9fa71f4..d80e99861 100644 --- a/include/osgParticle/ParticleSystemUpdater +++ b/include/osgParticle/ParticleSystemUpdater @@ -89,7 +89,7 @@ namespace osgParticle //added 1/17/06- bgandere@nps.edu //a var to keep from doing multiple updates per frame - int _frameNumber; + unsigned int _frameNumber; }; // INLINE FUNCTIONS diff --git a/include/osgPresentation/CompileSlideCallback b/include/osgPresentation/CompileSlideCallback index b2eb53c58..707b0b0f2 100644 --- a/include/osgPresentation/CompileSlideCallback +++ b/include/osgPresentation/CompileSlideCallback @@ -35,7 +35,7 @@ class OSGPRESENTATION_EXPORT CompileSlideCallback : public osg::Camera::DrawCall virtual ~CompileSlideCallback() {} mutable bool _needCompile; - mutable int _frameNumber; + mutable unsigned int _frameNumber; osg::ref_ptr _sceneToCompile; }; diff --git a/include/osgQt/QGraphicsViewAdapter b/include/osgQt/QGraphicsViewAdapter index 805ac5007..5afb01ecc 100644 --- a/include/osgQt/QGraphicsViewAdapter +++ b/include/osgQt/QGraphicsViewAdapter @@ -91,7 +91,7 @@ class OSGQT_EXPORT QGraphicsViewAdapter : public QObject OpenThreads::Mutex _qimagesMutex; OpenThreads::Mutex _qresizeMutex; - int _previousFrameNumber; + unsigned int _previousFrameNumber; bool _newImageAvailable; unsigned int _currentRead; unsigned int _currentWrite; diff --git a/include/osgSim/DOFTransform b/include/osgSim/DOFTransform index 873a2da8f..6f4cb3e8f 100644 --- a/include/osgSim/DOFTransform +++ b/include/osgSim/DOFTransform @@ -116,8 +116,8 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform virtual ~DOFTransform() {} - int _previousTraversalNumber; - double _previousTime; + unsigned int _previousTraversalNumber; + double _previousTime; osg::Vec3 _minHPR; osg::Vec3 _maxHPR; diff --git a/include/osgSim/ImpostorSprite b/include/osgSim/ImpostorSprite index 9e166c3cb..03f3426bc 100644 --- a/include/osgSim/ImpostorSprite +++ b/include/osgSim/ImpostorSprite @@ -71,10 +71,10 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable inline const osg::Vec3& getStoredLocalEyePoint() const { return _storedLocalEyePoint; } /** Set the frame number for when the ImpostorSprite was last used in rendering. */ - inline void setLastFrameUsed(int frameNumber) { _lastFrameUsed = frameNumber; } + inline void setLastFrameUsed(unsigned int frameNumber) { _lastFrameUsed = frameNumber; } /** Get the frame number for when the ImpostorSprite was last used in rendering. */ - inline int getLastFrameUsed() const { return _lastFrameUsed; } + inline unsigned int getLastFrameUsed() const { return _lastFrameUsed; } /** Get the coordinates of the corners of the quad. @@ -180,7 +180,7 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable ImpostorSprite* _previous; ImpostorSprite* _next; - int _lastFrameUsed; + unsigned int _lastFrameUsed; osg::Vec3 _storedLocalEyePoint; @@ -212,7 +212,7 @@ class OSGSIM_EXPORT ImpostorSpriteManager : public osg::Referenced void remove(ImpostorSprite* is); - ImpostorSprite* createOrReuseImpostorSprite(int s,int t,int frameNumber); + ImpostorSprite* createOrReuseImpostorSprite(int s,int t,unsigned int frameNumber); osg::StateSet* createOrReuseStateSet(); diff --git a/include/osgUtil/TransformCallback b/include/osgUtil/TransformCallback index f12b7aeda..c416fdab9 100644 --- a/include/osgUtil/TransformCallback +++ b/include/osgUtil/TransformCallback @@ -40,7 +40,7 @@ class OSGUTIL_EXPORT TransformCallback : public osg::NodeCallback osg::Vec3 _pivot; osg::Vec3 _axis; - int _previousTraversalNumber; + unsigned int _previousTraversalNumber; double _previousTime; bool _pause; diff --git a/include/osgViewer/Renderer b/include/osgViewer/Renderer index b039c3a75..adb4fe25b 100644 --- a/include/osgViewer/Renderer +++ b/include/osgViewer/Renderer @@ -29,7 +29,7 @@ class OSGVIEWER_EXPORT OpenGLQuerySupport : public osg::Referenced virtual void checkQuery(osg::Stats* stats, osg::State* state, osg::Timer_t startTick) = 0; - virtual void beginQuery(int frameNumber, osg::State* state) = 0; + virtual void beginQuery(unsigned int frameNumber, osg::State* state) = 0; virtual void endQuery(osg::State* state) = 0; virtual void initialize(osg::State* state, osg::Timer_t startTick); protected: diff --git a/src/osg/DeleteHandler.cpp b/src/osg/DeleteHandler.cpp index a103db1af..9c4b1e9d8 100644 --- a/src/osg/DeleteHandler.cpp +++ b/src/osg/DeleteHandler.cpp @@ -37,7 +37,7 @@ void DeleteHandler::flush() // list, but delete the objects outside this scoped lock so that if any objects deleted // unref their children then no deadlock happens. OpenThreads::ScopedLock lock(_mutex); - int frameNumberToClearTo = _currentFrameNumber - _numFramesToRetainObjects; + unsigned int frameNumberToClearTo = _currentFrameNumber - _numFramesToRetainObjects; ObjectsToDeleteList::iterator itr; for(itr = _objectsToDelete.begin(); @@ -65,7 +65,7 @@ void DeleteHandler::flush() void DeleteHandler::flushAll() { - int temp_numFramesToRetainObjects = _numFramesToRetainObjects; + unsigned int temp_numFramesToRetainObjects = _numFramesToRetainObjects; _numFramesToRetainObjects = 0; typedef std::list DeletionList; diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index 79be46833..171454f1f 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -512,7 +512,7 @@ OcclusionQueryNode::getPassed( const osg::Camera* camera, osg::NodeVisitor& nv ) // 2) we haven't rendered for an abnormally long time (probably because we're an out-of-range LOD child) // In these cases, assume we're visible to avoid blinking. OpenThreads::ScopedLock lock( _frameCountMutex ); - const int& lastQueryFrame( _frameCountMap[ camera ] ); + const unsigned int& lastQueryFrame( _frameCountMap[ camera ] ); if( ( lastQueryFrame == 0 ) || ( (nv.getTraversalNumber() - lastQueryFrame) > (_queryFrameCount + 1) ) ) return true; @@ -559,7 +559,7 @@ OcclusionQueryNode::traverseQuery( const osg::Camera* camera, osg::NodeVisitor& const int curFrame = nv.getTraversalNumber(); OpenThreads::ScopedLock lock( _frameCountMutex ); - int& lastQueryFrame = _frameCountMap[ camera ]; + unsigned int& lastQueryFrame = _frameCountMap[ camera ]; issueQuery = (curFrame - lastQueryFrame >= _queryFrameCount); if (issueQuery) lastQueryFrame = curFrame; diff --git a/src/osg/PagedLOD.cpp b/src/osg/PagedLOD.cpp index bfd15bdf0..9a1cf4774 100644 --- a/src/osg/PagedLOD.cpp +++ b/src/osg/PagedLOD.cpp @@ -127,7 +127,7 @@ void PagedLOD::traverse(NodeVisitor& nv) } double timeStamp = nv.getFrameStamp()?nv.getFrameStamp()->getReferenceTime():0.0; - int frameNumber = nv.getFrameStamp()?nv.getFrameStamp()->getFrameNumber():0; + unsigned int frameNumber = nv.getFrameStamp()?nv.getFrameStamp()->getFrameNumber():0; bool updateTimeStamp = nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR; switch(nv.getTraversalMode()) @@ -284,7 +284,7 @@ bool PagedLOD::removeChildren( unsigned int pos,unsigned int numChildrenToRemove return Group::removeChildren(pos,numChildrenToRemove); } -bool PagedLOD::removeExpiredChildren(double expiryTime, int expiryFrame, NodeList& removedChildren) +bool PagedLOD::removeExpiredChildren(double expiryTime, unsigned int expiryFrame, NodeList& removedChildren) { if (_children.size()>_numChildrenThatCannotBeExpired) { @@ -299,23 +299,3 @@ bool PagedLOD::removeExpiredChildren(double expiryTime, int expiryFrame, NodeLis } return false; } - -bool PagedLOD::releaseGLObjectsOnExpiredChildren(double releaseTime, int releaseFrame) -{ - unsigned int numChildrenReleased = 0; - - unsigned int numChildren = osg::minimum(_perRangeDataList.size(), _children.size()); - for(unsigned int i=_numChildrenThatCannotBeExpired; ireleaseGLObjects(); - ++numChildrenReleased; - } - } - return numChildrenReleased>0; -} diff --git a/src/osg/Stats.cpp b/src/osg/Stats.cpp index 48aa2a38f..9c6d21a5b 100644 --- a/src/osg/Stats.cpp +++ b/src/osg/Stats.cpp @@ -40,7 +40,7 @@ void Stats::allocate(unsigned int numberOfFrames) } -bool Stats::setAttribute(int frameNumber, const std::string& attributeName, double value) +bool Stats::setAttribute(unsigned int frameNumber, const std::string& attributeName, double value) { if (frameNumber= static_cast(_attributeMapList.size())) + if ( (frameNumber-_baseFrameNumber) >= static_cast(_attributeMapList.size())) { _baseFrameNumber = (frameNumber/_attributeMapList.size())*_attributeMapList.size(); } @@ -79,7 +79,7 @@ bool Stats::setAttribute(int frameNumber, const std::string& attributeName, doub return true; } -bool Stats::getAttributeNoMutex(int frameNumber, const std::string& attributeName, double& value) const +bool Stats::getAttributeNoMutex(unsigned int frameNumber, const std::string& attributeName, double& value) const { int index = getIndex(frameNumber); if (index<0) return false; @@ -97,7 +97,7 @@ bool Stats::getAveragedAttribute(const std::string& attributeName, double& value return getAveragedAttribute(getEarliestFrameNumber(), getLatestFrameNumber(), attributeName, value, averageInInverseSpace); } -bool Stats::getAveragedAttribute(int startFrameNumber, int endFrameNumber, const std::string& attributeName, double& value, bool averageInInverseSpace) const +bool Stats::getAveragedAttribute(unsigned int startFrameNumber, unsigned int endFrameNumber, const std::string& attributeName, double& value, bool averageInInverseSpace) const { if (endFrameNumber(geometry->getVertexArray()); if (!vertices) return; - int frameNumber = nv->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = nv->getFrameStamp()->getFrameNumber(); if (frameNumber == _frameNumber) return; @@ -253,7 +253,7 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback { osgText::Text* text = (osgText::Text*)drawable; - int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); if (frameNumber == _frameNumber) { text->drawImplementation(renderInfo); return; @@ -276,7 +276,7 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback osg::ref_ptr _stats; std::string _attributeName; mutable char _tmpText[128]; - mutable int _frameNumber; + mutable unsigned int _frameNumber; }; @@ -562,10 +562,10 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap typedef std::vector StatsList; StatsList statsList; - for (int i = 0; i < (int)finder._timelines.size(); i++) + for (unsigned int i = 0; i < finder._timelines.size(); i++) statsList.push_back(finder._timelines[i]->getStats()); - for(int i = statsList[0]->getEarliestFrameNumber(); i<= statsList[0]->getLatestFrameNumber()-1; ++i) + for(unsigned int i = statsList[0]->getEarliestFrameNumber(); i< statsList[0]->getLatestFrameNumber(); ++i) { for(StatsList::iterator itr = statsList.begin(); itr != statsList.end(); diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 7eb5f4245..6ec9846e7 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -46,10 +46,6 @@ using namespace OpenThreads; static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DO_PRE_COMPILE ","Switch on or off the pre compile of OpenGL object database pager."); static osg::ApplicationUsageProxy DatabasePager_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_DRAWABLE ","Set the drawable policy for setting of loaded drawable to specified type. mode can be one of DoNotModify, DisplayList, VBO or VertexArrays>."); static osg::ApplicationUsageProxy DatabasePager_e4(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_PRIORITY ", "Set the thread priority to DEFAULT, MIN, LOW, NOMINAL, HIGH or MAX."); -static osg::ApplicationUsageProxy DatabasePager_e7(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_EXPIRY_DELAY ","Set the length of time a PagedLOD child is kept in memory, without being used, before its tagged as expired, and ear marked to deletion."); -static osg::ApplicationUsageProxy DatabasePager_e8(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_EXPIRY_FRAMES ","Set number of frames a PagedLOD child is kept in memory, without being used, before its tagged as expired, and ear marked to deletion."); -static osg::ApplicationUsageProxy DatabasePager_e9(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_RELEASE_DELAY ","Set the length of time a PagedLOD child's OpenGL objects are kept in memory, without being used, before be released (setting to OFF disables this feature.)"); -static osg::ApplicationUsageProxy DatabasePager_e10(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_RELEASE_FRAMES ","Set number of frames a PagedLOD child's OpenGL objects are kept in memory, without being used, before be released."); static osg::ApplicationUsageProxy DatabasePager_e11(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_PAGEDLOD ","Set the target maximum number of PagedLOD to maintain."); // Convert function objects that take pointer args into functions that a @@ -154,10 +150,12 @@ public: traverse(plod); } - bool removeExpiredChildrenAndCountPagedLODs(osg::PagedLOD* plod, double expiryTime, int expiryFrame, osg::NodeList& removedChildren) + bool removeExpiredChildrenAndCountPagedLODs(osg::PagedLOD* plod, double expiryTime, unsigned int expiryFrame, osg::NodeList& removedChildren) { size_t sizeBefore = removedChildren.size(); + plod->removeExpiredChildren(expiryTime, expiryFrame, removedChildren); + for(size_t i = sizeBefore; iaccept(*this); @@ -197,7 +195,7 @@ public: virtual unsigned int size() { return _pagedLODs.size(); } virtual void removeExpiredChildren( - int numberChildrenToRemove, double expiryTime, int expiryFrame, + int numberChildrenToRemove, double expiryTime, unsigned int expiryFrame, DatabasePager::ObjectList& childrenRemoved, bool visitActive) { int leftToRemove = numberChildrenToRemove; @@ -208,34 +206,33 @@ public: osg::ref_ptr plod; if (itr->lock(plod)) { - int delta = expiryFrame - plod->getFrameNumberOfLastTraversal(); - if ((visitActive && delta > 0) || (!visitActive && delta <= 0)) + bool plodActive = expiryFrame < plod->getFrameNumberOfLastTraversal(); + if (visitActive==plodActive) // true if (visitActive && plodActive) OR (!visitActive &&!plodActive) { - ++itr; - continue; + DatabasePager::CountPagedLODsVisitor countPagedLODsVisitor; + osg::NodeList expiredChildren; // expired PagedLODs + countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs( + plod.get(), expiryTime, expiryFrame, expiredChildren); + // Clear any expired PagedLODs out of the set + for (DatabasePager::CountPagedLODsVisitor::PagedLODset::iterator + citr = countPagedLODsVisitor._pagedLODs.begin(), + end = countPagedLODsVisitor._pagedLODs.end(); + citr != end; + ++citr) + { + osg::observer_ptr clod(*citr); + // This child PagedLOD cannot be equal to the + // PagedLOD pointed to by itr because it must be + // in itr's subgraph. Therefore erasing it doesn't + // invalidate itr. + if (_pagedLODs.erase(clod) > 0) + leftToRemove--; + } + childrenRemoved.insert(childrenRemoved.end(), + expiredChildren.begin(), + expiredChildren.end()); } - DatabasePager::CountPagedLODsVisitor countPagedLODsVisitor; - osg::NodeList expiredChildren; // expired PagedLODs - countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs( - plod.get(), expiryTime, expiryFrame, expiredChildren); - // Clear any expired PagedLODs out of the set - for (DatabasePager::CountPagedLODsVisitor::PagedLODset::iterator - citr = countPagedLODsVisitor._pagedLODs.begin(), - end = countPagedLODsVisitor._pagedLODs.end(); - citr != end; - ++citr) - { - osg::observer_ptr clod(*citr); - // This child PagedLOD cannot be equal to the - // PagedLOD pointed to by itr because it must be - // in itr's subgraph. Therefore erasing it doesn't - // invalidate itr. - if (_pagedLODs.erase(clod) > 0) - leftToRemove--; - } - childrenRemoved.insert(childrenRemoved.end(), - expiredChildren.begin(), - expiredChildren.end()); + // advance the iterator to the next element ++itr; } @@ -485,7 +482,7 @@ bool DatabasePager::RequestQueue::pruneOldRequestsAndCheckIfEmpty() { OpenThreads::ScopedLock lock(_requestMutex); - int frameNumber = _pager->_frameNumber; + unsigned int frameNumber = _pager->_frameNumber; if (_frameNumberLastPruned != frameNumber) { for(RequestQueue::RequestList::iterator citr = _requestList.begin(); @@ -686,8 +683,7 @@ int DatabasePager::DatabaseThread::cancel() if( isRunning() ) { - - _done = true; + setDone(true); switch(_mode) { @@ -710,9 +706,10 @@ int DatabasePager::DatabaseThread::cancel() // OSG_INFO<<"Waiting for DatabasePager::DatabaseThread to cancel"<getReferenceTime():0.0; - int frameNumber = framestamp?framestamp->getFrameNumber():_frameNumber; + unsigned int frameNumber = framestamp?framestamp->getFrameNumber():static_cast(_frameNumber); // #define WITH_REQUESTNODEFILE_TIMING #ifdef WITH_REQUESTNODEFILE_TIMING @@ -1521,7 +1518,7 @@ void DatabasePager::signalBeginFrame(const osg::FrameStamp* framestamp) _dataToCompileList->pruneOldRequestsAndCheckIfEmpty(); //OSG_INFO << "signalBeginFrame "<getFrameNumber()<<">>>>>>>>>>>>>>>>"<getFrameNumber(); + _frameNumber.exchange(framestamp->getFrameNumber()); } //else OSG_INFO << "signalBeginFrame >>>>>>>>>>>>>>>>"<tick(), mid, last; @@ -1702,6 +1699,13 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) static double s_total_time_stage_c = 0.0; static double s_total_max_stage_c = 0.0; + if (frameStamp.getFrameNumber()==0) + { + // No need to remove anything on first frame. + return; + } + + osg::Timer_t startTick = osg::Timer::instance()->tick(); // numPagedLODs >= actual number of PagedLODs. There can be @@ -1727,7 +1731,7 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) ObjectList childrenRemoved; double expiryTime = frameStamp.getReferenceTime() - 0.1; - int expiryFrame = frameStamp.getFrameNumber() - 1; + unsigned int expiryFrame = frameStamp.getFrameNumber() - 1; // First traverse inactive PagedLODs, as their children will // certainly have expired. Then traverse active nodes if we still @@ -1783,7 +1787,7 @@ class DatabasePager::FindPagedLODsVisitor : public osg::NodeVisitor { public: - FindPagedLODsVisitor(DatabasePager::PagedLODList& pagedLODList, int frameNumber): + FindPagedLODsVisitor(DatabasePager::PagedLODList& pagedLODList, unsigned int frameNumber): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _activePagedLODList(pagedLODList), _frameNumber(frameNumber) @@ -1803,7 +1807,7 @@ public: } DatabasePager::PagedLODList& _activePagedLODList; - int _frameNumber; + unsigned int _frameNumber; protected: @@ -1811,7 +1815,7 @@ protected: }; -void DatabasePager::registerPagedLODs(osg::Node* subgraph, int frameNumber) +void DatabasePager::registerPagedLODs(osg::Node* subgraph, unsigned int frameNumber) { if (!subgraph) return; diff --git a/src/osgParticle/ParticleProcessor.cpp b/src/osgParticle/ParticleProcessor.cpp index b32a348b3..534c9bd2b 100644 --- a/src/osgParticle/ParticleProcessor.cpp +++ b/src/osgParticle/ParticleProcessor.cpp @@ -101,7 +101,7 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv) if (alive && _enabled && !_ps->isFrozen() && - (_ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !_ps->getFreezeOnCull())) + ((_ps->getLastFrameNumber()+1) >= (nv.getFrameStamp()->getFrameNumber()) || !_ps->getFreezeOnCull())) { // initialize matrix flags _need_ltw_matrix = true; diff --git a/src/osgPlugins/Inventor/PendulumCallback.cpp b/src/osgPlugins/Inventor/PendulumCallback.cpp index a36926f6a..3ceda5b79 100644 --- a/src/osgPlugins/Inventor/PendulumCallback.cpp +++ b/src/osgPlugins/Inventor/PendulumCallback.cpp @@ -11,7 +11,7 @@ PendulumCallback::PendulumCallback(const osg::Vec3& axis, _endAngle = endAngle; _frequency = frequency; - _previousTraversalNumber = -1; + _previousTraversalNumber = osg::UNINITIALIZED_FRAME_NUMBER; _previousTime = -1.0; _angle = 0.0; } diff --git a/src/osgPlugins/Inventor/PendulumCallback.h b/src/osgPlugins/Inventor/PendulumCallback.h index a3455cd41..265916216 100644 --- a/src/osgPlugins/Inventor/PendulumCallback.h +++ b/src/osgPlugins/Inventor/PendulumCallback.h @@ -21,7 +21,7 @@ class PendulumCallback : public osg::NodeCallback float _frequency; osg::Vec3 _axis; - int _previousTraversalNumber; + unsigned int _previousTraversalNumber; double _previousTime; float _angle; }; diff --git a/src/osgPlugins/Inventor/ShuttleCallback.cpp b/src/osgPlugins/Inventor/ShuttleCallback.cpp index 98be155a5..69c521201 100644 --- a/src/osgPlugins/Inventor/ShuttleCallback.cpp +++ b/src/osgPlugins/Inventor/ShuttleCallback.cpp @@ -10,7 +10,7 @@ ShuttleCallback::ShuttleCallback(const osg::Vec3& startPos, _endPos = endPos; _frequency = frequency; - _previousTraversalNumber = -1; + _previousTraversalNumber = osg::UNINITIALIZED_FRAME_NUMBER; _previousTime = -1.0; _angle = 0.0; } diff --git a/src/osgPlugins/Inventor/ShuttleCallback.h b/src/osgPlugins/Inventor/ShuttleCallback.h index 34e786341..cd8cf2f98 100644 --- a/src/osgPlugins/Inventor/ShuttleCallback.h +++ b/src/osgPlugins/Inventor/ShuttleCallback.h @@ -20,7 +20,7 @@ class ShuttleCallback : public osg::NodeCallback osg::Vec3 _endPos; float _frequency; - int _previousTraversalNumber; + unsigned int _previousTraversalNumber; double _previousTime; float _angle; }; diff --git a/src/osgPlugins/txp/TXPPagedLOD.cpp b/src/osgPlugins/txp/TXPPagedLOD.cpp index 34194ff34..a6e29165f 100644 --- a/src/osgPlugins/txp/TXPPagedLOD.cpp +++ b/src/osgPlugins/txp/TXPPagedLOD.cpp @@ -30,7 +30,7 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv) double timeStamp = nv.getFrameStamp()?nv.getFrameStamp()->getReferenceTime():0.0; bool updateTimeStamp = nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR; - int frameNumber = nv.getFrameStamp()?nv.getFrameStamp()->getFrameNumber():0; + unsigned int frameNumber = nv.getFrameStamp()?nv.getFrameStamp()->getFrameNumber():0; // set the frame number of the traversal so that external nodes can find out how active this // node is. diff --git a/src/osgQt/QGraphicsViewAdapter.cpp b/src/osgQt/QGraphicsViewAdapter.cpp index 8ee033cd8..b52585f8c 100644 --- a/src/osgQt/QGraphicsViewAdapter.cpp +++ b/src/osgQt/QGraphicsViewAdapter.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -100,7 +101,7 @@ QGraphicsViewAdapter::QGraphicsViewAdapter(osg::Image* image, QWidget* widget): _currentRead = 0; _currentWrite = 1; _previousWrite = 2; - _previousFrameNumber = 0; + _previousFrameNumber = osg::UNINITIALIZED_FRAME_NUMBER; _newImageAvailable = false; connect(_graphicsScene, SIGNAL(changed(const QList &)), diff --git a/src/osgSim/DOFTransform.cpp b/src/osgSim/DOFTransform.cpp index a61205dde..2fcaf228d 100644 --- a/src/osgSim/DOFTransform.cpp +++ b/src/osgSim/DOFTransform.cpp @@ -27,7 +27,7 @@ static const unsigned int SCALE_Z_LIMIT_BIT = 0x80000000u >> 8; DOFTransform::DOFTransform(): - _previousTraversalNumber(-1), + _previousTraversalNumber(osg::UNINITIALIZED_FRAME_NUMBER), _previousTime(0.0), _limitationFlags(0), _animationOn(false), diff --git a/src/osgSim/ImpostorSprite.cpp b/src/osgSim/ImpostorSprite.cpp index a63f68247..037bb613d 100644 --- a/src/osgSim/ImpostorSprite.cpp +++ b/src/osgSim/ImpostorSprite.cpp @@ -39,6 +39,8 @@ ImpostorSprite::ImpostorSprite() _previous = NULL; _next = NULL; + _lastFrameUsed = osg::UNINITIALIZED_FRAME_NUMBER; + _texture = NULL; _s = 0; _t = 0; @@ -238,7 +240,7 @@ void ImpostorSpriteManager::remove(ImpostorSprite* is) if (_last==is) _last = is->_previous; } -ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,int frameNumber) +ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,unsigned int frameNumber) { if (!empty()) { diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index f2d610486..c8b673b8f 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -1212,7 +1212,7 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie #endif if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen) { - int frameNumber = state.getFrameStamp()?state.getFrameStamp()->getFrameNumber():0; + unsigned int frameNumber = state.getFrameStamp()?state.getFrameStamp()->getFrameNumber():0; AutoTransformCache& atc = _autoTransformCache[contextID]; const osg::Matrix& modelview = state.getModelViewMatrix(); const osg::Matrix& projection = state.getProjectionMatrix(); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index ed5c1e2ae..8b91c6132 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -379,7 +379,7 @@ void SceneView::updateUniforms() if ((_activeUniforms & FRAME_NUMBER_UNIFORM) && _frameStamp.valid()) { - osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_FrameNumber",osg::Uniform::INT); + osg::Uniform* uniform = _localStateSet->getOrCreateUniform("osg_FrameNumber",osg::Uniform::UNSIGNED_INT); uniform->set(_frameStamp->getFrameNumber()); } diff --git a/src/osgUtil/TransformCallback.cpp b/src/osgUtil/TransformCallback.cpp index 60e1623c1..3b14aa164 100644 --- a/src/osgUtil/TransformCallback.cpp +++ b/src/osgUtil/TransformCallback.cpp @@ -22,7 +22,7 @@ TransformCallback::TransformCallback(const osg::Vec3& pivot,const osg::Vec3& axi _axis = axis; _angular_velocity = angularVelocity; - _previousTraversalNumber = -1; + _previousTraversalNumber = osg::UNINITIALIZED_FRAME_NUMBER; _previousTime = -1.0; _pause = false; diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index dfaddb81c..efdb6d49a 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -619,7 +619,7 @@ void CompositeViewer::advance(double simulationTime) if (_done) return; double prevousReferenceTime = _frameStamp->getReferenceTime(); - int previousFrameNumber = _frameStamp->getFrameNumber(); + unsigned int previousFrameNumber = _frameStamp->getFrameNumber(); _frameStamp->setFrameNumber(_frameStamp->getFrameNumber()+1); diff --git a/src/osgViewer/Renderer.cpp b/src/osgViewer/Renderer.cpp index 33ebc1f81..3857b4c21 100644 --- a/src/osgViewer/Renderer.cpp +++ b/src/osgViewer/Renderer.cpp @@ -45,12 +45,12 @@ class OSGVIEWER_EXPORT EXTQuerySupport : public OpenGLQuerySupport public: EXTQuerySupport(); void checkQuery(osg::Stats* stats, osg::State* state, osg::Timer_t startTick); - virtual void beginQuery(int frameNumber, osg::State* state); + virtual void beginQuery(unsigned int frameNumber, osg::State* state); virtual void endQuery(osg::State* state); virtual void initialize(osg::State* state, osg::Timer_t startTick); protected: GLuint createQueryObject(); - typedef std::pair QueryFrameNumberPair; + typedef std::pair QueryFrameNumberPair; typedef std::list QueryFrameNumberList; typedef std::vector QueryList; @@ -118,7 +118,7 @@ GLuint EXTQuerySupport::createQueryObject() } } -void EXTQuerySupport::beginQuery(int frameNumber, osg::State* state) +void EXTQuerySupport::beginQuery(unsigned int frameNumber, osg::State* state) { GLuint query = createQueryObject(); _extensions->glBeginQuery(GL_TIME_ELAPSED, query); @@ -148,7 +148,7 @@ public: virtual void checkQuery(osg::Stats* stats, osg::State* state, osg::Timer_t startTick); - virtual void beginQuery(int frameNumber, osg::State* state); + virtual void beginQuery(unsigned int frameNumber, osg::State* state); virtual void endQuery(osg::State* state); virtual void initialize(osg::State* state, osg::Timer_t startTick); protected: @@ -159,12 +159,12 @@ protected: : queries(start_, end_), frameNumber(frameNumber_) { } - ActiveQuery(const QueryPair& queries_, int frameNumber_) + ActiveQuery(const QueryPair& queries_, unsigned int frameNumber_) : queries(queries_), frameNumber(frameNumber_) { } QueryPair queries; - int frameNumber; + unsigned int frameNumber; }; typedef std::list QueryFrameList; typedef std::vector QueryList; @@ -177,7 +177,7 @@ void ARBQuerySupport::initialize(osg::State* state, osg::Timer_t startTick) OpenGLQuerySupport::initialize(state, startTick); } -void ARBQuerySupport::beginQuery(int frameNumber, osg::State* state) +void ARBQuerySupport::beginQuery(unsigned int frameNumber, osg::State* state) { QueryPair query; if (_availableQueryObjects.empty()) @@ -531,7 +531,7 @@ void Renderer::cull() osg::Stats* stats = sceneView->getCamera()->getStats(); osg::State* state = sceneView->getState(); const osg::FrameStamp* fs = state->getFrameStamp(); - int frameNumber = fs ? fs->getFrameNumber() : 0; + unsigned int frameNumber = fs ? fs->getFrameNumber() : 0; // do cull traversal osg::Timer_t beforeCullTick = osg::Timer::instance()->tick(); @@ -643,7 +643,7 @@ void Renderer::draw() osg::Stats* stats = sceneView->getCamera()->getStats(); osg::State* state = sceneView->getState(); - int frameNumber = state->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = state->getFrameStamp()->getFrameNumber(); if (!_initialized) { @@ -747,7 +747,7 @@ void Renderer::cull_draw() osg::Stats* stats = sceneView->getCamera()->getStats(); osg::State* state = sceneView->getState(); const osg::FrameStamp* fs = state->getFrameStamp(); - int frameNumber = fs ? fs->getFrameNumber() : 0; + unsigned int frameNumber = fs ? fs->getFrameNumber() : 0; if (!_initialized) { diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp index 601152e5d..3458afe6d 100644 --- a/src/osgViewer/StatsHandler.cpp +++ b/src/osgViewer/StatsHandler.cpp @@ -219,7 +219,7 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap } } - for(int i = viewer->getViewerStats()->getEarliestFrameNumber(); i<= viewer->getViewerStats()->getLatestFrameNumber()-1; ++i) + for(unsigned int i = viewer->getViewerStats()->getEarliestFrameNumber(); i<= viewer->getViewerStats()->getLatestFrameNumber()-1; ++i) { for(StatsList::iterator itr = statsList.begin(); itr != statsList.end(); @@ -402,7 +402,7 @@ struct RawValueTextDrawCallback : public virtual osg::Drawable::DrawCallback { _tickLastUpdated = tick; - int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); double value; if (_stats->getAttribute(frameNumber, _attributeName, value)) { @@ -469,7 +469,7 @@ struct CameraSceneStatsTextDrawCallback : public virtual osg::Drawable::DrawCall viewStr << _camera->getName(); viewStr << std::endl; - int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); if (!(renderer->getGraphicsThreadDoesCull())) { --frameNumber; @@ -556,7 +556,7 @@ struct ViewSceneStatsTextDrawCallback : public virtual osg::Drawable::DrawCallba viewStr << ": " << _view->getName(); viewStr << std::endl; - int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); // if (!(renderer->getGraphicsThreadDoesCull())) { --frameNumber; @@ -625,7 +625,6 @@ struct BlockDrawCallback : public virtual osg::Drawable::DrawCallback osg::Vec3Array* vertices = (osg::Vec3Array*)geom->getVertexArray(); int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); - int startFrame = frameNumber + _frameDelta - _numFrames + 1; int endFrame = frameNumber + _frameDelta; double referenceTime; @@ -755,7 +754,7 @@ protected: osg::Vec3Array* vertices = dynamic_cast(geometry->getVertexArray()); if (!vertices) return; - int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); + unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber(); // Get stats double value; @@ -837,11 +836,11 @@ protected: const float _max; const std::string _nameBegin; const std::string _nameEnd; - static int _frameNumber; + static unsigned int _frameNumber; }; }; -int StatsGraph::GraphUpdateCallback::_frameNumber = 0; +unsigned int StatsGraph::GraphUpdateCallback::_frameNumber = 0; osg::Geometry* StatsHandler::createGeometry(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks) diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp index 1c4e72c08..3aeaedae4 100644 --- a/src/osgViewer/Viewer.cpp +++ b/src/osgViewer/Viewer.cpp @@ -569,7 +569,7 @@ void Viewer::advance(double simulationTime) if (_done) return; double prevousReferenceTime = _frameStamp->getReferenceTime(); - int previousFrameNumber = _frameStamp->getFrameNumber(); + unsigned int previousFrameNumber = _frameStamp->getFrameNumber(); _frameStamp->setFrameNumber(_frameStamp->getFrameNumber()+1); diff --git a/src/osgViewer/ViewerBase.cpp b/src/osgViewer/ViewerBase.cpp index 2cbd6bac9..bd38dcc22 100644 --- a/src/osgViewer/ViewerBase.cpp +++ b/src/osgViewer/ViewerBase.cpp @@ -584,10 +584,10 @@ int ViewerBase::run() realize(); } - const char* str = getenv("OSG_RUN_FRAME_COUNT"); - int runTillFrameNumber = str==0 ? -1 : atoi(str); + const char* run_frame_count_str = getenv("OSG_RUN_FRAME_COUNT"); + unsigned int runTillFrameNumber = run_frame_count_str==0 ? osg::UNINITIALIZED_FRAME_NUMBER : atoi(run_frame_count_str); - while(!done() && (runTillFrameNumber<0 || getViewerFrameStamp()->getFrameNumber()getFrameNumber()0.0 ? 1.0/_runMaxFrameRate : 0.0; osg::Timer_t startFrameTick = osg::Timer::instance()->tick(); @@ -676,7 +676,7 @@ void ViewerBase::renderingTraversals() if (getViewerStats() && getViewerStats()->collectStats("scene")) { - int frameNumber = frameStamp ? frameStamp->getFrameNumber() : 0; + unsigned int frameNumber = frameStamp ? frameStamp->getFrameNumber() : 0; Views views; getViews(views); diff --git a/src/osgWrappers/serializers/osg/OcclusionQueryNode.cpp b/src/osgWrappers/serializers/osg/OcclusionQueryNode.cpp index 3c8bd7eac..ea74b21a2 100644 --- a/src/osgWrappers/serializers/osg/OcclusionQueryNode.cpp +++ b/src/osgWrappers/serializers/osg/OcclusionQueryNode.cpp @@ -10,6 +10,6 @@ REGISTER_OBJECT_WRAPPER( OcclusionQueryNode, { ADD_BOOL_SERIALIZER( QueriesEnabled, true ); // _enabled ADD_UINT_SERIALIZER( VisibilityThreshold, 0 ); // _visThreshold - ADD_INT_SERIALIZER( QueryFrameCount, 0 ); // _queryFrameCount + ADD_UINT_SERIALIZER( QueryFrameCount, 0 ); // _queryFrameCount ADD_BOOL_SERIALIZER( DebugDisplay, false ); // _debugBB } diff --git a/src/osgWrappers/serializers/osg/PagedLOD.cpp b/src/osgWrappers/serializers/osg/PagedLOD.cpp index cce4e1b5d..94e28b7a3 100644 --- a/src/osgWrappers/serializers/osg/PagedLOD.cpp +++ b/src/osgWrappers/serializers/osg/PagedLOD.cpp @@ -139,9 +139,17 @@ REGISTER_OBJECT_WRAPPER( PagedLOD, // Note: osg::Group is not in the list to prevent recording dynamic loaded children ADD_USER_SERIALIZER( DatabasePath ); // _databasePath - ADD_INT_SERIALIZER( FrameNumberOfLastTraversal, 0 ); // _frameNumberOfLastTraversal + ADD_UINT_SERIALIZER( FrameNumberOfLastTraversal, 0 ); // _frameNumberOfLastTraversal, note, not required, removed from soversion 70 onwwards, see below ADD_UINT_SERIALIZER( NumChildrenThatCannotBeExpired, 0 ); // _numChildrenThatCannotBeExpired ADD_BOOL_SERIALIZER( DisableExternalChildrenPaging, false ); // _disableExternalChildrenPaging ADD_USER_SERIALIZER( RangeDataList ); // _perRangeDataList ADD_USER_SERIALIZER( Children ); // _children (which are not loaded from external) + + UPDATE_TO_VERSION( 70 ) + { + REMOVE_SERIALIZER( FrameNumberOfLastTraversal ); + } + + + }