2012-08-14 09:17:48 +00:00
|
|
|
#ifndef SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
|
|
|
#define SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2013-08-06 15:15:09 +00:00
|
|
|
#include <sprout/limits.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/index_tuple/metafunction.hpp>
|
2012-08-14 09:17:48 +00:00
|
|
|
#include <sprout/tuple/tuple.hpp>
|
|
|
|
#include <sprout/darkroom/access/access.hpp>
|
|
|
|
#include <sprout/darkroom/colors/rgb.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace lights {
|
|
|
|
//
|
|
|
|
// light_list
|
|
|
|
//
|
|
|
|
template<typename... Lights>
|
|
|
|
class light_list {
|
|
|
|
public:
|
|
|
|
typedef sprout::tuples::tuple<Lights...> lights_type;
|
|
|
|
typedef typename sprout::darkroom::access::unit<lights_type>::type::color_type color_type;
|
|
|
|
private:
|
|
|
|
lights_type lights_;
|
|
|
|
private:
|
|
|
|
template<typename Color>
|
2012-10-05 15:58:56 +00:00
|
|
|
SPROUT_CONSTEXPR color_type
|
|
|
|
shade_2(Color const& col) const {
|
2012-08-14 09:17:48 +00:00
|
|
|
return col;
|
|
|
|
}
|
|
|
|
template<typename Color1, typename Color2, typename... Tail>
|
2012-10-05 15:58:56 +00:00
|
|
|
SPROUT_CONSTEXPR color_type
|
|
|
|
shade_2(Color1 const& col1, Color2 const& col2, Tail const&... tail) const {
|
2012-08-14 09:17:48 +00:00
|
|
|
return shade_2(
|
|
|
|
sprout::darkroom::colors::add(col1, col2),
|
|
|
|
tail...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
template<typename Intersection, typename Objects, sprout::index_t... Indexes>
|
2012-10-05 15:58:56 +00:00
|
|
|
SPROUT_CONSTEXPR color_type
|
|
|
|
shade_1(
|
2012-08-14 09:17:48 +00:00
|
|
|
Intersection const& inter, Objects const& objs,
|
|
|
|
sprout::index_tuple<Indexes...>
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
return shade_2(sprout::darkroom::access::get<Indexes>(lights_).template operator()(inter, objs)...);
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
explicit SPROUT_CONSTEXPR light_list(Lights const&... lights)
|
|
|
|
: lights_(lights...)
|
|
|
|
{}
|
|
|
|
template<typename Intersection, typename Objects>
|
2012-10-05 15:58:56 +00:00
|
|
|
SPROUT_CONSTEXPR color_type
|
|
|
|
operator()(Intersection const& inter, Objects const& objs) const {
|
2013-05-10 10:52:39 +00:00
|
|
|
return shade_1(inter, objs, sprout::index_pack<Lights...>::make());
|
2012-08-14 09:17:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
//
|
|
|
|
// make_light_list
|
|
|
|
//
|
|
|
|
template<typename... Lights>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::darkroom::lights::light_list<Lights...>
|
|
|
|
make_light_list(Lights const&... lights) {
|
|
|
|
return sprout::darkroom::lights::light_list<Lights...>(lights...);
|
|
|
|
}
|
|
|
|
} // namespace lights
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|