Show
Ignore:
Timestamp:
09/15/10 13:27:31 (4 years ago)
Author:
robert
Message:

From Lukasz Izdebski, "I made some changes in OcclusionQueryNode? file.
I move declaration of classes TestResult?, QueryGeometry? from cpp to header file and made a void createSupportNodes() a virtual method.

Now is possible to inherit from class OcclusionQueryNode?."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/OcclusionQueryNode

    r11127 r11760  
    1919#include <osg/CopyOp> 
    2020#include <osg/Group> 
    21  
     21#include <osg/Geometry> 
    2222 
    2323 
    2424namespace osg { 
    2525 
     26// Create and return a StateSet appropriate for performing an occlusion 
     27//   query test (disable lighting, texture mapping, etc). Probably some 
     28//   room for improvement here. Could disable shaders, for example. 
     29osg::StateSet* initOQState(); 
     30 
     31// Create and return a StateSet for rendering a debug representation of query geometry. 
     32osg::StateSet* initOQDebugState(); 
     33 
     34// TestResult -- stores (per context) results of an occlusion query 
     35//   test performed by QueryGeometry. An OcclusionQueryNode has a 
     36//   Geode owning a single QueryGeometry that 
     37//   draws the occlusion query geometry. QueryGeometry keeps a 
     38//   TestResult per context to store the result/status of each query. 
     39// Accessed during the cull and draw traversals. 
     40class TestResult : public osg::Referenced 
     41{ 
     42public: 
     43    TestResult() : _init( false ), _id( 0 ), _contextID( 0 ), _active( false ), _numPixels( 0 ) {} 
     44    ~TestResult() {} 
     45 
     46    bool _init; 
     47 
     48    // Query ID for this context. 
     49    GLuint _id; 
     50    // Context ID owning this query ID. 
     51    unsigned int _contextID; 
     52 
     53    // Set to true when a query gets issued and set to 
     54    //   false when the result is retrieved. 
     55    mutable bool _active; 
     56 
     57    // Result of last query. 
     58    GLint _numPixels; 
     59}; 
     60 
     61// QueryGeometry -- A Drawable that performs an occlusion query, 
     62//   using its geometric data as the query geometry. 
     63class QueryGeometry : public osg::Geometry 
     64{ 
     65public: 
     66    QueryGeometry( const std::string& oqnName=std::string("") ); 
     67    ~QueryGeometry(); 
     68 
     69    void reset(); 
     70 
     71    // TBD implement copy constructor 
     72 
     73    virtual void drawImplementation( osg::RenderInfo& renderInfo ) const; 
     74 
     75    unsigned int getNumPixels( const osg::Camera* cam ); 
     76 
     77 
     78    void releaseGLObjects( osg::State* state = 0 ); 
     79    static void deleteQueryObject( unsigned int contextID, GLuint handle ); 
     80    static void flushDeletedQueryObjects( unsigned int contextID, double currentTime, double& availableTime ); 
     81    static void discardDeletedQueryObjects( unsigned int contextID ); 
     82     
     83protected: 
     84    typedef std::map< const osg::Camera*, TestResult > ResultMap; 
     85    mutable ResultMap _results; 
     86    mutable OpenThreads::Mutex _mapMutex; 
     87 
     88    // Needed for debug only 
     89    std::string _oqnName; 
     90}; 
    2691 
    2792// This Node performs occlusion query testing on its children. 
     
    89154    // These methods are public so that osgUtil::CullVisitor can access them. 
    90155    // Not intended for application use. 
    91     bool getPassed( const osg::Camera* camera, osg::NodeVisitor& nv ); 
     156    virtual bool getPassed( const osg::Camera* camera, osg::NodeVisitor& nv ); 
    92157    void traverseQuery( const osg::Camera* camera, osg::NodeVisitor& nv ); 
    93158    void traverseDebug( osg::NodeVisitor& nv ); 
     
    106171    virtual ~OcclusionQueryNode(); 
    107172 
    108     void createSupportNodes(); 
     173    virtual void createSupportNodes(); 
    109174 
    110175    osg::ref_ptr< osg::Geode > _queryGeode;