Changeset 358
- Timestamp:
- 10/22/06 16:40:33 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGOcclusionCullingTreeBuilder.cpp
r355 r358 268 268 #endif 269 269 _numTestSamples = _rt->getOcclusionCullingQueryBufferSize(); 270 std::cout << "Buf size: " << _numTestSamples << std::endl;270 //std::cout << "Buf size: " << _numTestSamples << std::endl; 271 271 _testSamples = new GLuint[_numTestSamples]; 272 272 //std::cout << "Performing OCC on " << uNumNodes << " nodes." << std::endl; … … 462 462 { 463 463 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 } 465 478 pNode->setIsRendered(true); 466 479 } … … 503 516 void OcclusionCullingTreeBuilder::drawTestNode(RenderTreeNode *pNode, DrawEnv &denv, RenderPartition *part) 504 517 { 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 505 526 //DRAW DRAW DRAW 506 527 Window* win = denv.getWindow(); 507 528 pNode->setIsRendered(false); 508 509 //pNode->getCore()->getPositions();510 //std::cout << pNode->getNode()->getPositions()->size()<<std::endl;511 529 512 530 … … 539 557 v[1][2] = v[2][2] = v[5][2] = v[6][2] = max[2]; 540 558 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 }547 559 548 560 if(_currSample == _numTestSamples - 1) … … 552 564 _currSample++; 553 565 554 enterTesting(denv, part);555 566 StatCollector *sc = _rt->getStatistics(); 556 567 sc->getElem(statNOccTests )->inc(); 557 568 569 enterTesting(denv, part); 558 570 BeginQueryT beginq = (BeginQueryT) win->getFunction(_funcBeginQueryARB); 559 571 //std::cout << "Push: " << _currSample << std::endl; … … 583 595 leaveTesting(denv, part); 584 596 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 585 614 //STATE ACTIVATION 586 615 State *pNewState = pNode->getState(); … … 644 673 return; 645 674 } 646 GLuint sampleCount = 1 00; //XXX: Set to what it should be from calc above.675 GLuint sampleCount = 1; //XXX: Set to what it should be from calc above. 647 676 getquiv(_testSamples[pNode->getResultNum()], GL_QUERY_RESULT_ARB, &sampleCount); 648 677 649 678 if(sampleCount > _visPixelThreshold) 650 679 { 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); 692 681 } 693 682 else
