Changeset 358

Show
Ignore:
Timestamp:
10/22/06 16:40:33 (2 years ago)
Author:
dshipton
Message:

Simplify some code, also make sure our triangle culled take into account the small feature culling.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGOcclusionCullingTreeBuilder.cpp

    r355 r358  
    268268#endif 
    269269        _numTestSamples = _rt->getOcclusionCullingQueryBufferSize(); 
    270         std::cout << "Buf size: " << _numTestSamples << std::endl; 
     270        //std::cout << "Buf size: " << _numTestSamples << std::endl; 
    271271        _testSamples = new GLuint[_numTestSamples]; 
    272272        //std::cout << "Performing OCC on " << uNumNodes << " nodes." << std::endl; 
     
    462462                { 
    463463                    if(cbb * _vpWidth * _vpHeight < _minFeatureSize) //small feature culling 
    464                     { 
     464                    {                 
     465                        StatCollector *sc = _rt->getStatistics(); 
     466                        GeoStatsAttachmentPtr st = 
     467                                GeoStatsAttachment::get(pNode->getNode()); 
     468                        st->validate(); 
     469                        _rt->getStatistics()->getElem(statNOccTriangles)-> 
     470                                add(st->getTriangles()); 
     471                        if(_rt->getOcclusionCullingDebug() && pNode->getNode()) 
     472                        { 
     473                            pNode->getNode()->setTravMask( 
     474                                pNode->getNode()->getTravMask() |  
     475                                _rt->getOcclusionCulledDebugMask() 
     476                                );  
     477                        } 
    465478                        pNode->setIsRendered(true); 
    466479                    } 
     
    503516void OcclusionCullingTreeBuilder::drawTestNode(RenderTreeNode *pNode, DrawEnv &denv, RenderPartition *part) 
    504517{ 
     518 
     519    //std::cout << "Front: " << _currSample << " Back: " << _currSampleBack << std::endl; 
     520    while(_testPendingNodes.size() == _numTestSamples - 1) 
     521    { 
     522        drawTestResults(denv, part); 
     523        //std::cout << "NOW:  Front: " << _currSample << " Back: " << _currSampleBack << std::endl; 
     524    } 
     525 
    505526    //DRAW DRAW DRAW 
    506527    Window* win = denv.getWindow(); 
    507528    pNode->setIsRendered(false); 
    508  
    509     //pNode->getCore()->getPositions(); 
    510     //std::cout << pNode->getNode()->getPositions()->size()<<std::endl; 
    511529 
    512530 
     
    539557    v[1][2] = v[2][2] = v[5][2] = v[6][2] = max[2]; 
    540558 
    541     //std::cout << "Front: " << _currSample << " Back: " << _currSampleBack << std::endl; 
    542     while(_testPendingNodes.size() == _numTestSamples - 1) 
    543     { 
    544         drawTestResults(denv, part); 
    545         //std::cout << "NOW:  Front: " << _currSample << " Back: " << _currSampleBack << std::endl; 
    546     } 
    547559 
    548560    if(_currSample == _numTestSamples - 1) 
     
    552564    _currSample++; 
    553565 
    554     enterTesting(denv, part); 
    555566    StatCollector *sc = _rt->getStatistics(); 
    556567    sc->getElem(statNOccTests    )->inc(); 
    557568 
     569    enterTesting(denv, part); 
    558570    BeginQueryT beginq = (BeginQueryT) win->getFunction(_funcBeginQueryARB); 
    559571    //std::cout << "Push: " << _currSample << std::endl; 
     
    583595    leaveTesting(denv, part); 
    584596 
     597    UInt32 uiNextMatrix = pNode->getMatrixStore().first; 
     598 
     599    if(uiNextMatrix != 0 && uiNextMatrix != _uiActiveMatrix) 
     600    { 
     601        glLoadMatrixf(pNode->getMatrixStore().second.getValues()); 
     602 
     603        _uiActiveMatrix = uiNextMatrix; 
     604 
     605        _currMatrix.second = pNode->getMatrixStore().second; 
     606 
     607        updateTopMatrix(denv); 
     608 
     609        denv.setObjectToWorld(_accMatrix); 
     610 
     611        ++part->_uiNumMatrixChanges; 
     612    } 
     613 
    585614    //STATE ACTIVATION         
    586615    State         *pNewState         = pNode->getState(); 
     
    644673                return; 
    645674            }  
    646             GLuint sampleCount = 100;  //XXX: Set to what it should be from calc above. 
     675            GLuint sampleCount = 1;  //XXX: Set to what it should be from calc above. 
    647676            getquiv(_testSamples[pNode->getResultNum()], GL_QUERY_RESULT_ARB, &sampleCount); 
    648677             
    649678            if(sampleCount > _visPixelThreshold) 
    650679            { 
    651                 leaveTesting(denv, part); 
    652                 //MATRIX SETUP 
    653                 UInt32 uiNextMatrix = pNode->getMatrixStore().first; 
    654  
    655                 if(uiNextMatrix != 0 && uiNextMatrix != _uiActiveMatrix) 
    656                 { 
    657                     glLoadMatrixf(pNode->getMatrixStore().second.getValues()); 
    658                     _uiActiveMatrix = uiNextMatrix; 
    659                     _currMatrix.second = pNode->getMatrixStore().second; 
    660                     updateTopMatrix(denv); 
    661                     denv.setObjectToWorld(_accMatrix); 
    662                     ++part->_uiNumMatrixChanges; 
    663                 } 
    664                 // Negative scaled matrices in conjunction with double sided  
    665                 // lighting 
    666                 // gives wrong render results cause the lighting itselfs gets  
    667                 // inverted. This corrects this behavior. 
    668                 if(part->_bCorrectTwoSidedLighting) 
    669                 { 
    670                     const Matrix &m = _currMatrix.second; 
    671  
    672                     // test for a "flipped" matrix 
    673                     // glFrontFace can give conflicts with the polygon chunk ... 
    674  
    675                     if(m[0].cross(m[1]).dot(m[2]) < 0.0) 
    676                     { 
    677                         glFrontFace(GL_CW); 
    678                     } 
    679                     else 
    680                     { 
    681                         glFrontFace(GL_CCW); 
    682                     } 
    683                 }  
    684  
    685                 pNode->setIsRendered(true); 
    686                 //STATE ACTIVATION         
    687                 State         *pNewState         = pNode->getState(); 
    688                 StateOverride *pNewStateOverride = pNode->getStateOverride(); 
    689  
    690                 denv.activateState(pNewState, pNewStateOverride); 
    691                 pNode->getFunctor()(&denv); 
     680                drawNode(pNode, denv, part); 
    692681            } 
    693682            else