From ceb5d218df264b3231d077033879c1e39c5264b7 Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Thu, 26 Sep 2013 00:52:55 +0900 Subject: [PATCH] [darkroom.objects.sphere] Reduce unnecessary parameter. --- sprout/darkroom/objects/sphere.hpp | 33 ++++++++++++------------------ 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/sprout/darkroom/objects/sphere.hpp b/sprout/darkroom/objects/sphere.hpp index 1d944dcc..b693bfd5 100644 --- a/sprout/darkroom/objects/sphere.hpp +++ b/sprout/darkroom/objects/sphere.hpp @@ -66,9 +66,8 @@ namespace sprout { radius_type rad_; material_type mat_; private: - template - SPROUT_CONSTEXPR zwo_type - zweitens_2(Ray const&, unit_type const& i1, unit_type const& i2, int hit_side, bool does_intersect) const { + SPROUT_STATIC_CONSTEXPR zwo_type + zweitens_2(unit_type const& i1, unit_type const& i2, int hit_side, bool does_intersect) { return zwo_type( hit_side, does_intersect, @@ -77,11 +76,9 @@ namespace sprout { : -1 ); } - template - SPROUT_CONSTEXPR zwo_type - zweitens_1(Ray const& ray, unit_type const& i1, unit_type const& i2) const { + SPROUT_STATIC_CONSTEXPR zwo_type + zweitens_1(unit_type const& i1, unit_type const& i2) { return zweitens_2( - ray, i1, i2, i2 > 0 @@ -91,17 +88,16 @@ namespace sprout { i2 > 0 ); } - template - SPROUT_CONSTEXPR zwo_type - zweitens(Ray const& ray, bool neg, unit_type const& b, unit_type const& det) const { + SPROUT_STATIC_CONSTEXPR zwo_type + zweitens(bool neg, unit_type const& b, unit_type const& det) { return neg - ? zweitens_1(ray, b - det, b + det) + ? zweitens_1(b - det, b + det) : zwo_type(0, false, -1) ; } template SPROUT_CONSTEXPR drei_type - drittens_1(Ray const&, typename sprout::darkroom::access::unit::type point_of_intersection) const { + drittens_1(typename sprout::darkroom::access::unit::type point_of_intersection) const { return drei_type( point_of_intersection, sprout::darkroom::coords::normalize( @@ -113,7 +109,7 @@ namespace sprout { SPROUT_CONSTEXPR drei_type drittens(Ray const& ray, bool neg, unit_type const& distance) const { return neg - ? drittens_1(ray, sprout::darkroom::rays::point_of_intersection(ray, distance)) + ? drittens_1(sprout::darkroom::rays::point_of_intersection(ray, distance)) : drei_type( sprout::tuples::make(0, 0, 0), sprout::tuples::make(1, 1, 1) @@ -122,7 +118,7 @@ namespace sprout { } template SPROUT_CONSTEXPR typename intersection::type - intersect_6(Ray const&, zwo_type const& zwo, drei_type const& drei, Vec const& normal) const { + intersect_6(zwo_type const& zwo, drei_type const& drei, Vec const& normal) const { return typename intersection::type( sprout::tuples::get(zwo), sprout::tuples::get(zwo), @@ -149,9 +145,8 @@ namespace sprout { } template SPROUT_CONSTEXPR typename intersection::type - intersect_5(Ray const& ray, zwo_type const& zwo, drei_type const& drei) const { - return intersect_6( - ray, + intersect_5(zwo_type const& zwo, drei_type const& drei) const { + return intersect_6( zwo, drei, sprout::tuples::get(drei) @@ -160,8 +155,7 @@ namespace sprout { template SPROUT_CONSTEXPR typename intersection::type intersect_4(Ray const& ray, zwo_type const& zwo) const { - return intersect_5( - ray, + return intersect_5( zwo, drittens( ray, @@ -176,7 +170,6 @@ namespace sprout { return intersect_4( ray, zweitens( - ray, det_sq > 0, b, det_sq > 0 ? sprout::sqrt(det_sq) : unit_type(0)