Пример #1
0
    void visit( const LODNode& lodNode, VisitState& state )
    {
        const Boxf& worldBox = lodNode.getWorldBox();
        if( !_frustum.isInFrustum( worldBox ) || _clipPlanes.isClipped( worldBox ))
        {
           state.setVisitChild( false );
           return;
        }

        Vector3f vmin, vmax;
        const Plane& nearPlane = _frustum.getNearPlane();

        worldBox.computeNearFar( nearPlane, vmin, vmax );

        Vector4f hVmin = vmin;
        hVmin[ 3 ] = 1.0f;

        Vector4f hVmax = vmax;
        hVmax[ 3 ] = 1.0f;

        // The bounding box intersects the plane
       if( _frustum.getNearPlane().dot( hVmin ) < 0 ||
           _frustum.getNearPlane().dot( hVmax ) < 0 )
       {
           // Where eye direction intersects with near plane
           vmin = _frustum.getEyePos() - _frustum.getViewDir() * _frustum.nearPlane();
       }

       const Vector3f& voxelBox = lodNode.getVoxelBox().getSize();
       const Vector3f& worldSpacePerVoxel = worldBox.getSize() / voxelBox;

       bool lodVisible = isLODVisible( vmin, worldSpacePerVoxel.find_min( ));

       const VolumeInformation& volInfo = _dataSource.getVolumeInfo();
       const uint32_t depth = volInfo.rootNode.getDepth();
       lodVisible = ( lodVisible && lodNode.getRefLevel() >= _minLOD )
                    || ( lodNode.getRefLevel() == _maxLOD )
                    || ( lodNode.getRefLevel() == depth - 1 );

       if( lodVisible )
           _visibles.push_back( lodNode.getNodeId( ));

       state.setVisitChild( !lodVisible );
    }
Пример #2
0
    bool visit(const LODNode& lodNode)
    {
        const Boxf& worldBox = lodNode.getWorldBox();
        if (!_frustum.isInFrustum(worldBox) || _clipPlanes.isOutside(worldBox))
            return false;

        Vector3f vmin, vmax;
        const Plane& nearPlane = _frustum.getNearPlane();

        worldBox.computeNearFar(nearPlane, vmin, vmax);

        Vector4f hVmin = vmin;
        hVmin[3] = 1.0f;

        Vector4f hVmax = vmax;
        hVmax[3] = 1.0f;

        // The bounding box intersects the plane
        if (_frustum.getNearPlane().dot(hVmin) < 0 ||
            _frustum.getNearPlane().dot(hVmax) < 0)
        {
            // Where eye direction intersects with near plane
            vmin = _frustum.getEyePos() -
                   _frustum.getViewDir() * _frustum.nearPlane();
        }

        const Vector3f& voxelBox = lodNode.getVoxelBox().getSize();
        const Vector3f& worldSpacePerVoxel = worldBox.getSize() / voxelBox;
        const auto level = lodNode.getRefLevel();
        bool lodVisible = isLODVisible(vmin, worldSpacePerVoxel.find_min()) &&
                          level >= _minLOD;

        if (level == _maxLOD)
            lodVisible = true;

        if (lodVisible)
            _visibles.push_back(lodNode.getNodeId());

        return !lodVisible;
    }