2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2011-11-26 06:20:35 +00:00
|
|
|
#ifndef SPROUT_DARKROOM_INTERSECTS_INTERSECTION_HPP
|
|
|
|
#define SPROUT_DARKROOM_INTERSECTS_INTERSECTION_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/tuple/tuple.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/darkroom/access/access.hpp>
|
|
|
|
#include <sprout/darkroom/coords/vector.hpp>
|
|
|
|
#include <sprout/darkroom/materials/material.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace darkroom {
|
|
|
|
namespace intersects {
|
|
|
|
//
|
|
|
|
// does_intersect
|
|
|
|
// distance
|
|
|
|
// point_of_intersection
|
|
|
|
// normal
|
|
|
|
// material
|
|
|
|
//
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
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)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
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)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
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)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<2>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
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)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<3>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
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)))
|
2011-11-26 06:20:35 +00:00
|
|
|
{
|
|
|
|
return sprout::darkroom::access::get<4>(sprout::forward<T>(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// make_intersection
|
|
|
|
//
|
|
|
|
template<typename Distance, typename Point, typename Normal, typename Material>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::tuples::tuple<bool, Distance, Point, Normal, Material>
|
2011-11-26 06:20:35 +00:00
|
|
|
make_intersection(bool b, Distance const& dist, Point const& p, Normal const& nor, Material const& mat) {
|
|
|
|
return sprout::tuples::make_tuple(b, dist, p, nor, mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// intersection
|
|
|
|
//
|
|
|
|
typedef sprout::tuples::tuple<
|
|
|
|
bool,
|
|
|
|
double,
|
2013-03-26 17:02:16 +00:00
|
|
|
sprout::darkroom::coords::vector3d_t,
|
|
|
|
sprout::darkroom::coords::vector3d_t,
|
2011-11-26 06:20:35 +00:00
|
|
|
sprout::darkroom::materials::material
|
|
|
|
> intersection;
|
|
|
|
} // namespace intersects
|
|
|
|
} // namespace darkroom
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_DARKROOM_INTERSECTS_INTERSECTION_HPP
|