using System;
using Unity.Collections;
namespace UnityEngine.Rendering.Universal
{
///
/// Class that holds data related to culling.
///
public class CullContextData : ContextItem
{
internal ScriptableRenderContext? m_RenderContext;
///
public override void Reset()
{
m_RenderContext = null;
}
///
/// Assigns the render context once at initialization time.
///
/// The render context to assign.
public void SetRenderContext(in ScriptableRenderContext renderContext)
{
m_RenderContext = renderContext;
}
///
/// Performs scene culling based on the provided parameters.
///
/// The parameters used for the culling.
/// The culling results.
public CullingResults Cull(ref ScriptableCullingParameters parameters)
{
if (!m_RenderContext.HasValue)
{
throw new InvalidOperationException("The ScriptableRenderContext member is not set.");
}
return m_RenderContext.Value.Cull(ref parameters);
}
///
/// Performs shadow casters culling based on the provided parameters.
///
/// The scene culling results.
/// The shadow casters culling informations.
/// The parameters used for the shadow culling.
public void CullShadowCasters(CullingResults cullingResults, ShadowCastersCullingInfos shadowCastersCullingInfos)
{
if (!m_RenderContext.HasValue)
{
throw new InvalidOperationException("The ScriptableRenderContext member is not set.");
}
m_RenderContext.Value.CullShadowCasters(cullingResults, shadowCastersCullingInfos);
}
}
}