mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix darkroom: add make_object_list
This commit is contained in:
parent
abfa6082b4
commit
3cb882ce91
13 changed files with 128 additions and 14 deletions
|
@ -16,7 +16,7 @@ namespace darkcult {
|
|||
//
|
||||
// object
|
||||
//
|
||||
SPROUT_STATIC_CONSTEXPR auto object = sprout::make_tuple(
|
||||
SPROUT_STATIC_CONSTEXPR auto object = objects::make_object_list(
|
||||
objects::make_aa_plane(
|
||||
objects::aa_plane_direction::y,
|
||||
-2.0,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_DARKROOM_ACCESS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_DARKROOM_ACCESS_HPP
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/darkroom/access/traits.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
|
45
sprout/darkroom/access/traits.hpp
Normal file
45
sprout/darkroom/access/traits.hpp
Normal 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
|
|
@ -61,6 +61,7 @@ namespace sprout {
|
|||
return shade_1(inter, objs, sprout::index_pack<Lights...>::make());
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// make_light_list
|
||||
//
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace sprout {
|
|||
operator()(Intersection const& inter, Objects const& objs) const {
|
||||
return shade_1(
|
||||
inter,
|
||||
sprout::darkroom::objects::intersect_list(
|
||||
sprout::darkroom::objects::intersect(
|
||||
objs,
|
||||
sprout::darkroom::rays::make_ray(
|
||||
sprout::darkroom::coords::add(
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace sprout {
|
|||
inter,
|
||||
diff,
|
||||
direction,
|
||||
sprout::darkroom::objects::intersect_list(
|
||||
sprout::darkroom::objects::intersect(
|
||||
objs,
|
||||
sprout::darkroom::rays::make_ray(
|
||||
sprout::darkroom::coords::add(
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/darkroom/objects/intersect.hpp>
|
||||
#include <sprout/darkroom/objects/object_list.hpp>
|
||||
#include <sprout/darkroom/objects/sphere.hpp>
|
||||
#include <sprout/darkroom/objects/aa_plane.hpp>
|
||||
#include <sprout/darkroom/objects/polygon.hpp>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/intersects/intersection.hpp>
|
||||
|
||||
|
@ -19,15 +20,19 @@ namespace sprout {
|
|||
//
|
||||
// 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
|
||||
intersect(Object const& obj, Ray const& ray) {
|
||||
return obj.intersect(ray);
|
||||
}
|
||||
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
|
||||
intersect(Object const& obj, Ray const& ray);
|
||||
|
||||
//
|
||||
// intersect_list
|
||||
//
|
||||
namespace detail {
|
||||
template<std::size_t N>
|
||||
struct intersect_list_impl {
|
||||
|
@ -65,6 +70,9 @@ namespace sprout {
|
|||
}
|
||||
};
|
||||
} // namespace detail
|
||||
//
|
||||
// intersect_list
|
||||
//
|
||||
template<typename Objects, typename Ray>
|
||||
inline SPROUT_CONSTEXPR typename sprout::darkroom::access::unit<Objects>::type::template intersection<Ray>::type
|
||||
intersect_list(Objects const& objs, Ray const& ray) {
|
||||
|
@ -72,6 +80,26 @@ namespace sprout {
|
|||
sprout::darkroom::access::size<Objects>::value - 1
|
||||
>()(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 darkroom
|
||||
} // namespace sprout
|
||||
|
|
32
sprout/darkroom/objects/object_list.hpp
Normal file
32
sprout/darkroom/objects/object_list.hpp
Normal 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
|
|
@ -186,7 +186,7 @@ namespace sprout {
|
|||
return color_1<Color>(
|
||||
camera, objs, lights,
|
||||
ray, depth_max,
|
||||
sprout::darkroom::objects::intersect_list(objs, ray)
|
||||
sprout::darkroom::objects::intersect(objs, ray)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ execute() {
|
|||
|
||||
args=`getopt -o S:D:I:f -l stagedir:,gcc-version:,clang-version:,define:,include:,force,help -- "$@"`
|
||||
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
|
||||
fi
|
||||
eval set -- ${args}
|
||||
|
|
|
@ -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 -- "$@"`
|
||||
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
|
||||
fi
|
||||
eval set -- ${args}
|
||||
|
@ -148,7 +148,12 @@ for ((y=0; y<height; y+=tile_height)); do
|
|||
-DDARKROOM_TILE_HEIGHT=${tile_height} \
|
||||
-DDARKROOM_OFFSET_X=${x} \
|
||||
-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
|
||||
echo ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue