diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 384f716..e76a37b 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -546,6 +546,19 @@ namespace OpenSim.Framework | |||
546 | } | 546 | } |
547 | 547 | ||
548 | /// <summary> | 548 | /// <summary> |
549 | /// Determines whether a point is inside a bounding box. | ||
550 | /// </summary> | ||
551 | /// <param name='v'></param> | ||
552 | /// <param name='min'></param> | ||
553 | /// <param name='max'></param> | ||
554 | /// <returns></returns> | ||
555 | public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) | ||
556 | { | ||
557 | return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z | ||
558 | && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; | ||
559 | } | ||
560 | |||
561 | /// <summary> | ||
549 | /// Are the co-ordinates of the new region visible from the old region? | 562 | /// Are the co-ordinates of the new region visible from the old region? |
550 | /// </summary> | 563 | /// </summary> |
551 | /// <param name="oldx">Old region x-coord</param> | 564 | /// <param name="oldx">Old region x-coord</param> |
@@ -862,6 +875,12 @@ namespace OpenSim.Framework | |||
862 | return Math.Min(Math.Max(x, min), max); | 875 | return Math.Min(Math.Max(x, min), max); |
863 | } | 876 | } |
864 | 877 | ||
878 | public static Vector3 Clip(Vector3 vec, float min, float max) | ||
879 | { | ||
880 | return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max), | ||
881 | Clip(vec.Z, min, max)); | ||
882 | } | ||
883 | |||
865 | /// <summary> | 884 | /// <summary> |
866 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. | 885 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. |
867 | /// </summary> | 886 | /// </summary> |
@@ -1013,6 +1032,38 @@ namespace OpenSim.Framework | |||
1013 | } | 1032 | } |
1014 | } | 1033 | } |
1015 | 1034 | ||
1035 | /// <summary> | ||
1036 | /// Copy data from one stream to another, leaving the read position of both streams at the beginning. | ||
1037 | /// </summary> | ||
1038 | /// <param name='inputStream'> | ||
1039 | /// Input stream. Must be seekable. | ||
1040 | /// </param> | ||
1041 | /// <exception cref='ArgumentException'> | ||
1042 | /// Thrown if the input stream is not seekable. | ||
1043 | /// </exception> | ||
1044 | public static Stream Copy(Stream inputStream) | ||
1045 | { | ||
1046 | if (!inputStream.CanSeek) | ||
1047 | throw new ArgumentException("Util.Copy(Stream inputStream) must receive an inputStream that can seek"); | ||
1048 | |||
1049 | const int readSize = 256; | ||
1050 | byte[] buffer = new byte[readSize]; | ||
1051 | MemoryStream ms = new MemoryStream(); | ||
1052 | |||
1053 | int count = inputStream.Read(buffer, 0, readSize); | ||
1054 | |||
1055 | while (count > 0) | ||
1056 | { | ||
1057 | ms.Write(buffer, 0, count); | ||
1058 | count = inputStream.Read(buffer, 0, readSize); | ||
1059 | } | ||
1060 | |||
1061 | ms.Position = 0; | ||
1062 | inputStream.Position = 0; | ||
1063 | |||
1064 | return ms; | ||
1065 | } | ||
1066 | |||
1016 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) | 1067 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) |
1017 | { | 1068 | { |
1018 | return SendXmlRpcCommand(url, methodName, args); | 1069 | return SendXmlRpcCommand(url, methodName, args); |