mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +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
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue