extend convertTo function to also support SbRotation/Base::Rotation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user