mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
fix darkroom: fix template operator() member-function call -> calcurate() free-function
This commit is contained in:
parent
3cb882ce91
commit
dfcb6bcf31
25 changed files with 494 additions and 129 deletions
|
@ -11,8 +11,8 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_CAMERAS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/cameras/calculate.hpp>
|
||||
#include <sprout/darkroom/cameras/angle_of_view.hpp>
|
||||
#include <sprout/darkroom/cameras/simple_camera.hpp>
|
||||
|
||||
|
|
49
sprout/darkroom/cameras/calculate.hpp
Normal file
49
sprout/darkroom/cameras/calculate.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_DARKROOM_CAMERAS_CALCULATE_HPP
|
||||
#define SPROUT_DARKROOM_CAMERAS_CALCULATE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace cameras {
|
||||
//
|
||||
// calculate_result
|
||||
//
|
||||
template<typename Camera, typename Unit2D>
|
||||
struct calculate_result
|
||||
: public sprout::identity<typename Camera::ray_type>
|
||||
{};
|
||||
template<typename Camera, typename Unit2D>
|
||||
struct calculate_result<Camera const, Unit2D>
|
||||
: public sprout::darkroom::cameras::calculate_result<Camera, Unit2D>
|
||||
{};
|
||||
template<typename Camera, typename Unit2D>
|
||||
struct calculate_result<Camera volatile, Unit2D>
|
||||
: public sprout::darkroom::cameras::calculate_result<Camera, Unit2D>
|
||||
{};
|
||||
template<typename Camera, typename Unit2D>
|
||||
struct calculate_result<Camera const volatile, Unit2D>
|
||||
: public sprout::darkroom::cameras::calculate_result<Camera, Unit2D>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<typename Camera, typename Unit2D>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::cameras::calculate_result<Camera, Unit2D>::type
|
||||
calculate(Camera const& camera, Unit2D const& x, Unit2D const& y, Unit2D const& width, Unit2D const& height) {
|
||||
return camera(x, y, width, height);
|
||||
}
|
||||
} // namespace cameras
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_CAMERAS_CALCULATE_HPP
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_LIGHTS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/lights/calculate.hpp>
|
||||
#include <sprout/darkroom/lights/light_list.hpp>
|
||||
#include <sprout/darkroom/lights/parallel_light.hpp>
|
||||
#include <sprout/darkroom/lights/point_light.hpp>
|
||||
|
|
138
sprout/darkroom/lights/calculate.hpp
Normal file
138
sprout/darkroom/lights/calculate.hpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_DARKROOM_LIGHTS_CALCULATE_HPP
|
||||
#define SPROUT_DARKROOM_LIGHTS_CALCULATE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/indexes.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace lights {
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result;
|
||||
|
||||
namespace detail {
|
||||
template<typename Light, typename Intersection, typename Objects, bool IsTuple>
|
||||
struct calculate_result;
|
||||
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result<Light, Intersection, Objects, false>
|
||||
: public sprout::identity<typename Light::color_type>
|
||||
{};
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result<Light, Intersection, Objects, true>
|
||||
: public sprout::darkroom::lights::calculate_result<typename sprout::darkroom::access::unit<Light>::type, Intersection, Objects>
|
||||
{};
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// calculate_result
|
||||
//
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result
|
||||
: public sprout::darkroom::lights::detail::calculate_result<
|
||||
Light, Intersection, Objects,
|
||||
sprout::darkroom::access::is_tuple<Light>::value
|
||||
>
|
||||
{};
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result<Light const, Intersection, Objects>
|
||||
: public sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>
|
||||
{};
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result<Light volatile, Intersection, Objects>
|
||||
: public sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>
|
||||
{};
|
||||
template<typename Light, typename Intersection, typename Objects>
|
||||
struct calculate_result<Light const volatile, Intersection, Objects>
|
||||
: public sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<
|
||||
typename Light, typename Intersection, typename Objects,
|
||||
typename sprout::enabler_if<!sprout::darkroom::access::is_tuple<Light>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>::type
|
||||
calculate(Light const& light, Intersection const& inter, Objects const& objs);
|
||||
template<
|
||||
typename Light, typename Intersection, typename Objects,
|
||||
typename sprout::enabler_if<sprout::darkroom::access::is_tuple<Light>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>::type
|
||||
calculate(Light const& light, Intersection const& inter, Objects const& objs);
|
||||
|
||||
namespace detail {
|
||||
template<typename Lights, typename Intersection, typename Objects, typename Color>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Lights, Intersection, Objects>::type
|
||||
calculate_2(Color const& col) {
|
||||
return col;
|
||||
}
|
||||
template<typename Lights, typename Intersection, typename Objects, typename Color1, typename Color2, typename... Tail>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Lights, Intersection, Objects>::type
|
||||
calculate_2(Color1 const& col1, Color2 const& col2, Tail const&... tail) {
|
||||
return sprout::darkroom::lights::detail::calculate_2<Lights, Intersection, Objects>(
|
||||
sprout::darkroom::colors::add(col1, col2),
|
||||
tail...
|
||||
);
|
||||
}
|
||||
template<typename Lights, typename Intersection, typename Objects, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Lights, Intersection, Objects>::type
|
||||
calculate_1(
|
||||
Lights const& lights, Intersection const& inter, Objects const& objs,
|
||||
sprout::index_tuple<Indexes...>
|
||||
)
|
||||
{
|
||||
return sprout::darkroom::lights::detail::calculate_2<Lights, Intersection, Objects>(
|
||||
sprout::darkroom::lights::calculate(sprout::darkroom::access::get<Indexes>(lights), inter, objs)...
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// calculate_list
|
||||
//
|
||||
template<typename Lights, typename Intersection, typename Objects>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Lights, Intersection, Objects>::type
|
||||
calculate_list(Lights const& lights, Intersection const& inter, Objects const& objs) {
|
||||
return sprout::darkroom::lights::detail::calculate_1(
|
||||
lights, inter, objs,
|
||||
sprout::tuple_indexes<Lights>::make()
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<
|
||||
typename Light, typename Intersection, typename Objects,
|
||||
typename sprout::enabler_if<!sprout::darkroom::access::is_tuple<Light>::value>::type
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>::type
|
||||
calculate(Light const& light, Intersection const& inter, Objects const& objs) {
|
||||
return light(inter, objs);
|
||||
}
|
||||
template<
|
||||
typename Light, typename Intersection, typename Objects,
|
||||
typename sprout::enabler_if<sprout::darkroom::access::is_tuple<Light>::value>::type
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::lights::calculate_result<Light, Intersection, Objects>::type
|
||||
calculate(Light const& light, Intersection const& inter, Objects const& objs) {
|
||||
return sprout::darkroom::lights::calculate_list(light, inter, objs);
|
||||
}
|
||||
} // namespace lights
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_LIGHTS_CALCULATE_HPP
|
|
@ -9,66 +9,21 @@
|
|||
#define SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/limits.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/tuple/tuple/make_tuple.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace lights {
|
||||
//
|
||||
// light_list
|
||||
// make_object_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>
|
||||
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 {
|
||||
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(
|
||||
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>
|
||||
SPROUT_CONSTEXPR color_type
|
||||
operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(inter, objs, sprout::index_pack<Lights...>::make());
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// 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...);
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
make_light_list(Lights&&... lights)
|
||||
-> decltype(sprout::make_tuple(sprout::forward<Lights>(lights)...))
|
||||
{
|
||||
return sprout::make_tuple(sprout::forward<Lights>(lights)...);
|
||||
}
|
||||
} // namespace lights
|
||||
} // namespace darkroom
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_MATERIALS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/materials/calculate.hpp>
|
||||
#include <sprout/darkroom/materials/material.hpp>
|
||||
#include <sprout/darkroom/materials/interpolation.hpp>
|
||||
#include <sprout/darkroom/materials/uniform.hpp>
|
||||
|
|
49
sprout/darkroom/materials/calculate.hpp
Normal file
49
sprout/darkroom/materials/calculate.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_DARKROOM_MATERIALS_CALCULATE_HPP
|
||||
#define SPROUT_DARKROOM_MATERIALS_CALCULATE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace materials {
|
||||
//
|
||||
// calculate_result
|
||||
//
|
||||
template<typename Image, typename Unit>
|
||||
struct calculate_result
|
||||
: public sprout::identity<typename Image::result_type>
|
||||
{};
|
||||
template<typename Image, typename Unit>
|
||||
struct calculate_result<Image const, Unit>
|
||||
: public sprout::darkroom::materials::calculate_result<Image, Unit>
|
||||
{};
|
||||
template<typename Image, typename Unit>
|
||||
struct calculate_result<Image volatile, Unit>
|
||||
: public sprout::darkroom::materials::calculate_result<Image, Unit>
|
||||
{};
|
||||
template<typename Image, typename Unit>
|
||||
struct calculate_result<Image const volatile, Unit>
|
||||
: public sprout::darkroom::materials::calculate_result<Image, Unit>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<typename Image, typename Unit>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::materials::calculate_result<Image, Unit>::type
|
||||
calculate(Image const& image, Unit const& u, Unit const& v) {
|
||||
return image(u, v);
|
||||
}
|
||||
} // namespace materials
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_MATERIALS_CALCULATE_HPP
|
|
@ -13,6 +13,7 @@
|
|||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/materials/calculate.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
|
@ -39,40 +40,19 @@ namespace sprout {
|
|||
}
|
||||
|
||||
//
|
||||
// calc_color
|
||||
// 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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
return sprout::forward<Image>(t).template operator()(u, v);
|
||||
}
|
||||
|
||||
//
|
||||
// calc_material
|
||||
// calculate_material
|
||||
//
|
||||
template<typename Material, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_material(Material const& mat, Unit const& u, Unit const& v)
|
||||
calculate_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)
|
||||
sprout::darkroom::materials::calculate(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calculate(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
))
|
||||
{
|
||||
return 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)
|
||||
sprout::darkroom::materials::calculate(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calculate(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace sprout {
|
|||
private:
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_1(Unit const& u, Unit const& v) const {
|
||||
calculate_1(Unit const& u, Unit const& v) const {
|
||||
return (u >= 0 && v >= 0) || (u < 0 && v < 0) ? elem1_ : elem2_;
|
||||
}
|
||||
public:
|
||||
|
@ -43,7 +43,7 @@ namespace sprout {
|
|||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const& u, Unit const& v) const {
|
||||
return calc_1(
|
||||
return calculate_1(
|
||||
(u < 0
|
||||
? scale_ + sprout::fmod(u, scale_)
|
||||
: sprout::fmod(u, scale_)
|
||||
|
|
|
@ -92,12 +92,12 @@ namespace sprout {
|
|||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_nearest(Unit const& x, Unit const& y) const {
|
||||
calculate_nearest(Unit const& x, Unit const& y) const {
|
||||
return get_color(x, y);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear_1(
|
||||
calculate_bilinear_1(
|
||||
Unit const& x, Unit const& x0,
|
||||
Unit const& y, Unit const& y0
|
||||
) const
|
||||
|
@ -110,8 +110,8 @@ namespace sprout {
|
|||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear(Unit const& x, Unit const& y) const {
|
||||
return calc_bilinear_1(
|
||||
calculate_bilinear(Unit const& x, Unit const& y) const {
|
||||
return calculate_bilinear_1(
|
||||
x, sprout::floor(x),
|
||||
y, sprout::floor(y)
|
||||
);
|
||||
|
@ -119,8 +119,8 @@ namespace sprout {
|
|||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc(Unit const& x, Unit const& y) const {
|
||||
return is_nearest() ? calc_nearest(x, y)
|
||||
: calc_bilinear(x, y)
|
||||
return is_nearest() ? calculate_nearest(x, y)
|
||||
: calculate_bilinear(x, y)
|
||||
;
|
||||
}
|
||||
public:
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace sprout {
|
|||
unit_type,
|
||||
position_type,
|
||||
position_type,
|
||||
decltype(sprout::darkroom::materials::calc_material(
|
||||
decltype(sprout::darkroom::materials::calculate_material(
|
||||
std::declval<material_type const&>(),
|
||||
std::declval<unit_type const&>(),
|
||||
std::declval<unit_type const&>()
|
||||
|
@ -84,17 +84,17 @@ namespace sprout {
|
|||
: is_y() ? position_type(0, hit_side > 0 ? 1 : -1, 0)
|
||||
: position_type(0, 0, hit_side > 0 ? 1 : -1)
|
||||
,
|
||||
is_x() ? sprout::darkroom::materials::calc_material(
|
||||
is_x() ? sprout::darkroom::materials::calculate_material(
|
||||
mat_,
|
||||
sprout::darkroom::coords::z(point_of_intersection),
|
||||
sprout::darkroom::coords::y(point_of_intersection)
|
||||
)
|
||||
: is_y() ? sprout::darkroom::materials::calc_material(
|
||||
: is_y() ? sprout::darkroom::materials::calculate_material(
|
||||
mat_,
|
||||
sprout::darkroom::coords::x(point_of_intersection),
|
||||
sprout::darkroom::coords::z(point_of_intersection)
|
||||
)
|
||||
: sprout::darkroom::materials::calc_material(
|
||||
: sprout::darkroom::materials::calculate_material(
|
||||
mat_,
|
||||
sprout::darkroom::coords::x(point_of_intersection),
|
||||
sprout::darkroom::coords::y(point_of_intersection)
|
||||
|
|
|
@ -11,12 +11,53 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/intersects/intersection.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace objects {
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result;
|
||||
|
||||
namespace detail {
|
||||
template<typename Object, typename Ray, bool IsTuple>
|
||||
struct intersection_result;
|
||||
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result<Object, Ray, false>
|
||||
: public Object::template intersection<Ray>
|
||||
{};
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result<Object, Ray, true>
|
||||
: public sprout::darkroom::objects::intersection_result<typename sprout::darkroom::access::unit<Object>::type, Ray>
|
||||
{};
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// intersection_result
|
||||
//
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result
|
||||
: public sprout::darkroom::objects::detail::intersection_result<
|
||||
Object, Ray,
|
||||
sprout::darkroom::access::is_tuple<Object>::value
|
||||
>
|
||||
{};
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result<Object const, Ray>
|
||||
: public sprout::darkroom::objects::intersection_result<Object, Ray>
|
||||
{};
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result<Object volatile, Ray>
|
||||
: public sprout::darkroom::objects::intersection_result<Object, Ray>
|
||||
{};
|
||||
template<typename Object, typename Ray>
|
||||
struct intersection_result<Object const volatile, Ray>
|
||||
: public sprout::darkroom::objects::intersection_result<Object, Ray>
|
||||
{};
|
||||
|
||||
//
|
||||
// intersect
|
||||
//
|
||||
|
@ -24,13 +65,13 @@ namespace sprout {
|
|||
typename Object, typename Ray,
|
||||
typename sprout::enabler_if<!sprout::darkroom::access::is_tuple<Object>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename Object::template intersection<Ray>::type
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::objects::intersection_result<Object, Ray>::type
|
||||
intersect(Object const& obj, Ray const& ray);
|
||||
template<
|
||||
typename Object, typename Ray,
|
||||
typename sprout::enabler_if<sprout::darkroom::access::is_tuple<Object>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename Object::template intersection<Ray>::type
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::objects::intersection_result<Object, Ray>::type
|
||||
intersect(Object const& obj, Ray const& ray);
|
||||
|
||||
namespace detail {
|
||||
|
@ -38,7 +79,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::objects::intersection_result<Objects, Ray>::type
|
||||
comp(A const& a, B const& b) const {
|
||||
return sprout::darkroom::intersects::does_intersect(a)
|
||||
&& sprout::darkroom::intersects::does_intersect(b)
|
||||
|
@ -52,7 +93,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::objects::intersection_result<Objects, 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),
|
||||
|
@ -64,7 +105,7 @@ 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::objects::intersection_result<Objects, Ray>::type
|
||||
operator()(Objects const& objs, Ray const& ray) const {
|
||||
return sprout::darkroom::objects::intersect(sprout::darkroom::access::get<0>(objs), ray);
|
||||
}
|
||||
|
@ -74,7 +115,7 @@ namespace sprout {
|
|||
// intersect_list
|
||||
//
|
||||
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::objects::intersection_result<Objects, 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
|
||||
|
@ -86,17 +127,17 @@ namespace sprout {
|
|||
//
|
||||
template<
|
||||
typename Object, typename Ray,
|
||||
typename sprout::enabler_if<!sprout::darkroom::access::is_tuple<Object>::value>::type = sprout::enabler
|
||||
typename sprout::enabler_if<!sprout::darkroom::access::is_tuple<Object>::value>::type
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename Object::template intersection<Ray>::type
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::objects::intersection_result<Object, Ray>::type
|
||||
intersect(Object const& obj, Ray const& ray) {
|
||||
return obj.intersect(ray);
|
||||
}
|
||||
template<
|
||||
typename Object, typename Ray,
|
||||
typename sprout::enabler_if<sprout::darkroom::access::is_tuple<Object>::value>::type = sprout::enabler
|
||||
typename sprout::enabler_if<sprout::darkroom::access::is_tuple<Object>::value>::type
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Object>::type::template intersection<Ray>::type
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::objects::intersection_result<Object, Ray>::type
|
||||
intersect(Object const& obj, Ray const& ray) {
|
||||
return sprout::darkroom::objects::intersect_list(obj, ray);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple/make_tuple.hpp>
|
||||
#include <sprout/darkroom/intersects/intersection.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace sprout {
|
|||
unit_type,
|
||||
position_type,
|
||||
position_type,
|
||||
decltype(sprout::darkroom::materials::calc_material(
|
||||
decltype(sprout::darkroom::materials::calculate_material(
|
||||
std::declval<material_type const&>(),
|
||||
std::declval<unit_type const&>(),
|
||||
std::declval<unit_type const&>()
|
||||
|
@ -72,7 +72,7 @@ namespace sprout {
|
|||
: position_type(0, 0, 0)
|
||||
,
|
||||
normal_,//hit_side > 0 ? normal_ : sprout::darkroom::coords::negate(normal_),
|
||||
sprout::darkroom::materials::calc_material(mat_, unit_type(0), unit_type(0)) // ???
|
||||
sprout::darkroom::materials::calculate_material(mat_, unit_type(0), unit_type(0)) // ???
|
||||
);
|
||||
}
|
||||
template<typename Ray>
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace sprout {
|
|||
unit_type,
|
||||
position_type,
|
||||
position_type,
|
||||
decltype(sprout::darkroom::materials::calc_material(
|
||||
decltype(sprout::darkroom::materials::calculate_material(
|
||||
std::declval<material_type const&>(),
|
||||
std::declval<unit_type const&>(),
|
||||
std::declval<unit_type const&>()
|
||||
|
@ -128,7 +128,7 @@ namespace sprout {
|
|||
sprout::tuples::get<zw::distance>(zwo),
|
||||
sprout::tuples::get<dr::point_of_intersection>(drei),
|
||||
sprout::tuples::get<dr::normal>(drei),
|
||||
sprout::darkroom::materials::calc_material( // ! Spherical
|
||||
sprout::darkroom::materials::calculate_material( // ! Spherical
|
||||
mat_,
|
||||
sprout::atan2(
|
||||
sprout::darkroom::coords::z(normal),
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/tracers/calculate.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
|
@ -50,7 +51,8 @@ namespace sprout {
|
|||
typedef typename sprout::container_traits<pixel_line_type>::value_type pixel_type;
|
||||
return sprout::make<pixel_line_type>(
|
||||
sprout::darkroom::colors::rgb_f_to_rgb<pixel_type>(
|
||||
raytracer.template operator()(
|
||||
sprout::darkroom::tracers::calculate(
|
||||
raytracer,
|
||||
renderer, camera, objs, lights,
|
||||
x + XIndexes, y, width, height, depth_max
|
||||
)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_RENDERERS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/renderers/calculate.hpp>
|
||||
#include <sprout/darkroom/renderers/infinity.hpp>
|
||||
#include <sprout/darkroom/renderers/whitted_style.hpp>
|
||||
|
||||
|
|
55
sprout/darkroom/renderers/calculate.hpp
Normal file
55
sprout/darkroom/renderers/calculate.hpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_DARKROOM_RENDERERS_CALCULATE_HPP
|
||||
#define SPROUT_DARKROOM_RENDERERS_CALCULATE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace renderers {
|
||||
//
|
||||
// calculate_result
|
||||
//
|
||||
template<typename Color, typename Renderer, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
struct calculate_result
|
||||
: public sprout::identity<Color>
|
||||
{};
|
||||
template<typename Color, typename Renderer, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
struct calculate_result<Color, Renderer const, Camera, Objects, Lights, Ray>
|
||||
: public sprout::darkroom::renderers::calculate_result<Color, Renderer, Camera, Objects, Lights, Ray>
|
||||
{};
|
||||
template<typename Color, typename Renderer, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
struct calculate_result<Color, Renderer volatile, Camera, Objects, Lights, Ray>
|
||||
: public sprout::darkroom::renderers::calculate_result<Color, Renderer, Camera, Objects, Lights, Ray>
|
||||
{};
|
||||
template<typename Color, typename Renderer, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
struct calculate_result<Color, Renderer const volatile, Camera, Objects, Lights, Ray>
|
||||
: public sprout::darkroom::renderers::calculate_result<Color, Renderer, Camera, Objects, Lights, Ray>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<typename Color, typename Renderer, typename Camera, typename Objects, typename Lights, typename Ray>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::renderers::calculate_result<Color, Renderer, Camera, Objects, Lights, Ray>::type
|
||||
calculate(
|
||||
Renderer const& renderer,
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, std::size_t depth_max
|
||||
)
|
||||
{
|
||||
return renderer.template operator()<Color>(camera, objs, lights, ray, depth_max);
|
||||
}
|
||||
} // namespace renderers
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_RENDERERS_CALCULATE_HPP
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/coords/vector.hpp>
|
||||
|
||||
|
@ -83,6 +84,35 @@ namespace sprout {
|
|||
make_uniform_color(Color const& color) {
|
||||
return sprout::darkroom::renderers::uniform_color<Color>(color);
|
||||
}
|
||||
|
||||
//
|
||||
// infinity_result
|
||||
//
|
||||
template<typename Color, typename InfinityColor, typename Vector>
|
||||
struct infinity_result
|
||||
: public sprout::identity<Color>
|
||||
{};
|
||||
template<typename Color, typename InfinityColor, typename Vector>
|
||||
struct infinity_result<Color, InfinityColor const, Vector>
|
||||
: public sprout::darkroom::renderers::infinity_result<Color, InfinityColor, Vector>
|
||||
{};
|
||||
template<typename Color, typename InfinityColor, typename Vector>
|
||||
struct infinity_result<Color, InfinityColor volatile, Vector>
|
||||
: public sprout::darkroom::renderers::infinity_result<Color, InfinityColor, Vector>
|
||||
{};
|
||||
template<typename Color, typename InfinityColor, typename Vector>
|
||||
struct infinity_result<Color, InfinityColor const volatile, Vector>
|
||||
: public sprout::darkroom::renderers::infinity_result<Color, InfinityColor, Vector>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate_infinity
|
||||
//
|
||||
template<typename Color, typename InfinityColor, typename Vector>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::renderers::infinity_result<Color, InfinityColor, Vector>::type
|
||||
calculate_infinity(InfinityColor const& infinity_color, Vector const& dir) {
|
||||
return infinity_color.template operator()<Color>(dir);
|
||||
}
|
||||
} // namespace renderers
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <sprout/darkroom/materials/material.hpp>
|
||||
#include <sprout/darkroom/intersects/intersection.hpp>
|
||||
#include <sprout/darkroom/objects/intersect.hpp>
|
||||
#include <sprout/darkroom/lights/calculate.hpp>
|
||||
#include <sprout/darkroom/renderers/calculate.hpp>
|
||||
#include <sprout/darkroom/renderers/infinity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -33,18 +35,19 @@ namespace sprout {
|
|||
template<
|
||||
typename Color,
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection, typename Tracer,
|
||||
typename Ray, typename Intersection, typename Renderer,
|
||||
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,
|
||||
Ray const& ray, Intersection const& inter, Renderer const& renderer,
|
||||
std::size_t depth_max,
|
||||
Direction const& reflect_dir
|
||||
) const
|
||||
{
|
||||
return tracer.template operator()<Color>(
|
||||
return sprout::darkroom::renderers::calculate<Color>(
|
||||
renderer,
|
||||
camera, objs, lights,
|
||||
sprout::tuples::remake<Ray>(
|
||||
ray,
|
||||
|
@ -69,12 +72,12 @@ namespace sprout {
|
|||
template<
|
||||
typename Color,
|
||||
typename Camera, typename Objects, typename Lights,
|
||||
typename Ray, typename Intersection, typename Tracer
|
||||
typename Ray, typename Intersection, typename Renderer
|
||||
>
|
||||
SPROUT_CONSTEXPR Color
|
||||
operator()(
|
||||
Camera const& camera, Objects const& objs, Lights const& lights,
|
||||
Ray const& ray, Intersection const& inter, Tracer const& tracer,
|
||||
Ray const& ray, Intersection const& inter, Renderer const& renderer,
|
||||
std::size_t depth_max
|
||||
) const
|
||||
{
|
||||
|
@ -87,7 +90,7 @@ namespace sprout {
|
|||
> sprout::numeric_limits<reflection_type>::epsilon()
|
||||
? color_1<Color>(
|
||||
camera, objs, lights,
|
||||
ray, inter, tracer,
|
||||
ray, inter, renderer,
|
||||
depth_max,
|
||||
sprout::darkroom::coords::reflect(
|
||||
sprout::darkroom::rays::direction(ray),
|
||||
|
@ -126,7 +129,7 @@ namespace sprout {
|
|||
sprout::darkroom::materials::reflection(sprout::darkroom::intersects::material(inter))
|
||||
)
|
||||
)
|
||||
: infinity_color_.template operator()<Color>(sprout::darkroom::rays::direction(ray))
|
||||
: sprout::darkroom::renderers::calculate_infinity<Color>(infinity_color_, sprout::darkroom::rays::direction(ray))
|
||||
;
|
||||
}
|
||||
template<
|
||||
|
@ -165,7 +168,7 @@ namespace sprout {
|
|||
return color_2<Color>(
|
||||
camera, objs, lights,
|
||||
ray, depth_max, inter,
|
||||
lights.template operator()(inter, objs)
|
||||
sprout::darkroom::lights::calculate(lights, inter, objs)
|
||||
);
|
||||
}
|
||||
public:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_TRACERS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/tracers/calculate.hpp>
|
||||
#include <sprout/darkroom/tracers/raytracer.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_TRACERS_HPP
|
||||
|
|
56
sprout/darkroom/tracers/calculate.hpp
Normal file
56
sprout/darkroom/tracers/calculate.hpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2013 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_DARKROOM_TRACERS_CALCULATE_HPP
|
||||
#define SPROUT_DARKROOM_TRACERS_CALCULATE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
namespace tracers {
|
||||
//
|
||||
// calculate_result
|
||||
//
|
||||
template<typename Tracer, typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
struct calculate_result
|
||||
: public sprout::identity<typename Tracer::color_type>
|
||||
{};
|
||||
template<typename Tracer, typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
struct calculate_result<Tracer const, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
: public sprout::darkroom::tracers::calculate_result<Tracer, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
{};
|
||||
template<typename Tracer, typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
struct calculate_result<Tracer volatile, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
: public sprout::darkroom::tracers::calculate_result<Tracer, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
{};
|
||||
template<typename Tracer, typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
struct calculate_result<Tracer const volatile, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
: public sprout::darkroom::tracers::calculate_result<Tracer, Renderer, Camera, Objects, Lights, Unit2D>
|
||||
{};
|
||||
|
||||
//
|
||||
// calculate
|
||||
//
|
||||
template<typename Tracer, typename Renderer, typename Camera, typename Objects, typename Lights, typename Unit2D>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::tracers::calculate_result<Tracer, Renderer, Camera, Objects, Lights, Unit2D>::type
|
||||
calculate(
|
||||
Tracer const& tracer,
|
||||
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
|
||||
)
|
||||
{
|
||||
return tracer(renderer, camera, objs, lights, x, y, width, height, depth_max);
|
||||
}
|
||||
} // namespace tracers
|
||||
} // namespace darkroom
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_TRACERS_CALCULATE_HPP
|
|
@ -11,6 +11,8 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
#include <sprout/darkroom/cameras/calculate.hpp>
|
||||
#include <sprout/darkroom/renderers/calculate.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace darkroom {
|
||||
|
@ -30,9 +32,10 @@ namespace sprout {
|
|||
std::size_t depth_max = 8
|
||||
) const
|
||||
{
|
||||
return renderer.template operator()<color_type>(
|
||||
return sprout::darkroom::renderers::calculate<color_type>(
|
||||
renderer,
|
||||
camera, objs, lights,
|
||||
camera.template operator()(x, y, width, height),
|
||||
sprout::darkroom::cameras::calculate(camera, x, y, width, height),
|
||||
depth_max
|
||||
);
|
||||
}
|
||||
|
|
|
@ -138,22 +138,21 @@ for ((y=0; y<height; y+=tile_height)); do
|
|||
echo -n " x = "
|
||||
for ((x=0; x<width; x+=tile_width)); do
|
||||
echo -n "(${x}/${height})..."
|
||||
binname=${stagedir}/${y}/${x}.out
|
||||
${compiler} -o ${binname} -std=c++11 \
|
||||
binname=${y}/${x}.out
|
||||
bin=${stagedir}/${binname}
|
||||
${compiler} -o ${bin} -std=c++11 \
|
||||
${define_options} ${include_options} \
|
||||
-DDARKROOM_SOURCE="\"${src}\"" \
|
||||
-DDARKROOM_TOTAL_WIDTH=${width} \
|
||||
-DDARKROOM_TOTAL_HEIGHT=${height} \
|
||||
-DDARKROOM_TILE_WIDTH=${tile_width} \
|
||||
-DDARKROOM_TILE_HEIGHT=${tile_height} \
|
||||
-DDARKROOM_OFFSET_X=${x} \
|
||||
-DDARKROOM_OFFSET_Y=${y} \
|
||||
-DDARKROOM_TOTAL_WIDTH=${width} -DDARKROOM_TOTAL_HEIGHT=${height} \
|
||||
-DDARKROOM_TILE_WIDTH=${tile_width} -DDARKROOM_TILE_HEIGHT=${tile_height} \
|
||||
-DDARKROOM_OFFSET_X=${x} -DDARKROOM_OFFSET_Y=${y} \
|
||||
$(cd $(dirname $0); pwd)/darkcult.cpp
|
||||
if [ $? -ne 0 ]; then
|
||||
echo >&2 "error: compile failed."
|
||||
echo ""
|
||||
echo >&2 "error: compile(${binname}) failed."
|
||||
exit 1
|
||||
fi
|
||||
${binname} > ${stagedir}/${y}/${x}.ppm
|
||||
${bin} > ${stagedir}/${y}/${x}.ppm
|
||||
done
|
||||
echo ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue