coord/ops: use distinct trait to enable scalar ops
This commit is contained in:
parent
650f5c05e6
commit
517d7ce4a2
@ -50,6 +50,20 @@ namespace util {
|
|||||||
template <size_t,typename> class B
|
template <size_t,typename> class B
|
||||||
>
|
>
|
||||||
using result_t = typename result<A,B>::type;
|
using result_t = typename result<A,B>::type;
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
template <template <size_t,typename> class K>
|
||||||
|
struct has_scalar_op : public std::false_type { };
|
||||||
|
|
||||||
|
template <> struct has_scalar_op<colour> : public std::true_type { };
|
||||||
|
template <> struct has_scalar_op<extent> : public std::true_type { };
|
||||||
|
template <> struct has_scalar_op<point> : public std::true_type { };
|
||||||
|
template <> struct has_scalar_op<quaternion> : public std::true_type { };
|
||||||
|
template <> struct has_scalar_op<vector> : public std::true_type { };
|
||||||
|
|
||||||
|
template <template <size_t,typename> class K>
|
||||||
|
constexpr auto has_scalar_op_v = has_scalar_op<K>::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template <size_t,typename> class> struct is_coord : std::false_type { };
|
template <template <size_t,typename> class> struct is_coord : std::false_type { };
|
||||||
@ -129,7 +143,7 @@ namespace util {
|
|||||||
typename U, \
|
typename U, \
|
||||||
template <size_t,typename> class K, \
|
template <size_t,typename> class K, \
|
||||||
typename = std::enable_if_t< \
|
typename = std::enable_if_t< \
|
||||||
is_coord_v<K>,void \
|
coord::has_scalar_op_v<K>, void \
|
||||||
> \
|
> \
|
||||||
> \
|
> \
|
||||||
constexpr \
|
constexpr \
|
||||||
@ -149,7 +163,7 @@ namespace util {
|
|||||||
typename U, \
|
typename U, \
|
||||||
template <size_t,typename> class K, \
|
template <size_t,typename> class K, \
|
||||||
typename = std::enable_if_t< \
|
typename = std::enable_if_t< \
|
||||||
is_coord<K>::value,void \
|
coord::has_scalar_op_v<K>,void \
|
||||||
> \
|
> \
|
||||||
> \
|
> \
|
||||||
constexpr \
|
constexpr \
|
||||||
|
@ -137,34 +137,6 @@ util::operator/ (const quaternion<S,T> a, const quaternion<S,T> b)
|
|||||||
template quaternion<4,float> util::operator/ (quaternion<4,float>, quaternion<4,float>);
|
template quaternion<4,float> util::operator/ (quaternion<4,float>, quaternion<4,float>);
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
template <size_t S, typename T>
|
|
||||||
quaternion<S,T>
|
|
||||||
util::operator* (const quaternion<S,T> q, const T t)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
q.w * t,
|
|
||||||
q.x * t,
|
|
||||||
q.y * t,
|
|
||||||
q.z * t
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <size_t S, typename T>
|
|
||||||
quaternion<S,T>
|
|
||||||
util::operator/ (const quaternion<S,T> q, const T t)
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
q.w / t,
|
|
||||||
q.x / t,
|
|
||||||
q.y / t,
|
|
||||||
q.z / t
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
util::matrix4<T>
|
util::matrix4<T>
|
||||||
|
@ -55,11 +55,13 @@ namespace util {
|
|||||||
static const quaternion IDENTITY;
|
static const quaternion IDENTITY;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <size_t S, typename T> quaternion<S,T> operator* (const quaternion<S,T>, const quaternion<S,T>);
|
template <size_t S, typename T>
|
||||||
template <size_t S, typename T> quaternion<S,T> operator/ (const quaternion<S,T>, const quaternion<S,T>);
|
quaternion<S,T>
|
||||||
|
operator* (const quaternion<S,T>, const quaternion<S,T>);
|
||||||
|
|
||||||
template <size_t S, typename T> quaternion<S,T> operator* (const quaternion<S,T>, const T);
|
template <size_t S, typename T>
|
||||||
template <size_t S, typename T> quaternion<S,T> operator/ (const quaternion<S,T>, const T);
|
quaternion<S,T>
|
||||||
|
operator/ (const quaternion<S,T>, const quaternion<S,T>);
|
||||||
|
|
||||||
typedef quaternion<4,float> quaternionf;
|
typedef quaternion<4,float> quaternionf;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user