X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGVec4.hxx;h=4339dfd9b79879a3fab0da2b59a5cca747cc5578;hb=584ee1364f25e5c3795f9ff4633a792cba39bfc7;hp=6030c48ba03e2ea331b43442cebfd2df509fdf1b;hpb=819d3f5ded821235bd1c9bf0350b683ac7b5df89;p=simgear.git diff --git a/simgear/math/SGVec4.hxx b/simgear/math/SGVec4.hxx index 6030c48b..4339dfd9 100644 --- a/simgear/math/SGVec4.hxx +++ b/simgear/math/SGVec4.hxx @@ -18,10 +18,7 @@ #ifndef SGVec4_H #define SGVec4_H -#ifndef NO_OPENSCENEGRAPH_INTERFACE -#include -#include -#endif +#include /// 4D Vector Class template @@ -247,6 +244,19 @@ max(S s, const SGVec4& v) SGMisc::max(s, v(3))); } +/// Add two vectors taking care of (integer) overflows. The values are limited +/// to the respective minimum and maximum values. +template +SGVec4 addClipOverflow(SGVec4 const& lhs, SGVec4 const& rhs) +{ + return SGVec4( + SGMisc::addClipOverflow(lhs.x(), rhs.x()), + SGMisc::addClipOverflow(lhs.y(), rhs.y()), + SGMisc::addClipOverflow(lhs.z(), rhs.z()), + SGMisc::addClipOverflow(lhs.w(), rhs.w()) + ); +} + /// Scalar dot product template inline @@ -428,26 +438,4 @@ SGVec4d toVec4d(const SGVec4f& v) { return SGVec4d(v(0), v(1), v(2), v(3)); } -#ifndef NO_OPENSCENEGRAPH_INTERFACE -inline -SGVec4d -toSG(const osg::Vec4d& v) -{ return SGVec4d(v[0], v[1], v[2], v[3]); } - -inline -SGVec4f -toSG(const osg::Vec4f& v) -{ return SGVec4f(v[0], v[1], v[2], v[3]); } - -inline -osg::Vec4d -toOsg(const SGVec4d& v) -{ return osg::Vec4d(v[0], v[1], v[2], v[3]); } - -inline -osg::Vec4f -toOsg(const SGVec4f& v) -{ return osg::Vec4f(v[0], v[1], v[2], v[3]); } -#endif - #endif