extend convertTo function to also support SbRotation/Base::Rotation

This commit is contained in:
wmayer
2019-09-06 21:29:51 +02:00
parent 48aa182287
commit b14cf8a00d
16 changed files with 162 additions and 64 deletions

View File

@@ -244,46 +244,6 @@ inline Vector3<_Pr1> toVector(const Vector3<_Pr2>& v)
typedef Vector3<float> Vector3f;
typedef Vector3<double> Vector3d;
template <class vecT>
struct vec_traits { };
template <>
struct vec_traits<Vector3f> {
typedef Vector3f vec_type;
typedef float float_type;
vec_traits(const vec_type& v) : v(v){}
inline float_type x() { return v.x; }
inline float_type y() { return v.y; }
inline float_type z() { return v.z; }
private:
const vec_type& v;
};
template <>
struct vec_traits<Vector3d> {
typedef Vector3d vec_type;
typedef double float_type;
vec_traits(const vec_type& v) : v(v){}
inline float_type x() { return v.x; }
inline float_type y() { return v.y; }
inline float_type z() { return v.z; }
private:
const vec_type& v;
};
template <class _Vec1, class _Vec2>
inline _Vec1 convertTo(const _Vec2& v)
{
typedef _Vec1 out_type;
typedef _Vec2 inp_type;
typedef vec_traits<inp_type> traits_type;
typedef vec_traits<out_type> traits_out;
typedef typename traits_out::float_type float_type;
traits_type t(v);
return _Vec1((float_type)t.x(),(float_type)t.y(),(float_type)t.z());
}
} // namespace Base
#endif // BASE_VECTOR3D_H