Changeset 11046 for OpenSceneGraph/trunk/src/osgUtil/CullVisitor.cpp
- Timestamp:
- 02/10/10 13:44:59 (3 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgUtil/CullVisitor.cpp (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgUtil/CullVisitor.cpp
r11043 r11046 170 170 { 171 171 ++numTests; 172 // NOTIFY(osg::WARN)<<"testing computeNearestPointInFrustum with d_near = "<<itr->first<<std::endl;172 // OSG_NOTIFY(osg::WARN)<<"testing computeNearestPointInFrustum with d_near = "<<itr->first<<std::endl; 173 173 value_type d_near = computeNearestPointInFrustum(itr->second._matrix, itr->second._planes,*(itr->second._drawable)); 174 174 if (d_near<_computed_znear) 175 175 { 176 176 _computed_znear = d_near; 177 // NOTIFY(osg::WARN)<<"updating znear to "<<_computed_znear<<std::endl;177 // OSG_NOTIFY(osg::WARN)<<"updating znear to "<<_computed_znear<<std::endl; 178 178 } 179 179 } 180 180 181 181 // osg::Timer_t end_t = osg::Timer::instance()->tick(); 182 // NOTIFY(osg::NOTICE)<<"Took "<<osg::Timer::instance()->delta_m(start_t,end_t)<<"ms to test "<<numTests<<" out of "<<_nearPlaneCandidateMap.size()<<std::endl;182 // OSG_NOTIFY(osg::NOTICE)<<"Took "<<osg::Timer::instance()->delta_m(start_t,end_t)<<"ms to test "<<numTests<<" out of "<<_nearPlaneCandidateMap.size()<<std::endl; 183 183 184 184 _nearPlaneCandidateMap.clear(); … … 193 193 { 194 194 195 // NOTIFY(osg::INFO)<<"clamping "<< "znear="<<_computed_znear << " zfar="<<_computed_zfar<<std::endl;195 //OSG_NOTIFY(osg::INFO)<<"clamping "<< "znear="<<_computed_znear << " zfar="<<_computed_zfar<<std::endl; 196 196 197 197 … … 207 207 else 208 208 { 209 // NOTIFY(osg::INFO)<<"Not clamping "<< "znear="<<_computed_znear << " zfar="<<_computed_zfar<<std::endl;209 //OSG_NOTIFY(osg::INFO)<<"Not clamping "<< "znear="<<_computed_znear << " zfar="<<_computed_zfar<<std::endl; 210 210 } 211 211 … … 219 219 if (zfar<znear-epsilon) 220 220 { 221 NOTIFY(osg::INFO)<<"_clampProjectionMatrix not applied, invalid depth range, znear = "<<znear<<" zfar = "<<zfar<<std::endl;221 OSG_NOTIFY(osg::INFO)<<"_clampProjectionMatrix not applied, invalid depth range, znear = "<<znear<<" zfar = "<<zfar<<std::endl; 222 222 return false; 223 223 } … … 230 230 znear = average-epsilon; 231 231 zfar = average+epsilon; 232 // NOTIFY(osg::INFO) << "_clampProjectionMatrix widening znear and zfar to "<<znear<<" "<<zfar<<std::endl;232 // OSG_NOTIFY(osg::INFO) << "_clampProjectionMatrix widening znear and zfar to "<<znear<<" "<<zfar<<std::endl; 233 233 } 234 234 235 235 if (fabs(projection(0,3))<epsilon && fabs(projection(1,3))<epsilon && fabs(projection(2,3))<epsilon ) 236 236 { 237 // NOTIFY(osg::INFO) << "Orthographic matrix before clamping"<<projection<<std::endl;237 // OSG_NOTIFY(osg::INFO) << "Orthographic matrix before clamping"<<projection<<std::endl; 238 238 239 239 value_type delta_span = (zfar-znear)*0.02; … … 249 249 projection(3,2)=-(desired_zfar+desired_znear)/(desired_zfar-desired_znear); 250 250 251 // NOTIFY(osg::INFO) << "Orthographic matrix after clamping "<<projection<<std::endl;251 // OSG_NOTIFY(osg::INFO) << "Orthographic matrix after clamping "<<projection<<std::endl; 252 252 } 253 253 else 254 254 { 255 255 256 // NOTIFY(osg::INFO) << "Persepective matrix before clamping"<<projection<<std::endl;256 // OSG_NOTIFY(osg::INFO) << "Persepective matrix before clamping"<<projection<<std::endl; 257 257 258 258 //std::cout << "_computed_znear"<<_computed_znear<<std::endl; … … 286 286 0.0f,0.0f,center*ratio,1.0f)); 287 287 288 // NOTIFY(osg::INFO) << "Persepective matrix after clamping"<<projection<<std::endl;288 // OSG_NOTIFY(osg::INFO) << "Persepective matrix after clamping"<<projection<<std::endl; 289 289 } 290 290 return true; … … 337 337 n3 >= _znear) 338 338 { 339 // NOTIFY(osg::NOTICE)<<"Triangle totally beyond znear"<<std::endl;339 //OSG_NOTIFY(osg::NOTICE)<<"Triangle totally beyond znear"<<std::endl; 340 340 return; 341 341 } … … 346 346 n3 < 0.0) 347 347 { 348 // NOTIFY(osg::NOTICE)<<"Triangle totally behind eye point"<<std::endl;348 // OSG_NOTIFY(osg::NOTICE)<<"Triangle totally behind eye point"<<std::endl; 349 349 return; 350 350 } … … 367 367 if (numOutside==3) 368 368 { 369 // NOTIFY(osg::NOTICE)<<"Triangle totally outside frustum "<<d1<<"\t"<<d2<<"\t"<<d3<<std::endl;369 //OSG_NOTIFY(osg::NOTICE)<<"Triangle totally outside frustum "<<d1<<"\t"<<d2<<"\t"<<d3<<std::endl; 370 370 return; 371 371 } … … 376 376 } 377 377 378 // NOTIFY(osg::NOTICE)<<"Triangle ok w.r.t plane "<<d1<<"\t"<<d2<<"\t"<<d3<<std::endl;378 //OSG_NOTIFY(osg::NOTICE)<<"Triangle ok w.r.t plane "<<d1<<"\t"<<d2<<"\t"<<d3<<std::endl; 379 379 380 380 selector_mask <<= 1; … … 386 386 _znear = osg::minimum(_znear,n2); 387 387 _znear = osg::minimum(_znear,n3); 388 // NOTIFY(osg::NOTICE)<<"Triangle all inside frustum "<<n1<<"\t"<<n2<<"\t"<<n3<<" number of plane="<<_planes->size()<<std::endl;388 // OSG_NOTIFY(osg::NOTICE)<<"Triangle all inside frustum "<<n1<<"\t"<<n2<<"\t"<<n3<<" number of plane="<<_planes->size()<<std::endl; 389 389 return; 390 390 } … … 395 395 // this means that use brute force methods for deviding up triangle. 396 396 397 // NOTIFY(osg::NOTICE)<<"Using brute force method of triangle cutting frustum walls"<<std::endl;397 //OSG_NOTIFY(osg::NOTICE)<<"Using brute force method of triangle cutting frustum walls"<<std::endl; 398 398 _polygonOriginal.clear(); 399 399 _polygonOriginal.push_back(DistancePoint(0,v1)); … … 459 459 { 460 460 _znear = dist; 461 // NOTIFY(osg::NOTICE)<<"Near plane updated "<<_znear<<std::endl;461 //OSG_NOTIFY(osg::NOTICE)<<"Near plane updated "<<_znear<<std::endl; 462 462 } 463 463 } … … 467 467 CullVisitor::value_type CullVisitor::computeNearestPointInFrustum(const osg::Matrix& matrix, const osg::Polytope::PlaneList& planes,const osg::Drawable& drawable) 468 468 { 469 // NOTIFY(osg::WARN)<<"CullVisitor::computeNearestPointInFrustum("<<getTraversalNumber()<<"\t"<<planes.size()<<std::endl;469 // OSG_NOTIFY(osg::WARN)<<"CullVisitor::computeNearestPointInFrustum("<<getTraversalNumber()<<"\t"<<planes.size()<<std::endl; 470 470 471 471 osg::TriangleFunctor<ComputeNearestPointFunctor> cnpf; … … 489 489 if ( !EQUAL_F(d_near, d_far) ) 490 490 { 491 NOTIFY(osg::WARN)<<"Warning: CullVisitor::updateCalculatedNearFar(.) near>far in range calculation,"<< std::endl;492 NOTIFY(osg::WARN)<<" correcting by swapping values d_near="<<d_near<<" dfar="<<d_far<< std::endl;491 OSG_NOTIFY(osg::WARN)<<"Warning: CullVisitor::updateCalculatedNearFar(.) near>far in range calculation,"<< std::endl; 492 OSG_NOTIFY(osg::WARN)<<" correcting by swapping values d_near="<<d_near<<" dfar="<<d_far<< std::endl; 493 493 } 494 494 } … … 521 521 if (lastFrameNumber != getTraversalNumber()) 522 522 { 523 NOTIFY(osg::NOTICE)<<"Took "<<elapsed_time<<"ms to test "<<numBillboards<<" billboards"<<std::endl;523 OSG_NOTIFY(osg::NOTICE)<<"Took "<<elapsed_time<<"ms to test "<<numBillboards<<" billboards"<<std::endl; 524 524 numBillboards = 0; 525 525 elapsed_time = 0.0; … … 540 540 d_far = distance(bb.corner(bbCornerFar),matrix); 541 541 542 NOTIFY(osg::NOTICE).precision(15);542 OSG_NOTIFY(osg::NOTICE).precision(15); 543 543 544 544 if (false) 545 545 { 546 546 547 NOTIFY(osg::NOTICE)<<"TESTING Billboard near/far computation"<<std::endl;548 549 // NOTIFY(osg::WARN)<<"Checking corners of billboard "<<std::endl;547 OSG_NOTIFY(osg::NOTICE)<<"TESTING Billboard near/far computation"<<std::endl; 548 549 // OSG_NOTIFY(osg::WARN)<<"Checking corners of billboard "<<std::endl; 550 550 // deprecated brute force way, use all corners of the bounding box. 551 551 value_type nd_near, nd_far; … … 556 556 if (d<nd_near) nd_near = d; 557 557 if (d>nd_far) nd_far = d; 558 NOTIFY(osg::NOTICE)<<"\ti="<<i<<"\td="<<d<<std::endl;558 OSG_NOTIFY(osg::NOTICE)<<"\ti="<<i<<"\td="<<d<<std::endl; 559 559 } 560 560 561 561 if (nd_near==d_near && nd_far==d_far) 562 562 { 563 NOTIFY(osg::NOTICE)<<"\tBillboard near/far computation correct "<<std::endl;563 OSG_NOTIFY(osg::NOTICE)<<"\tBillboard near/far computation correct "<<std::endl; 564 564 } 565 565 else 566 566 { 567 NOTIFY(osg::NOTICE)<<"\tBillboard near/far computation ERROR\n\t\t"<<d_near<<"\t"<<nd_near567 OSG_NOTIFY(osg::NOTICE)<<"\tBillboard near/far computation ERROR\n\t\t"<<d_near<<"\t"<<nd_near 568 568 <<"\n\t\t"<<d_far<<"\t"<<nd_far<<std::endl; 569 569 } … … 591 591 if ( !EQUAL_F(d_near, d_far) ) 592 592 { 593 NOTIFY(osg::WARN)<<"Warning: CullVisitor::updateCalculatedNearFar(.) near>far in range calculation,"<< std::endl;594 NOTIFY(osg::WARN)<<" correcting by swapping values d_near="<<d_near<<" dfar="<<d_far<< std::endl;593 OSG_NOTIFY(osg::WARN)<<"Warning: CullVisitor::updateCalculatedNearFar(.) near>far in range calculation,"<< std::endl; 594 OSG_NOTIFY(osg::WARN)<<" correcting by swapping values d_near="<<d_near<<" dfar="<<d_far<< std::endl; 595 595 } 596 596 } … … 611 611 if (isBillboard) 612 612 { 613 // NOTIFY(osg::WARN)<<"Adding billboard into deffered list"<<std::endl;613 // OSG_NOTIFY(osg::WARN)<<"Adding billboard into deffered list"<<std::endl; 614 614 615 615 osg::Polytope transformed_frustum; … … 632 632 { 633 633 if (d_far>=0.0) _computed_znear = d_far; 634 else NOTIFY(osg::WARN)<<" 1) sett near with dnear="<<d_near<<" dfar="<<d_far<< std::endl;634 else OSG_NOTIFY(osg::WARN)<<" 1) sett near with dnear="<<d_near<<" dfar="<<d_far<< std::endl; 635 635 } 636 636 } … … 638 638 { 639 639 if (d_near>=0.0) _computed_znear = d_near; 640 else NOTIFY(osg::WARN)<<" 2) sett near with d_near="<<d_near<< std::endl;640 else OSG_NOTIFY(osg::WARN)<<" 2) sett near with d_near="<<d_near<< std::endl; 641 641 } 642 642 } 643 643 else 644 644 { 645 //if (d_near<0.0) NOTIFY(osg::WARN)<<" 3) set near with d_near="<<d_near<< std::endl;645 //if (d_near<0.0) OSG_NOTIFY(osg::WARN)<<" 3) set near with d_near="<<d_near<< std::endl; 646 646 _computed_znear = d_near; 647 647 } … … 682 682 { 683 683 _computed_znear = d; 684 if (d<0.0) NOTIFY(osg::WARN)<<"Alerting billboard ="<<d<< std::endl;684 if (d<0.0) OSG_NOTIFY(osg::WARN)<<"Alerting billboard ="<<d<< std::endl; 685 685 } 686 686 if (d>_computed_zfar) _computed_zfar = d; … … 773 773 if (osg::isNaN(depth)) 774 774 { 775 NOTIFY(osg::NOTICE)<<"CullVisitor::apply(Geode&) detected NaN,"<<std::endl775 OSG_NOTIFY(osg::NOTICE)<<"CullVisitor::apply(Geode&) detected NaN,"<<std::endl 776 776 <<" depth="<<depth<<", center=("<<bb.center()<<"),"<<std::endl 777 777 <<" matrix="<<matrix<<std::endl; 778 NOTIFY(osg::DEBUG_INFO) << " NodePath:" << std::endl;778 OSG_NOTIFY(osg::DEBUG_INFO) << " NodePath:" << std::endl; 779 779 for (NodePath::const_iterator i = getNodePath().begin(); i != getNodePath().end(); ++i) 780 780 { 781 NOTIFY(osg::DEBUG_INFO) << " \"" << (*i)->getName() << "\"" << std::endl;781 OSG_NOTIFY(osg::DEBUG_INFO) << " \"" << (*i)->getName() << "\"" << std::endl; 782 782 } 783 783 } … … 840 840 if (d<_computed_znear) 841 841 { 842 if (d<0.0) NOTIFY(osg::WARN)<<"Alerting billboard handling ="<<d<< std::endl;842 if (d<0.0) OSG_NOTIFY(osg::WARN)<<"Alerting billboard handling ="<<d<< std::endl; 843 843 _computed_znear = d; 844 844 } … … 851 851 if (osg::isNaN(depth)) 852 852 { 853 NOTIFY(osg::NOTICE)<<"CullVisitor::apply(Billboard&) detected NaN,"<<std::endl853 OSG_NOTIFY(osg::NOTICE)<<"CullVisitor::apply(Billboard&) detected NaN,"<<std::endl 854 854 <<" depth="<<depth<<", pos=("<<pos<<"),"<<std::endl 855 855 <<" *billboard_matrix="<<*billboard_matrix<<std::endl; 856 NOTIFY(osg::DEBUG_INFO) << " NodePath:" << std::endl;856 OSG_NOTIFY(osg::DEBUG_INFO) << " NodePath:" << std::endl; 857 857 for (NodePath::const_iterator i = getNodePath().begin(); i != getNodePath().end(); ++i) 858 858 { 859 NOTIFY(osg::DEBUG_INFO) << " \"" << (*i)->getName() << "\"" << std::endl;859 OSG_NOTIFY(osg::DEBUG_INFO) << " \"" << (*i)->getName() << "\"" << std::endl; 860 860 } 861 861 } … … 1026 1026 pushProjectionMatrix(matrix.get()); 1027 1027 1028 // NOTIFY(osg::INFO)<<"Push projection "<<*matrix<<std::endl;1028 //OSG_NOTIFY(osg::INFO)<<"Push projection "<<*matrix<<std::endl; 1029 1029 1030 1030 // note do culling check after the frustum has been updated to ensure … … 1037 1037 popProjectionMatrix(); 1038 1038 1039 // NOTIFY(osg::INFO)<<"Pop projection "<<*matrix<<std::endl;1039 //OSG_NOTIFY(osg::INFO)<<"Pop projection "<<*matrix<<std::endl; 1040 1040 1041 1041 _computed_znear = previous_znear;
