| | 562 | { |
| | 563 | // Two situations where we want to simply do a regular traversal: |
| | 564 | // 1) it's the first frame for this camers |
| | 565 | // 2) we haven't rendered for an abnormally long time (probably because we're an out-of-range LOD child) |
| | 566 | // In these cases, assume we're visible to avoid blinking. |
| | 567 | OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _frameCountMutex ); |
| | 568 | const int& lastQueryFrame( _frameCountMap[ camera ] ); |
| | 569 | if( ( lastQueryFrame == 0 ) || |
| | 570 | ( (nv.getTraversalNumber() - lastQueryFrame) > (_queryFrameCount + 1) ) ) |
| | 571 | return true; |
| | 572 | } |
| | 573 | |
| 571 | | // If the distance to the bounding sphere shell is positive, retrieve |
| 572 | | // the results. Others (we're inside the BS shell) we are considered |
| | 583 | // Get the near plane for the upcoming distance calculation. |
| | 584 | float nearPlane; |
| | 585 | const osg::Matrix& proj( camera->getProjectionMatrix() ); |
| | 586 | if( ( proj(3,3) != 1. ) || ( proj(2,3) != 0. ) || ( proj(1,3) != 0. ) || ( proj(0,3) != 0.) ) |
| | 587 | nearPlane = proj(3,2) / (proj(2,2)-1.); // frustum / perspective |
| | 588 | else |
| | 589 | nearPlane = (proj(3,2)+1.) / proj(2,2); // ortho |
| | 590 | |
| | 591 | // If the distance from the near plane to the bounding sphere shell is positive, retrieve |
| | 592 | // the results. Otherwise (near plane inside the BS shell) we are considered |