geom/ray: add validator specialisation

This commit is contained in:
Danny Robson 2018-04-16 15:56:37 +10:00
parent 401c59bc0e
commit 4dcd10243c

View File

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
* Copyright 2015-2018 Danny Robson <danny@nerdcruft.net>
*/
#include "ray.hpp"
@ -63,10 +63,26 @@ util::geom::operator<< (std::ostream &os, ray<S,T> r)
return os << "ray(" << r.origin << ',' << r.direction << ')';
}
template std::ostream& util::geom::operator<< (std::ostream&, ray<3,float>);
template std::ostream& util::geom::operator<< (std::ostream&, ray<3,double>);
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
struct util::debug::validator<ray<S,T>> {
static bool
is_valid (ray<S,T> const& val)
{
return util::debug::is_valid (val.origin) &&
util::debug::is_valid (val.direction) &&
is_normalised (val.direction);
}
};
///////////////////////////////////////////////////////////////////////////////
template struct util::geom::ray<2,float>;
template struct util::geom::ray<3,float>;
#define INSTANTIATE_S_T(S,T) \
template std::ostream& util::geom::operator<< (std::ostream&, ray<S,T>); \
template struct util::debug::validator<ray<S,T>>; \
template struct util::geom::ray<S,T>;
INSTANTIATE_S_T(2,float)
INSTANTIATE_S_T(3,float)