1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-02-04 21:33:56 +00:00

fix darkroom: add make_object_list

This commit is contained in:
bolero-MURAKAMI 2013-09-24 10:05:47 +09:00
parent abfa6082b4
commit 3cb882ce91
13 changed files with 128 additions and 14 deletions

View file

@ -16,7 +16,7 @@ namespace darkcult {
// //
// object // object
// //
SPROUT_STATIC_CONSTEXPR auto object = sprout::make_tuple( SPROUT_STATIC_CONSTEXPR auto object = objects::make_object_list(
objects::make_aa_plane( objects::make_aa_plane(
objects::aa_plane_direction::y, objects::aa_plane_direction::y,
-2.0, -2.0,

View file

@ -9,6 +9,7 @@
#define SPROUT_DARKROOM_ACCESS_HPP #define SPROUT_DARKROOM_ACCESS_HPP
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/darkroom/access/traits.hpp>
#include <sprout/darkroom/access/access.hpp> #include <sprout/darkroom/access/access.hpp>
#endif // #ifndef SPROUT_DARKROOM_ACCESS_HPP #endif // #ifndef SPROUT_DARKROOM_ACCESS_HPP

View file

@ -11,6 +11,7 @@
#include <cstddef> #include <cstddef>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp> #include <sprout/tuple/tuple.hpp>
#include <sprout/darkroom/access/traits.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {

View file

@ -0,0 +1,45 @@
/*=============================================================================
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_ACCESS_TRAITS_HPP
#define SPROUT_DARKROOM_ACCESS_TRAITS_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
namespace sprout {
namespace darkroom {
namespace access {
//
// is_tuple
//
template<typename T>
struct is_tuple
: public std::false_type
{};
template<typename T>
struct is_tuple<T const>
: public sprout::darkroom::access::is_tuple<T>
{};
template<typename T>
struct is_tuple<T volatile>
: public sprout::darkroom::access::is_tuple<T>
{};
template<typename T>
struct is_tuple<T const volatile>
: public sprout::darkroom::access::is_tuple<T>
{};
template<typename... Types>
struct is_tuple<sprout::tuples::tuple<Types...> >
: public std::true_type
{};
} // namespace access
} // namespace darkroom
} // namespace sprout
#endif // #ifndef SPROUT_DARKROOM_ACCESS_TRAITS_HPP

View file

@ -61,6 +61,7 @@ namespace sprout {
return shade_1(inter, objs, sprout::index_pack<Lights...>::make()); return shade_1(inter, objs, sprout::index_pack<Lights...>::make());
} }
}; };
// //
// make_light_list // make_light_list
// //

View file

@ -77,7 +77,7 @@ namespace sprout {
operator()(Intersection const& inter, Objects const& objs) const { operator()(Intersection const& inter, Objects const& objs) const {
return shade_1( return shade_1(
inter, inter,
sprout::darkroom::objects::intersect_list( sprout::darkroom::objects::intersect(
objs, objs,
sprout::darkroom::rays::make_ray( sprout::darkroom::rays::make_ray(
sprout::darkroom::coords::add( sprout::darkroom::coords::add(

View file

@ -81,7 +81,7 @@ namespace sprout {
inter, inter,
diff, diff,
direction, direction,
sprout::darkroom::objects::intersect_list( sprout::darkroom::objects::intersect(
objs, objs,
sprout::darkroom::rays::make_ray( sprout::darkroom::rays::make_ray(
sprout::darkroom::coords::add( sprout::darkroom::coords::add(

View file

@ -10,6 +10,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/darkroom/objects/intersect.hpp> #include <sprout/darkroom/objects/intersect.hpp>
#include <sprout/darkroom/objects/object_list.hpp>
#include <sprout/darkroom/objects/sphere.hpp> #include <sprout/darkroom/objects/sphere.hpp>
#include <sprout/darkroom/objects/aa_plane.hpp> #include <sprout/darkroom/objects/aa_plane.hpp>
#include <sprout/darkroom/objects/polygon.hpp> #include <sprout/darkroom/objects/polygon.hpp>

View file

@ -10,6 +10,7 @@
#include <cstddef> #include <cstddef>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/darkroom/access/access.hpp> #include <sprout/darkroom/access/access.hpp>
#include <sprout/darkroom/intersects/intersection.hpp> #include <sprout/darkroom/intersects/intersection.hpp>
@ -19,15 +20,19 @@ namespace sprout {
// //
// intersect // intersect
// //
template<typename Object, typename 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 Object::template intersection<Ray>::type
intersect(Object const& obj, Ray const& ray) { 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
>
inline SPROUT_CONSTEXPR typename Object::template intersection<Ray>::type
intersect(Object const& obj, Ray const& ray);
//
// intersect_list
//
namespace detail { namespace detail {
template<std::size_t N> template<std::size_t N>
struct intersect_list_impl { struct intersect_list_impl {
@ -65,6 +70,9 @@ namespace sprout {
} }
}; };
} // namespace detail } // namespace detail
//
// intersect_list
//
template<typename Objects, typename Ray> 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) { intersect_list(Objects const& objs, Ray const& ray) {
@ -72,6 +80,26 @@ namespace sprout {
sprout::darkroom::access::size<Objects>::value - 1 sprout::darkroom::access::size<Objects>::value - 1
>()(objs, ray); >()(objs, ray);
} }
//
// intersect
//
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
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
>
inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Object>::type::template intersection<Ray>::type
intersect(Object const& obj, Ray const& ray) {
return sprout::darkroom::objects::intersect_list(obj, ray);
}
} // namespace objects } // namespace objects
} // namespace darkroom } // namespace darkroom
} // namespace sprout } // namespace sprout

View file

@ -0,0 +1,32 @@
/*=============================================================================
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_OBJECTS_OBJECT_LIST_HPP
#define SPROUT_DARKROOM_OBJECTS_OBJECT_LIST_HPP
#include <sprout/config.hpp>
#include <sprout/tuple/tuple/make_tuple.hpp>
#include <sprout/darkroom/intersects/intersection.hpp>
namespace sprout {
namespace darkroom {
namespace objects {
//
// make_object_list
//
template<typename... Objects>
inline SPROUT_CONSTEXPR auto
make_object_list(Objects&&... objs)
-> decltype(sprout::make_tuple(sprout::forward<Objects>(objs)...))
{
return sprout::make_tuple(sprout::forward<Objects>(objs)...);
}
} // namespace objects
} // namespace darkroom
} // namespace sprout
#endif // #ifndef SPROUT_DARKROOM_OBJECTS_OBJECT_LIST_HPP

View file

@ -186,7 +186,7 @@ namespace sprout {
return color_1<Color>( return color_1<Color>(
camera, objs, lights, camera, objs, lights,
ray, depth_max, ray, depth_max,
sprout::darkroom::objects::intersect_list(objs, ray) sprout::darkroom::objects::intersect(objs, ray)
); );
} }
}; };

View file

@ -41,7 +41,7 @@ execute() {
args=`getopt -o S:D:I:f -l stagedir:,gcc-version:,clang-version:,define:,include:,force,help -- "$@"` args=`getopt -o S:D:I:f -l stagedir:,gcc-version:,clang-version:,define:,include:,force,help -- "$@"`
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo >&2 "error: options parse error. see 'test.sh --help'" echo >&2 "error: options parse error. See 'test.sh --help'"
exit 1 exit 1
fi fi
eval set -- ${args} eval set -- ${args}

View file

@ -26,7 +26,7 @@ use_help=0
args=`getopt -o s:S:o:C:w:h:W:H:D:I:f -l source:,stagedir:,output:,compiler:,width:,height:,tile-width:,tile-height:,define:,include:,force,help -- "$@"` args=`getopt -o s:S:o:C:w:h:W:H:D:I:f -l source:,stagedir:,output:,compiler:,width:,height:,tile-width:,tile-height:,define:,include:,force,help -- "$@"`
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo >&2 "error: options parse error. see 'darkcult.sh --help'" echo >&2 "error: options parse error. See 'darkcult.sh --help'"
exit 1 exit 1
fi fi
eval set -- ${args} eval set -- ${args}
@ -148,7 +148,12 @@ for ((y=0; y<height; y+=tile_height)); do
-DDARKROOM_TILE_HEIGHT=${tile_height} \ -DDARKROOM_TILE_HEIGHT=${tile_height} \
-DDARKROOM_OFFSET_X=${x} \ -DDARKROOM_OFFSET_X=${x} \
-DDARKROOM_OFFSET_Y=${y} \ -DDARKROOM_OFFSET_Y=${y} \
$(cd $(dirname $0); pwd)/darkcult.cpp && ${binname} > ${stagedir}/${y}/${x}.ppm $(cd $(dirname $0); pwd)/darkcult.cpp
if [ $? -ne 0 ]; then
echo >&2 "error: compile failed."
exit 1
fi
${binname} > ${stagedir}/${y}/${x}.ppm
done done
echo "" echo ""