diff options
author | Melanie | 2013-01-18 19:35:09 +0000 |
---|---|---|
committer | Melanie | 2013-01-18 19:35:09 +0000 |
commit | 9aad815177c76580e74b941b8af429335d1c259c (patch) | |
tree | c0ea29b07d6178e5c1982fa52067787154101aa8 /OpenSim/Framework | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-9aad815177c76580e74b941b8af429335d1c259c.zip opensim-SC_OLD-9aad815177c76580e74b941b8af429335d1c259c.tar.gz opensim-SC_OLD-9aad815177c76580e74b941b8af429335d1c259c.tar.bz2 opensim-SC_OLD-9aad815177c76580e74b941b8af429335d1c259c.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c049247..ba3a751 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -299,6 +299,18 @@ namespace OpenSim.Framework | |||
299 | x; | 299 | x; |
300 | } | 300 | } |
301 | 301 | ||
302 | // Clamp the maximum magnitude of a vector | ||
303 | public static Vector3 ClampV(Vector3 x, float max) | ||
304 | { | ||
305 | Vector3 ret = x; | ||
306 | float lenSq = x.LengthSquared(); | ||
307 | if (lenSq > (max * max)) | ||
308 | { | ||
309 | x = x / x.Length() * max; | ||
310 | } | ||
311 | return x; | ||
312 | } | ||
313 | |||
302 | // Inclusive, within range test (true if equal to the endpoints) | 314 | // Inclusive, within range test (true if equal to the endpoints) |
303 | public static bool InRange<T>(T x, T min, T max) | 315 | public static bool InRange<T>(T x, T min, T max) |
304 | where T : IComparable<T> | 316 | where T : IComparable<T> |