コード例 #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(CullSettingsTest, DefaultValues)
{
    CullSettings s;

    EXPECT_TRUE(s.isViewFrustumCullingEnabled());
    EXPECT_FALSE(s.isPixelSizeCullingEnabled());
    EXPECT_DOUBLE_EQ(80, s.pixelSizeCullingAreaThreshold());
}
コード例 #2
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());
}
コード例 #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);
    }
}