Exemplo n.º 1
0
bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const
{
    CullSettings* cs = dynamic_cast<CullSettings*>(nv);
    if (cs && !(cs->getCullingMode() & CullSettings::CLUSTER_CULLING))
    {
        // cluster culling switched off cull settings.
        return false;
    }

    if (_deviation<=-1.0f)
    {
        // cluster culling switch off by deviation.
        return false;
    }

    osg::Vec3 eye_cp = nv->getViewPoint() - _controlPoint;
    float radius = eye_cp.length();

    if (radius<_radius)
    {
        return false;
    }


    float deviation = (eye_cp * _normal)/radius;

//    OSG_NOTICE<<"ClusterCullingCallback::cull() _normal="<<_normal<<" _controlPointtest="<<_controlPoint<<" eye_cp="<<eye_cp<<std::endl;
//    OSG_NOTICE<<"                             deviation="<<deviation<<" _deviation="<<_deviation<<" test="<<(deviation < _deviation)<<std::endl;

    return deviation < _deviation;
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(CullSettingsTest, DefaultValues)
{
    CullSettings s;

    EXPECT_TRUE(s.isViewFrustumCullingEnabled());
    EXPECT_FALSE(s.isPixelSizeCullingEnabled());
    EXPECT_DOUBLE_EQ(80, s.pixelSizeCullingAreaThreshold());
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
/// Compute and append the visible parts in this node and all child nodes (recursive)
//--------------------------------------------------------------------------------------------------
void ModelBasicTreeNode::findVisibleParts(PartRenderHintCollection* visibleParts, const Camera& camera, const CullSettings& cullSettings, uint enableMask)
{
    if (!m_boundingBox.isValid())
    {
        return;
    }

    const size_t numChildren = m_children.size();
    const size_t numParts = m_partList.notNull() ? m_partList->partCount() : 0;

    if (numChildren > 0 || numParts > 1)
    {
        // View Frustum culling
        if (cullSettings.isViewFrustumCullingEnabled())
        {
            if (camera.frustum().isOutside(m_boundingBox))
            {
                // No parts on this level (or below) are visible. So just return
                return;
            }
        }

        // Pixel size culling
        if (cullSettings.isPixelSizeCullingEnabled())
        {
            double area = camera.computeProjectedBoundingSpherePixelArea(m_boundingBox.center(), m_boundingBox.radius());
            if (area < cullSettings.pixelSizeCullingAreaThreshold())
            {
                return;
            }
        }
    }

    size_t i;
    for (i = 0; i < numChildren; i++)
    {
        ModelBasicTreeNode* c = m_children[i];
        CVF_ASSERT(c);

        c->findVisibleParts(visibleParts, camera, cullSettings, enableMask);
    }

    if (m_partList.notNull()) 
    {
        m_partList->findVisibleParts(visibleParts, camera, cullSettings, enableMask);
    }
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(CullSettingsTest, GettersAndSetters)
{
    CullSettings s;
    s.enableViewFrustumCulling(false);
    s.enablePixelSizeCulling(true);
    s.setPixelSizeCullingAreaThreshold(5);

    EXPECT_FALSE(s.isViewFrustumCullingEnabled());
    EXPECT_TRUE(s.isPixelSizeCullingEnabled());
    EXPECT_DOUBLE_EQ(5, s.pixelSizeCullingAreaThreshold());
}