]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGVec3.hxx
canvas::Layout: support for contents margins.
[simgear.git] / simgear / math / SGVec3.hxx
index dbc8af543bf9a5d39a933be30d55e32b9dfc9c43..b0f6b20625c54b1bb9bce07cb8750ada27657022 100644 (file)
@@ -288,6 +288,18 @@ max(S s, const SGVec3<T>& v)
                    SGMisc<T>::max(s, v(2)));
 }
 
+/// Add two vectors taking care of (integer) overflows. The values are limited
+/// to the respective minimum and maximum values.
+template<class T>
+SGVec3<T> addClipOverflow(SGVec3<T> const& lhs, SGVec3<T> const& rhs)
+{
+  return SGVec3<T>(
+    SGMisc<T>::addClipOverflow(lhs.x(), rhs.x()),
+    SGMisc<T>::addClipOverflow(lhs.y(), rhs.y()),
+    SGMisc<T>::addClipOverflow(lhs.z(), rhs.z())
+  );
+}
+
 /// Scalar dot product
 template<typename T>
 inline