1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix darkroom: fix template operator() member-function call -> calcurate() free-function

This commit is contained in:
bolero-MURAKAMI 2013-09-24 15:08:36 +09:00
parent 3cb882ce91
commit dfcb6bcf31
25 changed files with 494 additions and 129 deletions

View file

@ -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)

View file

@ -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);
}

View file

@ -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 {

View file

@ -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>

View file

@ -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),