namespace renderer  { class LightSample; }
namespace renderer  { class Scene; }

namespace renderer
{

//
// The forward light sampler is intended to be used with forward tracing techniques
// such as light tracing, SPPM, etc.
//

class ForwardLightSampler
  : public LightSamplerBase
{
  public:
    // Constructor.
    ForwardLightSampler(
        const Scene&                    scene,
        const ParamArray&               params = ParamArray());

    // Return true if the scene contains at least one light or emitting triangle.
    bool has_lights() const;

    // Sample the sets of non-physical lights and emitting triangles.
    void sample(
        const ShadingRay::Time&         time,
        const foundation::Vector3f&     s,
        LightSample&                    light_sample) const;

  private:
    // Sample the set of non-physical lights.
    void sample_non_physical_lights(
        const ShadingRay::Time&         time,
        const foundation::Vector3f&     s,
        LightSample&                    light_sample) const;
};


//
// ForwardLightSampler class implementation.
//

inline bool ForwardLightSampler::has_lights() const
{
    return m_non_physical_lights_cdf.valid() || m_emitting_triangles_cdf.valid();
}

}       // namespace renderer

#endif  // !APPLESEED_RENDERER_KERNEL_LIGHTING_FORWARDLIGHTSAMPLER_H
