Changeset 11127
- Timestamp:
- 02/26/10 11:13:28 (3 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 3 modified
-
include/osg/OcclusionQueryNode (modified) (1 diff)
-
src/osg/OcclusionQueryNode.cpp (modified) (3 diffs)
-
src/osgUtil/CullVisitor.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/OcclusionQueryNode
r7889 r11127 89 89 // These methods are public so that osgUtil::CullVisitor can access them. 90 90 // Not intended for application use. 91 bool getPassed( const osg::Camera* camera, float distanceToEyePoint);91 bool getPassed( const osg::Camera* camera, osg::NodeVisitor& nv ); 92 92 void traverseQuery( const osg::Camera* camera, osg::NodeVisitor& nv ); 93 93 void traverseDebug( osg::NodeVisitor& nv ); -
OpenSceneGraph/trunk/src/osg/OcclusionQueryNode.cpp
r10933 r11127 553 553 554 554 bool 555 OcclusionQueryNode::getPassed( const osg::Camera* camera, float distanceToEyePoint)555 OcclusionQueryNode::getPassed( const osg::Camera* camera, osg::NodeVisitor& nv ) 556 556 { 557 557 if ( !_enabled ) … … 560 560 return true; 561 561 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 562 574 if (_queryGeode->getDrawable( 0 ) == NULL) 563 575 { … … 569 581 QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) ); 570 582 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 573 593 // to have passed and don't need to retrieve the query. 574 594 const osg::BoundingSphere& bs = getBound(); 575 float distance = distanceToEyePoint - bs._radius; 595 float distanceToEyePoint = nv.getDistanceToEyePoint( bs._center, false ); 596 597 float distance = distanceToEyePoint - nearPlane - bs._radius; 576 598 _passed = ( distance <= 0.f ); 577 599 if (!_passed) -
OpenSceneGraph/trunk/src/osgUtil/CullVisitor.cpp
r11046 r11127 1447 1447 1448 1448 // If previous query indicates visible, then traverse as usual. 1449 if (node.getPassed( camera, getDistanceToEyePoint( node.getBound()._center, false )))1449 if (node.getPassed( camera, *this )) 1450 1450 handle_cull_callbacks_and_traverse(node); 1451 1451
