#ifndef SGVec2_H
#define SGVec2_H
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-#include <osg/Vec2f>
-#include <osg/Vec2d>
-#endif
+#include <iosfwd>
/// 2D Vector Class
template<typename T>
max(S s, const SGVec2<T>& v)
{ return SGVec2<T>(SGMisc<T>::max(s, v(0)), SGMisc<T>::max(s, v(1))); }
+/// Add two vectors taking care of (integer) overflows. The values are limited
+/// to the respective minimum and maximum values.
+template<class T>
+SGVec2<T> addClipOverflow(SGVec2<T> const& lhs, SGVec2<T> const& rhs)
+{
+ return SGVec2<T>(
+ SGMisc<T>::addClipOverflow(lhs.x(), rhs.x()),
+ SGMisc<T>::addClipOverflow(lhs.y(), rhs.y())
+ );
+}
+
/// Scalar dot product
template<typename T>
inline
toVec2d(const SGVec2f& v)
{ return SGVec2d(v(0), v(1)); }
-#ifndef NO_OPENSCENEGRAPH_INTERFACE
-inline
-SGVec2d
-toSG(const osg::Vec2d& v)
-{ return SGVec2d(v[0], v[1]); }
-
-inline
-SGVec2f
-toSG(const osg::Vec2f& v)
-{ return SGVec2f(v[0], v[1]); }
-
-inline
-osg::Vec2d
-toOsg(const SGVec2d& v)
-{ return osg::Vec2d(v[0], v[1]); }
-
-inline
-osg::Vec2f
-toOsg(const SGVec2f& v)
-{ return osg::Vec2f(v[0], v[1]); }
-
-#endif
-
#endif