mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix coding-stype
This commit is contained in:
parent
2012838899
commit
df3023db30
196 changed files with 2510 additions and 3945 deletions
|
@ -34,9 +34,10 @@ namespace sprout {
|
|||
// get
|
||||
//
|
||||
template<std::size_t I, typename T>
|
||||
inline SPROUT_CONSTEXPR auto get(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<I>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::tuples::get<I>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
get(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<I>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::tuples::get<I>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::tuples::get<I>(sprout::forward<T>(t));
|
||||
}
|
||||
|
|
|
@ -29,13 +29,8 @@ namespace sprout {
|
|||
position_type fixation_point_;
|
||||
unit_type rotate_;
|
||||
private:
|
||||
SPROUT_CONSTEXPR position_type transform_1(
|
||||
position_type const& c,
|
||||
unit_type const& u,
|
||||
unit_type const& v,
|
||||
unit_type const& l
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR position_type
|
||||
transform_1(position_type const& c, unit_type const& u, unit_type const& v, unit_type const& l) const {
|
||||
return sprout::darkroom::coords::add(
|
||||
c,
|
||||
position_type(
|
||||
|
@ -45,12 +40,8 @@ namespace sprout {
|
|||
)
|
||||
);
|
||||
}
|
||||
SPROUT_CONSTEXPR position_type transform(
|
||||
position_type const& c,
|
||||
unit_type const& u,
|
||||
unit_type const& v
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR position_type
|
||||
transform(position_type const& c, unit_type const& u, unit_type const& v) const {
|
||||
return transform_1(
|
||||
c,
|
||||
u * sprout::cos(rotate_) - v * sprout::sin(rotate_),
|
||||
|
@ -62,11 +53,10 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Unit2D>
|
||||
SPROUT_CONSTEXPR position_type reference_width(
|
||||
Unit2D const& x,
|
||||
Unit2D const& y,
|
||||
Unit2D const& width,
|
||||
Unit2D const& height,
|
||||
SPROUT_CONSTEXPR position_type
|
||||
reference_width(
|
||||
Unit2D const& x, Unit2D const& y,
|
||||
Unit2D const& width, Unit2D const& height,
|
||||
unit_type const& rate
|
||||
) const
|
||||
{
|
||||
|
@ -80,11 +70,10 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Unit2D>
|
||||
SPROUT_CONSTEXPR position_type reference_height(
|
||||
Unit2D const& x,
|
||||
Unit2D const& y,
|
||||
Unit2D const& width,
|
||||
Unit2D const& height,
|
||||
SPROUT_CONSTEXPR position_type
|
||||
reference_height(
|
||||
Unit2D const& x, Unit2D const& y,
|
||||
Unit2D const& width, Unit2D const& height,
|
||||
unit_type const& rate
|
||||
) const
|
||||
{
|
||||
|
@ -112,13 +101,8 @@ namespace sprout {
|
|||
, rotate_(rotate)
|
||||
{}
|
||||
template<typename Unit2D>
|
||||
SPROUT_CONSTEXPR ray_type operator()(
|
||||
Unit2D const& x,
|
||||
Unit2D const& y,
|
||||
Unit2D const& width,
|
||||
Unit2D const& height
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR ray_type
|
||||
operator()(Unit2D const& x, Unit2D const& y, Unit2D const& width, Unit2D const& height) const {
|
||||
return ray_type(
|
||||
position_,
|
||||
sprout::darkroom::coords::normalize(
|
||||
|
|
|
@ -19,30 +19,34 @@ namespace sprout {
|
|||
// a
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto r(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
r(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto g(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
g(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto b(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
b(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<2>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto a(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<3>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<3>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
a(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<3>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<3>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<3>(sprout::forward<T>(t));
|
||||
}
|
||||
|
@ -58,7 +62,8 @@ namespace sprout {
|
|||
// mul
|
||||
//
|
||||
template<typename Color, typename Fac>
|
||||
inline SPROUT_CONSTEXPR Color mul(Color const& lhs, Fac const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Color
|
||||
mul(Color const& lhs, Fac const& rhs) {
|
||||
return sprout::tuples::remake<Color>(
|
||||
lhs,
|
||||
sprout::darkroom::colors::r(lhs) * rhs,
|
||||
|
@ -70,7 +75,8 @@ namespace sprout {
|
|||
// add
|
||||
//
|
||||
template<typename Color1, typename Color2>
|
||||
inline SPROUT_CONSTEXPR Color1 add(Color1 const& lhs, Color2 const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Color1
|
||||
add(Color1 const& lhs, Color2 const& rhs) {
|
||||
return sprout::tuples::remake<Color1>(
|
||||
lhs,
|
||||
sprout::darkroom::colors::r(lhs) + sprout::darkroom::colors::r(rhs),
|
||||
|
@ -82,7 +88,8 @@ namespace sprout {
|
|||
// filter
|
||||
//
|
||||
template<typename Color1, typename Color2>
|
||||
inline SPROUT_CONSTEXPR Color1 filter(Color1 const& lhs, Color2 const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Color1
|
||||
filter(Color1 const& lhs, Color2 const& rhs) {
|
||||
return sprout::tuples::remake<Color1>(
|
||||
lhs,
|
||||
sprout::darkroom::colors::r(lhs) * sprout::darkroom::colors::r(rhs),
|
||||
|
@ -95,7 +102,8 @@ namespace sprout {
|
|||
// rgb_f_to_rgb
|
||||
//
|
||||
template<typename RGB, typename RGB_F>
|
||||
inline SPROUT_CONSTEXPR RGB rgb_f_to_rgb(RGB_F const& col) {
|
||||
inline SPROUT_CONSTEXPR RGB
|
||||
rgb_f_to_rgb(RGB_F const& col) {
|
||||
typedef typename sprout::darkroom::access::unit<RGB>::type unit_type;
|
||||
return sprout::tuples::make<RGB>(
|
||||
sprout::darkroom::colors::r(col) < 0 ? std::numeric_limits<unit_type>::min()
|
||||
|
|
|
@ -17,23 +17,26 @@ namespace sprout {
|
|||
// z
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto x(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
x(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto y(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
y(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto z(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
z(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<2>(sprout::forward<T>(t));
|
||||
}
|
||||
|
@ -66,7 +69,8 @@ namespace sprout {
|
|||
// add
|
||||
//
|
||||
template<typename Vector1, typename Vector2>
|
||||
inline SPROUT_CONSTEXPR Vector1 add(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Vector1
|
||||
add(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
return sprout::tuples::remake<Vector1>(
|
||||
lhs,
|
||||
sprout::darkroom::coords::x(lhs) + sprout::darkroom::coords::x(rhs),
|
||||
|
@ -78,7 +82,8 @@ namespace sprout {
|
|||
// sub
|
||||
//
|
||||
template<typename Vector1, typename Vector2>
|
||||
inline SPROUT_CONSTEXPR Vector1 sub(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Vector1
|
||||
sub(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
return sprout::tuples::remake<Vector1>(
|
||||
lhs,
|
||||
sprout::darkroom::coords::x(lhs) - sprout::darkroom::coords::x(rhs),
|
||||
|
@ -90,7 +95,8 @@ namespace sprout {
|
|||
// scale
|
||||
//
|
||||
template<typename Vector, typename Fac>
|
||||
inline SPROUT_CONSTEXPR Vector scale(Vector const& lhs, Fac const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Vector
|
||||
scale(Vector const& lhs, Fac const& rhs) {
|
||||
return sprout::tuples::remake<Vector>(
|
||||
lhs,
|
||||
sprout::darkroom::coords::x(lhs) * rhs,
|
||||
|
@ -102,7 +108,8 @@ namespace sprout {
|
|||
// negate
|
||||
//
|
||||
template<typename Vector>
|
||||
inline SPROUT_CONSTEXPR Vector negate(Vector const& vec) {
|
||||
inline SPROUT_CONSTEXPR Vector
|
||||
negate(Vector const& vec) {
|
||||
return sprout::tuples::remake<Vector>(
|
||||
vec,
|
||||
-sprout::darkroom::coords::x(vec),
|
||||
|
@ -125,7 +132,8 @@ namespace sprout {
|
|||
// cross
|
||||
//
|
||||
template<typename Vector1, typename Vector2>
|
||||
inline SPROUT_CONSTEXPR Vector1 cross(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Vector1
|
||||
cross(Vector1 const& lhs, Vector2 const& rhs) {
|
||||
return sprout::tuples::remake<Vector1>(
|
||||
lhs,
|
||||
sprout::darkroom::coords::y(lhs) * sprout::darkroom::coords::z(rhs)
|
||||
|
@ -143,11 +151,8 @@ namespace sprout {
|
|||
//
|
||||
namespace detail {
|
||||
template<typename Vector>
|
||||
inline SPROUT_CONSTEXPR Vector normalize_impl(
|
||||
Vector const& vec,
|
||||
typename sprout::darkroom::access::unit<Vector>::type const& len
|
||||
)
|
||||
{
|
||||
inline SPROUT_CONSTEXPR Vector
|
||||
normalize_impl(Vector const& vec, typename sprout::darkroom::access::unit<Vector>::type const& len) {
|
||||
return sprout::tuples::remake<Vector>(
|
||||
vec,
|
||||
sprout::darkroom::coords::x(vec) / len,
|
||||
|
@ -157,7 +162,8 @@ namespace sprout {
|
|||
}
|
||||
} // namespace detail
|
||||
template<typename Vector>
|
||||
inline SPROUT_CONSTEXPR Vector normalize(Vector const& vec) {
|
||||
inline SPROUT_CONSTEXPR Vector
|
||||
normalize(Vector const& vec) {
|
||||
return sprout::darkroom::coords::detail::normalize_impl(
|
||||
vec,
|
||||
sprout::darkroom::coords::length(vec)
|
||||
|
@ -167,7 +173,8 @@ namespace sprout {
|
|||
// resize
|
||||
//
|
||||
template<typename Vector, typename Fac>
|
||||
inline SPROUT_CONSTEXPR Vector resize(Vector const& lhs, Fac const& rhs) {
|
||||
inline SPROUT_CONSTEXPR Vector
|
||||
resize(Vector const& lhs, Fac const& rhs) {
|
||||
return sprout::darkroom::coords::detail::normalize_impl(
|
||||
lhs,
|
||||
sprout::darkroom::coords::length(lhs) / rhs
|
||||
|
@ -177,7 +184,8 @@ namespace sprout {
|
|||
// reflect
|
||||
//
|
||||
template<typename Incident, typename Normal>
|
||||
inline SPROUT_CONSTEXPR Incident reflect(Incident const& incid, Normal const& nor) {
|
||||
inline SPROUT_CONSTEXPR Incident
|
||||
reflect(Incident const& incid, Normal const& nor) {
|
||||
return sprout::darkroom::coords::sub(
|
||||
incid,
|
||||
sprout::darkroom::coords::scale(nor, sprout::darkroom::coords::dot(incid, nor) * 2)
|
||||
|
|
|
@ -19,37 +19,42 @@ namespace sprout {
|
|||
// material
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto does_intersect(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
does_intersect(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto distance(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
distance(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto point_of_intersection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
point_of_intersection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<2>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<2>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<2>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto normal(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<3>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<3>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
normal(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<3>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<3>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<3>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto material(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<4>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<4>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
material(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<4>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<4>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<4>(sprout::forward<T>(t));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ namespace sprout {
|
|||
: col_(col)
|
||||
{}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type operator()(Intersection const& inter, Objects const&) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
operator()(Intersection const& inter, Objects const&) const {
|
||||
return sprout::darkroom::colors::filter(
|
||||
col_,
|
||||
sprout::darkroom::materials::color(sprout::darkroom::intersects::material(inter))
|
||||
|
|
|
@ -23,18 +23,21 @@ namespace sprout {
|
|||
lights_type lights_;
|
||||
private:
|
||||
template<typename Color>
|
||||
SPROUT_CONSTEXPR color_type shade_2(Color const& col) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_2(Color const& col) const {
|
||||
return col;
|
||||
}
|
||||
template<typename Color1, typename Color2, typename... Tail>
|
||||
SPROUT_CONSTEXPR color_type shade_2(Color1 const& col1, Color2 const& col2, Tail const&... tail) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_2(Color1 const& col1, Color2 const& col2, Tail const&... tail) const {
|
||||
return shade_2(
|
||||
sprout::darkroom::colors::add(col1, col2),
|
||||
tail...
|
||||
);
|
||||
}
|
||||
template<typename Intersection, typename Objects, sprout::index_t... Indexes>
|
||||
SPROUT_CONSTEXPR color_type shade_1(
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_1(
|
||||
Intersection const& inter, Objects const& objs,
|
||||
sprout::index_tuple<Indexes...>
|
||||
) const
|
||||
|
@ -46,7 +49,8 @@ namespace sprout {
|
|||
: lights_(lights...)
|
||||
{}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type operator()(Intersection const& inter, Objects const& objs) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(inter, objs, sprout::index_range<0, sizeof...(Lights)>::make());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,11 +32,8 @@ namespace sprout {
|
|||
color_type col_;
|
||||
private:
|
||||
template<typename Intersection>
|
||||
SPROUT_CONSTEXPR color_type shade_2(
|
||||
Intersection const& inter,
|
||||
unit_type const& intensity
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_2(Intersection const& inter, unit_type const& intensity) const {
|
||||
return sprout::darkroom::colors::mul(
|
||||
sprout::darkroom::colors::filter(
|
||||
col_,
|
||||
|
@ -46,11 +43,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Intersection, typename LightRayIntersection>
|
||||
SPROUT_CONSTEXPR color_type shade_1(
|
||||
Intersection const& inter,
|
||||
LightRayIntersection const& light_ray_inter
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_1(Intersection const& inter, LightRayIntersection const& light_ray_inter) const {
|
||||
return shade_2(
|
||||
inter,
|
||||
!sprout::darkroom::intersects::does_intersect(light_ray_inter)
|
||||
|
@ -67,15 +61,13 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_parallel_light(
|
||||
position_type const& dir,
|
||||
color_type const& col
|
||||
)
|
||||
SPROUT_CONSTEXPR basic_parallel_light(position_type const& dir, color_type const& col)
|
||||
: dir_(sprout::darkroom::coords::normalize(dir))
|
||||
, col_(col)
|
||||
{}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type operator()(Intersection const& inter, Objects const& objs) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(
|
||||
inter,
|
||||
sprout::darkroom::objects::intersect_list(
|
||||
|
|
|
@ -32,11 +32,8 @@ namespace sprout {
|
|||
color_type col_;
|
||||
private:
|
||||
template<typename Intersection>
|
||||
SPROUT_CONSTEXPR color_type shade_4(
|
||||
Intersection const& inter,
|
||||
unit_type const& intensity
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_4(Intersection const& inter, unit_type const& intensity) const {
|
||||
return sprout::darkroom::colors::mul(
|
||||
sprout::darkroom::colors::filter(
|
||||
col_,
|
||||
|
@ -46,10 +43,9 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Intersection, typename LightRayIntersection>
|
||||
SPROUT_CONSTEXPR color_type shade_3(
|
||||
Intersection const& inter,
|
||||
position_type const& diff,
|
||||
position_type const& direction,
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_3(
|
||||
Intersection const& inter, position_type const& diff, position_type const& direction,
|
||||
LightRayIntersection const& light_ray_inter
|
||||
) const
|
||||
{
|
||||
|
@ -72,13 +68,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type shade_2(
|
||||
Intersection const& inter,
|
||||
Objects const& objs,
|
||||
position_type const& diff,
|
||||
position_type const& direction
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_2(Intersection const& inter, Objects const& objs, position_type const& diff, position_type const& direction) const {
|
||||
return shade_3(
|
||||
inter,
|
||||
diff,
|
||||
|
@ -99,12 +90,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type shade_1(
|
||||
Intersection const& inter,
|
||||
Objects const& objs,
|
||||
position_type const& diff
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR color_type
|
||||
shade_1(Intersection const& inter, Objects const& objs, position_type const& diff) const {
|
||||
return shade_2(
|
||||
inter,
|
||||
objs,
|
||||
|
@ -113,15 +100,13 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_point_light(
|
||||
position_type const& pos,
|
||||
color_type const& col
|
||||
)
|
||||
SPROUT_CONSTEXPR basic_point_light(position_type const& pos, color_type const& col)
|
||||
: pos_(pos)
|
||||
, col_(col)
|
||||
{}
|
||||
template<typename Intersection, typename Objects>
|
||||
SPROUT_CONSTEXPR color_type operator()(Intersection const& inter, Objects const& objs) const {
|
||||
SPROUT_CONSTEXPR color_type
|
||||
operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(
|
||||
inter,
|
||||
objs,
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace sprout {
|
|||
// bilinear_interpolate
|
||||
//
|
||||
template<typename Color, typename Unit>
|
||||
inline SPROUT_CONSTEXPR Color bilinear_interpolate(
|
||||
inline SPROUT_CONSTEXPR Color
|
||||
bilinear_interpolate(
|
||||
Color const& c00, Color const& c01, Color const& c10, Color const& c11,
|
||||
Unit const& u, Unit const& v
|
||||
)
|
||||
|
|
|
@ -15,16 +15,18 @@ namespace sprout {
|
|||
// reflection
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto color(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
color(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto reflection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
reflection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
|
@ -34,14 +36,18 @@ namespace sprout {
|
|||
// calc_reflection
|
||||
//
|
||||
template<typename Image, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_color(Image&& t, Unit const& u, Unit const& v) SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_color(Image&& t, Unit const& u, Unit const& v)
|
||||
SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
{
|
||||
return sprout::forward<Image>(t).template operator()(u, v);
|
||||
}
|
||||
template<typename Image, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_reflection(Image&& t, Unit const& u, Unit const& v) SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_reflection(Image&& t, Unit const& u, Unit const& v)
|
||||
SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
{
|
||||
return sprout::forward<Image>(t).template operator()(u, v);
|
||||
}
|
||||
|
@ -50,11 +56,12 @@ namespace sprout {
|
|||
// calc_material
|
||||
//
|
||||
template<typename Material, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_material(Material const& mat, Unit const& u, Unit const& v)
|
||||
-> decltype(sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calc_reflection(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_material(Material const& mat, Unit const& u, Unit const& v)
|
||||
-> decltype(sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calc_reflection(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
))
|
||||
{
|
||||
return sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace sprout {
|
|||
typedef Element result_type;
|
||||
typedef Scale unit_type;
|
||||
private:
|
||||
static SPROUT_CONSTEXPR unit_type fmod(unit_type const& n, unit_type const& d) {
|
||||
static SPROUT_CONSTEXPR unit_type
|
||||
fmod(unit_type const& n, unit_type const& d) {
|
||||
return n - std::intmax_t(n / d) * d;
|
||||
}
|
||||
private:
|
||||
|
@ -26,24 +27,19 @@ namespace sprout {
|
|||
unit_type scale_;
|
||||
private:
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_1(Unit const& u, Unit const& v) const {
|
||||
return (u >= 0 && v >= 0) || (u < 0 && v < 0)
|
||||
? elem1_
|
||||
: elem2_
|
||||
;
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_1(Unit const& u, Unit const& v) const {
|
||||
return (u >= 0 && v >= 0) || (u < 0 && v < 0) ? elem1_ : elem2_;
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR plaid_element(
|
||||
result_type const& elem1,
|
||||
result_type const& elem2,
|
||||
unit_type const& scale = 1
|
||||
)
|
||||
SPROUT_CONSTEXPR plaid_element(result_type const& elem1, result_type const& elem2, unit_type const& scale = 1)
|
||||
: elem1_(elem1)
|
||||
, elem2_(elem2)
|
||||
, scale_(scale)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const& u, Unit const& v) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const& u, Unit const& v) const {
|
||||
return calc_1(
|
||||
(u < 0
|
||||
? scale_ + fmod(u, scale_)
|
||||
|
@ -79,11 +75,10 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::plaid_element<Color>,
|
||||
sprout::darkroom::materials::plaid_element<Reflection>
|
||||
> make_plaid_material_image(
|
||||
Color const& col1,
|
||||
Color const& col2,
|
||||
Reflection const& ref1,
|
||||
Reflection const& ref2
|
||||
>
|
||||
make_plaid_material_image(
|
||||
Color const& col1, Color const& col2,
|
||||
Reflection const& ref1, Reflection const& ref2
|
||||
)
|
||||
{
|
||||
return sprout::tuples::make_tuple(
|
||||
|
@ -95,11 +90,10 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::plaid_element<Color, Unit>,
|
||||
sprout::darkroom::materials::plaid_element<Reflection, Unit>
|
||||
> make_plaid_material_image(
|
||||
Color const& col1,
|
||||
Color const& col2,
|
||||
Reflection const& ref1,
|
||||
Reflection const& ref2,
|
||||
>
|
||||
make_plaid_material_image(
|
||||
Color const& col1, Color const& col2,
|
||||
Reflection const& ref1, Reflection const& ref2,
|
||||
Unit const& scale
|
||||
)
|
||||
{
|
||||
|
|
|
@ -45,22 +45,28 @@ namespace sprout {
|
|||
interpolation_type::values interpolation_value_;
|
||||
texture_map_placement::values placement_value_;
|
||||
private:
|
||||
SPROUT_CONSTEXPR bool is_nearest() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_nearest() const {
|
||||
return interpolation_value_ == interpolation_type::nearest_neighbor;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_bilinear() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_bilinear() const {
|
||||
return interpolation_value_ == interpolation_type::bilinear;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_bicubic() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_bicubic() const {
|
||||
return interpolation_value_ == interpolation_type::bicubic;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_tile() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_tile() const {
|
||||
return placement_value_ == texture_map_placement::tile;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_once() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_once() const {
|
||||
return placement_value_ == texture_map_placement::once;
|
||||
}
|
||||
SPROUT_CONSTEXPR result_type get_color(unit_type const& x, unit_type const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
get_color(unit_type const& x, unit_type const& y) const {
|
||||
return is_tile()
|
||||
? texture_.get()(
|
||||
x < 0
|
||||
|
@ -78,11 +84,13 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_nearest(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_nearest(Unit const& x, Unit const& y) const {
|
||||
return get_color(x, y);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_bilinear_1(
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear_1(
|
||||
Unit const& x, Unit const& x0,
|
||||
Unit const& y, Unit const& y0
|
||||
) const
|
||||
|
@ -94,24 +102,24 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_bilinear(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear(Unit const& x, Unit const& y) const {
|
||||
return calc_bilinear_1(
|
||||
x, sprout::floor(x),
|
||||
y, sprout::floor(y)
|
||||
);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc(Unit const& x, Unit const& y) const {
|
||||
return is_nearest() ? calc_nearest(x, y)
|
||||
: calc_bilinear(x, y)
|
||||
;
|
||||
}
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR texture_map(
|
||||
texture_type const& texture,
|
||||
unit_type const& scale = 1,
|
||||
unit_type const& offset_u = 0,
|
||||
unit_type const& offset_v = 0,
|
||||
texture_type const& texture, unit_type const& scale = 1,
|
||||
unit_type const& offset_u = 0, unit_type const& offset_v = 0,
|
||||
result_type const& default_color = result_type(),
|
||||
interpolation_type::values interpolation_value = interpolation_type::nearest_neighbor,
|
||||
texture_map_placement::values placement_value = texture_map_placement::tile
|
||||
|
@ -125,7 +133,8 @@ namespace sprout {
|
|||
, placement_value_(placement_value)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const& u, Unit const& v) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const& u, Unit const& v) const {
|
||||
return calc(
|
||||
(u - offset_u_ + scale_ / 2) / scale_ * texture_.get().width(),
|
||||
(-(v - offset_v_) + scale_ / 2) / scale_ * texture_.get().height()
|
||||
|
@ -143,10 +152,8 @@ namespace sprout {
|
|||
template<typename Texture, typename Unit>
|
||||
inline SPROUT_CONSTEXPR sprout::darkroom::materials::texture_map<Texture, Unit>
|
||||
make_texture_map(
|
||||
Texture const& texture,
|
||||
Unit const& scale,
|
||||
Unit const& offset_u = 0,
|
||||
Unit const& offset_v = 0,
|
||||
Texture const& texture, Unit const& scale,
|
||||
Unit const& offset_u = 0, Unit const& offset_v = 0,
|
||||
typename sprout::darkroom::materials::texture_map<Texture, Unit>::result_type const& default_color
|
||||
= typename sprout::darkroom::materials::texture_map<Texture, Unit>::result_typ()
|
||||
,
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace sprout {
|
|||
: elem_(elem)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const&, Unit const&) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const&, Unit const&) const {
|
||||
return elem_;
|
||||
}
|
||||
};
|
||||
|
@ -40,7 +41,8 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::uniform_element<Color>,
|
||||
sprout::darkroom::materials::uniform_element<Reflection>
|
||||
> make_uniform_material_image(Color const& col, Reflection const& ref) {
|
||||
>
|
||||
make_uniform_material_image(Color const& col, Reflection const& ref) {
|
||||
return sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::make_uniform(col),
|
||||
sprout::darkroom::materials::make_uniform(ref)
|
||||
|
|
|
@ -54,23 +54,21 @@ namespace sprout {
|
|||
unit_type val_;
|
||||
material_type mat_;
|
||||
private:
|
||||
SPROUT_CONSTEXPR bool is_x() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_x() const {
|
||||
return direction_value_ == aa_plane_direction::x;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_y() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_y() const {
|
||||
return direction_value_ == aa_plane_direction::y;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_z() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_z() const {
|
||||
return direction_value_ == aa_plane_direction::z;
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_5(
|
||||
int hit_side,
|
||||
bool does_intersect,
|
||||
unit_type distance,
|
||||
position_type const& point_of_intersection
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_5(int hit_side, bool does_intersect, unit_type distance, position_type const& point_of_intersection) const {
|
||||
return typename intersection<Ray>::type(
|
||||
does_intersect,
|
||||
distance,
|
||||
|
@ -97,13 +95,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_4(
|
||||
Ray const& ray,
|
||||
int hit_side,
|
||||
bool does_intersect,
|
||||
unit_type distance
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_4(Ray const& ray, int hit_side, bool does_intersect, unit_type distance) const {
|
||||
return intersect_5<Ray>(
|
||||
hit_side,
|
||||
does_intersect,
|
||||
|
@ -114,14 +107,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_3(
|
||||
Ray const& ray,
|
||||
unit_type pos_v,
|
||||
unit_type dir_v,
|
||||
int hit_side,
|
||||
bool does_intersect
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_3(Ray const& ray, unit_type pos_v, unit_type dir_v, int hit_side, bool does_intersect) const {
|
||||
return intersect_4(
|
||||
ray,
|
||||
hit_side,
|
||||
|
@ -132,13 +119,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_2(
|
||||
Ray const& ray,
|
||||
unit_type pos_v,
|
||||
unit_type dir_v,
|
||||
int hit_side
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_2(Ray const& ray, unit_type pos_v, unit_type dir_v, int hit_side) const {
|
||||
return intersect_3(
|
||||
ray,
|
||||
pos_v,
|
||||
|
@ -148,12 +130,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_1(
|
||||
Ray const& ray,
|
||||
unit_type pos_v,
|
||||
unit_type dir_v
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_1(Ray const& ray, unit_type pos_v, unit_type dir_v) const {
|
||||
return intersect_2(
|
||||
ray,
|
||||
pos_v,
|
||||
|
@ -162,17 +140,14 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_aa_plane(
|
||||
aa_plane_direction::values direction_value,
|
||||
unit_type val,
|
||||
material_type const& mat
|
||||
)
|
||||
SPROUT_CONSTEXPR basic_aa_plane(aa_plane_direction::values direction_value, unit_type val, material_type const& mat)
|
||||
: direction_value_(direction_value)
|
||||
, val_(val)
|
||||
, mat_(mat)
|
||||
{}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect(Ray const& ray) const {
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect(Ray const& ray) const {
|
||||
return intersect_1(
|
||||
ray,
|
||||
(is_x() ? sprout::darkroom::coords::x(sprout::darkroom::rays::position(ray))
|
||||
|
@ -191,12 +166,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Material, typename Unit>
|
||||
inline SPROUT_CONSTEXPR sprout::darkroom::objects::basic_aa_plane<Material>
|
||||
make_aa_plane(
|
||||
sprout::darkroom::objects::aa_plane_direction::values dir_val,
|
||||
Unit const& val,
|
||||
Material const& mat
|
||||
)
|
||||
{
|
||||
make_aa_plane(sprout::darkroom::objects::aa_plane_direction::values dir_val, Unit const& val, Material const& mat) {
|
||||
return sprout::darkroom::objects::basic_aa_plane<Material>(dir_val, val, mat);
|
||||
}
|
||||
} // namespace objects
|
||||
|
|
|
@ -26,8 +26,7 @@ namespace sprout {
|
|||
struct intersect_list_impl {
|
||||
private:
|
||||
template<typename Objects, typename Ray, typename A, typename B>
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type
|
||||
::template intersection<Ray>::type
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type::template intersection<Ray>::type
|
||||
comp(A const& a, B const& b) const {
|
||||
return sprout::darkroom::intersects::does_intersect(a)
|
||||
&& sprout::darkroom::intersects::does_intersect(b)
|
||||
|
@ -41,8 +40,7 @@ namespace sprout {
|
|||
}
|
||||
public:
|
||||
template<typename Objects, typename Ray>
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type
|
||||
::template intersection<Ray>::type
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type ::template intersection<Ray>::type
|
||||
operator()(Objects const& objs, Ray const& ray) const {
|
||||
return comp<Objects, Ray>(
|
||||
sprout::darkroom::objects::intersect(sprout::darkroom::access::get<N>(objs), ray),
|
||||
|
@ -54,16 +52,14 @@ namespace sprout {
|
|||
struct intersect_list_impl<0> {
|
||||
public:
|
||||
template<typename Objects, typename Ray>
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type
|
||||
::template intersection<Ray>::type
|
||||
SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type::template intersection<Ray>::type
|
||||
operator()(Objects const& objs, Ray const& ray) const {
|
||||
return sprout::darkroom::objects::intersect(sprout::darkroom::access::get<0>(objs), ray);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
template<typename Objects, typename Ray>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type
|
||||
::template intersection<Ray>::type
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type::template intersection<Ray>::type
|
||||
intersect_list(Objects const& objs, Ray const& ray) {
|
||||
return sprout::darkroom::objects::detail::intersect_list_impl<
|
||||
sprout::darkroom::access::size<Objects>::value - 1
|
||||
|
|
|
@ -45,7 +45,8 @@ namespace sprout {
|
|||
position_type normal_;
|
||||
private:
|
||||
template<typename Vector>
|
||||
SPROUT_CONSTEXPR bool within_test(Vector const& d0, Vector const& d1) {
|
||||
SPROUT_CONSTEXPR bool
|
||||
within_test(Vector const& d0, Vector const& d1) {
|
||||
return sprout::darkroom::coords::dot(
|
||||
sprout::darkroom::coords::cross(d0, d1),
|
||||
normal_
|
||||
|
@ -54,13 +55,8 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_5(
|
||||
Ray const& ray,
|
||||
int hit_side,
|
||||
bool does_intersect,
|
||||
unit_type distance
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_5(Ray const& ray, int hit_side, bool does_intersect, unit_type distance) const {
|
||||
return typename intersection<Ray>::type(
|
||||
does_intersect,
|
||||
distance,
|
||||
|
@ -73,13 +69,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_4(
|
||||
Ray const& ray,
|
||||
position_type const& v,
|
||||
int hit_side,
|
||||
bool does_intersect
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_4(Ray const& ray, position_type const& v, int hit_side, bool does_intersect) const {
|
||||
return intersect_5(
|
||||
ray,
|
||||
hit_side,
|
||||
|
@ -90,14 +81,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_3(
|
||||
Ray const& ray,
|
||||
position_type const& v,
|
||||
position_type const& p,
|
||||
int hit_side,
|
||||
bool exist_forward
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_3(Ray const& ray, position_type const& v, position_type const& p, int hit_side, bool exist_forward) const {
|
||||
return intersect_4(
|
||||
ray,
|
||||
v,
|
||||
|
@ -118,12 +103,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_2(
|
||||
Ray const& ray,
|
||||
unit_type const& t,
|
||||
int hit_side
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_2(Ray const& ray, unit_type const& t, int hit_side) const {
|
||||
return intersect_3(
|
||||
ray,
|
||||
sprout::darkroom::coords::scale(sprout::darkroom::rays::direction(ray), t),
|
||||
|
@ -138,12 +119,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_1(
|
||||
Ray const& ray,
|
||||
unit_type const& xpn,
|
||||
unit_type const& vn
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_1(Ray const& ray, unit_type const& xpn, unit_type const& vn) const {
|
||||
return intersect_2(
|
||||
ray,
|
||||
xpn / vn,
|
||||
|
@ -151,12 +128,7 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_triangle(
|
||||
material_type const& mat,
|
||||
position_type const& v0,
|
||||
position_type const& v1,
|
||||
position_type const& v2
|
||||
)
|
||||
SPROUT_CONSTEXPR basic_triangle(material_type const& mat, position_type const& v0, position_type const& v1, position_type const& v2)
|
||||
: mat_(mat)
|
||||
, vertices_{{v0, v1, v2}}
|
||||
, normal_(
|
||||
|
@ -169,7 +141,8 @@ namespace sprout {
|
|||
)
|
||||
{}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect(Ray const& ray) const {
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect(Ray const& ray) const {
|
||||
return intersect_1(
|
||||
ray,
|
||||
sprout::darkroom::coords::dot(
|
||||
|
@ -188,13 +161,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Material, typename Vertex>
|
||||
inline SPROUT_CONSTEXPR sprout::darkroom::objects::basic_triangle<Material, Vertex>
|
||||
make_triangle(
|
||||
Material const& mat,
|
||||
Vertex const& v0,
|
||||
Vertex const& v1,
|
||||
Vertex const& v2
|
||||
)
|
||||
{
|
||||
make_triangle(Material const& mat, Vertex const& v0, Vertex const& v1, Vertex const& v2) {
|
||||
return sprout::darkroom::objects::basic_triangle<Material, Vertex>(mat, v0, v1, v2);
|
||||
}
|
||||
} // namespace objects
|
||||
|
|
|
@ -60,14 +60,8 @@ namespace sprout {
|
|||
material_type mat_;
|
||||
private:
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR zwo_type zweitens_2(
|
||||
Ray const& ray,
|
||||
unit_type const& i1,
|
||||
unit_type const& i2,
|
||||
int hit_side,
|
||||
bool does_intersect
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR zwo_type
|
||||
zweitens_2(Ray const& ray, unit_type const& i1, unit_type const& i2, int hit_side, bool does_intersect) const {
|
||||
return zwo_type(
|
||||
hit_side,
|
||||
does_intersect,
|
||||
|
@ -77,12 +71,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR zwo_type zweitens_1(
|
||||
Ray const& ray,
|
||||
unit_type const& i1,
|
||||
unit_type const& i2
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR zwo_type
|
||||
zweitens_1(Ray const& ray, unit_type const& i1, unit_type const& i2) const {
|
||||
return zweitens_2(
|
||||
ray,
|
||||
i1,
|
||||
|
@ -95,24 +85,16 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR zwo_type zweitens(
|
||||
Ray const& ray,
|
||||
bool neg,
|
||||
unit_type const& b,
|
||||
unit_type const& det
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR zwo_type
|
||||
zweitens(Ray const& ray, bool neg, unit_type const& b, unit_type const& det) const {
|
||||
return neg
|
||||
? zweitens_1(ray, b - det, b + det)
|
||||
: zwo_type(0, false, -1)
|
||||
;
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR drei_type drittens_1(
|
||||
Ray const& ray,
|
||||
typename sprout::darkroom::access::unit<Ray>::type point_of_intersection
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR drei_type
|
||||
drittens_1(Ray const& ray, typename sprout::darkroom::access::unit<Ray>::type point_of_intersection) const {
|
||||
return drei_type(
|
||||
point_of_intersection,
|
||||
sprout::darkroom::coords::normalize(
|
||||
|
@ -121,12 +103,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR drei_type drittens(
|
||||
Ray const& ray,
|
||||
bool neg,
|
||||
unit_type const& distance
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR drei_type
|
||||
drittens(Ray const& ray, bool neg, unit_type const& distance) const {
|
||||
return neg
|
||||
? drittens_1(ray, sprout::darkroom::rays::point_of_intersection(ray, distance))
|
||||
: drei_type(
|
||||
|
@ -136,13 +114,8 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename Ray, typename Vec>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_6(
|
||||
Ray const& ray,
|
||||
zwo_type const& zwo,
|
||||
drei_type const& drei,
|
||||
Vec const& normal
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_6(Ray const& ray, zwo_type const& zwo, drei_type const& drei, Vec const& normal) const {
|
||||
return typename intersection<Ray>::type(
|
||||
sprout::tuples::get<zw::does_intersect>(zwo),
|
||||
sprout::tuples::get<zw::distance>(zwo),
|
||||
|
@ -168,12 +141,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_5(
|
||||
Ray const& ray,
|
||||
zwo_type const& zwo,
|
||||
drei_type const& drei
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_5(Ray const& ray, zwo_type const& zwo, drei_type const& drei) const {
|
||||
return intersect_6(
|
||||
ray,
|
||||
zwo,
|
||||
|
@ -182,11 +151,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_4(
|
||||
Ray const& ray,
|
||||
zwo_type const& zwo
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_4(Ray const& ray, zwo_type const& zwo) const {
|
||||
return intersect_5(
|
||||
ray,
|
||||
zwo,
|
||||
|
@ -198,12 +164,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_3(
|
||||
Ray const& ray,
|
||||
unit_type const& b,
|
||||
unit_type const& det_sq
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_3(Ray const& ray, unit_type const& b, unit_type const& det_sq) const {
|
||||
return intersect_4(
|
||||
ray,
|
||||
zweitens(
|
||||
|
@ -215,12 +177,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_2(
|
||||
Ray const& ray,
|
||||
position_type const& v,
|
||||
unit_type const& b
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_2(Ray const& ray, position_type const& v, unit_type const& b) const {
|
||||
return intersect_3(
|
||||
ray,
|
||||
b,
|
||||
|
@ -228,11 +186,8 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect_1(
|
||||
Ray const& ray,
|
||||
position_type const& v
|
||||
) const
|
||||
{
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect_1(Ray const& ray, position_type const& v) const {
|
||||
return intersect_2(
|
||||
ray,
|
||||
v,
|
||||
|
@ -240,17 +195,14 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR basic_sphere(
|
||||
position_type const& pos,
|
||||
radius_type rad,
|
||||
material_type const& mat
|
||||
)
|
||||
SPROUT_CONSTEXPR basic_sphere(position_type const& pos, radius_type rad, material_type const& mat)
|
||||
: pos_(pos)
|
||||
, rad_(rad)
|
||||
, mat_(mat)
|
||||
{}
|
||||
template<typename Ray>
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type intersect(Ray const& ray) const {
|
||||
SPROUT_CONSTEXPR typename intersection<Ray>::type
|
||||
intersect(Ray const& ray) const {
|
||||
return intersect_1(
|
||||
ray,
|
||||
sprout::darkroom::coords::sub(sprout::darkroom::rays::position(ray), pos_)
|
||||
|
|
|
@ -18,20 +18,14 @@ namespace sprout {
|
|||
namespace detail {
|
||||
template<
|
||||
typename Pixels,
|
||||
typename RayTracer,
|
||||
typename Renderer,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename RayTracer, typename Renderer, typename Camera,
|
||||
typename Objects, typename Lights,
|
||||
sprout::index_t... XIndexes
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Pixels>::value_type
|
||||
generate_impl_line(
|
||||
RayTracer const& raytracer,
|
||||
Renderer const& renderer,
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
RayTracer const& raytracer, Renderer const& renderer, Camera const& camera,
|
||||
Objects const& objs, Lights const& lights,
|
||||
typename sprout::container_traits<
|
||||
typename sprout::container_traits<Pixels>::value_type
|
||||
>::size_type x
|
||||
|
@ -51,35 +45,22 @@ namespace sprout {
|
|||
return sprout::make<pixel_line_type>(
|
||||
sprout::darkroom::colors::rgb_f_to_rgb<pixel_type>(
|
||||
raytracer.template operator()(
|
||||
renderer,
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
x + XIndexes,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
depth_max
|
||||
renderer, camera, objs, lights,
|
||||
x + XIndexes, y, width, height, depth_max
|
||||
)
|
||||
)...
|
||||
);
|
||||
}
|
||||
template<
|
||||
typename Pixels,
|
||||
typename RayTracer,
|
||||
typename Renderer,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename RayTracer, typename Renderer, typename Camera,
|
||||
typename Objects, typename Lights,
|
||||
sprout::index_t... YIndexes
|
||||
>
|
||||
inline SPROUT_CONSTEXPR Pixels
|
||||
generate_impl(
|
||||
RayTracer const& raytracer,
|
||||
Renderer const& renderer,
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
RayTracer const& raytracer, Renderer const& renderer, Camera const& camera,
|
||||
Objects const& objs, Lights const& lights,
|
||||
typename sprout::container_traits<
|
||||
typename sprout::container_traits<Pixels>::value_type
|
||||
>::size_type x
|
||||
|
@ -96,16 +77,8 @@ namespace sprout {
|
|||
{
|
||||
return sprout::make<Pixels>(
|
||||
sprout::darkroom::pixels::detail::generate_impl_line<Pixels>(
|
||||
raytracer,
|
||||
renderer,
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
x,
|
||||
y + YIndexes,
|
||||
width,
|
||||
height,
|
||||
depth_max,
|
||||
raytracer, renderer, camera, objs, lights,
|
||||
x, y + YIndexes, width, height, depth_max,
|
||||
sprout::index_range<
|
||||
0,
|
||||
sprout::container_traits<
|
||||
|
@ -118,18 +91,12 @@ namespace sprout {
|
|||
} // namespace detail
|
||||
template<
|
||||
typename Pixels,
|
||||
typename RayTracer,
|
||||
typename Renderer,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights
|
||||
typename RayTracer, typename Renderer, typename Camera,
|
||||
typename Objects, typename Lights
|
||||
>
|
||||
inline SPROUT_CONSTEXPR Pixels generate(
|
||||
RayTracer const& raytracer,
|
||||
Renderer const& renderer,
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
RayTracer const& raytracer, Renderer const& renderer, Camera const& camera,
|
||||
Objects const& objs, Lights const& lights,
|
||||
typename sprout::container_traits<
|
||||
typename sprout::container_traits<Pixels>::value_type
|
||||
>::size_type x
|
||||
|
@ -152,16 +119,8 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
return sprout::darkroom::pixels::detail::generate_impl<Pixels>(
|
||||
raytracer,
|
||||
renderer,
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
depth_max,
|
||||
raytracer, renderer, camera, objs, lights,
|
||||
x, y, width, height, depth_max,
|
||||
sprout::index_range<
|
||||
0,
|
||||
sprout::container_traits<Pixels>::static_size
|
||||
|
@ -175,10 +134,7 @@ namespace sprout {
|
|||
template<std::size_t Width, std::size_t Height, typename Color = sprout::darkroom::colors::rgb>
|
||||
struct color_pixels {
|
||||
public:
|
||||
typedef sprout::array<
|
||||
sprout::array<Color, Width>,
|
||||
Height
|
||||
> type;
|
||||
typedef sprout::array<sprout::array<Color, Width>, Height> type;
|
||||
};
|
||||
} // namespace pixels
|
||||
} // namespace darkroom
|
||||
|
|
|
@ -15,16 +15,18 @@ namespace sprout {
|
|||
// direction
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto position(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
position(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto direction(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
direction(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace sprout {
|
|||
// normal_to_color
|
||||
//
|
||||
template<typename Color, typename Normal>
|
||||
inline SPROUT_CONSTEXPR Color normal_to_color(Normal const& nor) {
|
||||
inline SPROUT_CONSTEXPR Color
|
||||
normal_to_color(Normal const& nor) {
|
||||
return sprout::tuples::make<Color>(
|
||||
0.5 + sprout::darkroom::coords::x(nor) * 0.5,
|
||||
0.5 + sprout::darkroom::coords::y(nor) * 0.5,
|
||||
|
@ -27,7 +28,8 @@ namespace sprout {
|
|||
class direction_gradation {
|
||||
public:
|
||||
template<typename TargetColor, typename Vector>
|
||||
SPROUT_CONSTEXPR TargetColor operator()(Vector const& dir) const {
|
||||
SPROUT_CONSTEXPR TargetColor
|
||||
operator()(Vector const& dir) const {
|
||||
return sprout::darkroom::renderers::normal_to_color<TargetColor>(dir);
|
||||
}
|
||||
};
|
||||
|
@ -57,7 +59,8 @@ namespace sprout {
|
|||
: color_(color)
|
||||
{}
|
||||
template<typename TargetColor, typename Vector>
|
||||
SPROUT_CONSTEXPR TargetColor operator()(Vector const&) const {
|
||||
SPROUT_CONSTEXPR TargetColor
|
||||
operator()(Vector const&) const {
|
||||
return color_;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -25,29 +25,20 @@ namespace sprout {
|
|||
private:
|
||||
template<
|
||||
typename Color,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Ray,
|
||||
typename Intersection,
|
||||
typename Tracer,
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection, typename Tracer,
|
||||
typename Direction
|
||||
>
|
||||
SPROUT_CONSTEXPR Color color_1(
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Ray const& ray,
|
||||
Intersection const& inter,
|
||||
Tracer const& tracer,
|
||||
SPROUT_CONSTEXPR Color
|
||||
color_1(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, Intersection const& inter, Tracer const& tracer,
|
||||
std::size_t depth_max,
|
||||
Direction const& reflect_dir
|
||||
) const
|
||||
{
|
||||
return tracer.template operator()<Color>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
camera, objs, lights,
|
||||
sprout::tuples::remake<Ray>(
|
||||
ray,
|
||||
sprout::darkroom::coords::add(
|
||||
|
@ -70,20 +61,13 @@ namespace sprout {
|
|||
public:
|
||||
template<
|
||||
typename Color,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Ray,
|
||||
typename Intersection,
|
||||
typename Tracer
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection, typename Tracer
|
||||
>
|
||||
SPROUT_CONSTEXPR Color operator()(
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Ray const& ray,
|
||||
Intersection const& inter,
|
||||
Tracer const& tracer,
|
||||
SPROUT_CONSTEXPR Color
|
||||
operator()(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, Intersection const& inter, Tracer const& tracer,
|
||||
std::size_t depth_max
|
||||
) const
|
||||
{
|
||||
|
@ -95,12 +79,8 @@ namespace sprout {
|
|||
&& sprout::darkroom::materials::reflection(sprout::darkroom::intersects::material(inter))
|
||||
> std::numeric_limits<reflection_type>::epsilon()
|
||||
? color_1<Color>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
ray,
|
||||
inter,
|
||||
tracer,
|
||||
camera, objs, lights,
|
||||
ray, inter, tracer,
|
||||
depth_max,
|
||||
sprout::darkroom::coords::reflect(
|
||||
sprout::darkroom::rays::direction(ray),
|
||||
|
@ -121,16 +101,11 @@ namespace sprout {
|
|||
private:
|
||||
infinity_color_type infinity_color_;
|
||||
private:
|
||||
template<
|
||||
typename Color,
|
||||
typename Ray,
|
||||
typename Intersection
|
||||
>
|
||||
SPROUT_CONSTEXPR Color color_3(
|
||||
Ray const& ray,
|
||||
Intersection const& inter,
|
||||
Color const& diffuse_color,
|
||||
Color const& mirror_color
|
||||
template<typename Color, typename Ray, typename Intersection>
|
||||
SPROUT_CONSTEXPR Color
|
||||
color_3(
|
||||
Ray const& ray, Intersection const& inter,
|
||||
Color const& diffuse_color, Color const& mirror_color
|
||||
) const
|
||||
{
|
||||
return sprout::darkroom::intersects::does_intersect(inter)
|
||||
|
@ -149,61 +124,40 @@ namespace sprout {
|
|||
}
|
||||
template<
|
||||
typename Color,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Ray,
|
||||
typename Intersection
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection
|
||||
>
|
||||
SPROUT_CONSTEXPR Color color_2(
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Ray const& ray,
|
||||
std::size_t depth_max,
|
||||
Intersection const& inter,
|
||||
SPROUT_CONSTEXPR Color
|
||||
color_2(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, std::size_t depth_max, Intersection const& inter,
|
||||
Color const& diffuse_color
|
||||
) const
|
||||
{
|
||||
return color_3<Color>(
|
||||
ray,
|
||||
inter,
|
||||
ray, inter,
|
||||
diffuse_color,
|
||||
sprout::darkroom::renderers::whitted_mirror().template operator()<Color>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
ray,
|
||||
inter,
|
||||
*this,
|
||||
camera, objs, lights,
|
||||
ray, inter, *this,
|
||||
depth_max
|
||||
)
|
||||
);
|
||||
}
|
||||
template<
|
||||
typename Color,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Ray,
|
||||
typename Intersection
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection
|
||||
>
|
||||
SPROUT_CONSTEXPR Color color_1(
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Ray const& ray,
|
||||
std::size_t depth_max,
|
||||
Intersection const& inter
|
||||
SPROUT_CONSTEXPR Color
|
||||
color_1(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, std::size_t depth_max, Intersection const& inter
|
||||
) const
|
||||
{
|
||||
return color_2<Color>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
ray,
|
||||
depth_max,
|
||||
inter,
|
||||
camera, objs, lights,
|
||||
ray, depth_max, inter,
|
||||
lights.template operator()(inter, objs)
|
||||
);
|
||||
}
|
||||
|
@ -215,27 +169,16 @@ namespace sprout {
|
|||
explicit SPROUT_CONSTEXPR whitted_style(infinity_color_type const& infinity_color)
|
||||
: infinity_color_(infinity_color)
|
||||
{}
|
||||
template<
|
||||
typename Color,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Ray
|
||||
>
|
||||
SPROUT_CONSTEXPR Color operator()(
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Ray const& ray,
|
||||
std::size_t depth_max
|
||||
template<typename Color, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
SPROUT_CONSTEXPR Color
|
||||
operator()(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, std::size_t depth_max
|
||||
) const
|
||||
{
|
||||
return color_1<Color>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
ray,
|
||||
depth_max,
|
||||
camera, objs, lights,
|
||||
ray, depth_max,
|
||||
sprout::darkroom::objects::intersect_list(objs, ray)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -61,11 +61,7 @@ namespace sprout {
|
|||
pixels_type pixels_;
|
||||
public:
|
||||
template<typename... Elems>
|
||||
SPROUT_CONSTEXPR image_type(
|
||||
unsigned long image_format,
|
||||
unsigned long pixel_format,
|
||||
Elems const&... elems
|
||||
)
|
||||
SPROUT_CONSTEXPR image_type(unsigned long image_format, unsigned long pixel_format, Elems const&... elems)
|
||||
: pixels_{{
|
||||
color_type(
|
||||
static_cast<color_component_type>((elems >> 16) & 0xFF) / 0xFF,
|
||||
|
@ -76,16 +72,20 @@ namespace sprout {
|
|||
{
|
||||
static_assert(sizeof...(Elems) == static_width * static_height, "image_type<>: unmatch image size");
|
||||
}
|
||||
SPROUT_CONSTEXPR value_type const& operator()(size_type x, size_type y) const {
|
||||
SPROUT_CONSTEXPR value_type const&
|
||||
operator()(size_type x, size_type y) const {
|
||||
return pixels_[y * static_width + x];
|
||||
}
|
||||
SPROUT_CONSTEXPR size_type width() const {
|
||||
SPROUT_CONSTEXPR size_type
|
||||
width() const {
|
||||
return static_width;
|
||||
}
|
||||
SPROUT_CONSTEXPR size_type height() const {
|
||||
SPROUT_CONSTEXPR size_type
|
||||
height() const {
|
||||
return static_height;
|
||||
}
|
||||
SPROUT_CONSTEXPR pixels_type const& pixels() const {
|
||||
SPROUT_CONSTEXPR pixels_type const&
|
||||
pixels() const {
|
||||
return pixels_;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,29 +16,15 @@ namespace sprout {
|
|||
public:
|
||||
typedef Color color_type;
|
||||
public:
|
||||
template<
|
||||
typename Renderer,
|
||||
typename Camera,
|
||||
typename Objects,
|
||||
typename Lights,
|
||||
typename Unit2D
|
||||
>
|
||||
template<typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
SPROUT_CONSTEXPR color_type operator()(
|
||||
Renderer const& renderer,
|
||||
Camera const& camera,
|
||||
Objects const& objs,
|
||||
Lights const& lights,
|
||||
Unit2D const& x,
|
||||
Unit2D const& y,
|
||||
Unit2D const& width,
|
||||
Unit2D const& height,
|
||||
Renderer const& renderer, Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Unit2D const& x, Unit2D const& y, Unit2D const& width, Unit2D const& height,
|
||||
std::size_t depth_max = 8
|
||||
) const
|
||||
{
|
||||
return renderer.template operator()<color_type>(
|
||||
camera,
|
||||
objs,
|
||||
lights,
|
||||
camera, objs, lights,
|
||||
camera.template operator()(x, y, width, height),
|
||||
depth_max
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue