Improved the handling of precision
This commit is contained in:
@@ -494,7 +494,7 @@ bool OcclusionQueryNode::getPassed( const Camera* camera, NodeVisitor& nv )
|
|||||||
QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) );
|
QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) );
|
||||||
|
|
||||||
// Get the near plane for the upcoming distance calculation.
|
// Get the near plane for the upcoming distance calculation.
|
||||||
float nearPlane;
|
osg::Matrix::value_type nearPlane;
|
||||||
const osg::Matrix& proj( camera->getProjectionMatrix() );
|
const osg::Matrix& proj( camera->getProjectionMatrix() );
|
||||||
if( ( proj(3,3) != 1. ) || ( proj(2,3) != 0. ) || ( proj(1,3) != 0. ) || ( proj(0,3) != 0.) )
|
if( ( proj(3,3) != 1. ) || ( proj(2,3) != 0. ) || ( proj(1,3) != 0. ) || ( proj(0,3) != 0.) )
|
||||||
nearPlane = proj(3,2) / (proj(2,2)-1.); // frustum / perspective
|
nearPlane = proj(3,2) / (proj(2,2)-1.); // frustum / perspective
|
||||||
@@ -505,10 +505,10 @@ bool OcclusionQueryNode::getPassed( const Camera* camera, NodeVisitor& nv )
|
|||||||
// the results. Otherwise (near plane inside the BS shell) we are considered
|
// the results. Otherwise (near plane inside the BS shell) we are considered
|
||||||
// to have passed and don't need to retrieve the query.
|
// to have passed and don't need to retrieve the query.
|
||||||
const osg::BoundingSphere& bs = getBound();
|
const osg::BoundingSphere& bs = getBound();
|
||||||
float distanceToEyePoint = nv.getDistanceToEyePoint( bs._center, false );
|
osg::Matrix::value_type distanceToEyePoint = nv.getDistanceToEyePoint( bs._center, false );
|
||||||
|
|
||||||
float distance = distanceToEyePoint - nearPlane - bs._radius;
|
osg::Matrix::value_type distance = distanceToEyePoint - nearPlane - bs._radius;
|
||||||
_passed = ( distance <= 0.f );
|
_passed = ( distance <= 0.0 );
|
||||||
if (!_passed)
|
if (!_passed)
|
||||||
{
|
{
|
||||||
int result = qg->getNumPixels( camera );
|
int result = qg->getNumPixels( camera );
|
||||||
|
|||||||
Reference in New Issue
Block a user